diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4a28177984..5d41091fcc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,4 +6,4 @@ # All of the people (and only those people) from the matching rule will be notified # Default rule: anything that doesn't match a more specific rule goes here -* @project-radius/Radius-Eng +* @radius-project/Radius-Eng diff --git a/.github/ISSUE_TEMPLATE/config.yaml b/.github/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 0000000000..debd7a4844 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Discord Support + url: https://discord.gg/SRG3ePMKNy + about: Please ask any questions you may have here diff --git a/.github/runners/runner-deployment.yaml b/.github/runners/runner-deployment.yaml index edd56b8143..85a4fcf5c2 100644 --- a/.github/runners/runner-deployment.yaml +++ b/.github/runners/runner-deployment.yaml @@ -6,7 +6,7 @@ spec: replicas: 12 template: spec: - organization: project-radius + organization: radius-project dockerdWithinRunnerContainer: true image: summerwind/actions-runner-dind nodeSelector: diff --git a/.github/scripts/radius-bot.js b/.github/scripts/radius-bot.js index 56af7dfb35..bde529465a 100644 --- a/.github/scripts/radius-bot.js +++ b/.github/scripts/radius-bot.js @@ -64,7 +64,7 @@ async function cmdOkToTest(github, issue, isFromPulls, username) { } // Check if the user has permission to trigger e2e test with an issue comment - const org = 'project-radius'; + const org = 'radius-project'; console.log(`Checking team membership for: ${username}`); const isMember = await checkTeamMembership(github, org, process.env.TEAM_SLUG, username); if (!isMember) { diff --git a/.github/workflows/assets.yaml b/.github/workflows/assets.yaml index 9ee7c2e48e..3033fa0272 100644 --- a/.github/workflows/assets.yaml +++ b/.github/workflows/assets.yaml @@ -25,7 +25,7 @@ on: jobs: publish: name: Assets - runs-on: [self-hosted, 1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 624943ecee..90f7816ed0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -42,14 +42,14 @@ env: GOTESTSUMVERSION: 1.10.0 # Use radiusdev.azurecr.io for PR build. Otherwise, use radius.azurecr.io. - # TODO_LAUNCH: Remove this variable when we opensource the repo - https://github.com/project-radius/radius/issues/5892 + # TODO_LAUNCH: Remove this variable when we opensource the repo - https://github.com/radius-project/radius/issues/5892 DOCKER_REGISTRY: ${{ github.event_name == 'pull_request' && 'radiusdev.azurecr.io' || 'radius.azurecr.io' }} # GitHub Actor for pushing images to GHCR GHCR_ACTOR: rad-ci-bot # Container registry url for GitHub container registry. - CONTAINER_REGISTRY: ${{ github.event_name == 'pull_request' && 'ghcr.io/project-radius/dev' || 'ghcr.io/project-radius/radius' }} + CONTAINER_REGISTRY: ${{ github.event_name == 'pull_request' && 'ghcr.io/radius-project/dev' || 'ghcr.io/radius-project/radius' }} # Local file path to the release binaries. RELEASE_PATH: ./release @@ -57,7 +57,7 @@ env: jobs: build: name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries - runs-on: [self-hosted, 1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest env: GOOS: ${{ matrix.target_os }} GOARCH: ${{ matrix.target_arch }} @@ -126,7 +126,7 @@ jobs: with: name: rad_cli_release path: ${{ env.RELEASE_PATH }} - # TOOD_LAUNCH: Remove this step when we opensource the repo - https://github.com/project-radius/radius/issues/5892 + # TOOD_LAUNCH: Remove this step when we opensource the repo - https://github.com/radius-project/radius/issues/5892 - name: Upload CLI binary uses: actions/upload-artifact@v3 with: @@ -211,10 +211,10 @@ jobs: # - tag the image with the PR version if the trigger was a PR # - push the image for pushes to master, or to a tag - # TODO_LAUNCH: Remove 'image' job when we opensource the repo - https://github.com/project-radius/radius/issues/5892 + # TODO_LAUNCH: Remove 'image' job when we opensource the repo - https://github.com/radius-project/radius/issues/5892 images: name: Container image build - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v3 @@ -263,7 +263,7 @@ jobs: # publish_image is building and publishing images to GHCR. publish_images: name: Build and publish container images - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v3 @@ -312,13 +312,13 @@ jobs: helm: name: Helm chart build needs: ['images', 'publish_images'] - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest env: ARTIFACT_DIR: ./dist/Charts HELM_PACKAGE_DIR: helm HELM_CHARTS_DIR: deploy/Chart OCI_REGISTRY: ghcr.io - OCI_REPOSITORY: ${{ startsWith(github.ref, 'refs/tags/v') && 'project-radius/helm-chart' || 'project-radius/dev/helm-chart' }} + OCI_REPOSITORY: ${{ startsWith(github.ref, 'refs/tags/v') && 'radius-project/helm-chart' || 'radius-project/dev/helm-chart' }} steps: - name: Checkout uses: actions/checkout@v3 @@ -353,7 +353,7 @@ jobs: publish_release: name: Publish GitHub Release needs: [ 'build' ] - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout @@ -388,11 +388,11 @@ jobs: --verify-tag env: GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }} - # TODO_LAUNCH: Remove this job once we opensource - https://github.com/project-radius/radius/issues/5892 + # TODO_LAUNCH: Remove this job once we opensource - https://github.com/radius-project/radius/issues/5892 publish: name: Publish rad CLI binaries needs: [ 'build' ] - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest if: (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') # upload on push to main or tag steps: - name: Checkout @@ -476,7 +476,7 @@ jobs: name: Delete artifacts needs: [ 'build', 'publish' ] if: ${{ always() && !contains(needs.build.result, 'failure') }} - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - name: Delete release artifacts uses: geekyeggo/delete-artifact@v1 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 162655903c..b9cc404bf0 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -18,7 +18,7 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body: | You are editing files which require a docs update. Please ensure you've made the appropriate changes to the docs and submitted a PR. - - Swagger changes require reference edge docs to be updated [here](https://github.com/project-radius/docs/tree/edge/docs/content/reference/resource-schema) + - Swagger changes require reference edge docs to be updated [here](https://github.com/radius-project/docs/tree/edge/docs/content/reference/resource-schema) - Make sure to create a branch and submit a PR into the edge branch instead of the default latest branch, as the swagger changes will not be available until the next release. For more information on contributing to docs please visit https://docs.radapp.dev/contributing/docs/. diff --git a/.github/workflows/e2e-test-azure.yaml b/.github/workflows/e2e-test-azure.yaml deleted file mode 100644 index f35b7a5784..0000000000 --- a/.github/workflows/e2e-test-azure.yaml +++ /dev/null @@ -1,449 +0,0 @@ -# ------------------------------------------------------------ -# Copyright 2023 The Radius Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ------------------------------------------------------------ - -# This workflow performs functional tests every an hour on a pre-provisioned -# AKS (Azure Kubernetes Service) cluster. -# -# There are two types of tests in Radius: functional-test and e2e-azure-test. -# 'functional-test' checks the functionality of our application using a local -# Kubernetes cluster (kind), while 'e2e-azure-test' is executed on an AKS cluster -# focusing on performance and reliability. -# -# The test AKS cluster is pre-provisioned with various monitoring tools using the -# Bicep template in /test/infra/azure. Additionally, this cluster has a -# monitoring and alerting system in place, configured to notify the team of any -# abnormalities during the test. -# -# It's also important to note that this workflow does not build the Radius in every -# run. Instead, Radius CLI and container images are built from the main branch every -# 12 hours. We leverage the GitHub Actions cache to store the 'rad cli' and test -# information. On workflow initiation, it checks the last build time to determine if -# the previous build is still valid. If valid, the workflow skips the build steps -# and uses the cached 'rad cli' for testing. -# -# Grafana dashboard URL: https://radiuse2e00-dashboard-audycmffgberbghy.wus3.grafana.azure.com/ - -name: E2E test on Azure -on: - schedule: - # Run every 1 hours - - cron: "0 * * * *" - pull_request: - branches: - - main - paths: - - '.github/workflows/e2e-test-azure.yaml' - -env: - # Go version - GOVER: '^1.21' - GOPROXY: https://proxy.golang.org - - # gotestsum version - see: https://github.com/gotestyourself/gotestsum - GOTESTSUM_VER: 1.10.0 - - # ACR for storing test images and recipes - CACHE_REGISTRY: radiusdev.azurecr.io - # Container registry for storing recipe artifacts - BICEP_RECIPE_REGISTRY: radiusdev.azurecr.io - # The radius functional test timeout - FUNCTIONALTEST_TIMEOUT: 60m - # The Azure Location to store test resources - AZURE_LOCATION: westus3 - # The base directory for storing test logs - RADIUS_CONTAINER_LOG_BASE: dist/container_logs - # The Radius helm chart location. - RADIUS_CHART_LOCATION: deploy/Chart/ - # The region for AWS resources - AWS_REGION: 'us-west-2' - # The AWS account ID - AWS_ACCOUNT_ID: '${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}' - - # The valid radius build time window in seconds to rebuild radius. 24 hours = 24 * 60 * 60 = 86400 - VALID_RADIUS_BUILD_WINDOW: 86400 - - # The AKS cluster name - AKS_CLUSTER_NAME: 'radiuse2e00-aks' - # The resource group for AKS_CLUSTER_NAME resource. - AKS_RESOURCE_GROUP: 'radiuse2e00' - - # Server where terraform test modules are deployed - TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local" - -jobs: - build: - name: Build Radius for test - runs-on: [ self-hosted, 1ES.Pool=1ES-Radius ] - outputs: - SKIP_BUILD: ${{ steps.skip-build.outputs.SKIP_BUILD }} - REL_VERSION: ${{ steps.gen-id.outputs.REL_VERSION }} - UNIQUE_ID: ${{ steps.gen-id.outputs.UNIQUE_ID }} - PR_NUMBER: ${{ steps.gen-id.outputs.PR_NUMBER }} - CHECKOUT_REPO: ${{ steps.gen-id.outputs.CHECKOUT_REPO }} - CHECKOUT_REF: ${{ steps.gen-id.outputs.CHECKOUT_REF }} - RAD_CLI_ARTIFACT_NAME: ${{ steps.gen-id.outputs.RAD_CLI_ARTIFACT_NAME }} - steps: - - name: Restore the latest cached binaries - uses: actions/cache/restore@v3 - with: - path: ./dist/cache - key: radius-test-latest- - - name: Skip build if build is still valid - if: github.event_name != 'pull_request' - id: skip-build - run: | - # check if the last build time to see if we need to build again - if [ -f ./dist/cache/.lastbuildtime ]; then - lastbuild=$(cat ./dist/cache/.lastbuildtime) - current_time=$(date +%s) - if [ $((current_time-lastbuild)) -lt ${{ env.VALID_RADIUS_BUILD_WINDOW }} ]; then - echo "Skipping build as the last build is still valid." - echo "SKIP_BUILD=true" >> $GITHUB_OUTPUT - fi - fi - - name: Set up checkout target (scheduled) - if: steps.skip-build.outputs.SKIP_BUILD != 'true' && github.event_name == 'schedule' - run: | - echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV - echo "CHECKOUT_REF=refs/heads/main" >> $GITHUB_ENV - - name: Set up checkout target (pull_request) - if: steps.skip-build.outputs.SKIP_BUILD != 'true' && github.event_name == 'pull_request' - run: | - echo "CHECKOUT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV - echo "CHECKOUT_REF=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV - echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV - - name: Generate ID for release - id: gen-id - run: | - if [ -z "${{ steps.skip-build.outputs.SKIP_BUILD }}" ]; then - BASE_STR="RADIUS|${GITHUB_SHA}|${GITHUB_SERVER_URL}|${GITHUB_REPOSITORY}|${GITHUB_RUN_ID}|${GITHUB_RUN_ATTEMPT}" - UNIQUE_ID=$(echo $BASE_STR | sha1sum | head -c 10) - echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV - - # Set output variables to be used in the other jobs - echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_OUTPUT - echo "UNIQUE_ID=${UNIQUE_ID}" >> $GITHUB_OUTPUT - echo "CHECKOUT_REPO=${{ env.CHECKOUT_REPO }}" >> $GITHUB_OUTPUT - echo "CHECKOUT_REF=${{ env.CHECKOUT_REF }}" >> $GITHUB_OUTPUT - echo "AZURE_TEST_RESOURCE_GROUP=radtest-${UNIQUE_ID}" >> $GITHUB_OUTPUT - echo "RAD_CLI_ARTIFACT_NAME=rad_cli_linux_amd64" >> $GITHUB_OUTPUT - echo "PR_NUMBER=${{ env.PR_NUMBER }}" >> $GITHUB_OUTPUT - else - cat ./dist/cache/.buildenv >> $GITHUB_OUTPUT - echo "## Radius functional test environment variables" >> $GITHUB_STEP_SUMMARY - echo "Use the previously built binaries for the current test run:" >> $GITHUB_STEP_SUMMARY - echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY - cat ./dist/cache/.buildenv >> $GITHUB_STEP_SUMMARY - echo "\`\`\`" >> $GITHUB_STEP_SUMMARY - fi - - name: Check out code - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - uses: actions/checkout@v3 - with: - repository: ${{ env.CHECKOUT_REPO }} - ref: ${{ env.CHECKOUT_REF }} - - name: Set up Go ${{ env.GOVER }} - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GOVER }} - - name: Log the summary of build info for new version. - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - continue-on-error: true - run: | - cat < summary.md - ## Radius functional test overview - - | Name | Value | - |------|-------| - |**Repository** | ${{ steps.gen-id.outputs.CHECKOUT_REPO }} | - |**Commit ref** | ${{ steps.gen-id.outputs.CHECKOUT_REF }} | - |**Unique ID** | ${{ steps.gen-id.outputs.UNIQUE_ID }} | - |**Image tag** | ${{ steps.gen-id.outputs.REL_VERSION }} | - -
- Click here to see the list of tools in the current test run - - * gotestsum ${{ env.GOTESTSUM_VER }} - * Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY}}/test/functional/shared/recipes/:${{ steps.gen-id.outputs.REL_VERSION }}` - * Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/.zip` (in cluster) - * applications-rp test image location: `${{ env.CACHE_REGISTRY }}/applications-rp:${{ steps.gen-id.outputs.REL_VERSION }}` - * ucp test image location: `${{ env.CACHE_REGISTRY }}/ucpd:${{ steps.gen-id.outputs.REL_VERSION }}` - -
- - ## Test Status - EOF - cat summary.md >> $GITHUB_STEP_SUMMARY - - name: Setup Azure CLI - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash - - name: Login to Azure - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - uses: azure/login@v1 - with: - creds: '{"clientId":"${{ secrets.INTEGRATION_TEST_SP_APP_ID }}","clientSecret":"${{ secrets.INTEGRATION_TEST_SP_PASSWORD }}","subscriptionId":"${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.INTEGRATION_TEST_TENANT_ID }}"}' - - name: Login ACR - ${{ env.CACHE_REGISTRY }} - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - run: | - az acr login -n ${{ env.CACHE_REGISTRY }} - - name: Build and Push container images - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - run: | - make build && make docker-build && make docker-push - env: - DOCKER_REGISTRY: ${{ env.CACHE_REGISTRY }} - DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} - - name: Upload CLI binary - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.gen-id.outputs.RAD_CLI_ARTIFACT_NAME }} - path: | - ./dist/linux_amd64/release/rad - - name: Log the build result (success) - if: steps.skip-build.outputs.SKIP_BUILD != 'true' && success() - continue-on-error: true - run: | - echo ":white_check_mark: Container images build succeeded" >> $GITHUB_STEP_SUMMARY - - name: Log the build result (failure) - if: steps.skip-build.outputs.SKIP_BUILD != 'true' && failure() - continue-on-error: true - run: | - echo ":x: Container images build failed" >> $GITHUB_STEP_SUMMARY - - name: Log test Bicep recipe publish status - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - continue-on-error: true - run: | - echo ":hourglass: Publishing Bicep Recipes for functional tests..." >> $GITHUB_STEP_SUMMARY - - name: Download rad-bicep - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - run: | - mkdir -p dist - ./.github/scripts/curl-with-retries.sh https://get.radapp.dev/tools/bicep-extensibility/edge/linux-x64/rad-bicep --output dist/rad-bicep - chmod +x dist/rad-bicep - - name: Move the latest binaries to cache - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - run: | - mkdir -p ./dist/cache - mv ./dist/linux_amd64/release/rad ./dist/cache - echo $(date +%s) > ./dist/cache/.lastbuildtime - echo "UNIQUE_ID=${{ steps.gen-id.outputs.UNIQUE_ID }}" >> ./dist/cache/.buildenv - echo "REL_VERSION=${{ steps.gen-id.outputs.REL_VERSION }}" >> ./dist/cache/.buildenv - echo "CHECKOUT_REPO=${{ steps.gen-id.outputs.CHECKOUT_REPO }}" >> ./dist/cache/.buildenv - echo "CHECKOUT_REF=$(git rev-parse HEAD)" >> ./dist/cache/.buildenv - echo "PR_NUMBER=${{ steps.gen-id.outputs.PR_NUMBER }}" >> ./dist/cache/.buildenv - echo "BICEP_RECIPE_TAG_VERSION=${{ steps.gen-id.outputs.REL_VERSION }}" >> ./dist/cache/.buildenv - - name: Store the latest binaries into cache - uses: actions/cache/save@v3 - if: steps.skip-build.outputs.SKIP_BUILD != 'true' && success() - with: - path: ./dist/cache - key: radius-test-latest-${{ github.sha }}-${{ github.run_number }} - - name: Publish Bicep Test Recipes - if: steps.skip-build.outputs.SKIP_BUILD != 'true' - run: | - make publish-test-bicep-recipes - env: - BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} - BICEP_RECIPE_TAG_VERSION: ${{ env.REL_VERSION }} - RAD_BICEP_PATH: dist - - name: Log Bicep recipe publish status (success) - if: steps.skip-build.outputs.SKIP_BUILD != 'true' && success() - run: | - echo ":white_check_mark: Recipe publishing succeeded" >> $GITHUB_STEP_SUMMARY - - name: Log recipe publish status (failure) - if: steps.skip-build.outputs.SKIP_BUILD != 'true' && failure() - run: | - echo ":x: Test recipe publishing failed" >> $GITHUB_STEP_SUMMARY - tests: - name: Run functional tests - needs: build - runs-on: [ self-hosted, 1ES.Pool=1ES-Radius ] - env: - SKIP_BUILD: ${{ needs.build.outputs.SKIP_BUILD }} - UNIQUE_ID: ${{ needs.build.outputs.UNIQUE_ID }} - REL_VERSION: ${{ needs.build.outputs.REL_VERSION }} - CHECKOUT_REPO: ${{ needs.build.outputs.CHECKOUT_REPO }} - CHECKOUT_REF: ${{ needs.build.outputs.CHECKOUT_REF }} - PR_NUMBER: ${{ needs.build.outputs.PR_NUMBER }} - AZURE_TEST_RESOURCE_GROUP: radtest-${{ needs.build.outputs.UNIQUE_ID }}-e2e-all - RAD_CLI_ARTIFACT_NAME: ${{ needs.build.outputs.RAD_CLI_ARTIFACT_NAME }} - BICEP_RECIPE_TAG_VERSION: ${{ needs.build.outputs.REL_VERSION }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - repository: ${{ env.CHECKOUT_REPO }} - ref: ${{ env.CHECKOUT_REF }} - - name: Set up Go ${{ env.GOVER }} - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GOVER }} - - name: Download rad CLI - if: env.SKIP_BUILD != 'true' - uses: actions/download-artifact@v3 - with: - name: ${{ env.RAD_CLI_ARTIFACT_NAME }} - path: bin - - name: Restore the latest cached binaries - if: env.SKIP_BUILD == 'true' - uses: actions/cache/restore@v3 - with: - path: ./dist/cache - key: radius-test-latest- - - name: Install rad CLI in bin - if: env.SKIP_BUILD == 'true' - run: | - mkdir -p ./bin - mv ./dist/cache/rad ./bin/ - chmod +x ./bin/rad - - name: Login to Azure - uses: azure/login@v1 - with: - creds: '{"clientId":"${{ secrets.INTEGRATION_TEST_SP_APP_ID }}","clientSecret":"${{ secrets.INTEGRATION_TEST_SP_PASSWORD }}","subscriptionId":"${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.INTEGRATION_TEST_TENANT_ID }}"}' - - name: Create azure resource group - ${{ env.AZURE_TEST_RESOURCE_GROUP }} - run: | - current_time=$(date +%s) - az group create \ - --location ${{ env.AZURE_LOCATION }} \ - --name $RESOURCE_GROUP \ - --subscription ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ - --tags creationTime=$current_time - while [ $(az group exists --name $RESOURCE_GROUP) = false ]; do sleep 2; done - env: - RESOURCE_GROUP: ${{ env.AZURE_TEST_RESOURCE_GROUP }} - - name: Get kubeconf credential for AKS cluster - run: | - az aks get-credentials \ - --subscription ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ - --resource-group ${{ env.AKS_RESOURCE_GROUP }} \ - --name ${{ env.AKS_CLUSTER_NAME }} --admin - env: - RESOURCE_GROUP: ${{ env.AZURE_TEST_RESOURCE_GROUP }} - - name: Clean up cluster - run: ./.github/scripts/cleanup-cluster.sh - - name: Download Bicep - run: | - chmod +x ./bin/rad - export PATH=$GITHUB_WORKSPACE/bin:$PATH - which rad || { echo "cannot find rad"; exit 1; } - rad bicep download - rad version - - name: Install gotestsum (test reporting tool) - run: | - go install gotest.tools/gotestsum@v${{ env.GOTESTSUM_VER }} - - name: Install Radius - if: env.SKIP_BUILD != 'true' - run: | - set -x - export PATH=$GITHUB_WORKSPACE/bin:$PATH - which rad || { echo "cannot find rad"; exit 1; } - - echo "*** Installing Radius to Kubernetes ***" - rad install kubernetes --reinstall \ - --chart ${{ env.RADIUS_CHART_LOCATION }} \ - --set rp.image=${{ env.CACHE_REGISTRY }}/applications-rp,rp.tag=${{ env.REL_VERSION }},ucp.image=${{ env.CACHE_REGISTRY }}/ucpd,ucp.tag=${{ env.REL_VERSION }} - - name: Configure Radius test workspace - run: | - set -x - - export PATH=$GITHUB_WORKSPACE/bin:$PATH - which rad || { echo "cannot find rad"; exit 1; } - - echo "*** Create workspace, group and environment for test ***" - rad workspace create kubernetes - rad workspace list - rad group create radius-e2e - rad group switch radius-e2e - - # The functional test is designed to use default namespace. So you must create the environment for default namespace. - rad env create radius-e2e --namespace default - rad env switch radius-e2e - rad workspace list - - echo "*** Configuring Azure provider ***" - rad env update radius-e2e --azure-subscription-id ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ - --azure-resource-group ${{ env.AZURE_TEST_RESOURCE_GROUP }} - rad credential register azure --client-id ${{ secrets.INTEGRATION_TEST_SP_APP_ID }} \ - --client-secret ${{ secrets.INTEGRATION_TEST_SP_PASSWORD }} \ - --tenant-id ${{ secrets.INTEGRATION_TEST_TENANT_ID }} - - echo "*** Configuring AWS provider ***" - rad env update radius-e2e --aws-region ${{ env.AWS_REGION }} --aws-account-id ${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }} - rad credential register aws \ - --access-key-id ${{ secrets.FUNCTEST_AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.FUNCTEST_AWS_SECRET_ACCESS_KEY }} - - az acr login -n ${{ env.CACHE_REGISTRY }} - - name: Log radius installation status (failure) - if: failure() - run: | - echo ":x: Failed to install Radius for functional test." >> $GITHUB_STEP_SUMMARY - - name: Publish Terraform test recipes - run: | - make publish-test-terraform-recipes - - name: Get OIDC Issuer from AKS cluster - run: | - echo "FUNCTEST_OIDC_ISSUER=$(az aks show -n ${{ env.AKS_CLUSTER_NAME }} -g ${{ env.AKS_RESOURCE_GROUP }} --query "oidcIssuerProfile.issuerUrl" -otsv)" >> $GITHUB_ENV - - name: Run functional tests - run: | - # Ensure rad cli is in path before running tests. - export PATH=$GITHUB_WORKSPACE/bin:$PATH - cd $GITHUB_WORKSPACE - - which rad || { echo "cannot find rad"; exit 1; } - - # Populate the following test environment variables from JSON secret. - # AZURE_MONGODB_RESOURCE_ID - # AZURE_COSMOS_MONGODB_ACCOUNT_ID - # AZURE_TABLESTORAGE_RESOURCE_ID - # AZURE_SERVICEBUS_RESOURCE_ID - # AZURE_REDIS_RESOURCE_ID - # AZURE_MSSQL_RESOURCE_ID - # AZURE_MSSQL_USERNAME - # AZURE_MSSQL_PASSWORD - eval "export $(echo "${{ secrets.FUNCTEST_PREPROVISIONED_RESOURCE_JSON }}" | jq -r 'to_entries | map("\(.key)=\(.value)") | @sh')" - - make test-functional-all - env: - TEST_TIMEOUT: ${{ env.FUNCTIONALTEST_TIMEOUT }} - RADIUS_CONTAINER_LOG_PATH: ${{ github.workspace }}/${{ env.RADIUS_CONTAINER_LOG_BASE }} - AWS_ACCESS_KEY_ID: ${{ secrets.FUNCTEST_AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.FUNCTEST_AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ env.AWS_REGION }} - RADIUS_SAMPLES_REPO_ROOT: ${{ github.workspace }}/samples - # Test_MongoDB_Recipe_Parameters is using the following environment variable. - INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} - FUNC_TEST_OIDC_ISSUER: ${{ env.FUNCTEST_OIDC_ISSUER }} - - name: Log radius e2e test status (success) - if: success() - run: | - echo ":white_check_mark: functional tests succeeded" >> $GITHUB_STEP_SUMMARY - - name: Log radius e2e test status (failure) - if: failure() - run: | - echo ":x: functional test failed." >> $GITHUB_STEP_SUMMARY - - name: Delete azure resource group - ${{ env.AZURE_TEST_RESOURCE_GROUP }} - if: always() - run: | - # if deletion fails, purge workflow will purge the resource group and its resources later. - az group delete \ - --subscription ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ - --name ${{ env.AZURE_TEST_RESOURCE_GROUP }} \ - --yes --verbose - - name: Clean up cluster - if: always() - run: ./.github/scripts/cleanup-cluster.sh diff --git a/.github/workflows/functional-test.yaml b/.github/workflows/functional-test.yaml index 5bbcc1fcc7..b4bcfe42a1 100644 --- a/.github/workflows/functional-test.yaml +++ b/.github/workflows/functional-test.yaml @@ -44,14 +44,16 @@ env: KIND_VER: 'v0.20.0' # Dapr version DAPR_VER: '1.11.0' + # Kubectl version + KUBECTL_VER: 'v1.25.0' # Azure Keyvault CSI driver chart version AZURE_KEYVAULT_CSI_DRIVER_VER: '1.4.2' # Azure workload identity webhook chart version AZURE_WORKLOAD_IDENTITY_WEBHOOK_VER: '1.1.0' # Container registry for storing test images and recipes - CACHE_REGISTRY: ghcr.io/project-radius/dev + CACHE_REGISTRY: ghcr.io/radius-project/dev # Container registry for storing recipe artifacts - # TODO_LAUNCH: Change it to ghcr.io/project-radius/dev - https://github.com/project-radius/radius/issues/5892 + # TODO_LAUNCH: Change it to ghcr.io/radius-project/dev - https://github.com/radius-project/radius/issues/5892 BICEP_RECIPE_REGISTRY: radiusdev.azurecr.io # The radius functional test timeout FUNCTIONALTEST_TIMEOUT: 60m @@ -72,11 +74,10 @@ env: # GitHub Actor for pushing images to GHCR GHCR_ACTOR: rad-ci-bot - jobs: build: name: Build Radius for test - runs-on: [ self-hosted, 1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest env: DE_IMAGE: 'radius.azurecr.io/deployment-engine' DE_TAG: 'latest' @@ -98,8 +99,8 @@ jobs: - name: Set up checkout target (pull_request) if: github.event_name == 'pull_request' run: | - echo "CHECKOUT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV - echo "CHECKOUT_REF=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV + echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV + echo "CHECKOUT_REF=${{ github.ref }}" >> $GITHUB_ENV echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV - name: Set up checkout target (repository_dispatch from /ok-to-test) if: github.event_name == 'repository_dispatch' @@ -290,11 +291,16 @@ jobs: tests: name: Run ${{ matrix.name }} functional tests needs: build - runs-on: [ self-hosted, 1ES.Pool=1ES-Radius ] strategy: fail-fast: true matrix: - name: [ucp,shared,msgrp,daprrp,datastoresrp,samples] + os: [ubuntu-latest] + name: [ucp,shared,msgrp,daprrp,samples] + include: + # datastorerp functional tests need the larger VM. + - os: ubuntu-latest-m + name: datastoresrp + runs-on: ${{ matrix.os }} env: UNIQUE_ID: ${{ needs.build.outputs.UNIQUE_ID }} REL_VERSION: ${{ needs.build.outputs.REL_VERSION }} @@ -316,7 +322,7 @@ jobs: uses: actions/checkout@v3 if: matrix.name == 'samples' with: - repository: project-radius/samples + repository: radius-project/samples ref: refs/heads/edge token: ${{ secrets.GH_RAD_CI_BOT_PAT }} path: samples @@ -471,7 +477,7 @@ jobs: rad credential register aws \ --access-key-id ${{ secrets.FUNCTEST_AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.FUNCTEST_AWS_SECRET_ACCESS_KEY }} - # TODO_LAUNCH: Remove this login once we move recipe to GHCR - https://github.com/project-radius/radius/issues/5892 + # TODO_LAUNCH: Remove this login once we move recipe to GHCR - https://github.com/radius-project/radius/issues/5892 az acr login -n ${{ env.BICEP_RECIPE_REGISTRY }} - uses: marocchino/sticky-pull-request-comment@v2 if: failure() && env.PR_NUMBER != '' @@ -517,6 +523,19 @@ jobs: INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} BICEP_RECIPE_TAG_VERSION: ${{ env.BICEP_RECIPE_TAG_VERSION }} + - uses: azure/setup-kubectl@v3 + if: always() + with: + version: ${{ env.KUBECTL_VER }} + - name: Collect Pod details + if: always() + run: | + POD_STATE_LOG_FILENAME='${{ env.RADIUS_CONTAINER_LOG_BASE }}/${{ matrix.name }}-tests-pod-states.log' + mkdir -p $(dirname $POD_STATE_LOG_FILENAME) + echo "kubectl get pods -A" >> $POD_STATE_LOG_FILENAME + kubectl get pods -A >> $POD_STATE_LOG_FILENAME + echo "kubectl describe pods -A" >> $POD_STATE_LOG_FILENAME + kubectl describe pods -A >> $POD_STATE_LOG_FILENAME - name: Upload container logs if: always() uses: actions/upload-artifact@v3 @@ -552,7 +571,7 @@ jobs: report-failure: name: Report test failure needs: [build, tests] - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest if: failure() && github.event_name == 'schedule' steps: - name: Create failure issue for failing scheduled run diff --git a/.github/workflows/issues.yaml b/.github/workflows/issues.yaml index 8ece916762..23d81019c7 100644 --- a/.github/workflows/issues.yaml +++ b/.github/workflows/issues.yaml @@ -7,7 +7,7 @@ on: jobs: customer: name: Add a label if Issue created by customer - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }} steps: @@ -16,8 +16,8 @@ jobs: ISSUE: ${{ github.event.issue.html_url }} AUTHOR: ${{ github.actor }} run: | - MEMBERS=$(gh api orgs/project-radius/teams/Radius-Preview/members | jq -r '.[] | .login') - ADMINS=$(gh api orgs/project-radius/teams/Radius-Admin/members | jq -r '.[] | .login') + MEMBERS=$(gh api orgs/radius-project/teams/Radius-Preview/members | jq -r '.[] | .login') + ADMINS=$(gh api orgs/radius-project/teams/Radius-Admin/members | jq -r '.[] | .login') for USER in $MEMBERS; do if [[ "$USER" == "$AUTHOR" ]]; then ISADMIN=false diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 319d0cb219..4e3ff81bcb 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -30,7 +30,7 @@ concurrency: jobs: linter_check: name: Lint - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest timeout-minutes: 30 env: GOVER: '^1.21' @@ -42,13 +42,13 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ env.GOVER }} - - name: Setup npm + - name: Setup NodeJS uses: actions/setup-node@v3 with: - node-version: '16' - - name: Install cadl compiler + node-version: '18' + - name: Install TypeSpec compiler run: | - pushd cadl + pushd typespec npm ci popd - name: Install autorest diff --git a/.github/workflows/long-running-azure.yaml b/.github/workflows/long-running-azure.yaml new file mode 100644 index 0000000000..306638a6b6 --- /dev/null +++ b/.github/workflows/long-running-azure.yaml @@ -0,0 +1,449 @@ +# ------------------------------------------------------------ +# Copyright 2023 The Radius Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------ + +# This workflow performs functional tests every an hour on a pre-provisioned +# AKS (Azure Kubernetes Service) cluster. +# +# There are two types of tests in Radius: functional-test and e2e-azure-test. +# 'functional-test' checks the functionality of our application using a local +# Kubernetes cluster (kind), while 'e2e-azure-test' is executed on an AKS cluster +# focusing on performance and reliability. +# +# The test AKS cluster is pre-provisioned with various monitoring tools using the +# Bicep template in /test/infra/azure. Additionally, this cluster has a +# monitoring and alerting system in place, configured to notify the team of any +# abnormalities during the test. +# +# It's also important to note that this workflow does not build the Radius in every +# run. Instead, Radius CLI and container images are built from the main branch every +# 12 hours. We leverage the GitHub Actions cache to store the 'rad cli' and test +# information. On workflow initiation, it checks the last build time to determine if +# the previous build is still valid. If valid, the workflow skips the build steps +# and uses the cached 'rad cli' for testing. +# +# Grafana dashboard URL: https://radiuse2e00-dashboard-audycmffgberbghy.wus3.grafana.azure.com/ + +name: Long-running test on Azure +on: + schedule: + # Run every 2 hours + - cron: "0 */2 * * *" + pull_request: + branches: + - main + paths: + - '.github/workflows/long-running-azure.yaml' + +env: + # Go version + GOVER: '^1.21' + GOPROXY: https://proxy.golang.org + + # gotestsum version - see: https://github.com/gotestyourself/gotestsum + GOTESTSUM_VER: 1.10.0 + + # ACR for storing test images and recipes + CACHE_REGISTRY: radiusdev.azurecr.io + # Container registry for storing recipe artifacts + BICEP_RECIPE_REGISTRY: radiusdev.azurecr.io + # The radius functional test timeout + FUNCTIONALTEST_TIMEOUT: 60m + # The Azure Location to store test resources + AZURE_LOCATION: westus3 + # The base directory for storing test logs + RADIUS_CONTAINER_LOG_BASE: dist/container_logs + # The Radius helm chart location. + RADIUS_CHART_LOCATION: deploy/Chart/ + # The region for AWS resources + AWS_REGION: 'us-west-2' + # The AWS account ID + AWS_ACCOUNT_ID: '${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }}' + + # The valid radius build time window in seconds to rebuild radius. 24 hours = 24 * 60 * 60 = 86400 + VALID_RADIUS_BUILD_WINDOW: 86400 + + # The AKS cluster name + AKS_CLUSTER_NAME: 'radiuse2e00-aks' + # The resource group for AKS_CLUSTER_NAME resource. + AKS_RESOURCE_GROUP: 'radiuse2e00' + + # Server where terraform test modules are deployed + TF_RECIPE_MODULE_SERVER_URL: "http://tf-module-server.radius-test-tf-module-server.svc.cluster.local" + +jobs: + build: + name: Build Radius for test + runs-on: ubuntu-latest + outputs: + SKIP_BUILD: ${{ steps.skip-build.outputs.SKIP_BUILD }} + REL_VERSION: ${{ steps.gen-id.outputs.REL_VERSION }} + UNIQUE_ID: ${{ steps.gen-id.outputs.UNIQUE_ID }} + PR_NUMBER: ${{ steps.gen-id.outputs.PR_NUMBER }} + CHECKOUT_REPO: ${{ steps.gen-id.outputs.CHECKOUT_REPO }} + CHECKOUT_REF: ${{ steps.gen-id.outputs.CHECKOUT_REF }} + RAD_CLI_ARTIFACT_NAME: ${{ steps.gen-id.outputs.RAD_CLI_ARTIFACT_NAME }} + steps: + - name: Restore the latest cached binaries + uses: actions/cache/restore@v3 + with: + path: ./dist/cache + key: radius-test-latest- + - name: Skip build if build is still valid + if: github.event_name != 'pull_request' + id: skip-build + run: | + # check if the last build time to see if we need to build again + if [ -f ./dist/cache/.lastbuildtime ]; then + lastbuild=$(cat ./dist/cache/.lastbuildtime) + current_time=$(date +%s) + if [ $((current_time-lastbuild)) -lt ${{ env.VALID_RADIUS_BUILD_WINDOW }} ]; then + echo "Skipping build as the last build is still valid." + echo "SKIP_BUILD=true" >> $GITHUB_OUTPUT + fi + fi + - name: Set up checkout target (scheduled) + if: steps.skip-build.outputs.SKIP_BUILD != 'true' && github.event_name == 'schedule' + run: | + echo "CHECKOUT_REPO=${{ github.repository }}" >> $GITHUB_ENV + echo "CHECKOUT_REF=refs/heads/main" >> $GITHUB_ENV + - name: Set up checkout target (pull_request) + if: steps.skip-build.outputs.SKIP_BUILD != 'true' && github.event_name == 'pull_request' + run: | + echo "CHECKOUT_REPO=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV + echo "CHECKOUT_REF=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV + echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV + - name: Generate ID for release + id: gen-id + run: | + if [ -z "${{ steps.skip-build.outputs.SKIP_BUILD }}" ]; then + BASE_STR="RADIUS|${GITHUB_SHA}|${GITHUB_SERVER_URL}|${GITHUB_REPOSITORY}|${GITHUB_RUN_ID}|${GITHUB_RUN_ATTEMPT}" + UNIQUE_ID=$(echo $BASE_STR | sha1sum | head -c 10) + echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_ENV + + # Set output variables to be used in the other jobs + echo "REL_VERSION=pr-${UNIQUE_ID}" >> $GITHUB_OUTPUT + echo "UNIQUE_ID=${UNIQUE_ID}" >> $GITHUB_OUTPUT + echo "CHECKOUT_REPO=${{ env.CHECKOUT_REPO }}" >> $GITHUB_OUTPUT + echo "CHECKOUT_REF=${{ env.CHECKOUT_REF }}" >> $GITHUB_OUTPUT + echo "AZURE_TEST_RESOURCE_GROUP=radtest-${UNIQUE_ID}" >> $GITHUB_OUTPUT + echo "RAD_CLI_ARTIFACT_NAME=rad_cli_linux_amd64" >> $GITHUB_OUTPUT + echo "PR_NUMBER=${{ env.PR_NUMBER }}" >> $GITHUB_OUTPUT + else + cat ./dist/cache/.buildenv >> $GITHUB_OUTPUT + echo "## Radius functional test environment variables" >> $GITHUB_STEP_SUMMARY + echo "Use the previously built binaries for the current test run:" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY + cat ./dist/cache/.buildenv >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + fi + - name: Check out code + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + uses: actions/checkout@v3 + with: + repository: ${{ env.CHECKOUT_REPO }} + ref: ${{ env.CHECKOUT_REF }} + - name: Set up Go ${{ env.GOVER }} + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GOVER }} + - name: Log the summary of build info for new version. + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + continue-on-error: true + run: | + cat < summary.md + ## Radius functional test overview + + | Name | Value | + |------|-------| + |**Repository** | ${{ steps.gen-id.outputs.CHECKOUT_REPO }} | + |**Commit ref** | ${{ steps.gen-id.outputs.CHECKOUT_REF }} | + |**Unique ID** | ${{ steps.gen-id.outputs.UNIQUE_ID }} | + |**Image tag** | ${{ steps.gen-id.outputs.REL_VERSION }} | + +
+ Click here to see the list of tools in the current test run + + * gotestsum ${{ env.GOTESTSUM_VER }} + * Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY}}/test/functional/shared/recipes/:${{ steps.gen-id.outputs.REL_VERSION }}` + * Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/.zip` (in cluster) + * applications-rp test image location: `${{ env.CACHE_REGISTRY }}/applications-rp:${{ steps.gen-id.outputs.REL_VERSION }}` + * ucp test image location: `${{ env.CACHE_REGISTRY }}/ucpd:${{ steps.gen-id.outputs.REL_VERSION }}` + +
+ + ## Test Status + EOF + cat summary.md >> $GITHUB_STEP_SUMMARY + - name: Setup Azure CLI + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash + - name: Login to Azure + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + uses: azure/login@v1 + with: + creds: '{"clientId":"${{ secrets.INTEGRATION_TEST_SP_APP_ID }}","clientSecret":"${{ secrets.INTEGRATION_TEST_SP_PASSWORD }}","subscriptionId":"${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.INTEGRATION_TEST_TENANT_ID }}"}' + - name: Login ACR - ${{ env.CACHE_REGISTRY }} + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + run: | + az acr login -n ${{ env.CACHE_REGISTRY }} + - name: Build and Push container images + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + run: | + make build && make docker-build && make docker-push + env: + DOCKER_REGISTRY: ${{ env.CACHE_REGISTRY }} + DOCKER_TAG_VERSION: ${{ env.REL_VERSION }} + - name: Upload CLI binary + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.gen-id.outputs.RAD_CLI_ARTIFACT_NAME }} + path: | + ./dist/linux_amd64/release/rad + - name: Log the build result (success) + if: steps.skip-build.outputs.SKIP_BUILD != 'true' && success() + continue-on-error: true + run: | + echo ":white_check_mark: Container images build succeeded" >> $GITHUB_STEP_SUMMARY + - name: Log the build result (failure) + if: steps.skip-build.outputs.SKIP_BUILD != 'true' && failure() + continue-on-error: true + run: | + echo ":x: Container images build failed" >> $GITHUB_STEP_SUMMARY + - name: Log test Bicep recipe publish status + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + continue-on-error: true + run: | + echo ":hourglass: Publishing Bicep Recipes for functional tests..." >> $GITHUB_STEP_SUMMARY + - name: Download rad-bicep + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + run: | + mkdir -p dist + ./.github/scripts/curl-with-retries.sh https://get.radapp.dev/tools/bicep-extensibility/edge/linux-x64/rad-bicep --output dist/rad-bicep + chmod +x dist/rad-bicep + - name: Move the latest binaries to cache + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + run: | + mkdir -p ./dist/cache + mv ./dist/linux_amd64/release/rad ./dist/cache + echo $(date +%s) > ./dist/cache/.lastbuildtime + echo "UNIQUE_ID=${{ steps.gen-id.outputs.UNIQUE_ID }}" >> ./dist/cache/.buildenv + echo "REL_VERSION=${{ steps.gen-id.outputs.REL_VERSION }}" >> ./dist/cache/.buildenv + echo "CHECKOUT_REPO=${{ steps.gen-id.outputs.CHECKOUT_REPO }}" >> ./dist/cache/.buildenv + echo "CHECKOUT_REF=$(git rev-parse HEAD)" >> ./dist/cache/.buildenv + echo "PR_NUMBER=${{ steps.gen-id.outputs.PR_NUMBER }}" >> ./dist/cache/.buildenv + echo "BICEP_RECIPE_TAG_VERSION=${{ steps.gen-id.outputs.REL_VERSION }}" >> ./dist/cache/.buildenv + - name: Store the latest binaries into cache + uses: actions/cache/save@v3 + if: steps.skip-build.outputs.SKIP_BUILD != 'true' && success() + with: + path: ./dist/cache + key: radius-test-latest-${{ github.sha }}-${{ github.run_number }} + - name: Publish Bicep Test Recipes + if: steps.skip-build.outputs.SKIP_BUILD != 'true' + run: | + make publish-test-bicep-recipes + env: + BICEP_RECIPE_REGISTRY: ${{ env.BICEP_RECIPE_REGISTRY }} + BICEP_RECIPE_TAG_VERSION: ${{ env.REL_VERSION }} + RAD_BICEP_PATH: dist + - name: Log Bicep recipe publish status (success) + if: steps.skip-build.outputs.SKIP_BUILD != 'true' && success() + run: | + echo ":white_check_mark: Recipe publishing succeeded" >> $GITHUB_STEP_SUMMARY + - name: Log recipe publish status (failure) + if: steps.skip-build.outputs.SKIP_BUILD != 'true' && failure() + run: | + echo ":x: Test recipe publishing failed" >> $GITHUB_STEP_SUMMARY + tests: + name: Run functional tests + needs: build + runs-on: ubuntu-latest + env: + SKIP_BUILD: ${{ needs.build.outputs.SKIP_BUILD }} + UNIQUE_ID: ${{ needs.build.outputs.UNIQUE_ID }} + REL_VERSION: ${{ needs.build.outputs.REL_VERSION }} + CHECKOUT_REPO: ${{ needs.build.outputs.CHECKOUT_REPO }} + CHECKOUT_REF: ${{ needs.build.outputs.CHECKOUT_REF }} + PR_NUMBER: ${{ needs.build.outputs.PR_NUMBER }} + AZURE_TEST_RESOURCE_GROUP: radtest-${{ needs.build.outputs.UNIQUE_ID }}-e2e-all + RAD_CLI_ARTIFACT_NAME: ${{ needs.build.outputs.RAD_CLI_ARTIFACT_NAME }} + BICEP_RECIPE_TAG_VERSION: ${{ needs.build.outputs.REL_VERSION }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + repository: ${{ env.CHECKOUT_REPO }} + ref: ${{ env.CHECKOUT_REF }} + - name: Set up Go ${{ env.GOVER }} + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GOVER }} + - name: Download rad CLI + if: env.SKIP_BUILD != 'true' + uses: actions/download-artifact@v3 + with: + name: ${{ env.RAD_CLI_ARTIFACT_NAME }} + path: bin + - name: Restore the latest cached binaries + if: env.SKIP_BUILD == 'true' + uses: actions/cache/restore@v3 + with: + path: ./dist/cache + key: radius-test-latest- + - name: Install rad CLI in bin + if: env.SKIP_BUILD == 'true' + run: | + mkdir -p ./bin + mv ./dist/cache/rad ./bin/ + chmod +x ./bin/rad + - name: Login to Azure + uses: azure/login@v1 + with: + creds: '{"clientId":"${{ secrets.INTEGRATION_TEST_SP_APP_ID }}","clientSecret":"${{ secrets.INTEGRATION_TEST_SP_PASSWORD }}","subscriptionId":"${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.INTEGRATION_TEST_TENANT_ID }}"}' + - name: Create azure resource group - ${{ env.AZURE_TEST_RESOURCE_GROUP }} + run: | + current_time=$(date +%s) + az group create \ + --location ${{ env.AZURE_LOCATION }} \ + --name $RESOURCE_GROUP \ + --subscription ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ + --tags creationTime=$current_time + while [ $(az group exists --name $RESOURCE_GROUP) = false ]; do sleep 2; done + env: + RESOURCE_GROUP: ${{ env.AZURE_TEST_RESOURCE_GROUP }} + - name: Get kubeconf credential for AKS cluster + run: | + az aks get-credentials \ + --subscription ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ + --resource-group ${{ env.AKS_RESOURCE_GROUP }} \ + --name ${{ env.AKS_CLUSTER_NAME }} --admin + env: + RESOURCE_GROUP: ${{ env.AZURE_TEST_RESOURCE_GROUP }} + - name: Clean up cluster + run: ./.github/scripts/cleanup-cluster.sh + - name: Download Bicep + run: | + chmod +x ./bin/rad + export PATH=$GITHUB_WORKSPACE/bin:$PATH + which rad || { echo "cannot find rad"; exit 1; } + rad bicep download + rad version + - name: Install gotestsum (test reporting tool) + run: | + go install gotest.tools/gotestsum@v${{ env.GOTESTSUM_VER }} + - name: Install Radius + if: env.SKIP_BUILD != 'true' + run: | + set -x + export PATH=$GITHUB_WORKSPACE/bin:$PATH + which rad || { echo "cannot find rad"; exit 1; } + + echo "*** Installing Radius to Kubernetes ***" + rad install kubernetes --reinstall \ + --chart ${{ env.RADIUS_CHART_LOCATION }} \ + --set rp.image=${{ env.CACHE_REGISTRY }}/applications-rp,rp.tag=${{ env.REL_VERSION }},ucp.image=${{ env.CACHE_REGISTRY }}/ucpd,ucp.tag=${{ env.REL_VERSION }} + - name: Configure Radius test workspace + run: | + set -x + + export PATH=$GITHUB_WORKSPACE/bin:$PATH + which rad || { echo "cannot find rad"; exit 1; } + + echo "*** Create workspace, group and environment for test ***" + rad workspace create kubernetes + rad workspace list + rad group create radius-e2e + rad group switch radius-e2e + + # The functional test is designed to use default namespace. So you must create the environment for default namespace. + rad env create radius-e2e --namespace default + rad env switch radius-e2e + rad workspace list + + echo "*** Configuring Azure provider ***" + rad env update radius-e2e --azure-subscription-id ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ + --azure-resource-group ${{ env.AZURE_TEST_RESOURCE_GROUP }} + rad credential register azure --client-id ${{ secrets.INTEGRATION_TEST_SP_APP_ID }} \ + --client-secret ${{ secrets.INTEGRATION_TEST_SP_PASSWORD }} \ + --tenant-id ${{ secrets.INTEGRATION_TEST_TENANT_ID }} + + echo "*** Configuring AWS provider ***" + rad env update radius-e2e --aws-region ${{ env.AWS_REGION }} --aws-account-id ${{ secrets.FUNCTEST_AWS_ACCOUNT_ID }} + rad credential register aws \ + --access-key-id ${{ secrets.FUNCTEST_AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.FUNCTEST_AWS_SECRET_ACCESS_KEY }} + + az acr login -n ${{ env.CACHE_REGISTRY }} + - name: Log radius installation status (failure) + if: failure() + run: | + echo ":x: Failed to install Radius for functional test." >> $GITHUB_STEP_SUMMARY + - name: Publish Terraform test recipes + run: | + make publish-test-terraform-recipes + - name: Get OIDC Issuer from AKS cluster + run: | + echo "FUNCTEST_OIDC_ISSUER=$(az aks show -n ${{ env.AKS_CLUSTER_NAME }} -g ${{ env.AKS_RESOURCE_GROUP }} --query "oidcIssuerProfile.issuerUrl" -otsv)" >> $GITHUB_ENV + - name: Run functional tests + run: | + # Ensure rad cli is in path before running tests. + export PATH=$GITHUB_WORKSPACE/bin:$PATH + cd $GITHUB_WORKSPACE + + which rad || { echo "cannot find rad"; exit 1; } + + # Populate the following test environment variables from JSON secret. + # AZURE_MONGODB_RESOURCE_ID + # AZURE_COSMOS_MONGODB_ACCOUNT_ID + # AZURE_TABLESTORAGE_RESOURCE_ID + # AZURE_SERVICEBUS_RESOURCE_ID + # AZURE_REDIS_RESOURCE_ID + # AZURE_MSSQL_RESOURCE_ID + # AZURE_MSSQL_USERNAME + # AZURE_MSSQL_PASSWORD + eval "export $(echo "${{ secrets.FUNCTEST_PREPROVISIONED_RESOURCE_JSON }}" | jq -r 'to_entries | map("\(.key)=\(.value)") | @sh')" + + make test-functional-all + env: + TEST_TIMEOUT: ${{ env.FUNCTIONALTEST_TIMEOUT }} + RADIUS_CONTAINER_LOG_PATH: ${{ github.workspace }}/${{ env.RADIUS_CONTAINER_LOG_BASE }} + AWS_ACCESS_KEY_ID: ${{ secrets.FUNCTEST_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.FUNCTEST_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ env.AWS_REGION }} + RADIUS_SAMPLES_REPO_ROOT: ${{ github.workspace }}/samples + # Test_MongoDB_Recipe_Parameters is using the following environment variable. + INTEGRATION_TEST_RESOURCE_GROUP_NAME: ${{ env.AZURE_TEST_RESOURCE_GROUP }} + FUNC_TEST_OIDC_ISSUER: ${{ env.FUNCTEST_OIDC_ISSUER }} + - name: Log radius e2e test status (success) + if: success() + run: | + echo ":white_check_mark: functional tests succeeded" >> $GITHUB_STEP_SUMMARY + - name: Log radius e2e test status (failure) + if: failure() + run: | + echo ":x: functional test failed." >> $GITHUB_STEP_SUMMARY + - name: Delete azure resource group - ${{ env.AZURE_TEST_RESOURCE_GROUP }} + if: always() + run: | + # if deletion fails, purge workflow will purge the resource group and its resources later. + az group delete \ + --subscription ${{ secrets.INTEGRATION_TEST_SUBSCRIPTION_ID }} \ + --name ${{ env.AZURE_TEST_RESOURCE_GROUP }} \ + --yes --verbose + - name: Clean up cluster + if: always() + run: ./.github/scripts/cleanup-cluster.sh diff --git a/.github/workflows/publish-bicep.yaml b/.github/workflows/publish-bicep.yaml index 69e5e78ae6..46939f7cb3 100644 --- a/.github/workflows/publish-bicep.yaml +++ b/.github/workflows/publish-bicep.yaml @@ -23,7 +23,7 @@ on: jobs: update-types: name: Update Bicep extensibility provider types - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest timeout-minutes: 10 env: GOVER: '^1.21' @@ -38,9 +38,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: '16' - - name: Install cadl compiler + - name: Install TypeSpec compiler run: | - pushd cadl + pushd typespec npm ci popd - name: Install autorest @@ -69,25 +69,25 @@ jobs: exit 1 - id: get_radius_commit_hash - name: Get commit hash (project-radius/radius) + name: Get commit hash (radius-project/radius) run: | echo "commit_hash_short=$(git rev-parse HEAD --short)" >> $GITHUB_OUTPUT - echo "gh_uri=https://github.com/project-radius/radius/tree/$(git rev-parse HEAD)/hack/bicep-types-radius/generated" >> $GITHUB_OUTPUT + echo "gh_uri=https://github.com/radius-project/radius/tree/$(git rev-parse HEAD)/hack/bicep-types-radius/generated" >> $GITHUB_OUTPUT - - name: Clone https://github.com/project-radius/bicep + - name: Clone https://github.com/radius-project/bicep uses: actions/checkout@v3 with: token: ${{ secrets.GH_RAD_CI_BOT_PAT }} - repository: project-radius/bicep + repository: radius-project/bicep path: workflow-temp/bicep ref: bicep-extensibility - - name: Copy generated files to project-radius/bicep repo + - name: Copy generated files to radius-project/bicep repo run: | mkdir -p workflow-temp/bicep/src/Bicep.Types.Radius/generated cp -R hack/bicep-types-radius/generated/* workflow-temp/bicep/src/Bicep.Types.Radius/generated - - name: Create Pull Request in project-radius/bicep repo + - name: Create Pull Request in radius-project/bicep repo uses: peter-evans/create-pull-request@v4 with: path: workflow-temp/bicep @@ -101,7 +101,7 @@ jobs: Update Radius extensibility provider for Bicep body: | ## Autogenerated Report - - Updates Bicep extensibility type definitions generated from [project-radius/radius](${{ steps.get_radius_commit_hash.outputs.gh_uri }}) + - Updates Bicep extensibility type definitions generated from [radius-project/radius](${{ steps.get_radius_commit_hash.outputs.gh_uri }}) commit-message: | update generated types from ${{ steps.get_radius_commit_hash.outputs.gh_uri }} labels: | diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index b6d805cdfd..6df36b7d84 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -18,12 +18,12 @@ jobs: runs-on: ubuntu-latest env: GOVER: '^1.21' - GOPRIVATE: github.com/project-radius + GOPRIVATE: github.com/radius-project steps: - name: Checkout radius repository uses: actions/checkout@v3 with: - repository: project-radius/radius + repository: radius-project/radius path: radius - name: Parse release version and set environment variables run: python radius/.github/scripts/get_release_version.py @@ -37,7 +37,7 @@ jobs: - name: Checkout docs repository uses: actions/checkout@v3 with: - repository: project-radius/docs + repository: radius-project/docs path: docs ref: ${{ env.DOCS_BRANCH }} token: ${{ secrets.GH_RAD_CI_BOT_PAT }} diff --git a/.github/workflows/purge-artifacts.yaml b/.github/workflows/purge-artifacts.yaml index fd1993e11a..765740b1a4 100644 --- a/.github/workflows/purge-artifacts.yaml +++ b/.github/workflows/purge-artifacts.yaml @@ -10,7 +10,7 @@ on: jobs: delete-artifacts: - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - uses: kolpav/purge-artifacts-action@v1 with: diff --git a/.github/workflows/purge-aws-test-resources.yaml b/.github/workflows/purge-aws-test-resources.yaml new file mode 100644 index 0000000000..b2effb7e9d --- /dev/null +++ b/.github/workflows/purge-aws-test-resources.yaml @@ -0,0 +1,46 @@ +# ------------------------------------------------------------ +# Copyright 2023 The Radius Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ------------------------------------------------------------ + +name: Purge AWS test resources +on: + workflow_dispatch: + schedule: + # Run at 12:00AM PST every day. + - cron: "0 7 * * 0-6" + +env: + AWS_REGION: us-west-2 + AWS_RESOURCE_TYPES: 'AWS::Kinesis::Stream,AWS::S3::Bucket,AWS::RDS::DBInstance,AWS::RDS::DBSubnetGroup,AWS::MemoryDB::Cluster,AWS::MemoryDB::SubnetGroup' +jobs: + purge_aws_resources: + name: AWS resources clean-ups + runs-on: ubuntu-latest + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.FUNCTEST_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.FUNCTEST_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Filter and delete resources + run: | + for resource_type in ${${{env.AWS_RESOURCE_TYPES}}//,/ } + do + aws cloudcontrol list-resources --type-name "$resource_type" --query "ResourceDescriptions[].Identifier" --output text | tr '\t' '\n' | while read identifier + do + aws cloudcontrol delete-resource --type-name "$resource_type" --identifier "$identifier" + done + done diff --git a/.github/workflows/purge-test-resources.yaml b/.github/workflows/purge-test-resources.yaml index 1e8815d22a..b5cbfe0279 100644 --- a/.github/workflows/purge-test-resources.yaml +++ b/.github/workflows/purge-test-resources.yaml @@ -35,11 +35,11 @@ jobs: image-names: dev/* cut-off: 3 days ago UTC account-type: org - org-name: project-radius + org-name: radius-project token: ${{ secrets.GH_RAD_CI_BOT_PAT }} purge_azure_resources: name: Azure resources clean-ups - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - name: Setup Azure CLI run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash diff --git a/.github/workflows/radius-bot.yaml b/.github/workflows/radius-bot.yaml index 58d82cfc01..1a591aacde 100644 --- a/.github/workflows/radius-bot.yaml +++ b/.github/workflows/radius-bot.yaml @@ -7,7 +7,7 @@ on: jobs: radius-bot: name: Run Radius Bot script - runs-on: [self-hosted, 1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v3 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d2826776e9..72eae60ad5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -34,12 +34,12 @@ env: jobs: generate_release_note: name: Generate release note from template - runs-on: [ self-hosted, 1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest if: github.event_name == 'pull_request' env: RELNOTE_FOUND: false steps: - - name: Checkout project-radius/radius + - name: Checkout radius-project/radius uses: actions/checkout@v3 - name: Get supported versions from versions.yaml id: get-supported-versions @@ -110,7 +110,7 @@ jobs: ## :warning: Missing release note :warning: This is the official Radius release. Create the release note by following instruction: - 1. Create ./docs/release-notes/${{ steps.get-version.outputs.release-version }}.md from [release note template](https://github.com/project-radius/radius/blob/main/docs/release-notes/template.md) + 1. Create ./docs/release-notes/${{ steps.get-version.outputs.release-version }}.md from [release note template](https://github.com/radius-project/radius/blob/main/docs/release-notes/template.md) 2. Update the each section and add the above Change logs to the end of release note. 3. Push release note changes to the PR branch. - name: Stop the workflow if release is the offical and its release note is not found. @@ -119,33 +119,33 @@ jobs: release: name: Create a new Radius release if: github.event_name == 'push' - runs-on: [ self-hosted, 1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - - name: Checkout project-radius/radius@main + - name: Checkout radius-project/radius@main uses: actions/checkout@v3 with: - repository: project-radius/radius + repository: radius-project/radius ref: main token: ${{ secrets.GH_RAD_CI_BOT_PAT }} path: radius - - name: Checkout project-radius/bicep@bicep-extensibility + - name: Checkout radius-project/bicep@bicep-extensibility uses: actions/checkout@v3 with: - repository: project-radius/bicep + repository: radius-project/bicep ref: bicep-extensibility token: ${{ secrets.GH_RAD_CI_BOT_PAT }} path: bicep - - name: Checkout project-radius/deployment-engine@main + - name: Checkout radius-project/deployment-engine@main uses: actions/checkout@v3 with: - repository: project-radius/deployment-engine + repository: radius-project/deployment-engine ref: main token: ${{ secrets.GH_RAD_CI_BOT_PAT }} path: deployment-engine - - name: Checkout project-radius/recipes@main + - name: Checkout radius-project/recipes@main uses: actions/checkout@v3 with: - repository: project-radius/recipes + repository: radius-project/recipes ref: main token: ${{ secrets.GH_RAD_CI_BOT_PAT }} path: recipes @@ -171,19 +171,19 @@ jobs: echo "* Desired release tag: ${{ steps.get-version.outputs.release-version }}" >> $GITHUB_STEP_SUMMARY echo "* Desired release branch: ${{ steps.get-version.outputs.release-branch-name }}" >> $GITHUB_STEP_SUMMARY echo "* Release date: $(date)" >> $GITHUB_STEP_SUMMARY - - name: Release project-radius/radius version ${{ steps.get-version.outputs.release-version }} + - name: Release radius-project/radius version ${{ steps.get-version.outputs.release-version }} run: | ./radius/.github/scripts/release-create-tag-and-branch.sh radius ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }} if: success() - - name: Release project-radius/bicep version ${{ steps.get-version.outputs.release-version }} + - name: Release radius-project/bicep version ${{ steps.get-version.outputs.release-version }} run: | ./radius/.github/scripts/release-create-tag-and-branch.sh bicep ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }} if: success() - - name: Release project-radius/deployment-engine version ${{ steps.get-version.outputs.release-version }} + - name: Release radius-project/deployment-engine version ${{ steps.get-version.outputs.release-version }} run: | ./radius/.github/scripts/release-create-tag-and-branch.sh deployment-engine ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }} if: success() - - name: Release project-radius/recipes version ${{ steps.get-version.outputs.release-version }} + - name: Release radius-project/recipes version ${{ steps.get-version.outputs.release-version }} run: | ./radius/.github/scripts/release-create-tag-and-branch.sh recipes ${{ steps.get-version.outputs.release-version }} ${{ steps.get-version.outputs.release-branch-name }} if: success() diff --git a/.github/workflows/validate-bicep.yaml b/.github/workflows/validate-bicep.yaml index f5505f4fb8..9b1d4c7681 100644 --- a/.github/workflows/validate-bicep.yaml +++ b/.github/workflows/validate-bicep.yaml @@ -29,7 +29,7 @@ concurrency: jobs: build: name: Validate Bicep Code - runs-on: [self-hosted,1ES.Pool=1ES-Radius ] + runs-on: ubuntu-latest steps: - name: Check out repo uses: actions/checkout@v3 @@ -38,15 +38,15 @@ jobs: uses: actions/checkout@v3 with: token: ${{ secrets.GH_RAD_CI_BOT_PAT }} - repository: project-radius/docs - path: temp/project-radius/docs + repository: radius-project/docs + path: temp/radius-project/docs ref: edge - name: Clone samples repo uses: actions/checkout@v3 with: token: ${{ secrets.GH_RAD_CI_BOT_PAT }} - repository: project-radius/samples - path: temp/project-radius/samples + repository: radius-project/samples + path: temp/radius-project/samples ref: edge - name: Setup Azure CLI run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash diff --git a/.gitignore b/.gitignore index e4a2b21912..b989e02b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -44,8 +44,7 @@ main .DS_Store .idea/ creds.json -__debug_bin -__debug_bin.exe +__debug_bin* default.profraw # Editor backup files @@ -56,7 +55,7 @@ default.profraw pkg/handlers/gomock_* # node modules -cadl/node_modules +node_modules # terraform state .terraform/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 1d07be7d45..001c31578f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,8 +15,8 @@ "args": [ "--config-file", "${workspaceFolder}/cmd/applications-rp/radius-self-hosted.yaml", - "--link-config", - "${workspaceFolder}/cmd/applications-rp/link-self-hosted.yaml", + "--portableresource-config", + "${workspaceFolder}/cmd/applications-rp/portableresource-self-hosted.yaml", ], "env": { "RADIUS_ENV": "self-hosted" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 930784ca77..3778301523 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,7 @@ "command": "bash", "args": [ "-c", - "(test -d ../deployment-engine/src && test -d ../deployment-engine/submodules/bicep-extensibility/src) || { echo >&1 \"The project-radius/deployment-engine is not cloned as a sibling to the radius repo or is missing submodules. Please clone the project-radius/deployment-engine repo next to the Radius repo and run git submodule update --init and try again.\"; exit 1; }" + "(test -d ../deployment-engine/src && test -d ../deployment-engine/submodules/bicep-extensibility/src) || { echo >&1 \"The radius-project/deployment-engine is not cloned as a sibling to the radius repo or is missing submodules. Please clone the radius-project/deployment-engine repo next to the Radius repo and run git submodule update --init and try again.\"; exit 1; }" ], "type": "shell", "options": { @@ -23,7 +23,7 @@ }, { "label": "Build Deployment Engine", - "detail": "Builds the Deployment Engine. This requires the project-radius/deployment engine repo to be cloned as a sibling to the project-radius/radius repo", + "detail": "Builds the Deployment Engine. This requires the radius-project/deployment engine repo to be cloned as a sibling to the radius-project/radius repo", "dependsOn": ["Check for Deployment Engine"], "command": "dotnet build", "type": "shell", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1ef5943ba..4e20c58262 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,25 +7,25 @@ Radius is in an early phase of development right now. We welcome feedback in the You can find our full **contributor documentation** including instructions at the following links: - [How to contribute](./docs/contributing/how-to.md) -- [See "good first issues"](https://github.com/project-radius/radius/issues?q=is:issue+is:open+label:%22good+first+issue%22) +- [See "good first issues"](https://github.com/radius-project/radius/issues?q=is:issue+is:open+label:%22good+first+issue%22) - [Install prerequisites](./docs/contributing/contributing-code/contributing-code-prerequisites/) - [Create your first commit (full walkthrough)](./contributing-code-first-commit/first-commit-00-prerequisites.md) - [Building the repo](./docs/contributing/contributing-code/contributing-code-building/) - [Understanding repo organiztion](./docs/contributing/contributing-code/contributing-code-organization/) - [Contribute to issues](./docs/contributing/contributing-issues/) - [Create pull requests](./docs/contributing/contributing-pull-requests/) -- [Contribute to documentation](https://github.com/project-radius/docs) +- [Contribute to documentation](https://github.com/radius-project/docs) ## Current status We welcome small pull request contributions from anyone (docs improvements, bug fixes, minor features.) as long as they follow a few guidelines: - For very minor changes like correcting a typo feel free to send a pull request. Otherwise ... -- Please start by [choosing an existing issue](https://github.com/project-radius/radius/issues), or [opening an issue](https://github.com/project-radius/radius/issues/new/choose) to work on. +- Please start by [choosing an existing issue](https://github.com/radius-project/radius/issues), or [opening an issue](https://github.com/radius-project/radius/issues/new/choose) to work on. - The maintainers will respond to your issue, please work with the maintainers to ensure that what you're doing is in scope for the project before writing any code. - If you have any doubt whether a contribution would be valuable, feel free to ask. ## Code of conduct This project has adopted the [Contributor Covenant](http://contributor-covenant.org/). -For more information see [CODE_OF_CONDUCT.md](https://github.com/project-radius/community/blob/main/CODE-OF-CONDUCT.md) +For more information see [CODE_OF_CONDUCT.md](https://github.com/radius-project/community/blob/main/CODE-OF-CONDUCT.md) diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 27e8523afb..67b40ec176 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -2,4 +2,4 @@ ## Code of Conduct -This project has adopted the [Contributor Covenant Code of Conduct](https://github.com/project-radius/community/blob/main/CODE-OF-CONDUCT.md). \ No newline at end of file +This project has adopted the [Contributor Covenant Code of Conduct](https://github.com/radius-project/community/blob/main/CODE-OF-CONDUCT.md). \ No newline at end of file diff --git a/README.md b/README.md index f3503a99a6..e0d0643208 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Radius is currently in an invitation-only private release and we are working har ## Quickstarts and samples -See the [Radius quickstarts](https://docs.radapp.dev/getting-started/quickstarts/) and [samples repository](https://github.com/project-radius/samples) for tutorials and code examples that can help you get started with Radius. +See the [Radius quickstarts](https://docs.radapp.dev/getting-started/quickstarts/) and [samples repository](https://github.com/radius-project/samples) for tutorials and code examples that can help you get started with Radius. ## Getting help @@ -37,7 +37,7 @@ See the [Radius quickstarts](https://docs.radapp.dev/getting-started/quickstarts ## Community -We welcome your contributions and suggestions! One of the easiest ways to contribute is to participate in Issue discussions, chat on [Discord server](https://discord.gg/SRG3ePMKNy) or the monthly [community calls](#community-calls). For more information on the community engagement, developer and contributing guidelines and more, head over to the [Radius community repo](https://github.com/project-radius/community). +We welcome your contributions and suggestions! One of the easiest ways to contribute is to participate in Issue discussions, chat on [Discord server](https://discord.gg/SRG3ePMKNy) or the monthly [community calls](#community-calls). For more information on the community engagement, developer and contributing guidelines and more, head over to the [Radius community repo](https://github.com/radius-project/community). ### Contact us @@ -47,7 +47,7 @@ Please visit our [Discord server](https://discord.gg/SRG3ePMKNy) to contact us a Every month we host a community call to showcase new features, review upcoming milestones, and engage in a Q&A. All are welcome! -📞 Visit our [community meetings](https://github.com/project-radius/community/#community-meetings) page for upcoming dates and the meeting link. +📞 Visit our [community meetings](https://github.com/radius-project/community/#community-meetings) page for upcoming dates and the meeting link. ## Contributing to Radius @@ -57,17 +57,17 @@ To contribute to Radius documentation visit [Radius documentation](https://docs. ## Repositories -[Radius](https://github.com/project-radius/radius) is the main Radius repository. It contains all of Radius code and documentation. +[Radius](https://github.com/radius-project/radius) is the main Radius repository. It contains all of Radius code and documentation. In addition, we have the below repositories. | Repo | Description | |:-----|:------------| -| [Docs](https://github.com/project-radius/docs) | This repository contains the Radius documentation source for Radius. -| [Samples](https://github.com/project-radius/samples) | This repository contains the source code for quickstarts, reference apps, and tutorials for Radius. -| [Recipes](https://github.com/project-radius/recipes) | This repo contains commonly used Recipe templates for Radius environments. -| [Website](https://github.com/project-radius/website) | This repository contains the source code for the Radius website. -| [Bicep](https://github.com/project-radius/bicep) | This repository contains source code for Bicep, which is a DSL for deploying cloud resources types. -| [AWS Bicep Types](https://github.com/project-radius/bicep-types-aws) | This repository contains the tooling for Bicep support for AWS resource types. +| [Docs](https://github.com/radius-project/docs) | This repository contains the Radius documentation source for Radius. +| [Samples](https://github.com/radius-project/samples) | This repository contains the source code for quickstarts, reference apps, and tutorials for Radius. +| [Recipes](https://github.com/radius-project/recipes) | This repo contains commonly used Recipe templates for Radius environments. +| [Website](https://github.com/radius-project/website) | This repository contains the source code for the Radius website. +| [Bicep](https://github.com/radius-project/bicep) | This repository contains source code for Bicep, which is a DSL for deploying cloud resources types. +| [AWS Bicep Types](https://github.com/radius-project/bicep-types-aws) | This repository contains the tooling for Bicep support for AWS resource types. ## Security diff --git a/build/build.mk b/build/build.mk index b8e9f12076..16f7fe77d8 100644 --- a/build/build.mk +++ b/build/build.mk @@ -14,7 +14,7 @@ # limitations under the License. # ------------------------------------------------------------ -BASE_PACKAGE_NAME := github.com/project-radius/radius +BASE_PACKAGE_NAME := github.com/radius-project/radius OUT_DIR := ./dist GOOS ?= $(shell go env GOOS) diff --git a/build/docker.mk b/build/docker.mk index 5413d2b84c..6c9a917c94 100644 --- a/build/docker.mk +++ b/build/docker.mk @@ -16,7 +16,7 @@ DOCKER_REGISTRY?=$(shell whoami) DOCKER_TAG_VERSION?=latest -IMAGE_SRC?=https://github.com/project-radius/radius +IMAGE_SRC?=https://github.com/radius-project/radius ##@ Docker Images diff --git a/build/generate.mk b/build/generate.mk index c4b6b8b672..3863d7b2fe 100644 --- a/build/generate.mk +++ b/build/generate.mk @@ -23,23 +23,22 @@ ifeq ($(GOOS),windows) endif .PHONY: generate -generate: generate-genericcliclient generate-rad-corerp-client generate-rad-linkrp-client generate-rad-datastoresrp-client generate-rad-messagingrp-client generate-rad-daprrp-client generate-rad-ucp-client generate-go generate-bicep-types generate-ucp-crd ## Generates all targets. - -.PHONY: generate-cadl-installed -generate-cadl-installed: - @echo "$(ARROW) Detecting cadl..." - cd cadl/Applications.Link && npx$(CMD_EXT) -q cadl --help > /dev/null || { echo "cadl is a required dependency"; exit 1; } - @echo "$(ARROW) OK" +generate: generate-genericcliclient generate-rad-corerp-client generate-rad-datastoresrp-client generate-rad-messagingrp-client generate-rad-daprrp-client generate-rad-ucp-client generate-go generate-bicep-types generate-ucp-crd ## Generates all targets. +.PHONY: generate-tsp-installed +generate-tsp-installed: + @echo "$(ARROW) Detecting tsp..." + cd typespec/ && npx$(CMD_EXT) -q tsp --help > /dev/null || { echo "run 'npm ci' in typespec directory."; exit 1; } + @echo "$(ARROW) OK" .PHONY: generate-openapi-spec -generate-openapi-spec: - @echo "Generating openapi specs from cadl models." - cd cadl/Applications.Link && npx$(CMD_EXT) cadl compile . - cd cadl/UCP && npx$(CMD_EXT) cadl compile . - cd cadl/Applications.Messaging && npx$(CMD_EXT) cadl compile . - cd cadl/Applications.Dapr && npx$(CMD_EXT) cadl compile . - cd cadl/Applications.Datastores && npx$(CMD_EXT) cadl compile . +generate-openapi-spec: # Generates all Radius OpenAPI specs from TypeSpec. + @echo "Generating openapi specs from typespec models." + cd typespec/UCP && npx$(CMD_EXT) tsp compile . + cd typespec/Applications.Core && npx$(CMD_EXT) tsp compile . + cd typespec/Applications.Dapr && npx$(CMD_EXT) tsp compile . + cd typespec/Applications.Messaging && npx$(CMD_EXT) tsp compile . + cd typespec/Applications.Datastores && npx$(CMD_EXT) tsp compile . .PHONY: generate-node-installed generate-node-installed: @@ -71,27 +70,22 @@ generate-genericcliclient: generate-node-installed generate-autorest-installed autorest pkg/cli/clients_new/README.md --tag=2022-03-15-privatepreview .PHONY: generate-rad-corerp-client -generate-rad-corerp-client: generate-node-installed generate-autorest-installed ## Generates the corerp client SDK (Autorest). +generate-rad-corerp-client: generate-node-installed generate-autorest-installed generate-tsp-installed generate-openapi-spec ## Generates the corerp client SDK (Autorest). @echo "$(AUTOREST_MODULE_VERSION) is module version" autorest pkg/corerp/api/README.md --tag=core-2022-03-15-privatepreview -.PHONY: generate-rad-linkrp-client -generate-rad-linkrp-client: generate-node-installed generate-autorest-installed generate-openapi-spec ## Generates the linkrp client SDK (Autorest). - @echo "$(AUTOREST_MODULE_VERSION) is module version" - autorest pkg/linkrp/api/README.md --tag=link-2022-03-15-privatepreview - .PHONY: generate-rad-datastoresrp-client -generate-rad-datastoresrp-client: generate-node-installed generate-autorest-installed generate-openapi-spec ## Generates the datastoresrp client SDK (Autorest). +generate-rad-datastoresrp-client: generate-node-installed generate-autorest-installed generate-tsp-installed generate-openapi-spec ## Generates the datastoresrp client SDK (Autorest). @echo "$(AUTOREST_MODULE_VERSION) is module version" autorest pkg/datastoresrp/api/README.md --tag=datastores-2022-03-15-privatepreview .PHONY: generate-rad-messagingrp-client -generate-rad-messagingrp-client: generate-node-installed generate-autorest-installed generate-openapi-spec ## Generates the messagingrp client SDK (Autorest). +generate-rad-messagingrp-client: generate-node-installed generate-autorest-installed generate-tsp-installed generate-openapi-spec ## Generates the messagingrp client SDK (Autorest). @echo "$(AUTOREST_MODULE_VERSION) is module version" autorest pkg/messagingrp/api/README.md --tag=messaging-2022-03-15-privatepreview .PHONY: generate-rad-daprrp-client -generate-rad-daprrp-client: generate-node-installed generate-autorest-installed generate-openapi-spec ## Generates the daprrp client SDK (Autorest). +generate-rad-daprrp-client: generate-node-installed generate-autorest-installed generate-tsp-installed generate-openapi-spec ## Generates the daprrp client SDK (Autorest). @echo "$(AUTOREST_MODULE_VERSION) is module version" autorest pkg/daprrp/api/README.md --tag=dapr-2022-03-15-privatepreview diff --git a/build/test.mk b/build/test.mk index fa1d7c5517..e87c9ee739 100644 --- a/build/test.mk +++ b/build/test.mk @@ -86,7 +86,7 @@ oav-installed: @which oav > /dev/null || { echo "run 'npm install -g oav' to install oav"; exit 1; } @echo "$(ARROW) OK" -# TODO re-enable https://github.com/project-radius/radius/issues/5091 +# TODO re-enable https://github.com/radius-project/radius/issues/5091 .PHONY: test-ucp-spec-examples test-ucp-spec-examples: oav-installed ## Validates UCP examples conform to UCP OpenAPI Spec # @echo "$(ARROW) Testing x-ms-examples conform to ucp spec..." diff --git a/cadl/Applications.Core/cadl-output/containers.json b/cadl/Applications.Core/cadl-output/containers.json deleted file mode 100644 index 4ca1cd5f35..0000000000 --- a/cadl/Applications.Core/cadl-output/containers.json +++ /dev/null @@ -1,914 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "version": "0000-00-00", - "description": "REST API for Applications.Core Container Resource", - "x-cadl-generated": [ - { - "emitter": "@azure-tools/cadl-autorest" - } - ] - }, - "schemes": [ - "https" - ], - "host": "management.azure.com", - "produces": [ - "application/json" - ], - "consumes": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "description": "Azure Active Directory OAuth2 Flow.", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "" - } - } - }, - "tags": [ - { - "name": "Containers" - }, - { - "name": "Operations" - } - ], - "paths": { - "/{rootScope}/providers/Applications.Core/containers": { - "get": { - "tags": [ - "Containers" - ], - "operationId": "Containers_ListByResourceGroup", - "description": "List ContainerResource resources by resource group", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/ContainerResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/containers/{containerName}": { - "get": { - "tags": [ - "Containers" - ], - "operationId": "Containers_Get", - "description": "Get a ContainerResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ContainerResource.containerName" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "Containers" - ], - "operationId": "Containers_CreateOrUpdate", - "description": "Create a ContainerResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ContainerResource.containerName" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - }, - "patch": { - "tags": [ - "Containers" - ], - "operationId": "Containers_Update", - "description": "Update a ContainerResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ContainerResource.containerName" - }, - { - "name": "properties", - "in": "body", - "required": true, - "description": "The resource properties to be updated.", - "schema": { - "$ref": "#/definitions/ContainerResourceUpdate" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "Containers" - ], - "operationId": "Containers_Delete", - "description": "Delete a ContainerResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ContainerResource.containerName" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - } - }, - "/providers/Applications.Core/operations": { - "get": { - "tags": [ - "Operations" - ], - "operationId": "Operations_List", - "description": "List the operations for the provider", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/OperationListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - } - }, - "definitions": { - "BasicResourceProperties": { - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource." - } - }, - "description": "Basic properties of a Radius resource.", - "required": [ - "status" - ] - }, - "ConnectionProperties": { - "type": "object", - "properties": { - "source": { - "type": "string", - "description": "The source of the connection" - }, - "disableDefaultEnvVars": { - "type": "boolean", - "description": "default environment variable override", - "default": false - }, - "iam": { - "$ref": "#/definitions/IamProperties", - "description": "iam properties" - } - }, - "description": "Connection Properties", - "required": [ - "source" - ] - }, - "Container": { - "type": "object", - "properties": { - "image": { - "type": "string", - "description": "The registry and image to download and run in your container" - }, - "env": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "x-cadl-name": "Map", - "description": "environment" - }, - "ports": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ContainerPort" - }, - "x-cadl-name": "Map", - "description": "container ports" - }, - "readinessProbe": { - "$ref": "#/definitions/HealthProbeProperties", - "description": "readiness probe properties" - }, - "livenessProbe": { - "$ref": "#/definitions/HealthProbeProperties", - "description": "liveness probe properties" - }, - "volumes": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Volume" - }, - "x-cadl-name": "Map", - "description": "container volumes" - } - }, - "description": "Definition of a container", - "required": [ - "image" - ] - }, - "ContainerPort": { - "type": "object", - "properties": { - "containerPort": { - "type": "integer", - "format": "int32", - "description": "The listening port number" - }, - "protocol": { - "$ref": "#/definitions/PortProtocol", - "description": "Protocol in use by the port" - }, - "provides": { - "type": "string", - "description": "Specifies a route provided by this port" - } - }, - "description": "Specifies a listening port for the container", - "required": [ - "containerPort" - ] - }, - "ContainerProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "The status of the last operation." - }, - "application": { - "type": "string", - "description": "Specifies resource id of the application" - }, - "connections": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ConnectionProperties" - }, - "x-cadl-name": "Map", - "description": "Specifies a connection to another resource." - }, - "container": { - "$ref": "#/definitions/Container", - "description": "Definition of a container." - }, - "extensions": { - "type": "array", - "items": { - "$ref": "#/definitions/Extension" - }, - "x-ms-identifiers": [], - "x-cadl-name": "Extension[]", - "description": "Extensions spec of the resource" - } - }, - "description": "Container properties", - "required": [ - "application", - "connections", - "container", - "extensions" - ], - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "ContainerResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/ContainerProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-mutability": [ - "read", - "create" - ], - "x-ms-client-flatten": true - } - }, - "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", - "required": [ - "properties" - ], - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "ContainerResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/ContainerResource" - }, - "x-cadl-name": "ContainerResource[]", - "description": "The ContainerResource items on this page" - }, - "nextLink": { - "type": "string", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a ContainerResource list operation.", - "required": [ - "value" - ] - }, - "ContainerResourceUpdate": { - "type": "object", - "properties": { - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "x-cadl-name": "Record", - "description": "Resource tags." - }, - "properties": { - "$ref": "#/definitions/ContainerResourceUpdateProperties" - } - }, - "description": "The type used for update operations of the ContainerResource." - }, - "ContainerResourceUpdateProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "The status of the last operation." - }, - "application": { - "type": "string", - "description": "Specifies resource id of the application" - }, - "connections": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ConnectionProperties" - }, - "x-cadl-name": "Map", - "description": "Specifies a connection to another resource." - }, - "container": { - "$ref": "#/definitions/Container", - "description": "Definition of a container." - }, - "extensions": { - "type": "array", - "items": { - "$ref": "#/definitions/Extension" - }, - "x-ms-identifiers": [], - "x-cadl-name": "Extension[]", - "description": "Extensions spec of the resource" - }, - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource." - } - }, - "description": "The updatable properties of the ContainerResource." - }, - "DaprProtocol": { - "type": "string", - "enum": [ - "http", - "grpc" - ], - "x-ms-enum": { - "name": "DaprProtocol", - "modelAsString": true - } - }, - "DaprSidecarExtension": { - "type": "object", - "properties": { - "appPort": { - "type": "integer", - "format": "int32", - "description": "The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. " - }, - "appId": { - "type": "string", - "description": "The Dapr appId. Specifies the identifier used by Dapr for service invocation." - }, - "config": { - "type": "string", - "description": "Specifies the Dapr configuration to use for the resource." - }, - "protocol": { - "$ref": "#/definitions/DaprProtocol", - "description": "Specifies the Dapr app-protocol to use for the resource." - }, - "provides": { - "type": "string", - "description": "Specifies the resource id of a dapr.io.InvokeHttpRoute that can route traffic to this resource." - } - }, - "description": "Specifies the resource should have a Dapr sidecar injected", - "required": [ - "appId", - "provides" - ], - "allOf": [ - { - "$ref": "#/definitions/Extension" - } - ], - "x-ms-discriminator-value": "daprSidecar" - }, - "EphemeralVolume": { - "type": "object", - "properties": { - "managedStore": { - "$ref": "#/definitions/ManagedStore", - "description": "Backing store for the ephemeral volume" - } - }, - "description": "Specifies an ephemeral volume for a container", - "required": [ - "managedStore" - ], - "allOf": [ - { - "$ref": "#/definitions/Volume" - } - ], - "x-ms-discriminator-value": "ephemeral" - }, - "ExecHealthProbeProperties": { - "type": "object", - "properties": { - "command": { - "type": "string", - "description": "Command to execute to probe readiness/liveness" - } - }, - "description": "Specifies the properties for readiness/liveness probe using an executable", - "required": [ - "command" - ], - "allOf": [ - { - "$ref": "#/definitions/HealthProbeProperties" - } - ], - "x-ms-discriminator-value": "exec" - }, - "Extension": { - "type": "object", - "properties": { - "kind": { - "type": "string", - "description": "Discriminator property for Extension." - } - }, - "description": "Extension of a resource.", - "discriminator": "kind", - "required": [ - "kind" - ] - }, - "HealthProbeProperties": { - "type": "object", - "properties": { - "kind": { - "type": "string", - "description": "Discriminator property for HealthProbeProperties." - }, - "initialDelaySeconds": { - "type": "number", - "format": "float", - "description": "Initial delay in seconds before probing for readiness/liveness" - }, - "failureThreshold": { - "type": "number", - "format": "float", - "description": "Threshold number of times the probe fails after which a failure would be reported" - }, - "periodSeconds": { - "type": "number", - "format": "float", - "description": "Interval for the readiness/liveness probe in seconds" - } - }, - "description": "Properties for readiness/liveness probe", - "discriminator": "kind", - "required": [ - "kind" - ] - }, - "HttpGetHealthProbeProperties": { - "type": "object", - "properties": { - "containerPort": { - "type": "integer", - "format": "int32", - "description": "The listening port number" - }, - "path": { - "type": "string", - "description": "The route to make the HTTP request on" - }, - "headers": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "x-cadl-name": "Map", - "description": "Custom HTTP headers to add to the get request" - } - }, - "description": "Specifies the properties for readiness/liveness probe using HTTP Get", - "required": [ - "containerPort", - "path" - ], - "allOf": [ - { - "$ref": "#/definitions/HealthProbeProperties" - } - ], - "x-ms-discriminator-value": "httpGet" - }, - "IamProperties": { - "type": "object", - "properties": { - "kind": { - "$ref": "#/definitions/Kind", - "description": "The kind of IAM provider to configure" - }, - "roles": { - "type": "array", - "items": { - "type": "string" - }, - "x-cadl-name": "string[]", - "description": "RBAC permissions to be assigned on the source resource" - } - }, - "description": "Iam properties", - "required": [ - "kind", - "roles" - ] - }, - "Kind": { - "type": "string", - "enum": [ - "azure" - ], - "x-ms-enum": { - "name": "Kind", - "modelAsString": true - } - }, - "ManagedStore": { - "type": "string", - "enum": [ - "memory", - "disk" - ], - "x-ms-enum": { - "name": "ManagedStore", - "modelAsString": true - } - }, - "ManualScalingExtension": { - "type": "object", - "properties": { - "replicas": { - "type": "integer", - "format": "int32", - "description": "Replica count." - } - }, - "description": "ManualScaling Extension", - "required": [ - "replicas" - ], - "allOf": [ - { - "$ref": "#/definitions/Extension" - } - ], - "x-ms-discriminator-value": "manualScaling" - }, - "OutputResource": { - "type": "object", - "properties": {}, - "description": "Properties of an output resource." - }, - "PersistentVolume": { - "type": "object", - "properties": { - "rbac": { - "$ref": "#/definitions/VolumePermission", - "description": "Container read/write access to the volume" - }, - "source": { - "type": "string", - "description": "The source of the volume" - } - }, - "description": "Specifies a persistent volume for a container", - "required": [ - "source" - ], - "allOf": [ - { - "$ref": "#/definitions/Volume" - } - ], - "x-ms-discriminator-value": "persistent" - }, - "PortProtocol": { - "type": "string", - "enum": [ - "TCP", - "UDP" - ], - "x-ms-enum": { - "name": "PortProtocol", - "modelAsString": true - } - }, - "ProvisioningState": { - "type": "string", - "enum": [ - "Succeeded", - "Failed", - "Canceled", - "Provisioning", - "Updating", - "Deleting", - "Accepted" - ], - "x-ms-enum": { - "name": "ProvisioningState", - "modelAsString": true - } - }, - "ResourceStatus": { - "type": "object", - "properties": { - "outputResources": { - "type": "array", - "items": { - "$ref": "#/definitions/OutputResource" - }, - "x-ms-identifiers": [], - "x-cadl-name": "OutputResource[]", - "description": "Properties of an output resource" - } - }, - "description": "Status of a resource.", - "required": [ - "outputResources" - ] - }, - "TcpHealthProbeProperties": { - "type": "object", - "properties": { - "containerPort": { - "type": "integer", - "format": "int32", - "description": "The listening port number" - } - }, - "description": "Specifies the properties for readiness/liveness probe using TCP", - "required": [ - "containerPort" - ], - "allOf": [ - { - "$ref": "#/definitions/HealthProbeProperties" - } - ], - "x-ms-discriminator-value": "tcp" - }, - "Volume": { - "type": "object", - "properties": { - "kind": { - "type": "string", - "description": "Discriminator property for Volume." - }, - "mountPath": { - "type": "string", - "description": "The path where the volume is mounted" - } - }, - "description": "Specifies a volume for a container", - "discriminator": "kind", - "required": [ - "kind" - ] - }, - "VolumePermission": { - "type": "string", - "enum": [ - "read", - "write" - ], - "x-ms-enum": { - "name": "VolumePermission", - "modelAsString": true - } - } - }, - "parameters": { - "ContainerResource.containerName": { - "name": "containerName", - "in": "path", - "required": true, - "description": "Container name", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string", - "x-ms-parameter-location": "method" - }, - "RootScopeParam": { - "name": "rootScope", - "in": "path", - "required": true, - "description": "root scope path", - "minLength": 1, - "type": "string", - "x-ms-parameter-location": "method" - } - } -} diff --git a/cadl/Applications.Core/cadl-output/environment.json b/cadl/Applications.Core/cadl-output/environment.json deleted file mode 100644 index 26fdb1c8a6..0000000000 --- a/cadl/Applications.Core/cadl-output/environment.json +++ /dev/null @@ -1,462 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "version": "0000-00-00", - "description": "REST API for Applications.Core Environment Resource", - "x-cadl-generated": [ - { - "emitter": "@azure-tools/cadl-autorest" - } - ] - }, - "schemes": [ - "https" - ], - "host": "management.azure.com", - "produces": [ - "application/json" - ], - "consumes": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "description": "Azure Active Directory OAuth2 Flow.", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "" - } - } - }, - "tags": [ - { - "name": "Environment" - }, - { - "name": "Operations" - } - ], - "paths": { - "/{rootScope}/providers/Applications.Core/environments": { - "get": { - "tags": [ - "Environment" - ], - "operationId": "Environment_ListByResourceGroup", - "description": "List EnvironmentResource resources by resource group", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/EnvironmentResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/environments/{environmentName}": { - "get": { - "tags": [ - "Environment" - ], - "operationId": "Environment_Get", - "description": "Get a EnvironmentResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/EnvironmentResource.environmentName" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "Environment" - ], - "operationId": "Environment_CreateOrUpdate", - "description": "Create a EnvironmentResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/EnvironmentResource.environmentName" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - }, - "patch": { - "tags": [ - "Environment" - ], - "operationId": "Environment_Update", - "description": "Update a EnvironmentResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/EnvironmentResource.environmentName" - }, - { - "name": "properties", - "in": "body", - "required": true, - "description": "The resource properties to be updated.", - "schema": { - "$ref": "#/definitions/EnvironmentResourceUpdate" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "Environment" - ], - "operationId": "Environment_Delete", - "description": "Delete a EnvironmentResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/EnvironmentResource.environmentName" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - } - }, - "/providers/Applications.Core/operations": { - "get": { - "tags": [ - "Operations" - ], - "operationId": "Operations_List", - "description": "List the operations for the provider", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/OperationListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - } - }, - "definitions": { - "EnvironmentCompute": { - "type": "object", - "properties": { - "kind": { - "type": "string", - "description": "Discriminator property for EnvironmentCompute." - }, - "resourceId": { - "type": "string", - "description": "The resource id of the compute resource for application environment." - } - }, - "description": "Compute resource used by application environment resource.", - "discriminator": "kind", - "required": [ - "kind", - "resourceId" - ] - }, - "EnvironmentProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "The status of the last operation.", - "readOnly": true - }, - "compute": { - "$ref": "#/definitions/EnvironmentCompute", - "description": "The compute resource used by application environment." - } - }, - "description": "Environment properties", - "required": [ - "compute" - ] - }, - "EnvironmentResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/EnvironmentProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-mutability": [ - "read", - "create" - ], - "x-ms-client-flatten": true - } - }, - "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", - "required": [ - "properties" - ], - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "EnvironmentResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/EnvironmentResource" - }, - "x-cadl-name": "EnvironmentResource[]", - "description": "The EnvironmentResource items on this page" - }, - "nextLink": { - "type": "string", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a EnvironmentResource list operation.", - "required": [ - "value" - ] - }, - "EnvironmentResourceUpdate": { - "type": "object", - "properties": { - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "x-cadl-name": "Record", - "description": "Resource tags." - }, - "properties": { - "$ref": "#/definitions/EnvironmentResourceUpdateProperties" - } - }, - "description": "The type used for update operations of the EnvironmentResource." - }, - "EnvironmentResourceUpdateProperties": { - "type": "object", - "properties": { - "compute": { - "$ref": "#/definitions/EnvironmentCompute", - "description": "The compute resource used by application environment." - } - }, - "description": "The updatable properties of the EnvironmentResource." - }, - "KubernetesCompute": { - "type": "object", - "properties": { - "nameSpace": { - "type": "string", - "description": "The namespace to use for the environment" - } - }, - "description": "Specifies the properties for Kubernetes compute environment", - "required": [ - "nameSpace" - ], - "allOf": [ - { - "$ref": "#/definitions/EnvironmentCompute" - } - ], - "x-ms-discriminator-value": "kubernetes" - }, - "ProvisioningState": { - "type": "string", - "enum": [ - "Succeeded", - "Failed", - "Canceled", - "Provisioning", - "Updating", - "Deleting", - "Accepted" - ], - "x-ms-enum": { - "name": "ProvisioningState", - "modelAsString": true - } - } - }, - "parameters": { - "EnvironmentResource.environmentName": { - "name": "environmentName", - "in": "path", - "required": true, - "description": "environment name", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string", - "x-ms-parameter-location": "method" - }, - "RootScopeParam": { - "name": "rootScope", - "in": "path", - "required": true, - "description": "root scope path", - "minLength": 1, - "type": "string", - "x-ms-parameter-location": "method" - } - } -} diff --git a/cadl/Applications.Core/cadl-output/gateways.json b/cadl/Applications.Core/cadl-output/gateways.json deleted file mode 100644 index 0897679d8b..0000000000 --- a/cadl/Applications.Core/cadl-output/gateways.json +++ /dev/null @@ -1,552 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "version": "0000-00-00", - "description": "REST API for Applications.Core Gateway Resource", - "x-cadl-generated": [ - { - "emitter": "@azure-tools/cadl-autorest" - } - ] - }, - "schemes": [ - "https" - ], - "host": "management.azure.com", - "produces": [ - "application/json" - ], - "consumes": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "description": "Azure Active Directory OAuth2 Flow.", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "" - } - } - }, - "tags": [ - { - "name": "Gateway" - }, - { - "name": "Operations" - } - ], - "paths": { - "/{rootScope}/providers/Applications.Core/gateways": { - "get": { - "tags": [ - "Gateway" - ], - "operationId": "Gateway_ListByResourceGroup", - "description": "List GatewayResource resources by resource group", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/GatewayResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/gateways/{gatewayName}": { - "get": { - "tags": [ - "Gateway" - ], - "operationId": "Gateway_Get", - "description": "Get a GatewayResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/GatewayResource.gatewayName" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "Gateway" - ], - "operationId": "Gateway_CreateOrUpdate", - "description": "Create a GatewayResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/GatewayResource.gatewayName" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - }, - "patch": { - "tags": [ - "Gateway" - ], - "operationId": "Gateway_Update", - "description": "Update a GatewayResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/GatewayResource.gatewayName" - }, - { - "name": "properties", - "in": "body", - "required": true, - "description": "The resource properties to be updated.", - "schema": { - "$ref": "#/definitions/GatewayResourceUpdate" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "Gateway" - ], - "operationId": "Gateway_Delete", - "description": "Delete a GatewayResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/GatewayResource.gatewayName" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - } - }, - "/providers/Applications.Core/operations": { - "get": { - "tags": [ - "Operations" - ], - "operationId": "Operations_List", - "description": "List the operations for the provider", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/OperationListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - } - }, - "definitions": { - "BasicResourceProperties": { - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource." - } - }, - "description": "Basic properties of a Radius resource.", - "required": [ - "status" - ] - }, - "GatewayProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the Gateway at the time the operation was called.", - "readOnly": true - }, - "application": { - "type": "string", - "description": "The resource id of the application linked to Gateway resource." - }, - "internal": { - "type": "boolean", - "description": "Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).", - "default": false - }, - "hostname": { - "$ref": "#/definitions/GatewayPropertiesHostname", - "description": "Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io." - }, - "routes": { - "type": "array", - "items": { - "$ref": "#/definitions/GatewayRoute" - }, - "x-ms-identifiers": [], - "x-cadl-name": "GatewayRoute[]", - "description": "Routes attached to this Gateway" - }, - "url": { - "type": "string", - "description": "URL of the gateway resource. Readonly", - "readOnly": true - } - }, - "description": "Gateway properties", - "required": [ - "application", - "routes" - ], - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "GatewayPropertiesHostname": { - "type": "object", - "properties": { - "prefix": { - "type": "string", - "description": "Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined." - }, - "fullyQualifiedHostname": { - "type": "string", - "description": "Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined." - } - }, - "description": "Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io.", - "required": [ - "prefix", - "fullyQualifiedHostname" - ] - }, - "GatewayResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/GatewayProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-mutability": [ - "read", - "create" - ], - "x-ms-client-flatten": true - } - }, - "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", - "required": [ - "properties" - ], - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "GatewayResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/GatewayResource" - }, - "x-cadl-name": "GatewayResource[]", - "description": "The GatewayResource items on this page" - }, - "nextLink": { - "type": "string", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a GatewayResource list operation.", - "required": [ - "value" - ] - }, - "GatewayResourceUpdate": { - "type": "object", - "properties": { - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "x-cadl-name": "Record", - "description": "Resource tags." - }, - "properties": { - "$ref": "#/definitions/GatewayResourceUpdateProperties" - } - }, - "description": "The type used for update operations of the GatewayResource." - }, - "GatewayResourceUpdateProperties": { - "type": "object", - "properties": { - "application": { - "type": "string", - "description": "The resource id of the application linked to Gateway resource." - }, - "internal": { - "type": "boolean", - "description": "Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).", - "default": false - }, - "hostname": { - "$ref": "#/definitions/GatewayPropertiesHostname", - "description": "Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io." - }, - "routes": { - "type": "array", - "items": { - "$ref": "#/definitions/GatewayRoute" - }, - "x-ms-identifiers": [], - "x-cadl-name": "GatewayRoute[]", - "description": "Routes attached to this Gateway" - }, - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource." - } - }, - "description": "The updatable properties of the GatewayResource." - }, - "GatewayRoute": { - "type": "object", - "properties": { - "path": { - "type": "string", - "description": "The path to match the incoming request path on. Ex - /myservice." - }, - "destination": { - "type": "string", - "description": "The HttpRoute to route to. Ex - myserviceroute.id." - }, - "replacePrefix": { - "type": "string", - "description": "Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute'" - } - }, - "description": "Route attached to Gateway", - "required": [ - "path", - "destination", - "replacePrefix" - ] - }, - "OutputResource": { - "type": "object", - "properties": {}, - "description": "Properties of an output resource." - }, - "ProvisioningState": { - "type": "string", - "enum": [ - "Succeeded", - "Failed", - "Canceled", - "Provisioning", - "Updating", - "Deleting", - "Accepted" - ], - "x-ms-enum": { - "name": "ProvisioningState", - "modelAsString": true - } - }, - "ResourceStatus": { - "type": "object", - "properties": { - "outputResources": { - "type": "array", - "items": { - "$ref": "#/definitions/OutputResource" - }, - "x-ms-identifiers": [], - "x-cadl-name": "OutputResource[]", - "description": "Properties of an output resource" - } - }, - "description": "Status of a resource.", - "required": [ - "outputResources" - ] - } - }, - "parameters": { - "GatewayResource.gatewayName": { - "name": "gatewayName", - "in": "path", - "required": true, - "description": "Gateway name", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string", - "x-ms-parameter-location": "method" - }, - "RootScopeParam": { - "name": "rootScope", - "in": "path", - "required": true, - "description": "root scope path", - "minLength": 1, - "type": "string", - "x-ms-parameter-location": "method" - } - } -} diff --git a/cadl/Applications.Core/cadl-output/httpRoutes.json b/cadl/Applications.Core/cadl-output/httpRoutes.json deleted file mode 100644 index 17b70d6074..0000000000 --- a/cadl/Applications.Core/cadl-output/httpRoutes.json +++ /dev/null @@ -1,504 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "version": "0000-00-00", - "description": "REST API for Applications.Core HttpRoute Resource", - "x-cadl-generated": [ - { - "emitter": "@azure-tools/cadl-autorest" - } - ] - }, - "schemes": [ - "https" - ], - "host": "management.azure.com", - "produces": [ - "application/json" - ], - "consumes": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "description": "Azure Active Directory OAuth2 Flow.", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "" - } - } - }, - "tags": [ - { - "name": "HttpRoute" - }, - { - "name": "Operations" - } - ], - "paths": { - "/{rootScope}/providers/Applications.Core/httpRoute": { - "get": { - "tags": [ - "HttpRoute" - ], - "operationId": "HttpRoute_ListByResourceGroup", - "description": "List HttpRouteResource resources by resource group", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/HttpRouteResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/httpRoute/{httpRouteName}": { - "get": { - "tags": [ - "HttpRoute" - ], - "operationId": "HttpRoute_Get", - "description": "Get a HttpRouteResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/HttpRouteResource.httpRouteName" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "HttpRoute" - ], - "operationId": "HttpRoute_CreateOrUpdate", - "description": "Create a HttpRouteResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/HttpRouteResource.httpRouteName" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - }, - "patch": { - "tags": [ - "HttpRoute" - ], - "operationId": "HttpRoute_Update", - "description": "Update a HttpRouteResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/HttpRouteResource.httpRouteName" - }, - { - "name": "properties", - "in": "body", - "required": true, - "description": "The resource properties to be updated.", - "schema": { - "$ref": "#/definitions/HttpRouteResourceUpdate" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "HttpRoute" - ], - "operationId": "HttpRoute_Delete", - "description": "Delete a HttpRouteResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/HttpRouteResource.httpRouteName" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - } - }, - "/providers/Applications.Core/operations": { - "get": { - "tags": [ - "Operations" - ], - "operationId": "Operations_List", - "description": "List the operations for the provider", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/OperationListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - } - }, - "definitions": { - "BasicResourceProperties": { - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource." - } - }, - "description": "Basic properties of a Radius resource.", - "required": [ - "status" - ] - }, - "HttpRouteProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the HttpRoute at the time the operation was called.", - "readOnly": true - }, - "application": { - "type": "string", - "description": "The resource id of the application linked to HTTP Route resource." - }, - "internal": { - "type": "boolean", - "description": "Sets HttpRoute to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).", - "default": false - }, - "hostname": { - "type": "string", - "description": "The internal hostname accepting traffic for the HTTP Route. Readonly.", - "readOnly": true - }, - "port": { - "type": "integer", - "format": "int32", - "description": "The port number for the HTTP Route. Defaults to 80. Readonly.", - "default": 80, - "readOnly": true - }, - "scheme": { - "type": "string", - "description": "The scheme used for traffic. Readonly." - }, - "url": { - "type": "string", - "description": "A stable URL that that can be used to route traffic to a resource. Readonly.", - "readOnly": true - } - }, - "description": "HttpRoute properties", - "required": [ - "application" - ], - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "HttpRouteResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/HttpRouteProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-mutability": [ - "read", - "create" - ], - "x-ms-client-flatten": true - } - }, - "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", - "required": [ - "properties" - ], - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "HttpRouteResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/HttpRouteResource" - }, - "x-cadl-name": "HttpRouteResource[]", - "description": "The HttpRouteResource items on this page" - }, - "nextLink": { - "type": "string", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a HttpRouteResource list operation.", - "required": [ - "value" - ] - }, - "HttpRouteResourceUpdate": { - "type": "object", - "properties": { - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "x-cadl-name": "Record", - "description": "Resource tags." - }, - "properties": { - "$ref": "#/definitions/HttpRouteResourceUpdateProperties" - } - }, - "description": "The type used for update operations of the HttpRouteResource." - }, - "HttpRouteResourceUpdateProperties": { - "type": "object", - "properties": { - "application": { - "type": "string", - "description": "The resource id of the application linked to HTTP Route resource." - }, - "internal": { - "type": "boolean", - "description": "Sets HttpRoute to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).", - "default": false - }, - "scheme": { - "type": "string", - "description": "The scheme used for traffic. Readonly." - }, - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource." - } - }, - "description": "The updatable properties of the HttpRouteResource." - }, - "OutputResource": { - "type": "object", - "properties": {}, - "description": "Properties of an output resource." - }, - "ProvisioningState": { - "type": "string", - "enum": [ - "Succeeded", - "Failed", - "Canceled", - "Provisioning", - "Updating", - "Deleting", - "Accepted" - ], - "x-ms-enum": { - "name": "ProvisioningState", - "modelAsString": true - } - }, - "ResourceStatus": { - "type": "object", - "properties": { - "outputResources": { - "type": "array", - "items": { - "$ref": "#/definitions/OutputResource" - }, - "x-ms-identifiers": [], - "x-cadl-name": "OutputResource[]", - "description": "Properties of an output resource" - } - }, - "description": "Status of a resource.", - "required": [ - "outputResources" - ] - } - }, - "parameters": { - "HttpRouteResource.httpRouteName": { - "name": "httpRouteName", - "in": "path", - "required": true, - "description": "HttpRoute name", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string", - "x-ms-parameter-location": "method" - }, - "RootScopeParam": { - "name": "rootScope", - "in": "path", - "required": true, - "description": "root scope path", - "minLength": 1, - "type": "string", - "x-ms-parameter-location": "method" - } - } -} diff --git a/cadl/Applications.Core/containers.cadl b/cadl/Applications.Core/containers.cadl deleted file mode 100644 index 12b7dc4e61..0000000000 --- a/cadl/Applications.Core/containers.cadl +++ /dev/null @@ -1,280 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; - -@armNamespace -@serviceTitle("Applications.Core Management APIs") -@doc("REST API for Applications.Core Container Resource") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Core; - -@doc("Specifies a listening port for the container") -model ContainerPort { - @doc("The listening port number") - containerPort: int32; - - @doc("Protocol in use by the port") - protocol?: PortProtocol; - - @doc("Specifies a route provided by this port") - provides?: string; -} - -@doc("Properties for readiness/liveness probe") -@discriminator("kind") -model HealthProbeProperties { - @doc("Initial delay in seconds before probing for readiness/liveness") - initialDelaySeconds?: float32; - - @doc("Threshold number of times the probe fails after which a failure would be reported") - failureThreshold?: float32; - - @doc("Interval for the readiness/liveness probe in seconds") - periodSeconds?: float32; -} - -@doc("Specifies the properties for readiness/liveness probe using HTTP Get") -model HttpGetHealthProbeProperties extends HealthProbeProperties { - @doc("The HealthProbeProperties kind") - kind: "httpGet"; - - @doc("The listening port number") - containerPort: int32; - - @doc("The route to make the HTTP request on") - path: string; - - @doc("Custom HTTP headers to add to the get request") - headers?: Map; -} - -@doc("Specifies the properties for readiness/liveness probe using TCP") -model TcpHealthProbeProperties extends HealthProbeProperties { - @doc("The HealthProbeProperties kind") - kind: "tcp"; - - @doc("The listening port number") - containerPort: int32; -} - -@doc("Specifies the properties for readiness/liveness probe using an executable") -model ExecHealthProbeProperties extends HealthProbeProperties { - @doc("The HealthProbeProperties kind") - kind: "exec"; - - @doc("Command to execute to probe readiness/liveness") - command: string; -} - -@discriminator("kind") -@doc("Specifies a volume for a container") -model Volume { - @doc("The path where the volume is mounted") - mountPath?: string; -} - -@doc("Specifies an ephemeral volume for a container") -model EphemeralVolume extends Volume { - @doc("The Volume kind") - kind: "ephemeral"; - - @doc("Backing store for the ephemeral volume") - managedStore: ManagedStore; -} - -@doc("Specifies a persistent volume for a container") -model PersistentVolume extends Volume { - @doc("The Volume kind") - kind: "persistent"; - - @doc("Container read/write access to the volume") - rbac?: VolumePermission; - - @doc("The source of the volume") - source: string; -} - -@doc("Extension of a resource.") -@discriminator("kind") -model Extension {} - -@doc("ManualScaling Extension") -model ManualScalingExtension extends Extension { - @doc("Specifies the extension of the resource") - kind: "manualScaling"; - - @doc("Replica count.") - replicas: int32; -} - -@doc("Specifies the resource should have a Dapr sidecar injected") -model DaprSidecarExtension extends Extension { - @doc("Specifies the extension of the resource") - kind: "daprSidecar"; - - @doc("The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. ") - appPort?: int32; - - @doc("The Dapr appId. Specifies the identifier used by Dapr for service invocation.") - appId: string; - - @doc("Specifies the Dapr configuration to use for the resource.") - config?: string; - - @doc("Specifies the Dapr app-protocol to use for the resource.") - protocol?: DaprProtocol; -} - -@doc("Iam properties") -model IamProperties { - @doc("The kind of IAM provider to configure") - kind: Kind; - - @doc("RBAC permissions to be assigned on the source resource") - roles: string[]; -} - -@doc("Connection Properties") -model ConnectionProperties { - @doc("The source of the connection") - source: string; - - @doc("default environment variable override") - disableDefaultEnvVars?: boolean = false; - - @doc("iam properties") - iam?: IamProperties; -} - -@doc("Definition of a container") -model Container { - @doc("The registry and image to download and run in your container") - image: string; - - @doc("environment") - env?: Map; - - @doc("container ports") - ports?: Map; - - @doc("readiness probe properties") - readinessProbe?: HealthProbeProperties; - - @doc("liveness probe properties") - livenessProbe?: HealthProbeProperties; - - @doc("container volumes") - volumes?: Map; -} - -@doc("Container properties") -model ContainerProperties extends BasicResourceProperties { - @doc("The status of the last operation.") - provisioningState?: ProvisioningState; - - @doc("Specifies resource id of the application") - application: string; - - @doc("Specifies a connection to another resource.") - connections: Map; - - @doc("Definition of a container.") - container: Container; - - @doc("Extensions spec of the resource") - extensions: Extension[]; -} - -model ContainerResource is TrackedResource { - @doc("Container name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("containerName") - @path - @segment("containers") - name: string; -} - -@armResourceOperations -interface Containers - extends Radius.RootScopeResourceOperations< - ContainerResource, - ContainerProperties, - RootScopeParam - > {} - -@knownValues(ProvisioningStateKV) -model ProvisioningState is string; -enum ProvisioningStateKV { - Succeeded, - Failed, - Canceled, - Provisioning, - Updating, - Deleting, - Accepted, -} - -@knownValues(PortProtocolKV) -model PortProtocol is string; -enum PortProtocolKV { - TCP, - UDP, -} - -@knownValues(ManagedStoreKV) -model ManagedStore is string; -enum ManagedStoreKV { - memory, - disk, -} - -@knownValues(VolumePermissionKV) -model VolumePermission is string; -enum VolumePermissionKV { - read, - write, -} - -@knownValues(KindKV) -model Kind is string; -enum KindKV { - azure, -} - -@knownValues(DaprProtocolKV) -model DaprProtocol is string; -enum DaprProtocolKV { - http, - grpc, -} diff --git a/cadl/Applications.Core/environment.cadl b/cadl/Applications.Core/environment.cadl deleted file mode 100644 index f2402e20ba..0000000000 --- a/cadl/Applications.Core/environment.cadl +++ /dev/null @@ -1,95 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; - -@armNamespace -@serviceTitle("Applications.Core Management APIs") -@doc("REST API for Applications.Core Environment Resource") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Core; - -@discriminator("kind") -@doc("Compute resource used by application environment resource.") -model EnvironmentCompute { - @doc("The resource id of the compute resource for application environment.") - resourceId: string; -} - -@doc("Specifies the properties for Kubernetes compute environment") -model KubernetesCompute extends EnvironmentCompute { - @doc("resource compute kind") - kind: "kubernetes"; - - @doc("The namespace to use for the environment") - nameSpace: string; -} - -@doc("Environment properties") -model EnvironmentProperties { - @visibility("read") - @doc("The status of the last operation.") - provisioningState?: ProvisioningState; - - @doc("The compute resource used by application environment.") - compute: EnvironmentCompute; -} - -model EnvironmentResource is TrackedResource { - @doc("environment name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("environmentName") - @path - @segment("environments") - name: string; -} - -@armResourceOperations -interface Environment - extends Radius.RootScopeResourceOperations< - EnvironmentResource, - EnvironmentProperties, - RootScopeParam - > {} - -@knownValues(ProvisioningStateKV) -model ProvisioningState is string; -enum ProvisioningStateKV { - Succeeded, - Failed, - Canceled, - Provisioning, - Updating, - Deleting, - Accepted, -} diff --git a/cadl/Applications.Core/gateways.cadl b/cadl/Applications.Core/gateways.cadl deleted file mode 100644 index 988425f1bc..0000000000 --- a/cadl/Applications.Core/gateways.cadl +++ /dev/null @@ -1,112 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -@armNamespace -@serviceTitle("Applications.Core Management APIs") -@doc("REST API for Applications.Core Gateway Resource") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Core; - -@doc("Gateway properties") -model GatewayProperties extends BasicResourceProperties { - @doc("Provisioning state of the Gateway at the time the operation was called.") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("The resource id of the application linked to Gateway resource.") - application: string; - - @doc("Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).") - internal?: boolean = false; - - @doc("Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io.") - hostname?: GatewayPropertiesHostname; - - @doc("Routes attached to this Gateway") - routes: GatewayRoute[]; - - @doc("URL of the gateway resource. Readonly") - @visibility("read") - url?: string; -} - -@doc("Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io.") -model GatewayPropertiesHostname { - @doc("Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined.") - prefix: string; - - @doc("Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined.") - fullyQualifiedHostname: string; -} - -@doc("Route attached to Gateway") -model GatewayRoute { - @doc("The path to match the incoming request path on. Ex - /myservice.") - path: string; - - @doc("The HttpRoute to route to. Ex - myserviceroute.id.") - destination: string; - - @doc("Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute'") - replacePrefix: string; -} - -model GatewayResource is TrackedResource { - @doc("Gateway name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("gatewayName") - @path - @segment("gateways") - name: string; -} - -@armResourceOperations -interface Gateway - extends Radius.RootScopeResourceOperations< - GatewayResource, - GatewayProperties, - RootScopeParam - > {} - -@knownValues(ProvisioningStateKV) -model ProvisioningState is string; -enum ProvisioningStateKV { - Succeeded, - Failed, - Canceled, - Provisioning, - Updating, - Deleting, - Accepted, -} diff --git a/cadl/Applications.Core/global.cadl b/cadl/Applications.Core/global.cadl deleted file mode 100644 index 5746c8b3ab..0000000000 --- a/cadl/Applications.Core/global.cadl +++ /dev/null @@ -1,14 +0,0 @@ -@doc("Basic properties of a Radius resource.") -model BasicResourceProperties { - @doc("Status of a resource.") - status: ResourceStatus; -} - -@doc("Status of a resource.") -model ResourceStatus { - @doc("Properties of an output resource") - outputResources: OutputResource[]; -} - -@doc("Properties of an output resource.") -model OutputResource {} diff --git a/cadl/Applications.Core/httpRoutes.cadl b/cadl/Applications.Core/httpRoutes.cadl deleted file mode 100644 index 78a0ff3d6d..0000000000 --- a/cadl/Applications.Core/httpRoutes.cadl +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; - -@armNamespace -@serviceTitle("Applications.Core Management APIs") -@doc("REST API for Applications.Core HttpRoute Resource") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Core; - -@doc("HttpRoute properties") -model HttpRouteProperties extends BasicResourceProperties { - @doc("Provisioning state of the HttpRoute at the time the operation was called.") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("The resource id of the application linked to HTTP Route resource.") - application: string; - - @doc("Sets HttpRoute to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).") - internal?: boolean = false; - - @doc("The internal hostname accepting traffic for the HTTP Route. Readonly.") - @visibility("read") - hostname?: string; - - @doc("The port number for the HTTP Route. Defaults to 80. Readonly.") - @visibility("read") - port?: int32 = 80; - - @doc("The scheme used for traffic. Readonly.") - scheme?: string; - - @doc("A stable URL that that can be used to route traffic to a resource. Readonly.") - @visibility("read") - url?: string; -} - -model HttpRouteResource is TrackedResource { - @doc("HttpRoute name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("httpRouteName") - @path - @segment("httpRoute") - name: string; -} - -@armResourceOperations -interface HttpRoute - extends Radius.RootScopeResourceOperations< - HttpRouteResource, - HttpRouteProperties, - RootScopeParam - > {} - -@knownValues(ProvisioningStateKV) -model ProvisioningState is string; -enum ProvisioningStateKV { - Succeeded, - Failed, - Canceled, - Provisioning, - Updating, - Deleting, - Accepted, -} diff --git a/cadl/Applications.Dapr/cadl-project.yaml b/cadl/Applications.Dapr/cadl-project.yaml deleted file mode 100644 index e462dbc8a3..0000000000 --- a/cadl/Applications.Dapr/cadl-project.yaml +++ /dev/null @@ -1,5 +0,0 @@ -emit: - - "@azure-tools/cadl-autorest" -options: - "@azure-tools/cadl-autorest": - emitter-output-dir: "{project-root}/../../swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/" \ No newline at end of file diff --git a/cadl/Applications.Dapr/main.cadl b/cadl/Applications.Dapr/main.cadl deleted file mode 100644 index 44c055608b..0000000000 --- a/cadl/Applications.Dapr/main.cadl +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "./pubSubBrokers.cadl"; -import "./secretStores.cadl"; -import "./stateStores.cadl"; -import "@cadl-lang/openapi"; -import "../common.cadl"; - -using OpenAPI; -using Cadl.Versioning; -using Azure.ResourceManager; - -@armProviderNamespace -@service({ - title: "Applications.Dapr Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Dapr") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Dapr; - -interface Operations extends Azure.ResourceManager.Operations {} \ No newline at end of file diff --git a/cadl/Applications.Dapr/pubSubBrokers.cadl b/cadl/Applications.Dapr/pubSubBrokers.cadl deleted file mode 100644 index fc23464936..0000000000 --- a/cadl/Applications.Dapr/pubSubBrokers.cadl +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -namespace Applications.Dapr; -@doc("Dapr PubSubBroker portable resource properties") -model DaprPubSubBrokerProperties extends BasicDaprResourceProperties { - @doc("Provisioning state of the Dapr PubSubBroker portable resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Metadata for the Dapr PubSubBroker resource. This should match the values specified in Dapr component spec") - metadata?: object; - - @doc("The recipe used to automatically deploy underlying infrastructure for the Dapr PubSubBroker portable resource") - recipe?: Recipe; - - @doc("A collection of references to resources associated with the Dapr PubSubBroker") - resources?: ResourceReference[]; - - @doc("Dapr PubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format.") - type?: string; - - @doc("Dapr component version") - version?: string; -} - -@doc("Dapr PubSubBroker portable resource") -model DaprPubSubBrokerResource is TrackedResource { - @doc("Dapr PubSubBroker name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$") - @key("daprPubSubBrokerName") - @path - @extension("x-ms-parameter-location", "method") - @segment("pubSubBrokers") - name: string; -} - -@armResourceOperations -interface DaprPubSubBroker - extends Radius.ResourceOperationWithAsyncDelete< - DaprPubSubBrokerResource, - DaprPubSubBrokerProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/Applications.Dapr/secretStores.cadl b/cadl/Applications.Dapr/secretStores.cadl deleted file mode 100644 index 04cd162b6b..0000000000 --- a/cadl/Applications.Dapr/secretStores.cadl +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -namespace Applications.Dapr; -@doc("Dapr SecretStore portable resource properties") -model DaprSecretStoreProperties extends BasicDaprResourceProperties { - @doc("Provisioning state of the dapr secret store portable resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Dapr SecretStore type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/") - type?: string; - - @doc("Dapr component version") - version?: string; - - @doc("Metadata for the Dapr SecretStore resource. This should match the values specified in Dapr component spec") - metadata?: object; - - @doc("The recipe used to automatically deploy underlying infrastructure for the Dapr SecretStore portable resource") - recipe?: Recipe; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; -} - -@doc("Dapr SecretStore portable resource") -model DaprSecretStoreResource is TrackedResource { - @doc("Dapr SecretStore name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$") - @key("daprSecretStoreName") - @path - @segment("secretStores") - @extension("x-ms-parameter-location", "method") - name: string; -} - -@armResourceOperations -interface DaprSecretStore - extends Radius.ResourceOperationWithSyncDelete< - DaprSecretStoreResource, - DaprSecretStoreProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/Applications.Dapr/stateStores.cadl b/cadl/Applications.Dapr/stateStores.cadl deleted file mode 100644 index cdd549d9e1..0000000000 --- a/cadl/Applications.Dapr/stateStores.cadl +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -namespace Applications.Dapr; -@doc("Dapr StateStore portable resource properties") -model DaprStateStoreProperties extends BasicDaprResourceProperties { - @doc("Provisioning state of the DaprStateStore portable resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Metadata for the Dapr StateStore resource. This should match the values specified in Dapr component spec") - metadata?: object; - - @doc("The recipe used to automatically deploy underlying infrastructure for the Dapr StateStore portable resource") - recipe?: Recipe; - - @doc("A collection of references to resources associated with the Dapr StateStore") - resources?: ResourceReference[]; - - @doc("Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format.") - type?: string; - - @doc("Dapr component version") - version?: string; -} - -@doc("Dapr StateStore portable resource") -model DaprStateStoreResource is TrackedResource { - @doc("Dapr StateStore name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$") - @key("daprStateStoreName") - @path - @segment("stateStores") - @extension("x-ms-parameter-location", "method") - name: string; -} - -@armResourceOperations -interface DaprStateStore - extends Radius.ResourceOperationWithAsyncDelete< - DaprStateStoreResource, - DaprStateStoreProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/Applications.Datastores/cadl-project.yaml b/cadl/Applications.Datastores/cadl-project.yaml deleted file mode 100644 index 1d06506b2e..0000000000 --- a/cadl/Applications.Datastores/cadl-project.yaml +++ /dev/null @@ -1,5 +0,0 @@ -emit: - - "@azure-tools/cadl-autorest" -options: - "@azure-tools/cadl-autorest": - emitter-output-dir: "{project-root}/../../swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/" \ No newline at end of file diff --git a/cadl/Applications.Datastores/main.cadl b/cadl/Applications.Datastores/main.cadl deleted file mode 100644 index 8d4e1be6a9..0000000000 --- a/cadl/Applications.Datastores/main.cadl +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "./mongoDatabases.cadl"; -import "./sqlDatabases.cadl"; -import "./redisCaches.cadl"; -import "@cadl-lang/openapi"; -import "../common.cadl"; - -using OpenAPI; -using Cadl.Versioning; -using Azure.ResourceManager; - -@armProviderNamespace -@service({ - title: "Applications.Datastores Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Datastores") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Datastores; - -interface Operations extends Azure.ResourceManager.Operations {} \ No newline at end of file diff --git a/cadl/Applications.Datastores/mongoDatabases.cadl b/cadl/Applications.Datastores/mongoDatabases.cadl deleted file mode 100644 index c23714b480..0000000000 --- a/cadl/Applications.Datastores/mongoDatabases.cadl +++ /dev/null @@ -1,111 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -namespace Applications.Datastores; -@doc("Mongo database portable resource") -model MongoDatabaseResource is TrackedResource { - @doc("The name of the Mongo database portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @segment("mongoDatabases") - @key("mongoDatabaseName") - @extension("x-ms-parameter-location", "method") - name: string; -} - -@doc("The secret values for the given Mongo database resource") -model MongoDatabaseListSecretsResult is MongoDatabaseSecrets; - -@doc("The secret values for the given Mongo database resource") -model MongoDatabaseSecrets { - @doc("Password to use when connecting to the target Mongo database") - password?: string; - - @doc("Connection string used to connect to the target Mongo database") - connectionString?: string; -} - -@doc("Mongo database portable resource properties") -model MongoDatabaseProperties extends BasicResourceProperties{ - @doc("Provisioning state of the Mongo database portable resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Secret values provided for the resource") - secrets?: MongoDatabaseSecrets; - - @doc("Host name of the target Mongo database") - host?: string; - - @doc("Port value of the target Mongo database") - port?: int32; - - @doc("Database name of the target Mongo database") - database?: string; - - @doc("The recipe used to automatically deploy underlying infrastructure for the Mongo database portable resource") - recipe?: Recipe; - - @doc("List of the resource IDs that support the Mongo database resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Username to use when connecting to the target Mongo database") - username?: string; -} - -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified Mongo database resource") -@post -@route("/{rootScope}/providers/Applications.Datastores/mongoDatabases/{mongoDatabaseName}/listSecrets") -op MongoDatabases_listSecrets(...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the Mongo database portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - mongoDatabaseName: string): ArmResponse - | ErrorResponse; - -@armResourceOperations -interface MongoDatabases - extends Radius.ResourceOperationWithAsyncDelete< - MongoDatabaseResource, - MongoDatabaseProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/Applications.Datastores/redisCaches.cadl b/cadl/Applications.Datastores/redisCaches.cadl deleted file mode 100644 index ff107121ea..0000000000 --- a/cadl/Applications.Datastores/redisCaches.cadl +++ /dev/null @@ -1,113 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -namespace Applications.Datastores; -@doc("Redis cache portable resource") -model RedisCacheResource - is TrackedResource { - @doc("The name of the Redis cache portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("redisCacheName") - @path - @segment("redisCaches") - name: string; -} - -@doc("The secret values for the given Redis cache resource") -model RedisCacheListSecretsResult is RedisCacheSecrets; - -@doc("The secret values for the given Redis cache resource") -model RedisCacheSecrets { - @doc("The connection string used to connect to the Redis cache") - connectionString?: string; - - @doc("The password for this Redis cache instance") - password?: string; - - @doc("The URL used to connect to the Redis cache") - url?: string -} - -@doc("Redis cache portable resource properties") -model RedisCacheProperties extends BasicResourceProperties { - @doc("Provisioning state of the redis cache portable at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Secrets provided by resource") - secrets?: RedisCacheSecrets; - - @doc("The host name of the target Redis cache") - host?: string; - - @doc("The port value of the target Redis cache") - port?: int32; - - @doc("The username for Redis cache") - username?: string; - - @doc("Specifies whether to enable SSL connections to the Redis cache") - tls?: boolean; - - @doc("The recipe used to automatically deploy underlying infrastructure for the Redis cache portable resource") - recipe?: Recipe; - - @doc("List of the resource IDs that support the Redis resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; -} -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified Redis cache resource") -@route("/{rootScope}/providers/Applications.Datastores/redisCaches/{redisCacheName}/listSecrets") -@post -op RedisCaches_listSecrets( - ...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the Redis cache portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - redisCacheName: string): ArmResponse | ErrorResponse; - -@armResourceOperations -interface RedisCaches - extends Radius.ResourceOperationWithSyncDelete< - RedisCacheResource, - RedisCacheProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/Applications.Datastores/sqlDatabases.cadl b/cadl/Applications.Datastores/sqlDatabases.cadl deleted file mode 100644 index f784960c5d..0000000000 --- a/cadl/Applications.Datastores/sqlDatabases.cadl +++ /dev/null @@ -1,111 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -namespace Applications.Datastores; -@doc("Sql database properties") -model SqlDatabaseProperties extends BasicResourceProperties { - @doc("Provisioning state of the SQL database portable resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("The name of the SQL database.") - database?: string; - - @doc("The fully qualified domain name of the target SQL database.") - server?: string; - - @doc("Port value of the target SQL database") - port?: int32; - - @doc("Username to use when connecting to the target SQL database") - username?: string; - - @doc("The recipe used to automatically deploy underlying infrastructure for the SQL database portable resource") - recipe?: Recipe; - - @doc("List of the resource IDs that support the SQL database resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Secret values provided for the resource") - secrets?: SqlDatabaseSecrets; -} - -@doc("The secret values for the given SQL database resource") -model SqlDatabaseListSecretsResult is SqlDatabaseSecrets; - -@doc("The secret values for the given SQL database resource") -model SqlDatabaseSecrets { - @doc("Password to use when connecting to the target SQL database") - password?: string; - - @doc("Connection string used to connect to the target SQL database") - connectionString?: string; -} - -@doc("Sql database portable resource") -model SqlDatabaseResource is TrackedResource { - @doc("The name of the SQL database portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("sqlDatabaseName") - @path - @segment("sqlDatabases") - @extension("x-ms-parameter-location", "method") - name: string; -} - -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified SQL database resource") -@post -@route("/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}/listSecrets") -op SqlDatabases_listSecrets(...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the SQL database portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - sqlDatabaseName: string): ArmResponse - | ErrorResponse; - -@armResourceOperations -interface SqlDatabases - extends Radius.ResourceOperationWithSyncDelete< - SqlDatabaseResource, - SqlDatabaseProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/Applications.Link/daprPubSubBrokers.cadl b/cadl/Applications.Link/daprPubSubBrokers.cadl deleted file mode 100644 index b0ffdd482c..0000000000 --- a/cadl/Applications.Link/daprPubSubBrokers.cadl +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Link DaprPubSubBroker Resource") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; - -@doc("DaprPubSubBroker link properties") -model DaprPubSubBrokerProperties extends BasicDaprResourceProperties { - @doc("Provisioning state of the daprPubSubBroker resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Metadata for the daprPubSubBroker resource. This should match the values specified in Dapr component spec") - metadata?: object; - - @doc("The recipe used to automatically deploy underlying infrastructure for the daprPubSubBroker link") - recipe?: Recipe; - - @doc("A collection of references to resources associated with the daprPubSubBroker") - resources?: ResourceReference[]; - - @doc("DaprPubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format.") - type?: string; - - @doc("Dapr component version") - version?: string; -} - -@doc("DaprPubSubBroker link") -model DaprPubSubBrokerResource is TrackedResource { - @doc("DaprPubSubBroker name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$") - @key("daprPubSubBrokerName") - @path - @extension("x-ms-parameter-location", "method") - @segment("daprPubSubBrokers") - name: string; -} - -@armResourceOperations -interface DaprPubSubBroker - extends Radius.ResourceOperationWithAsyncDelete< - DaprPubSubBrokerResource, - DaprPubSubBrokerProperties, - RootScopeParam - > {} diff --git a/cadl/Applications.Link/daprSecretStores.cadl b/cadl/Applications.Link/daprSecretStores.cadl deleted file mode 100644 index 68df941a93..0000000000 --- a/cadl/Applications.Link/daprSecretStores.cadl +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Link/daprSecretStores") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; -@doc("DaprSecretStore link properties") -model DaprSecretStoreProperties extends BasicDaprResourceProperties { - @doc("Provisioning state of the dapr secret store link at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Dapr Secret Store type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/") - type?: string; - - @doc("Dapr component version") - version?: string; - - @doc("Metadata for the Secret Store resource. This should match the values specified in Dapr component spec") - metadata?: object; - - @doc("The recipe used to automatically deploy underlying infrastructure for the daprSecretStore link") - recipe?: Recipe; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; -} - -@doc("DaprSecretStore link") -model DaprSecretStoreResource is TrackedResource { - @doc("DaprSecretStore name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$") - @key("daprSecretStoreName") - @path - @segment("daprSecretStores") - @extension("x-ms-parameter-location", "method") - name: string; -} - -@armResourceOperations -interface DaprSecretStore - extends Radius.ResourceOperationWithSyncDelete< - DaprSecretStoreResource, - DaprSecretStoreProperties, - RootScopeParam - > {} diff --git a/cadl/Applications.Link/daprStateStores.cadl b/cadl/Applications.Link/daprStateStores.cadl deleted file mode 100644 index e1326a52a8..0000000000 --- a/cadl/Applications.Link/daprStateStores.cadl +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST API for Applications.Link DaprStateStore Resource") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; - -@doc("DaprStateStore link properties") -model DaprStateStoreProperties extends BasicDaprResourceProperties { - @doc("Provisioning state of the DaprStateStore link at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Metadata for the state store resource. This should match the values specified in Dapr component spec") - metadata?: object; - - @doc("The recipe used to automatically deploy underlying infrastructure for the daprStateStore link") - recipe?: Recipe; - - @doc("A collection of references to resources associated with the state store") - resources?: ResourceReference[]; - - @doc("Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format.") - type?: string; - - @doc("Dapr component version") - version?: string; -} - -@doc("DaprStateStore link") -model DaprStateStoreResource is TrackedResource { - @doc("DaprStateStore name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$") - @key("daprStateStoreName") - @path - @segment("daprStateStores") - @extension("x-ms-parameter-location", "method") - name: string; -} - -@armResourceOperations -interface DaprStateStore - extends Radius.ResourceOperationWithAsyncDelete< - DaprStateStoreResource, - DaprStateStoreProperties, - RootScopeParam - > {} diff --git a/cadl/Applications.Link/extenders.cadl b/cadl/Applications.Link/extenders.cadl deleted file mode 100644 index 689e60a9b4..0000000000 --- a/cadl/Applications.Link/extenders.cadl +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-providerhub"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST API for Applications.Link Extender Resource") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; - -@doc("Extender link") -model ExtenderResource is TrackedResource { - @doc("Extender name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("extenderName") - @path - @segment("extenders") - @extension("x-ms-parameter-location", "method") - name: string; -} -@doc("The secret values for the given Extender resource") -model ExtenderListSecretsResult is ExtenderSecrets; - -@doc("The secret values for the given Extender resource") -model ExtenderSecrets {} - -@doc("Extender link properties") -model ExtenderProperties extends BasicResourceProperties { - @doc("Provisioning state of the extender link at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("The secrets value for the resource") - secrets?: ExtenderSecrets; - - @doc("The recipe used to automatically deploy underlying infrastructure for the Extender") - recipe?: Recipe; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; -} - -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified Extender resource") -@post -@route("/{rootScope}/providers/Applications.Link/extenders/{extenderName}/listSecrets") -op Extenders_listSecrets( - ...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the Extender link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - extenderName: string): ArmResponse | ErrorResponse; - -@armResourceOperations -interface Extenders - extends Radius.RootScopeResourceOperations< - ExtenderResource, - ExtenderProperties, - RootScopeParam - > {} diff --git a/cadl/Applications.Link/global.cadl b/cadl/Applications.Link/global.cadl deleted file mode 100644 index e11a38fa19..0000000000 --- a/cadl/Applications.Link/global.cadl +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/openapi"; - -using OpenAPI; - - -@doc("Basic properties of a Radius resource.") -model BasicResourceProperties { - @doc("Status of a resource.") - @visibility("read") - status?: ResourceStatus; - - @doc("Fully qualified resource ID for the environment that the link is linked to") - environment: string; - - @doc("Fully qualified resource ID for the application that the link is consumed by") - application?: Application -} - -@doc("Basic properties of a Dapr component object.") -model BasicDaprResourceProperties extends BasicResourceProperties{ - @doc("The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.") - @visibility("read") - componentName?: string; -} - -@doc("Status of a resource.") -model ResourceStatus { - @doc("Properties of an output resource") - @extension("x-ms-identifiers", []) - outputResources?: OutputResource[]; -} - -@doc("Describes a reference to an existing resource") -model ResourceReference { - @doc("Resource id of an existing resource") - id: string -} - -@doc("Properties of an output resource.") -model OutputResource {} - -@doc("Fully qualified resource ID for the application that the link is consumed by") -scalar Application extends string; - -@doc("Provisioning state of the link at the time the operation was called") -enum ProvisioningState { - Succeeded, - Failed, - Canceled, - Provisioning, - Updating, - Deleting, - Accepted, -} - -@doc("Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.") -enum ResourceProvisioning { - recipe, - manual, -} - -@doc("The recipe used to automatically deploy underlying infrastructure for a link") -model Recipe{ - @doc("The name of the recipe within the environment to use") - name: string; - @doc("Key/value parameters to pass into the recipe at deployment") - parameters?: Parameters; -} -@doc("Key/value parameters to pass into the recipe at deployment") -model Parameters{} \ No newline at end of file diff --git a/cadl/Applications.Link/main.cadl b/cadl/Applications.Link/main.cadl deleted file mode 100644 index 14f25140fe..0000000000 --- a/cadl/Applications.Link/main.cadl +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/openapi"; -import "@azure-tools/cadl-autorest"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; - -import "./mongoDatabases.cadl"; -import "./sqlDatabases.cadl"; -import "./redisCaches.cadl"; -import "./rabbitMQMessageQueues.cadl"; -import "./daprSecretStores.cadl"; -import "./daprStateStores.cadl"; -import "./daprPubSubBrokers.cadl"; -// Extender app model spec is not generated using cadl as "additionalPropertis" property is not supported by cadl. -//import "./extenders.cadl"; \ No newline at end of file diff --git a/cadl/Applications.Link/mongoDatabases.cadl b/cadl/Applications.Link/mongoDatabases.cadl deleted file mode 100644 index dd48c4bef4..0000000000 --- a/cadl/Applications.Link/mongoDatabases.cadl +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - - -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Link/mongoDatabases") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; -@doc("MongoDatabase link") -model MongoDatabaseResource is TrackedResource { - @doc("The name of the MongoDatabase link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @segment("mongoDatabases") - @key("mongoDatabaseName") - @extension("x-ms-parameter-location", "method") - name: string; -} - -@doc("The secret values for the given MongoDatabase resource") -model MongoDatabaseListSecretsResult is MongoDatabaseSecrets; - -@doc("The secret values for the given MongoDatabase resource") -model MongoDatabaseSecrets { - @doc("Password to use when connecting to the target Mongo database") - password?: string; - - @doc("Connection string used to connect to the target Mongo database") - connectionString?: string; -} - -@doc("MongoDatabase link properties") -model MongoDatabaseProperties extends BasicResourceProperties{ - @doc("Provisioning state of the mongo database link at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Secret values provided for the resource") - secrets?: MongoDatabaseSecrets; - - @doc("Host name of the target Mongo database") - host?: string; - - @doc("Port value of the target Mongo database") - port?: int32; - - @doc("Database name of the target Mongo database") - database?: string; - - @doc("The recipe used to automatically deploy underlying infrastructure for the MongoDB link") - recipe?: Recipe; - - @doc("List of the resource IDs that support the MongoDB resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Username to use when connecting to the target Mongo database") - username?: string; -} - -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified MongoDatabase resource") -@post -@route("/{rootScope}/providers/Applications.Link/mongoDatabases/{mongoDatabaseName}/listSecrets") -op MongoDatabases_listSecrets(...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the MongoDatabase link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - mongoDatabaseName: string): ArmResponse - | ErrorResponse; - -@armResourceOperations -interface MongoDatabases - extends Radius.ResourceOperationWithAsyncDelete< - MongoDatabaseResource, - MongoDatabaseProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/Applications.Link/rabbitMQMessageQueues.cadl b/cadl/Applications.Link/rabbitMQMessageQueues.cadl deleted file mode 100644 index d1d07a390e..0000000000 --- a/cadl/Applications.Link/rabbitMQMessageQueues.cadl +++ /dev/null @@ -1,133 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Link/rabbitMQMessageQueues") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("RabbitMQMessageQueue link") -model RabbitMQMessageQueueResource - is TrackedResource { - @doc("The name of the RabbitMQMessageQueue link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("rabbitMQMessageQueueName") - @path - @segment("rabbitMQMessageQueues") - name: string; -} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("The secret values for the given RabbitMQMessageQueue resource") -model RabbitMQListSecretsResult is RabbitMQSecrets; - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("The secret values for the given RabbitMQMessageQueue resource") -model RabbitMQSecrets { - @doc("The password used to connect to the RabbitMQ instance") - password?: string; - - @doc("The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value") - uri?: string; -} -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("RabbitMQMessageQueue link properties") -model RabbitMQMessageQueueProperties extends BasicResourceProperties { - @doc("Provisioning state of the rabbitMQ message queue link at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Secrets provided by resources,") - secrets?: RabbitMQSecrets; - - @doc("The name of the queue") - queue?: string; - - @doc("The hostname of the RabbitMQ instance") - host?: string; - - @doc("The port of the RabbitMQ instance. Defaults to 5672") - port?: int32; - - @doc("The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost.") - vHost?: string; - - @doc("The username to use when connecting to the RabbitMQ instance") - username?: string; - - @doc("List of the resource IDs that support the rabbitMQ resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("The recipe used to automatically deploy underlying infrastructure for the rabbitMQ link") - recipe?: Recipe; - - @doc("Specifies whether to use SSL when connecting to the RabbitMQ instance") - tls?: boolean; - -} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use camelCase" -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified RabbitMQMessageQueue resource") -@post -@route("/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues/{rabbitMQMessageQueueName}/listSecrets") -op RabbitMQMessageQueues_listSecrets( - ...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the RabbitMQMessageQueue link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - rabbitMQMessageQueueName: string -): ArmResponse | ErrorResponse; - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Interface types must use PascalCase" -@armResourceOperations -interface RabbitMQMessageQueues - extends Radius.ResourceOperationWithSyncDelete< - RabbitMQMessageQueueResource, - RabbitMQMessageQueueProperties, - RootScopeParam - > {} diff --git a/cadl/Applications.Link/redisCaches.cadl b/cadl/Applications.Link/redisCaches.cadl deleted file mode 100644 index 66001ff5c4..0000000000 --- a/cadl/Applications.Link/redisCaches.cadl +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Link/redisCaches") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; - -@doc("RedisCache link") -model RedisCacheResource - is TrackedResource { - @doc("The name of the RedisCache link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("redisCacheName") - @path - @segment("redisCaches") - name: string; -} - -@doc("The secret values for the given RedisCache resource") -model RedisCacheListSecretsResult is RedisCacheSecrets; - -@doc("The secret values for the given RedisCache resource") -model RedisCacheSecrets { - @doc("The connection string used to connect to the Redis cache") - connectionString?: string; - - @doc("The password for this Redis cache instance") - password?: string; - - @doc("The URL used to connect to the Redis cache") - url?: string -} - -@doc("RedisCache link properties") -model RedisCacheProperties extends BasicResourceProperties { - @doc("Provisioning state of the redis cache link at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Secrets provided by resource") - secrets?: RedisCacheSecrets; - - @doc("The host name of the target Redis cache") - host?: string; - - @doc("The port value of the target Redis cache") - port?: int32; - - @doc("The username for Redis cache") - username?: string; - - @doc("Specifies whether to enable SSL connections to the Redis cache") - tls?: boolean; - - @doc("The recipe used to automatically deploy underlying infrastructure for the Redis caches link") - recipe?: Recipe; - - @doc("List of the resource IDs that support the Redis resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; -} -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified RedisCache resource") -@route("/{rootScope}/providers/Applications.Link/redisCaches/{redisCacheName}/listSecrets") -@post -op RedisCaches_listSecrets( - ...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the RedisCache link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - redisCacheName: string): ArmResponse | ErrorResponse; - -@armResourceOperations -interface RedisCaches - extends Radius.ResourceOperationWithSyncDelete< - RedisCacheResource, - RedisCacheProperties, - RootScopeParam - > {} diff --git a/cadl/Applications.Link/sqlDatabases.cadl b/cadl/Applications.Link/sqlDatabases.cadl deleted file mode 100644 index 92a7fbfdfe..0000000000 --- a/cadl/Applications.Link/sqlDatabases.cadl +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -import "./global.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -@armProviderNamespace -@service({ - title: "Applications.Link Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Link/sqlDatabases") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Link; - -interface Operations extends Azure.ResourceManager.Operations {} -@doc("SqlDatabase properties") -model SqlDatabaseProperties extends BasicResourceProperties { - @doc("Provisioning state of the Sql database link at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("The name of the Sql database.") - database?: string; - - @doc("The fully qualified domain name of the Sql database.") - server?: string; - - @doc("Port value of the target Sql database") - port?: int32; - - @doc("Username to use when connecting to the target Sql database") - username?: string; - - @doc("The recipe used to automatically deploy underlying infrastructure for the sqldatabases link") - recipe?: Recipe; - - @doc("List of the resource IDs that support the SqlDatabase resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("Secret values provided for the resource") - secrets?: SqlDatabaseSecrets; -} - -@doc("The secret values for the given SqlDatabase resource") -model SqlDatabaseListSecretsResult is SqlDatabaseSecrets; - -@doc("The secret values for the given SqlDatabase resource") -model SqlDatabaseSecrets { - @doc("Password to use when connecting to the target Sql database") - password?: string; - - @doc("Connection string used to connect to the target Sql database") - connectionString?: string; -} - -@doc("SqlDatabase link") -model SqlDatabaseResource is TrackedResource { - @doc("The name of the SqlDatabase link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("sqlDatabaseName") - @path - @segment("sqlDatabases") - @extension("x-ms-parameter-location", "method") - name: string; -} - -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified SqlDatabase resource") -@post -@route("/{rootScope}/providers/Applications.Link/sqlDatabases/{sqlDatabaseName}/listSecrets") -op SqlDatabases_listSecrets(...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the SqlDatabase link resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - sqlDatabaseName: string): ArmResponse - | ErrorResponse; - -@armResourceOperations -interface SqlDatabases - extends Radius.ResourceOperationWithSyncDelete< - SqlDatabaseResource, - SqlDatabaseProperties, - RootScopeParam - > {} diff --git a/cadl/Applications.Messaging/cadl-project.yaml b/cadl/Applications.Messaging/cadl-project.yaml deleted file mode 100644 index d1cdac3f53..0000000000 --- a/cadl/Applications.Messaging/cadl-project.yaml +++ /dev/null @@ -1,5 +0,0 @@ -emit: - - "@azure-tools/cadl-autorest" -options: - "@azure-tools/cadl-autorest": - emitter-output-dir: "{project-root}/../../swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/" \ No newline at end of file diff --git a/cadl/Applications.Messaging/main.cadl b/cadl/Applications.Messaging/main.cadl deleted file mode 100644 index 4d2c0daccf..0000000000 --- a/cadl/Applications.Messaging/main.cadl +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "./rabbitMQQueues.cadl"; -import "@cadl-lang/openapi"; -import "../common.cadl"; - -using OpenAPI; -using Cadl.Versioning; -using Azure.ResourceManager; - -@armProviderNamespace -@service({ - title: "Applications.Messaging Management APIs", - version: "2022-03-15-privatepreview", -}) -@doc("REST APIs for Applications.Messaging") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Applications.Messaging; - -interface Operations extends Azure.ResourceManager.Operations {} diff --git a/cadl/Applications.Messaging/rabbitMQQueues.cadl b/cadl/Applications.Messaging/rabbitMQQueues.cadl deleted file mode 100644 index 2403f0022a..0000000000 --- a/cadl/Applications.Messaging/rabbitMQQueues.cadl +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -// These files allow the use of {rootScope} in the generated paths with a custom resourceOperations object -import "../customRootScope.cadl"; -import "../aksrootscope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using OpenAPI; - -namespace Applications.Messaging; - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("RabbitMQQueue portable resource") -model RabbitMQQueueResource - is TrackedResource { - @doc("The name of the RabbitMQQueue portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("rabbitMQQueueName") - @path - @segment("rabbitMQQueues") - name: string; -} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("The secret values for the given RabbitMQQueue resource") -model RabbitMQListSecretsResult is RabbitMQSecrets; - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("The secret values for the given RabbitMQQueue resource") -model RabbitMQSecrets { - @doc("The password used to connect to the RabbitMQ instance") - password?: string; - - @doc("The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value") - uri?: string; -} -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use PascalCase" -@doc("RabbitMQQueue portable resource properties") -model RabbitMQQueueProperties extends BasicResourceProperties { - @doc("Provisioning state of the rabbitMQ message queue portable resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; - - @doc("Secrets provided by resources,") - secrets?: RabbitMQSecrets; - - @doc("The name of the queue") - queue?: string; - - @doc("The hostname of the RabbitMQ instance") - host?: string; - - @doc("The port of the RabbitMQ instance. Defaults to 5672") - port?: int32; - - @doc("The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost.") - vHost?: string; - - @doc("The username to use when connecting to the RabbitMQ instance") - username?: string; - - @doc("List of the resource IDs that support the rabbitMQ resource") - resources?: ResourceReference[]; - - @doc("Specifies how the underlying service/resource is provisioned and managed.") - resourceProvisioning?: ResourceProvisioning; - - @doc("The recipe used to automatically deploy underlying infrastructure for the rabbitMQQueue portable resource") - recipe?: Recipe; - - @doc("Specifies whether to use SSL when connecting to the RabbitMQ instance") - tls?: boolean; - -} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Model types must use camelCase" -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-operation-outside-interface" "This is an interface template" -@doc("Lists secrets values for the specified RabbitMQQueue resource") -@post -@route("/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}/listSecrets") -op RabbitMQQueues_listSecrets( - ...ApiVersionParameter, - ...RootScopeParam, - @doc("The name of the RabbitMQQueue portable resource") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @path - @extension("x-ms-parameter-location", "method") - rabbitMQQueueName: string -): ArmResponse | ErrorResponse; - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Interface types must use PascalCase" -@armResourceOperations -interface RabbitMQQueues - extends Radius.ResourceOperationWithSyncDelete< - RabbitMQQueueResource, - RabbitMQQueueProperties, - RootScopeParam - > {} \ No newline at end of file diff --git a/cadl/README.md b/cadl/README.md deleted file mode 100644 index 66ba17c31c..0000000000 --- a/cadl/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Cadl-fying Radius -Cadl is a language for describing cloud service APIs and generating other API description languages, client and service code, documentation, and other assets. Cadl provides highly extensible core language primitives that can describe API shapes common among REST, GraphQL, gRPC, and other protocols. - -You can try a work-in-progress build of the compiler by following the steps in the Getting Started section in the Cadl repository. If you have more in depth questions about Cadl, Brian Terlson, Mark Colishaw and the Cadl Discussion channel on Teams as a whole are a great resource. - -## Important Resources -- [Cadl Repository](https://github.com/microsoft/cadl "Cadl Repository") -- [Cadl Tutorial](https://github.com/microsoft/cadl/blob/main/docs/tutorial.md) -- [Cadl for the OpenAPI developer](https://github.com/microsoft/cadl/blob/34eaea96bb2e355d4df5bed0b3a1eeeee34a03bf/docs/cadl-for-openapi-dev.md) -- [Cadl Azure Playground](https://cadlplayground.z22.web.core.windows.net/cadl-azure/ "Cadl Azure Playground") -- [Cadl Discussion Teams Channel](https://teams.microsoft.com/l/channel/19%3a906c1efbbec54dc8949ac736633e6bdf%40thread.skype/Cadl%2520Discussion%2520%25F0%259F%2590%25AE?groupId=3e17dcb0-4257-4a30-b843-77f47f1d4121&tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47) (Note: After clicking into this link you may need to request access to the channel by following the prompts in Teams) - -## Recommended Dependencies -- @azure-tools/cadl-autorest -- @azure-tools/cadl-azure-core -- @azure-tools/cadl-azure-resource-manager -- @azure-tools/cadl-providerhub -- @cadl-lang/compiler -- @cadl-lang/openapi3 -- @cadl-lang/rest -- @cadl-lang/versioning - -## Tracked Resources -Currently all of our resources are tracked resources. That means that when writing a new resource, each file will have the following: - -```TypeScript -model ResourceProperties {} - -model Resource is TrackedResource { - name: string; -} - -@armResourceOperations -interface InterfaceName - extends Radius.RootScopeResourceOperations -``` -There may be more or less depending on the resource being modeled - -## {rootScope} -At the time of writing this, the Radius team's spec has not been approved by ARM. As a result, the Cadl team has created a custom `RootScopeResourceOperations` object. This makes it so that the paths generated for resources are prepended by `{rootScope}` as required in Radius. - -To utilize this object, do the following: -1. Import `customRootScope.cadl` into the resource file. -2. When creating the `@armResourceOperations` use the `RootScopeResourceOperations` object under the Radius namespace instead of the standard `ResourceOperations` object: -```TypeScript -@armResourceOperations -interface InterfaceName - extends Radius.RootScopeResourceOperations -``` - -## Emitting and Compiling -In the `cadl-project.yaml` the emitter is set to `"@azure-tools/cadl-autorest": true`. This means that it compiles to swagger instead of OpenApi3. If you want to compile to OpenApi3, set the emitter to `"@cadl-lang/openapi3": true`. - -To compile with {rootScope} to a custom file, import `aksrootscope.cadl` into the resource file and run the following command in the terminal: -```TypeScript -cadl compile {fileName}.cadl --option "@azure-tools/cadl-autorest.output-file={fileName}.json" -``` - -To compile with the ARM compliant spec to a custom file, import `armrootscope.cadl` into the resource file and run the following command in the terminal: -```TypeScript -cadl compile {fileName}.cadl --option "@azure-tools/cadl-autorest.output-file={fileName}.json" -``` - -In both cases replace {fileName} with the file you want to compile. - -## Formatting -Run `cadl compile .` to format all files. diff --git a/cadl/UCP/cadl-project.yaml b/cadl/UCP/cadl-project.yaml deleted file mode 100644 index fd97954896..0000000000 --- a/cadl/UCP/cadl-project.yaml +++ /dev/null @@ -1,5 +0,0 @@ -emit: - - "@azure-tools/cadl-autorest" -options: - "@azure-tools/cadl-autorest": - emitter-output-dir: "{project-root}/../../swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/" \ No newline at end of file diff --git a/cadl/UCP/customPlaneScope.cadl b/cadl/UCP/customPlaneScope.cadl deleted file mode 100644 index c38bb49460..0000000000 --- a/cadl/UCP/customPlaneScope.cadl +++ /dev/null @@ -1,138 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Currently, our spec is not approved by ARM so this is a workaround that the CADL team gave us -// so that we can preface our paths with {rootScope} -// To generate {rootScope} in the path, use the tag --import "./aksrootscope.cadl" while compiling - -import "@cadl-lang/openapi"; -import "@cadl-lang/rest"; -import "@azure-tools/cadl-autorest"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-azure-core"; - -namespace Azure.ResourceManager.Radius; - -using Cadl.Http; -using Cadl.Rest; -using OpenAPI; -using Autorest; -using Azure.Core; -using Azure.ResourceManager.Foundations; - -// Skip generation of ListBySubscription -interface PlaneResourceListBySubscription {} - -model CommonParameters { - ...ApiVersionParameter; -} - -model PlaneParentScope { - ...CommonParameters; - ...ParentKeysOf; -} - -model ResourceParentScope { - ...CommonParameters; - ...ParentKeysOf; - ...TRootParams; -} - -model PlaneInstanceParameters { - ...CommonParameters; - ...KeysOf; - ...TRootParams; -} - -model ResourceGroupInstanceParameters { - ...CommonParameters; - ...TRootParams; - ...KeysOf; -} - -interface CommonResourceOperations< - TResource extends ArmResource, - TProperties extends object, - TRootParams -> - extends Azure.ResourceManager.Radius.ResourceRead< - TResource, - ResourceGroupInstanceParameters - >, - Azure.ResourceManager.Radius.ResourceCreate< - TResource, - ResourceGroupInstanceParameters - >, - Azure.ResourceManager.Radius.ResourceDelete< - TResource, - ResourceGroupInstanceParameters - >, - ListByParent {} - -interface PlaneResourceOperations< - TResource extends ArmResource, - TProperties extends object, - TRootParams -> - extends Azure.ResourceManager.Radius.ResourceRead< - TResource, - PlaneInstanceParameters - >, - Azure.ResourceManager.Radius.ResourceCreate< - TResource, - PlaneInstanceParameters - >, - Azure.ResourceManager.Radius.ResourceDelete< - TResource, - PlaneInstanceParameters - >, - PlaneListByParent {} - -interface PlaneTypeOperations< - TResource extends ArmResource, - TProperties extends object, - TRootParams -> - extends Azure.ResourceManager.Radius.ResourceRead< - TResource, - PlaneInstanceParameters - > {} - -interface ListByParent { - @get - //@pageable - @doc("Lists information about all {name}", TResource) - @autoRoute - @list(TResource) - @segmentOf(TResource) - @armResourceList(TResource) - ListByRootScope( - ...ResourceParentScope - ): ArmResponse> | ErrorResponse; -} - -interface PlaneListByParent { - @get - //@pageable - @doc("Lists information about all {name}s in the given plane", TResource) - @autoRoute - @list(TResource) - @segmentOf(TResource) - @armResourceList(TResource) - ListByRootScope( - ...PlaneParentScope - ): ArmResponse> | ErrorResponse; -} diff --git a/cadl/UCP/main.cadl b/cadl/UCP/main.cadl deleted file mode 100644 index 34bbb43f66..0000000000 --- a/cadl/UCP/main.cadl +++ /dev/null @@ -1,9 +0,0 @@ -import "@cadl-lang/rest"; -import "@cadl-lang/openapi"; -import "@azure-tools/cadl-autorest"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; - -import "./ucp.cadl"; -import "./customPlaneScope.cadl"; - diff --git a/cadl/UCP/ucp.cadl b/cadl/UCP/ucp.cadl deleted file mode 100644 index 6f914528aa..0000000000 --- a/cadl/UCP/ucp.cadl +++ /dev/null @@ -1,284 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@cadl-lang/versioning"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; - -import "@cadl-lang/openapi"; - -import "../aksrootscope.cadl"; -import "../customRootScope.cadl"; - -using Cadl.Http; -using Cadl.Rest; -using Cadl.Versioning; -using Azure.ResourceManager; -using Azure.ResourceManager.Radius; -using Azure.ResourceManager.Foundations; -using OpenAPI; - -// Don't need operation APIs. -#suppress "@azure-tools/cadl-azure-resource-manager/missing-operations-endpoint" -@armProviderNamespace -@service({ - title: "UCP Management APIs", - version: "2022-09-01-privatepreview", -}) -@doc("REST APIs for UCP") -@versionedDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -namespace Ucp; - -@doc("UCP ResourceGroup.") -model ResourceGroupResource is TrackedResource { - @doc("UCP resourcegroup name") - @maxLength(63) - @pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") - @key("resourceGroupName") - @path - @segment("resourcegroups") - @extension("x-ms-parameter-location", "method") - name: string; -} - -@doc("Basic properties of a UCP resource.") -model BasicResourceProperties { - @doc("Provisioning state of the resource at the time the operation was called") - @visibility("read") - provisioningState?: ProvisioningState; -} - -@doc("UCP PlaneResource.") -model PlaneResource is TrackedResource { - @key("planeType") - @doc("The plane type.") - @segment("planes") - @path - name: string; -} - -@doc("Plane kinds supported.") -enum PlaneKind { - UCPNative, - Azure, - AWS, -} - -@doc("Credential store kinds supported.") -enum CredentialStorageKind { - Internal, -} - -@doc("AWS credential kinds supported.") -enum AWSCredentialKind { - AccessKey, -} - -@doc("Azure credential kinds supported.") -enum AzureCredentialKind { - ServicePrincipal, -} - -@doc("Plane properties.") -model PlaneResourceProperties extends BasicResourceProperties { - @doc("The kind of plane") - kind: PlaneKind; - - @doc("URL to forward requests to for non UCP Native Plane") - url?: string; - // TODO try record here - - @doc("Resource Providers for UCP Native Plane") - resourceProviders?: Record; -} - -@discriminator("kind") -@doc("Azure Credential properties") -model AzureCredentialProperties extends BasicResourceProperties {} - -@doc("Service Principal credential storage properties") -model AzureServicePrincipalProperties extends AzureCredentialProperties { - @doc("Service principal kind") - kind: "ServicePrincipal"; - - @doc("clientId for ServicePrincipal") - clientId: string; - - @doc("secret for ServicePrincipal") - @extension("x-ms-secret", true) - clientSecret: string; - - @doc("tenantId for ServicePrincipal") - tenantId: string; - - @doc("The storage properties") - storage: CredentialStorageProperties; -} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Interface types must use PascalCaseCadl()" -@discriminator("kind") -@doc("AWS Credential properties") -model AWSCredentialProperties extends BasicResourceProperties {} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Interface types must use PascalCaseCadl()" -@doc("AWS credential storage properties") -model AWSAccessKeyCredentialProperties extends AWSCredentialProperties { - @doc("Access Key kind") - kind: "AccessKey"; - - @doc("Access key ID for AWS identity") - @extension("x-ms-secret", true) - accessKeyId: string; - - @doc("Secret Access Key for AWS identity") - @extension("x-ms-secret", true) - secretAccessKey: string; - - @doc("The storage properties") - storage: CredentialStorageProperties; -} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Interface types must use PascalCaseCadl()" -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-path-segment-invalid-chars" -model AWSCredentialResource is TrackedResource { - @key("credentialName") - @doc("The AWS credential name.") - @path - @segment("providers/System.AWS/credentials") - @pattern("^[a-z]([-a-z0-9]*[a-z0-9])?$") - @maxLength(63) - name: string; -} - -#suppress "@azure-tools/cadl-azure-resource-manager/arm-resource-path-segment-invalid-chars" -model AzureCredentialResource is TrackedResource { - @key("credentialName") - @doc("The Azure credential name.") - @path - @segment("providers/System.Azure/credentials") - @pattern("^[a-z]([-a-z0-9]*[a-z0-9])?$") - @maxLength(63) - name: string; -} - -@doc("Credential storage properties") -@discriminator("kind") -model CredentialStorageProperties {} - -@doc("Internal credential storage properties") -model InternalCredentialStorageProperties extends CredentialStorageProperties { - @doc("Internal kind") - kind: "Internal"; - - @doc("The name of secret stored.") - @visibility("read") - secretName: string; -} - -@doc("Custom root scope") -model PlaneNameParameter { - @doc("The name of the plane") - @maxLength(63) - @path - @pattern("^[a-z]([-a-z0-9]*[a-z0-9])?$") - @extension("x-ms-skip-url-encoding", true) - @extension("x-ms-parameter-location", "method") - planeName: string; -} - -@doc("Provisioning state of the link at the time the operation was called") -enum ProvisioningState { - Succeeded, - Failed, - Canceled, - Provisioning, - Updating, - Deleting, - Accepted, -} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Interface types must use PascalCaseCadl()" -@doc("Custom root scope") -model AWSPlaneNameParameter { - @doc("The name of the plane") - @maxLength(63) - @path - @pattern("^[a-z]([-a-z0-9]*[a-z0-9])?$") - @segment("planes/aws") - @extension("x-ms-skip-url-encoding", true) - @extension("x-ms-parameter-location", "method") - planeName: string; -} - -@doc("Custom root scope") -model AzurePlaneNameParameter { - @doc("The name of the plane") - @maxLength(63) - @path - @pattern("^[a-z]([-a-z0-9]*[a-z0-9])?$") - @segment("planes/azure") - @extension("x-ms-skip-url-encoding", true) - @extension("x-ms-parameter-location", "method") - planeName: string; -} - -@armResourceOperations -interface Planes - extends Radius.PlaneResourceOperations< - PlaneResource, - PlaneResourceProperties, - PlaneNameParameter - > {} - -@armResourceOperations -interface PlaneTypes - extends Radius.PlaneTypeOperations< - PlaneResource, - PlaneResourceProperties, - {} - > {} - -model Root { - ...KeysOf; - ...PlaneNameParameter; -} - -@armResourceOperations -interface ResourceGroups - extends CommonResourceOperations< - ResourceGroupResource, - BasicResourceProperties, - Root - > {} - -@armResourceOperations -interface AzureCredential - extends CommonResourceOperations< - AzureCredentialResource, - AzureCredentialProperties, - AzurePlaneNameParameter - > {} - -#suppress "@azure-tools/cadl-azure-core/casing-style" "The names of Interface types must use PascalCaseCadl()" -@armResourceOperations -interface AWSCredential - extends CommonResourceOperations< - AWSCredentialResource, - AWSCredentialProperties, - AWSPlaneNameParameter - > {} diff --git a/cadl/aksrootscope.cadl b/cadl/aksrootscope.cadl deleted file mode 100644 index 47f097a425..0000000000 --- a/cadl/aksrootscope.cadl +++ /dev/null @@ -1,39 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@cadl-lang/rest"; -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-providerhub"; -import "@cadl-lang/openapi"; - -using OpenAPI; -using Cadl.Http; -using Cadl.Rest; -using Azure.ResourceManager; - -@doc("Custom root scope") -model RootScopeParam { - @doc("The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}") - @minLength(1) - @path - @extension("x-ms-skip-url-encoding", true) - @extension("x-ms-parameter-location", "client") - rootScope: string; -} - -// Skip generation of ListBySubscription -interface RootScopeResourceListBySubscription {} diff --git a/cadl/armrootscope.cadl b/cadl/armrootscope.cadl deleted file mode 100644 index a394678ba0..0000000000 --- a/cadl/armrootscope.cadl +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import "@azure-tools/cadl-azure-core"; -import "@azure-tools/cadl-azure-resource-manager"; - -using Cadl.Http; -using Cadl.Rest; -using Azure.Core; -using Azure.ResourceManager; - -// /subscription/{id}/rg/{rgname}... -@doc("Root scope param") -model RootScopeParam { - ...SubscriptionId; - ...ResourceGroup; -} - -alias RootScopeResourceListBySubscription = ResourceListBySubscription; diff --git a/cadl/cadl-project.yaml b/cadl/cadl-project.yaml deleted file mode 100644 index 7797ff9b39..0000000000 --- a/cadl/cadl-project.yaml +++ /dev/null @@ -1,5 +0,0 @@ -emit: - - "@azure-tools/cadl-autorest" -options: - "@azure-tools/cadl-autorest": - emitter-output-dir: "{project-root}/../swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/" \ No newline at end of file diff --git a/cadl/common.cadl b/cadl/common.cadl deleted file mode 100644 index 268b53b3c2..0000000000 --- a/cadl/common.cadl +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 The Radius Authors. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using OpenAPI; - -@doc("Basic properties of a Radius resource.") -model BasicResourceProperties { - @doc("Status of a resource.") - @visibility("read") - status?: ResourceStatus; - - @doc("Fully qualified resource ID for the environment that the portable resource is linked to") - environment: string; - - @doc("Fully qualified resource ID for the application that the portable resource is consumed by") - application?: Application -} - -@doc("Basic properties of a Dapr component object.") -model BasicDaprResourceProperties extends BasicResourceProperties{ - @doc("The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.") - @visibility("read") - componentName?: string; -} - -@doc("Status of a resource.") -model ResourceStatus { - @doc("Properties of an output resource") - @extension("x-ms-identifiers", []) - outputResources?: OutputResource[]; -} - -@doc("Properties of an output resource.") -model OutputResource {} - -@doc("Fully qualified resource ID for the application that the portable resource is consumed by") -scalar Application extends string; - -@doc("Describes a reference to an existing resource") -model ResourceReference { - @doc("Resource id of an existing resource") - id: string -} - -@doc("Provisioning state of the portable resource at the time the operation was called") -enum ProvisioningState { - Succeeded, - Failed, - Canceled, - Provisioning, - Updating, - Deleting, - Accepted, -} - -@doc("Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.") -enum ResourceProvisioning { - recipe, - manual, -} - -@doc("The recipe used to automatically deploy underlying infrastructure for a portable resource") -model Recipe{ - @doc("The name of the recipe within the environment to use") - name: string; - @doc("Key/value parameters to pass into the recipe at deployment") - parameters?: Parameters; -} -@doc("Key/value parameters to pass into the recipe at deployment") -model Parameters{} \ No newline at end of file diff --git a/cadl/customRootScope.cadl b/cadl/customRootScope.cadl deleted file mode 100644 index 3faa8157d6..0000000000 --- a/cadl/customRootScope.cadl +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Currently, our spec is not approved by ARM so this is a workaround that the CADL team gave us -// so that we can preface our paths with {rootScope} -// To generate {rootScope} in the path, use the tag --import "./aksrootscope.cadl" while compiling - -import "@cadl-lang/openapi"; -import "@cadl-lang/rest"; -import "@azure-tools/cadl-autorest"; -import "@azure-tools/cadl-azure-resource-manager"; -import "@azure-tools/cadl-azure-core"; - -namespace Azure.ResourceManager.Radius; - -using Cadl.Http; -using Cadl.Rest; -using OpenAPI; -using Autorest; -using Azure.Core; -using Azure.ResourceManager.Foundations; - -model RootScopeParentScope { - ...RootScopeResourceCommonParameters; - ...ParentKeysOf; -} - -model RootScopeResourceCommonParameters { - ...ApiVersionParameter; - ...TRootParams; - ...ProviderNamespace; -} - -model RootScopeResourceInstanceParameters { - ...RootScopeResourceCommonParameters; - ...KeysOf; -} - -interface ResourceRead { - @autoRoute - @doc("Retrieves information about a {name}", TResource) - @get - @armResourceRead(TResource) - Get(...TRootParams): ArmResponse | ErrorResponse; -} - -interface ResourceCreate { - @autoRoute - @doc("Creates or updates a {name}", TResource) - @armResourceCreateOrUpdate(TResource) - @put - CreateOrUpdate( - ...TRootParams, - - @doc("Resource create parameters.") - @body - resource: TResource - ): ArmResponse | ArmCreatedResponse | ErrorResponse; -} -interface ResourceDelete { - @autoRoute - @doc("Deletes an existing {name}", TResource) - @armResourceDelete(TResource) - @delete - Delete(...TRootParams): - | ArmDeletedResponse - | ArmDeleteAcceptedResponse - | ArmDeletedNoContentResponse - | ErrorResponse; -} - -interface ResourceDeleteAsync { - @autoRoute - @doc("Deletes an existing {name}", TResource) - @extension("x-ms-long-running-operation", true) - @asyncOperationOptions("azure-async-operation") - @armResourceDelete(TResource) - @delete - Delete(...TRootParams): - | ArmDeletedResponse - | ArmDeleteAcceptedResponse - | ArmDeletedNoContentResponse - | ErrorResponse; -} - -interface ResourceListByParent { - @get - //@pageable - @doc("Lists information about all {name}s in the given root scope", TResource) - @autoRoute - @list(TResource) - @segmentOf(TResource) - @armResourceList(TResource) - ListByRootScope( - ...RootScopeParentScope, - ): ArmResponse> | ErrorResponse; -} - -interface RootScopeResourceOperations - extends ResourceRead< - TResource, - RootScopeResourceInstanceParameters - >, - ResourceCreate< - TResource, - RootScopeResourceInstanceParameters - >, - ResourceListByParent {} - -// ResourceOperationWithSyncDelete, ResourceOperationWithAsyncDelete intersfaces will be moved into RootScopeResourceOperations when we have async delete support for all link resources. -interface ResourceOperationWithSyncDelete - extends RootScopeResourceOperations< - TResource, TProperties, TRootParams - >, - ResourceDelete< - TResource, - RootScopeResourceInstanceParameters - >{} - -interface ResourceOperationWithAsyncDelete - extends RootScopeResourceOperations< - TResource, TProperties, TRootParams - >, - ResourceDeleteAsync< - TResource, - RootScopeResourceInstanceParameters - >{} diff --git a/cadl/package-lock.json b/cadl/package-lock.json deleted file mode 100644 index 2e6a0bbef3..0000000000 --- a/cadl/package-lock.json +++ /dev/null @@ -1,1873 +0,0 @@ -{ - "name": "cadl-project", - "version": "1.0.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "cadl-project", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "@azure-tools/cadl-autorest": "^0.24.0", - "@azure-tools/cadl-azure-core": "^0.24.0", - "@azure-tools/cadl-azure-resource-manager": "^0.24.0", - "@azure-tools/cadl-providerhub": "^0.24.0", - "@cadl-lang/compiler": "^0.38.5", - "@cadl-lang/openapi3": "^0.38.0", - "@cadl-lang/rest": "^0.38.0", - "@cadl-lang/versioning": "^0.38.0" - } - }, - "node_modules/@azure-tools/cadl-autorest": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-autorest/-/cadl-autorest-0.24.0.tgz", - "integrity": "sha512-q8A3GRlwyQJ+/8cJs3dzyB4sRSVORItVS27NOraOwaXMudk9W6wW4uwBpyR07B3iHUanC8ZECe6CaCDUUttbtg==", - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@azure-tools/cadl-azure-core": "~0.24.0", - "@cadl-lang/compiler": "~0.38.0", - "@cadl-lang/openapi": "~0.38.0", - "@cadl-lang/rest": "~0.38.0", - "@cadl-lang/versioning": "~0.38.0" - } - }, - "node_modules/@azure-tools/cadl-azure-core": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-azure-core/-/cadl-azure-core-0.24.0.tgz", - "integrity": "sha512-Pzs1uC03Rbd783dAN8yvsFEWKJIBpV7zKf+Mj2S2x7F9IsR+KS1nlPmifIAtSCeSRPVkU21xD1WmzXvB1GR59w==", - "dependencies": { - "@cadl-lang/lint": "~0.38.0" - }, - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@cadl-lang/compiler": "~0.38.0", - "@cadl-lang/rest": "~0.38.0" - } - }, - "node_modules/@azure-tools/cadl-azure-resource-manager": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-azure-resource-manager/-/cadl-azure-resource-manager-0.24.0.tgz", - "integrity": "sha512-ufuDnjRp4bShMKKeMIYa07cKZCKLs4ofbB6bbYPihP9lodwgSCF444Hi76Qz+GiSv0nyS/ySJdH0kQPiVcsz8A==", - "dependencies": { - "@cadl-lang/lint": "~0.38.0" - }, - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@azure-tools/cadl-autorest": "~0.24.0", - "@azure-tools/cadl-azure-core": "~0.24.0", - "@cadl-lang/compiler": "~0.38.0", - "@cadl-lang/openapi": "~0.38.0", - "@cadl-lang/rest": "~0.38.0", - "@cadl-lang/versioning": "~0.38.0" - } - }, - "node_modules/@azure-tools/cadl-providerhub": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-providerhub/-/cadl-providerhub-0.24.0.tgz", - "integrity": "sha512-VCXW/cDGTf8KB84oFm9LtQIItLOol7A3CFf9PpI+mrPWDBlhsTNvI2aaj8hlPBqQ4e+mwUmk0EXRPwzFfL3ipQ==", - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@azure-tools/cadl-autorest": "~0.24.0", - "@azure-tools/cadl-azure-core": "~0.24.0", - "@azure-tools/cadl-azure-resource-manager": "~0.24.0", - "@cadl-lang/compiler": "~0.38.0", - "@cadl-lang/openapi": "~0.38.0", - "@cadl-lang/rest": "~0.38.0", - "@cadl-lang/versioning": "~0.38.0" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", - "dependencies": { - "@babel/highlight": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", - "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@cadl-lang/compiler": { - "version": "0.38.5", - "resolved": "https://registry.npmjs.org/@cadl-lang/compiler/-/compiler-0.38.5.tgz", - "integrity": "sha512-jd6a8TEp9ApBzekTb39aBPocYrkuqzsQbLTDcc/c6tA47Wmr87463MAXpeB80ziEsr15sccI01j3g63jt5W0Aw==", - "dependencies": { - "@babel/code-frame": "~7.18.6", - "ajv": "~8.11.2", - "change-case": "~4.1.2", - "globby": "~13.1.1", - "js-yaml": "~4.1.0", - "mkdirp": "~1.0.4", - "mustache": "~4.2.0", - "node-fetch": "3.2.8", - "node-watch": "~0.7.1", - "picocolors": "~1.0.0", - "prettier": "~2.7.1", - "prompts": "~2.4.1", - "vscode-languageserver": "~8.0.2", - "vscode-languageserver-textdocument": "~1.0.1", - "yargs": "~17.6.2" - }, - "bin": { - "cadl": "cmd/cadl.js", - "cadl-server": "cmd/cadl-server.js" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@cadl-lang/lint": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/lint/-/lint-0.38.0.tgz", - "integrity": "sha512-6g4yoXeaNnTYxEWA0QywN3HkTCINPTHI56IsDKp6JhLOiROj1NvoufUzX438vdTqDqNyHg2t08fRmLMJP4GsCQ==", - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@cadl-lang/compiler": "~0.38.0" - } - }, - "node_modules/@cadl-lang/openapi": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/openapi/-/openapi-0.38.0.tgz", - "integrity": "sha512-lFmU5AsZtw7Ofcnq3lg18Ieg21iuS73NOb+549BxPZX2j70vEqqfRT3CCCFmpGCK2sAUy2x2qD+pVUBcQIXeHQ==", - "peer": true, - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@cadl-lang/compiler": "~0.38.0", - "@cadl-lang/rest": "~0.38.0" - } - }, - "node_modules/@cadl-lang/openapi3": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/openapi3/-/openapi3-0.38.0.tgz", - "integrity": "sha512-l7000SmmTTqQsnoNunbpKHNemfcUyPt6EBLW9F0vpzVHK4YTC40biVu/6EIYF4KeKq2mTtbC4akRH3kLrpQoKQ==", - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@cadl-lang/compiler": "~0.38.0", - "@cadl-lang/openapi": "~0.38.0", - "@cadl-lang/rest": "~0.38.0", - "@cadl-lang/versioning": "~0.38.0" - } - }, - "node_modules/@cadl-lang/rest": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/rest/-/rest-0.38.0.tgz", - "integrity": "sha512-DvLLoUaG3//nf4HC4BhFFNK8cotYbwtL35cb6Nko8MYruLCuxQn0vZKtAMLnlvZWXc65qfbnTz1W/EI0NQh8+w==", - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@cadl-lang/compiler": "~0.38.0" - } - }, - "node_modules/@cadl-lang/versioning": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/versioning/-/versioning-0.38.0.tgz", - "integrity": "sha512-7ECvYQShLu80eyQzRgRH1Lu/P1lrjnHpnEcNZK8bVoHoy+QT+DkY/c22OoBRwcb5kux9/T1/CMF61WqfrKC8jQ==", - "dependencies": { - "@cadl-lang/compiler": "~0.38.0" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/ajv": { - "version": "8.11.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", - "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "dependencies": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, - "node_modules/capital-case": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", - "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/change-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", - "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", - "dependencies": { - "camel-case": "^4.1.2", - "capital-case": "^1.0.4", - "constant-case": "^3.0.4", - "dot-case": "^3.0.4", - "header-case": "^2.0.4", - "no-case": "^3.0.4", - "param-case": "^3.0.4", - "pascal-case": "^3.1.2", - "path-case": "^3.0.4", - "sentence-case": "^3.0.4", - "snake-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" - }, - "node_modules/constant-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", - "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case": "^2.0.2" - } - }, - "node_modules/data-uri-to-buffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", - "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==", - "engines": { - "node": ">= 12" - } - }, - "node_modules/dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dependencies": { - "path-type": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" - }, - "node_modules/fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dependencies": { - "reusify": "^1.0.4" - } - }, - "node_modules/fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "paypal", - "url": "https://paypal.me/jimmywarting" - } - ], - "dependencies": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - }, - "engines": { - "node": "^12.20 || >= 14.13" - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "dependencies": { - "fetch-blob": "^3.1.2" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/globby": { - "version": "13.1.2", - "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz", - "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==", - "dependencies": { - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.11", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "engines": { - "node": ">=4" - } - }, - "node_modules/header-case": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", - "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", - "dependencies": { - "capital-case": "^1.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", - "engines": { - "node": ">= 4" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" - }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "node_modules/kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "engines": { - "node": ">=6" - } - }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/mustache": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", - "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", - "bin": { - "mustache": "bin/mustache" - } - }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "engines": { - "node": ">=10.5.0" - } - }, - "node_modules/node-fetch": { - "version": "3.2.8", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.8.tgz", - "integrity": "sha512-KtpD1YhGszhntMpBDyp5lyagk8KIMopC1LEb7cQUAh7zcosaX5uK8HnbNb2i3NTQK3sIawCItS0uFC3QzcLHdg==", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" - } - }, - "node_modules/node-watch": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.7.3.tgz", - "integrity": "sha512-3l4E8uMPY1HdMMryPRUAl+oIHtXtyiTlIiESNSVSNxcPfzAFzeTbXFQkZfAwBbo0B1qMSG8nUABx+Gd+YrbKrQ==", - "engines": { - "node": ">=6" - } - }, - "node_modules/param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/path-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", - "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "engines": { - "node": ">=8" - } - }, - "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, - "node_modules/prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "dependencies": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "engines": { - "node": ">=6" - } - }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "node_modules/sentence-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", - "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, - "node_modules/sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" - }, - "node_modules/slash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", - "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" - }, - "node_modules/upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", - "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/upper-case-first": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", - "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/vscode-jsonrpc": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz", - "integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/vscode-languageserver": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.2.tgz", - "integrity": "sha512-bpEt2ggPxKzsAOZlXmCJ50bV7VrxwCS5BI4+egUmure/oI/t4OlFzi/YNtVvY24A2UDOZAgwFGgnZPwqSJubkA==", - "dependencies": { - "vscode-languageserver-protocol": "3.17.2" - }, - "bin": { - "installServerIntoExtension": "bin/installServerIntoExtension" - } - }, - "node_modules/vscode-languageserver-protocol": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz", - "integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==", - "dependencies": { - "vscode-jsonrpc": "8.0.2", - "vscode-languageserver-types": "3.17.2" - } - }, - "node_modules/vscode-languageserver-textdocument": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.5.tgz", - "integrity": "sha512-1ah7zyQjKBudnMiHbZmxz5bYNM9KKZYz+5VQLj+yr8l+9w3g+WAhCkUkWbhMEdC5u0ub4Ndiye/fDyS8ghIKQg==" - }, - "node_modules/vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" - }, - "node_modules/web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/wrap-ansi/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "17.6.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz", - "integrity": "sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "engines": { - "node": ">=12" - } - } - }, - "dependencies": { - "@azure-tools/cadl-autorest": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-autorest/-/cadl-autorest-0.24.0.tgz", - "integrity": "sha512-q8A3GRlwyQJ+/8cJs3dzyB4sRSVORItVS27NOraOwaXMudk9W6wW4uwBpyR07B3iHUanC8ZECe6CaCDUUttbtg==", - "requires": {} - }, - "@azure-tools/cadl-azure-core": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-azure-core/-/cadl-azure-core-0.24.0.tgz", - "integrity": "sha512-Pzs1uC03Rbd783dAN8yvsFEWKJIBpV7zKf+Mj2S2x7F9IsR+KS1nlPmifIAtSCeSRPVkU21xD1WmzXvB1GR59w==", - "requires": { - "@cadl-lang/lint": "~0.38.0" - } - }, - "@azure-tools/cadl-azure-resource-manager": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-azure-resource-manager/-/cadl-azure-resource-manager-0.24.0.tgz", - "integrity": "sha512-ufuDnjRp4bShMKKeMIYa07cKZCKLs4ofbB6bbYPihP9lodwgSCF444Hi76Qz+GiSv0nyS/ySJdH0kQPiVcsz8A==", - "requires": { - "@cadl-lang/lint": "~0.38.0" - } - }, - "@azure-tools/cadl-providerhub": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@azure-tools/cadl-providerhub/-/cadl-providerhub-0.24.0.tgz", - "integrity": "sha512-VCXW/cDGTf8KB84oFm9LtQIItLOol7A3CFf9PpI+mrPWDBlhsTNvI2aaj8hlPBqQ4e+mwUmk0EXRPwzFfL3ipQ==", - "requires": {} - }, - "@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", - "requires": { - "@babel/highlight": "^7.18.6" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==" - }, - "@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", - "requires": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } - }, - "@cadl-lang/compiler": { - "version": "0.38.5", - "resolved": "https://registry.npmjs.org/@cadl-lang/compiler/-/compiler-0.38.5.tgz", - "integrity": "sha512-jd6a8TEp9ApBzekTb39aBPocYrkuqzsQbLTDcc/c6tA47Wmr87463MAXpeB80ziEsr15sccI01j3g63jt5W0Aw==", - "requires": { - "@babel/code-frame": "~7.18.6", - "ajv": "~8.11.2", - "change-case": "~4.1.2", - "globby": "~13.1.1", - "js-yaml": "~4.1.0", - "mkdirp": "~1.0.4", - "mustache": "~4.2.0", - "node-fetch": "3.2.8", - "node-watch": "~0.7.1", - "picocolors": "~1.0.0", - "prettier": "~2.7.1", - "prompts": "~2.4.1", - "vscode-languageserver": "~8.0.2", - "vscode-languageserver-textdocument": "~1.0.1", - "yargs": "~17.6.2" - } - }, - "@cadl-lang/lint": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/lint/-/lint-0.38.0.tgz", - "integrity": "sha512-6g4yoXeaNnTYxEWA0QywN3HkTCINPTHI56IsDKp6JhLOiROj1NvoufUzX438vdTqDqNyHg2t08fRmLMJP4GsCQ==", - "requires": {} - }, - "@cadl-lang/openapi": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/openapi/-/openapi-0.38.0.tgz", - "integrity": "sha512-lFmU5AsZtw7Ofcnq3lg18Ieg21iuS73NOb+549BxPZX2j70vEqqfRT3CCCFmpGCK2sAUy2x2qD+pVUBcQIXeHQ==", - "peer": true, - "requires": {} - }, - "@cadl-lang/openapi3": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/openapi3/-/openapi3-0.38.0.tgz", - "integrity": "sha512-l7000SmmTTqQsnoNunbpKHNemfcUyPt6EBLW9F0vpzVHK4YTC40biVu/6EIYF4KeKq2mTtbC4akRH3kLrpQoKQ==", - "requires": {} - }, - "@cadl-lang/rest": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/rest/-/rest-0.38.0.tgz", - "integrity": "sha512-DvLLoUaG3//nf4HC4BhFFNK8cotYbwtL35cb6Nko8MYruLCuxQn0vZKtAMLnlvZWXc65qfbnTz1W/EI0NQh8+w==", - "requires": {} - }, - "@cadl-lang/versioning": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@cadl-lang/versioning/-/versioning-0.38.0.tgz", - "integrity": "sha512-7ECvYQShLu80eyQzRgRH1Lu/P1lrjnHpnEcNZK8bVoHoy+QT+DkY/c22OoBRwcb5kux9/T1/CMF61WqfrKC8jQ==", - "requires": { - "@cadl-lang/compiler": "~0.38.0" - } - }, - "@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "requires": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - } - }, - "@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==" - }, - "@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "requires": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - } - }, - "ajv": { - "version": "8.11.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.2.tgz", - "integrity": "sha512-E4bfmKAhGiSTvMfL1Myyycaub+cUEU2/IvpylXkUu7CHBkBj1f/ikdzbD7YQ6FKUbixDxeYvB/xY4fvyroDlQg==", - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "camel-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", - "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", - "requires": { - "pascal-case": "^3.1.2", - "tslib": "^2.0.3" - } - }, - "capital-case": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", - "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "change-case": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", - "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", - "requires": { - "camel-case": "^4.1.2", - "capital-case": "^1.0.4", - "constant-case": "^3.0.4", - "dot-case": "^3.0.4", - "header-case": "^2.0.4", - "no-case": "^3.0.4", - "param-case": "^3.0.4", - "pascal-case": "^3.1.2", - "path-case": "^3.0.4", - "sentence-case": "^3.0.4", - "snake-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" - }, - "constant-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", - "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case": "^2.0.2" - } - }, - "data-uri-to-buffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", - "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==" - }, - "dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "requires": { - "path-type": "^4.0.0" - } - }, - "dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==" - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" - }, - "fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", - "requires": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - } - }, - "fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "requires": { - "reusify": "^1.0.4" - } - }, - "fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "requires": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "requires": { - "fetch-blob": "^3.1.2" - } - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "requires": { - "is-glob": "^4.0.1" - } - }, - "globby": { - "version": "13.1.2", - "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.2.tgz", - "integrity": "sha512-LKSDZXToac40u8Q1PQtZihbNdTYSNMuWe+K5l+oa6KgDzSvVrHXlJy40hUP522RjAIoNLJYBJi7ow+rbFpIhHQ==", - "requires": { - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.11", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^4.0.0" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==" - }, - "header-case": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", - "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", - "requires": { - "capital-case": "^1.0.4", - "tslib": "^2.0.3" - } - }, - "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==" - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "requires": { - "argparse": "^2.0.1" - } - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" - }, - "kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==" - }, - "lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "requires": { - "tslib": "^2.0.3" - } - }, - "merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" - }, - "micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "requires": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - } - }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" - }, - "mustache": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", - "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==" - }, - "no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "requires": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, - "node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" - }, - "node-fetch": { - "version": "3.2.8", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.8.tgz", - "integrity": "sha512-KtpD1YhGszhntMpBDyp5lyagk8KIMopC1LEb7cQUAh7zcosaX5uK8HnbNb2i3NTQK3sIawCItS0uFC3QzcLHdg==", - "requires": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - } - }, - "node-watch": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.7.3.tgz", - "integrity": "sha512-3l4E8uMPY1HdMMryPRUAl+oIHtXtyiTlIiESNSVSNxcPfzAFzeTbXFQkZfAwBbo0B1qMSG8nUABx+Gd+YrbKrQ==" - }, - "param-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", - "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", - "requires": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "pascal-case": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", - "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "path-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", - "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", - "requires": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==" - }, - "picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" - }, - "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==" - }, - "prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "requires": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - } - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" - }, - "queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==" - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" - }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" - }, - "run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "requires": { - "queue-microtask": "^1.2.2" - } - }, - "sentence-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", - "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, - "sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" - }, - "slash": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", - "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==" - }, - "snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "requires": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "requires": { - "has-flag": "^3.0.0" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - } - }, - "tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" - }, - "upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", - "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", - "requires": { - "tslib": "^2.0.3" - } - }, - "upper-case-first": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", - "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", - "requires": { - "tslib": "^2.0.3" - } - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "requires": { - "punycode": "^2.1.0" - } - }, - "vscode-jsonrpc": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz", - "integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==" - }, - "vscode-languageserver": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.0.2.tgz", - "integrity": "sha512-bpEt2ggPxKzsAOZlXmCJ50bV7VrxwCS5BI4+egUmure/oI/t4OlFzi/YNtVvY24A2UDOZAgwFGgnZPwqSJubkA==", - "requires": { - "vscode-languageserver-protocol": "3.17.2" - } - }, - "vscode-languageserver-protocol": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz", - "integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==", - "requires": { - "vscode-jsonrpc": "8.0.2", - "vscode-languageserver-types": "3.17.2" - } - }, - "vscode-languageserver-textdocument": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.5.tgz", - "integrity": "sha512-1ah7zyQjKBudnMiHbZmxz5bYNM9KKZYz+5VQLj+yr8l+9w3g+WAhCkUkWbhMEdC5u0ub4Ndiye/fDyS8ghIKQg==" - }, - "vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" - }, - "web-streams-polyfill": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", - "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==" - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - } - } - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" - }, - "yargs": { - "version": "17.6.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.2.tgz", - "integrity": "sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==", - "requires": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - } - }, - "yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==" - } - } -} diff --git a/cadl/package.json b/cadl/package.json deleted file mode 100644 index ed0008258a..0000000000 --- a/cadl/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "cadl-project", - "dependencies": { - "@azure-tools/cadl-autorest": "^0.24.0", - "@azure-tools/cadl-azure-core": "^0.24.0", - "@azure-tools/cadl-azure-resource-manager": "^0.24.0", - "@azure-tools/cadl-providerhub": "^0.24.0", - "@cadl-lang/compiler": "^0.38.5", - "@cadl-lang/openapi3": "^0.38.0", - "@cadl-lang/rest": "^0.38.0", - "@cadl-lang/versioning": "^0.38.0" - }, - "private": true, - "description": "Cadl is a language for describing cloud service APIs and generating other API description languages, client and service code, documentation, and other assets. Cadl provides highly extensible core language primitives that can describe API shapes common among REST, GraphQL, gRPC, and other protocols.", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC" -} diff --git a/cmd/applications-rp/link-dev.yaml b/cmd/applications-rp/link-dev.yaml deleted file mode 100644 index 77c5a933b0..0000000000 --- a/cmd/applications-rp/link-dev.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# This is an example of configuration file. -environment: - name: Dev - roleLocation: "global" -storageProvider: - provider: "etcd" - etcd: - inmemory: true -queueProvider: - provider: inmemory -profilerProvider: - enabled: true - port: 6060 -secretProvider: - provider: etcd - etcd: - inmemory: true -metricsProvider: - prometheus: - enabled: true - path: "/metrics" - port: 9090 -featureFlags: - - "PLACEHOLDER" -server: - host: "0.0.0.0" - port: 8081 - enableArmAuth: false -workerServer: - maxOperationConcurrency: 3 - maxOperationRetryCount: 2 -ucp: - kind: kubernetes -logging: - level: "info" - json: false -terraform: - path: "/terraform" diff --git a/cmd/applications-rp/link-self-hosted.yaml b/cmd/applications-rp/link-self-hosted.yaml deleted file mode 100644 index 0c34a7492d..0000000000 --- a/cmd/applications-rp/link-self-hosted.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# This configuration file is used in development when launching from VS Code. -# -# This configures the link RP to... -# -# - Use Kubernetes (namespace: radius-testing) for storage and secrets -# - Listen on port 8081 -# - Talk to UCP on port 9000 -# - Disables metrics and profiler -# -environment: - name: Dev - roleLocation: "global" -storageProvider: - provider: "apiserver" - apiserver: - context: '' - namespace: 'radius-testing' -queueProvider: - provider: "apiserver" - apiserver: - context: '' - namespace: 'radius-testing' -profilerProvider: - enabled: false - port: 6060 -secretProvider: - provider: "kubernetes" -metricsProvider: - prometheus: - enabled: false - path: "/metrics" - port: 9090 -featureFlags: - - "PLACEHOLDER" -server: - host: "0.0.0.0" - port: 8081 - enableArmAuth: false -workerServer: - maxOperationConcurrency: 3 - maxOperationRetryCount: 2 -ucp: - kind: direct - direct: - endpoint: "http://localhost:9000/apis/api.ucp.dev/v1alpha3" -logging: - level: "info" - json: false -terraform: - path: "/tmp" \ No newline at end of file diff --git a/cmd/applications-rp/main.go b/cmd/applications-rp/main.go index 4f7dde480f..57b93a00a0 100644 --- a/cmd/applications-rp/main.go +++ b/cmd/applications-rp/main.go @@ -18,75 +18,57 @@ package main import ( "context" - "flag" "fmt" "log" "os" "os/signal" "syscall" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/corerp/backend" - "github.com/project-radius/radius/pkg/corerp/frontend" - metricsservice "github.com/project-radius/radius/pkg/metrics/service" - profilerservice "github.com/project-radius/radius/pkg/profiler/service" - "github.com/project-radius/radius/pkg/trace" - - link_backend "github.com/project-radius/radius/pkg/linkrp/backend" - link_frontend "github.com/project-radius/radius/pkg/linkrp/frontend" - "github.com/project-radius/radius/pkg/logging" - "github.com/project-radius/radius/pkg/ucp/data" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/hosting" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "github.com/go-logr/logr" + "github.com/spf13/pflag" etcdclient "go.etcd.io/etcd/client/v3" runtimelog "sigs.k8s.io/controller-runtime/pkg/log" -) - -const serviceName = "applications.core" -func newLinkHosts(configFile string, enableAsyncWorker bool) ([]hosting.Service, *hostoptions.HostOptions, error) { - hostings := []hosting.Service{} - options, err := hostoptions.NewHostOptionsFromEnvironment(configFile) - if err != nil { - return nil, nil, err - } - hostings = append(hostings, link_frontend.NewService(options)) - if enableAsyncWorker { - hostings = append(hostings, link_backend.NewService(options)) - } + "github.com/radius-project/radius/pkg/armrpc/builder" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + metricsservice "github.com/radius-project/radius/pkg/metrics/service" + profilerservice "github.com/radius-project/radius/pkg/profiler/service" + "github.com/radius-project/radius/pkg/recipes/controllerconfig" + "github.com/radius-project/radius/pkg/server" + "github.com/radius-project/radius/pkg/trace" + + pr_backend "github.com/radius-project/radius/pkg/portableresources/backend" + pr_frontend "github.com/radius-project/radius/pkg/portableresources/frontend" + "github.com/radius-project/radius/pkg/ucp/data" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/ucplog" + + corerp_setup "github.com/radius-project/radius/pkg/corerp/setup" +) - return hostings, &options, nil -} +const serviceName = "radius" func main() { var configFile string - var enableAsyncWorker bool - - var runLink bool - var linkConfigFile string - defaultConfig := fmt.Sprintf("radius-%s.yaml", hostoptions.Environment()) - flag.StringVar(&configFile, "config-file", defaultConfig, "The service configuration file.") - flag.BoolVar(&enableAsyncWorker, "enable-asyncworker", true, "Flag to run async request process worker (for private preview and dev/test purpose).") - - flag.BoolVar(&runLink, "run-link", true, "Flag to run Applications.Link RP (for private preview and dev/test purpose).") - defaultLinkConfig := fmt.Sprintf("link-%s.yaml", hostoptions.Environment()) - flag.StringVar(&linkConfigFile, "link-config", defaultLinkConfig, "The service configuration file for Applications.Link.") - + pflag.StringVar(&configFile, "config-file", defaultConfig, "The service configuration file.") if configFile == "" { log.Fatal("config-file is empty.") //nolint:forbidigo // this is OK inside the main function. } - flag.Parse() + var portableResourceConfigFile string + defaultPortableRsConfig := fmt.Sprintf("portableresource-%s.yaml", hostoptions.Environment()) + pflag.StringVar(&portableResourceConfigFile, "portableresource-config", defaultPortableRsConfig, "The service configuration file for portable resource providers.") + + pflag.Parse() options, err := hostoptions.NewHostOptionsFromEnvironment(configFile) if err != nil { log.Fatal(err) //nolint:forbidigo // this is OK inside the main function. } - hostingSvc := []hosting.Service{frontend.NewService(options)} + + hostingSvc := []hosting.Service{} metricOptions := metricsservice.NewHostOptionsFromEnvironment(*options.Config) metricOptions.Config.ServiceName = serviceName @@ -99,7 +81,7 @@ func main() { hostingSvc = append(hostingSvc, profilerservice.NewService(profilerOptions)) } - logger, flush, err := ucplog.NewLogger(logging.AppCoreLoggerName, &options.Config.Logging) + logger, flush, err := ucplog.NewLogger(serviceName, &options.Config.Logging) if err != nil { log.Fatal(err) //nolint:forbidigo // this is OK inside the main function. } @@ -108,22 +90,10 @@ func main() { // Must set the logger before using controller-runtime. runtimelog.SetLogger(logger) - if enableAsyncWorker { - logger.Info("Enable AsyncRequestProcessWorker.") - hostingSvc = append(hostingSvc, backend.NewService(options)) - } - - // Configure Applications.Link to run it with Applications.Core RP. - var linkOpts *hostoptions.HostOptions - if runLink && linkConfigFile != "" { - logger.Info("Run Applications.Link.") - var linkSvcs []hosting.Service - var err error - linkSvcs, linkOpts, err = newLinkHosts(linkConfigFile, enableAsyncWorker) - if err != nil { - log.Fatal(err) //nolint:forbidigo // this is OK inside the main function. - } - hostingSvc = append(hostingSvc, linkSvcs...) + // Load portable resource config. + prOptions, err := hostoptions.NewHostOptionsFromEnvironment(portableResourceConfigFile) + if err != nil { + log.Fatal(err) //nolint:forbidigo // this is OK inside the main function. } if options.Config.StorageProvider.Provider == dataprovider.TypeETCD && @@ -135,13 +105,31 @@ func main() { client := hosting.NewAsyncValue[etcdclient.Client]() options.Config.StorageProvider.ETCD.Client = client options.Config.SecretProvider.ETCD.Client = client - if linkOpts != nil { - linkOpts.Config.StorageProvider.ETCD.Client = client - linkOpts.Config.SecretProvider.ETCD.Client = client - } + + // Portable resource options + prOptions.Config.StorageProvider.ETCD.Client = client + prOptions.Config.SecretProvider.ETCD.Client = client + hostingSvc = append(hostingSvc, data.NewEmbeddedETCDService(data.EmbeddedETCDServiceOptions{ClientConfigSink: client})) } + builders, err := builders(options) + if err != nil { + log.Fatal(err) //nolint:forbidigo // this is OK inside the main function. + } + + hostingSvc = append( + hostingSvc, + server.NewAPIService(options, builders), + server.NewAsyncWorker(options, builders), + + // Configure Portable Resources to run it with Applications.Core RP. + // + // This is temporary until we migrate these resources to use the new registration model. + pr_frontend.NewService(prOptions), + pr_backend.NewService(prOptions), + ) + loggerValues := []any{} host := &hosting.Host{ Services: hostingSvc, @@ -190,3 +178,15 @@ func main() { panic(err) } } + +func builders(options hostoptions.HostOptions) ([]builder.Builder, error) { + config, err := controllerconfig.New(options) + if err != nil { + return nil, err + } + + return []builder.Builder{ + corerp_setup.SetupNamespace(config).GenerateBuilder(), + // Add resource provider builders... + }, nil +} diff --git a/cmd/applications-rp/portableresource-dev.yaml b/cmd/applications-rp/portableresource-dev.yaml new file mode 100644 index 0000000000..89fd579140 --- /dev/null +++ b/cmd/applications-rp/portableresource-dev.yaml @@ -0,0 +1,39 @@ +# This is an example of configuration file. +environment: + name: Dev + roleLocation: "global" +storageProvider: + provider: "etcd" + etcd: + inmemory: true +queueProvider: + provider: inmemory + name: radiusportable +profilerProvider: + enabled: true + port: 6060 +secretProvider: + provider: etcd + etcd: + inmemory: true +metricsProvider: + prometheus: + enabled: true + path: "/metrics" + port: 9090 +featureFlags: + - "PLACEHOLDER" +server: + host: "0.0.0.0" + port: 8081 + enableArmAuth: false +workerServer: + maxOperationConcurrency: 3 + maxOperationRetryCount: 2 +ucp: + kind: kubernetes +logging: + level: "info" + json: false +terraform: + path: "/terraform" diff --git a/cmd/applications-rp/portableresource-self-hosted.yaml b/cmd/applications-rp/portableresource-self-hosted.yaml new file mode 100644 index 0000000000..37c587e086 --- /dev/null +++ b/cmd/applications-rp/portableresource-self-hosted.yaml @@ -0,0 +1,51 @@ +# This configuration file is used in development when launching from VS Code. +# +# This configures the Portable Resources' Providers to... +# +# - Use Kubernetes (namespace: radius-testing) for storage and secrets +# - Listen on port 8081 +# - Talk to UCP on port 9000 +# - Disables metrics and profiler +# +environment: + name: Dev + roleLocation: "global" +storageProvider: + provider: "apiserver" + apiserver: + context: '' + namespace: 'radius-testing' +queueProvider: + provider: "apiserver" + name: radiusportable + apiserver: + context: '' + namespace: 'radius-testing' +profilerProvider: + enabled: false + port: 6060 +secretProvider: + provider: "kubernetes" +metricsProvider: + prometheus: + enabled: false + path: "/metrics" + port: 9090 +featureFlags: + - "PLACEHOLDER" +server: + host: "0.0.0.0" + port: 8081 + enableArmAuth: false +workerServer: + maxOperationConcurrency: 3 + maxOperationRetryCount: 2 +ucp: + kind: direct + direct: + endpoint: "http://localhost:9000/apis/api.ucp.dev/v1alpha3" +logging: + level: "info" + json: false +terraform: + path: "/tmp" \ No newline at end of file diff --git a/cmd/applications-rp/radius-cloud.yaml b/cmd/applications-rp/radius-cloud.yaml index 8555e931fa..66c36258a2 100644 --- a/cmd/applications-rp/radius-cloud.yaml +++ b/cmd/applications-rp/radius-cloud.yaml @@ -19,6 +19,7 @@ storageProvider: masterKey: set-me-in-a-different-way queueProvider: provider: inmemory + name: radius profilerProvider: enabled: true port: 6060 diff --git a/cmd/applications-rp/radius-dev.yaml b/cmd/applications-rp/radius-dev.yaml index a679384d92..3c64758fe6 100644 --- a/cmd/applications-rp/radius-dev.yaml +++ b/cmd/applications-rp/radius-dev.yaml @@ -8,6 +8,7 @@ storageProvider: inmemory: true queueProvider: provider: inmemory + name: radius profilerProvider: enabled: true port: 6060 diff --git a/cmd/applications-rp/radius-self-hosted.yaml b/cmd/applications-rp/radius-self-hosted.yaml index 63090e1448..b247043a15 100644 --- a/cmd/applications-rp/radius-self-hosted.yaml +++ b/cmd/applications-rp/radius-self-hosted.yaml @@ -17,6 +17,7 @@ storageProvider: namespace: 'radius-testing' queueProvider: provider: "apiserver" + name: radius apiserver: context: '' namespace: 'radius-testing' diff --git a/cmd/docgen/main.go b/cmd/docgen/main.go index b1e679d454..ed5c62dc86 100644 --- a/cmd/docgen/main.go +++ b/cmd/docgen/main.go @@ -24,7 +24,7 @@ import ( "path/filepath" "strings" - "github.com/project-radius/radius/cmd/rad/cmd" + "github.com/radius-project/radius/cmd/rad/cmd" "github.com/spf13/cobra/doc" ) diff --git a/cmd/rad/cmd/bicepDelete.go b/cmd/rad/cmd/bicepDelete.go index a5049811bd..5676f6e42e 100644 --- a/cmd/rad/cmd/bicepDelete.go +++ b/cmd/rad/cmd/bicepDelete.go @@ -17,8 +17,8 @@ limitations under the License. package cmd import ( - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/output" "github.com/spf13/cobra" ) diff --git a/cmd/rad/cmd/bicepDownload.go b/cmd/rad/cmd/bicepDownload.go index c4bf15bf88..91bbe4e433 100644 --- a/cmd/rad/cmd/bicepDownload.go +++ b/cmd/rad/cmd/bicepDownload.go @@ -19,9 +19,9 @@ package cmd import ( "fmt" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/version" "github.com/spf13/cobra" ) diff --git a/cmd/rad/cmd/debuglogs.go b/cmd/rad/cmd/debuglogs.go index 952e6ae4d1..7a296578b4 100644 --- a/cmd/rad/cmd/debuglogs.go +++ b/cmd/rad/cmd/debuglogs.go @@ -24,10 +24,10 @@ import ( "os" "path/filepath" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/kubernetes" - k8slabels "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/kubernetes" + k8slabels "github.com/radius-project/radius/pkg/kubernetes" "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/cmd/rad/cmd/recipe.go b/cmd/rad/cmd/recipe.go index 8bc7c3d506..b5b2f73060 100644 --- a/cmd/rad/cmd/recipe.go +++ b/cmd/rad/cmd/recipe.go @@ -23,9 +23,9 @@ import ( func NewRecipeCommand() *cobra.Command { return &cobra.Command{ Use: "recipe", - Short: "Manage link recipes", - Long: `Manage link recipes - Link recipes automate the deployment of infrastructure and configuration of links.`, + Short: "Manage recipes", + Long: `Manage recipes + Recipes automate the deployment of infrastructure and configuration of portable resources.`, } } diff --git a/cmd/rad/cmd/resourceExpose.go b/cmd/rad/cmd/resourceExpose.go index 8b101eca20..346e468547 100644 --- a/cmd/rad/cmd/resourceExpose.go +++ b/cmd/rad/cmd/resourceExpose.go @@ -22,11 +22,11 @@ import ( "strings" "github.com/agnivade/levenshtein" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" "github.com/spf13/cobra" ) diff --git a/cmd/rad/cmd/resourceLogs.go b/cmd/rad/cmd/resourceLogs.go index abeb48d987..d1be2400f3 100644 --- a/cmd/rad/cmd/resourceLogs.go +++ b/cmd/rad/cmd/resourceLogs.go @@ -24,10 +24,10 @@ import ( "os" "strings" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" "github.com/spf13/cobra" ) diff --git a/cmd/rad/cmd/root.go b/cmd/rad/cmd/root.go index 7a17c6fef6..3a2af0fdcd 100644 --- a/cmd/rad/cmd/root.go +++ b/cmd/rad/cmd/root.go @@ -24,58 +24,58 @@ import ( "strings" "github.com/acarl005/stripansi" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clierrors" - app_switch "github.com/project-radius/radius/pkg/cli/cmd/app/appswitch" - app_connections "github.com/project-radius/radius/pkg/cli/cmd/app/connections" - app_delete "github.com/project-radius/radius/pkg/cli/cmd/app/delete" - app_list "github.com/project-radius/radius/pkg/cli/cmd/app/list" - app_show "github.com/project-radius/radius/pkg/cli/cmd/app/show" - app_status "github.com/project-radius/radius/pkg/cli/cmd/app/status" - bicep_publish "github.com/project-radius/radius/pkg/cli/cmd/bicep/publish" - credential "github.com/project-radius/radius/pkg/cli/cmd/credential" - cmd_deploy "github.com/project-radius/radius/pkg/cli/cmd/deploy" - env_create "github.com/project-radius/radius/pkg/cli/cmd/env/create" - env_delete "github.com/project-radius/radius/pkg/cli/cmd/env/delete" - env_switch "github.com/project-radius/radius/pkg/cli/cmd/env/envswitch" - env_list "github.com/project-radius/radius/pkg/cli/cmd/env/list" - "github.com/project-radius/radius/pkg/cli/cmd/env/namespace" - env_show "github.com/project-radius/radius/pkg/cli/cmd/env/show" - env_update "github.com/project-radius/radius/pkg/cli/cmd/env/update" - group "github.com/project-radius/radius/pkg/cli/cmd/group" - "github.com/project-radius/radius/pkg/cli/cmd/install" - install_kubernetes "github.com/project-radius/radius/pkg/cli/cmd/install/kubernetes" - "github.com/project-radius/radius/pkg/cli/cmd/radinit" - recipe_list "github.com/project-radius/radius/pkg/cli/cmd/recipe/list" - recipe_register "github.com/project-radius/radius/pkg/cli/cmd/recipe/register" - recipe_show "github.com/project-radius/radius/pkg/cli/cmd/recipe/show" - recipe_unregister "github.com/project-radius/radius/pkg/cli/cmd/recipe/unregister" - resource_delete "github.com/project-radius/radius/pkg/cli/cmd/resource/delete" - resource_list "github.com/project-radius/radius/pkg/cli/cmd/resource/list" - resource_show "github.com/project-radius/radius/pkg/cli/cmd/resource/show" - "github.com/project-radius/radius/pkg/cli/cmd/run" - "github.com/project-radius/radius/pkg/cli/cmd/uninstall" - uninstall_kubernetes "github.com/project-radius/radius/pkg/cli/cmd/uninstall/kubernetes" - workspace_create "github.com/project-radius/radius/pkg/cli/cmd/workspace/create" - workspace_delete "github.com/project-radius/radius/pkg/cli/cmd/workspace/delete" - workspace_list "github.com/project-radius/radius/pkg/cli/cmd/workspace/list" - workspace_show "github.com/project-radius/radius/pkg/cli/cmd/workspace/show" - workspace_switch "github.com/project-radius/radius/pkg/cli/cmd/workspace/switch" - "github.com/project-radius/radius/pkg/cli/config" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/deploy" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/kubernetes/logstream" - "github.com/project-radius/radius/pkg/cli/kubernetes/portforward" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/trace" + "github.com/radius-project/radius/pkg/azure/clientv2" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clierrors" + app_switch "github.com/radius-project/radius/pkg/cli/cmd/app/appswitch" + app_connections "github.com/radius-project/radius/pkg/cli/cmd/app/connections" + app_delete "github.com/radius-project/radius/pkg/cli/cmd/app/delete" + app_list "github.com/radius-project/radius/pkg/cli/cmd/app/list" + app_show "github.com/radius-project/radius/pkg/cli/cmd/app/show" + app_status "github.com/radius-project/radius/pkg/cli/cmd/app/status" + bicep_publish "github.com/radius-project/radius/pkg/cli/cmd/bicep/publish" + credential "github.com/radius-project/radius/pkg/cli/cmd/credential" + cmd_deploy "github.com/radius-project/radius/pkg/cli/cmd/deploy" + env_create "github.com/radius-project/radius/pkg/cli/cmd/env/create" + env_delete "github.com/radius-project/radius/pkg/cli/cmd/env/delete" + env_switch "github.com/radius-project/radius/pkg/cli/cmd/env/envswitch" + env_list "github.com/radius-project/radius/pkg/cli/cmd/env/list" + "github.com/radius-project/radius/pkg/cli/cmd/env/namespace" + env_show "github.com/radius-project/radius/pkg/cli/cmd/env/show" + env_update "github.com/radius-project/radius/pkg/cli/cmd/env/update" + group "github.com/radius-project/radius/pkg/cli/cmd/group" + "github.com/radius-project/radius/pkg/cli/cmd/install" + install_kubernetes "github.com/radius-project/radius/pkg/cli/cmd/install/kubernetes" + "github.com/radius-project/radius/pkg/cli/cmd/radinit" + recipe_list "github.com/radius-project/radius/pkg/cli/cmd/recipe/list" + recipe_register "github.com/radius-project/radius/pkg/cli/cmd/recipe/register" + recipe_show "github.com/radius-project/radius/pkg/cli/cmd/recipe/show" + recipe_unregister "github.com/radius-project/radius/pkg/cli/cmd/recipe/unregister" + resource_delete "github.com/radius-project/radius/pkg/cli/cmd/resource/delete" + resource_list "github.com/radius-project/radius/pkg/cli/cmd/resource/list" + resource_show "github.com/radius-project/radius/pkg/cli/cmd/resource/show" + "github.com/radius-project/radius/pkg/cli/cmd/run" + "github.com/radius-project/radius/pkg/cli/cmd/uninstall" + uninstall_kubernetes "github.com/radius-project/radius/pkg/cli/cmd/uninstall/kubernetes" + workspace_create "github.com/radius-project/radius/pkg/cli/cmd/workspace/create" + workspace_delete "github.com/radius-project/radius/pkg/cli/cmd/workspace/delete" + workspace_list "github.com/radius-project/radius/pkg/cli/cmd/workspace/list" + workspace_show "github.com/radius-project/radius/pkg/cli/cmd/workspace/show" + workspace_switch "github.com/radius-project/radius/pkg/cli/cmd/workspace/switch" + "github.com/radius-project/radius/pkg/cli/config" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/deploy" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/kubernetes/logstream" + "github.com/radius-project/radius/pkg/cli/kubernetes/portforward" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/trace" "go.opentelemetry.io/otel" "github.com/spf13/cobra" diff --git a/cmd/rad/cmd/version.go b/cmd/rad/cmd/version.go index c30b6e2787..3c65106290 100644 --- a/cmd/rad/cmd/version.go +++ b/cmd/rad/cmd/version.go @@ -19,9 +19,9 @@ package cmd import ( "io" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/version" "github.com/spf13/cobra" ) diff --git a/cmd/rad/main.go b/cmd/rad/main.go index eb720c0091..6669760550 100644 --- a/cmd/rad/main.go +++ b/cmd/rad/main.go @@ -19,7 +19,7 @@ package main import ( "os" - "github.com/project-radius/radius/cmd/rad/cmd" + "github.com/radius-project/radius/cmd/rad/cmd" ) func main() { diff --git a/cmd/ucpd/cmd/root.go b/cmd/ucpd/cmd/root.go index 3df2fa20e0..839a47dbdb 100644 --- a/cmd/ucpd/cmd/root.go +++ b/cmd/ucpd/cmd/root.go @@ -28,11 +28,11 @@ import ( etcdclient "go.etcd.io/etcd/client/v3" runtimelog "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/project-radius/radius/pkg/trace" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/hosting" - "github.com/project-radius/radius/pkg/ucp/server" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/trace" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/server" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var rootCmd = &cobra.Command{ diff --git a/cmd/ucpd/main.go b/cmd/ucpd/main.go index 6338c44d50..4bf53ec973 100644 --- a/cmd/ucpd/main.go +++ b/cmd/ucpd/main.go @@ -16,7 +16,7 @@ limitations under the License. package main -import "github.com/project-radius/radius/cmd/ucpd/cmd" +import "github.com/radius-project/radius/cmd/ucpd/cmd" func main() { cmd.Execute() diff --git a/cmd/ucpd/ucp-self-hosted-dev.yaml b/cmd/ucpd/ucp-self-hosted-dev.yaml index 294a083103..8e73d30861 100644 --- a/cmd/ucpd/ucp-self-hosted-dev.yaml +++ b/cmd/ucpd/ucp-self-hosted-dev.yaml @@ -6,7 +6,7 @@ # - Listen on port 9000 # - Talk to Deployment Engine on port 5017 # - Talk to Core RP on port 8080 -# - Talk to Link RP on port 8081 +# - Talk to Portable Resources' Providers on port 8081 # - Disables metrics and profiler # storageProvider: @@ -20,6 +20,7 @@ secretProvider: queueProvider: provider: "apiserver" + name: 'ucp' apiserver: context: '' namespace: 'radius-testing' @@ -38,7 +39,6 @@ planes: properties: resourceProviders: Applications.Core: "http://localhost:8080" - Applications.Link: "http://localhost:8081" Applications.Messaging: "http://localhost:8081" Applications.Dapr: "http://localhost:8081" Applications.Datastores: "http://localhost:8081" diff --git a/deploy/Chart/Chart.yaml b/deploy/Chart/Chart.yaml index 18ce7f3113..17861d27a1 100644 --- a/deploy/Chart/Chart.yaml +++ b/deploy/Chart/Chart.yaml @@ -7,10 +7,10 @@ version: '0.42.42-dev' appVersion: 'edge' home: https://radapp.dev sources: - - https://github.com/project-radius/radius/tree/main/deploy/Chart + - https://github.com/radius-project/radius/tree/main/deploy/Chart maintainers: - name: Radius Authors - url: https://github.com/project-radius/radius + url: https://github.com/radius-project/radius icon: https://radapp.dev/images/logo.png keywords: - radius diff --git a/deploy/Chart/templates/rp/configmaps.yaml b/deploy/Chart/templates/rp/configmaps.yaml index b6ce94b4b8..8dbecbc90e 100644 --- a/deploy/Chart/templates/rp/configmaps.yaml +++ b/deploy/Chart/templates/rp/configmaps.yaml @@ -9,7 +9,7 @@ metadata: data: radius-self-host.yaml: |- # Radius configuration file. - # See https://github.com/project-radius/radius/blob/main/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md for more information. + # See https://github.com/radius-project/radius/blob/main/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md for more information. environment: name: self-hosted roleLocation: "global" @@ -20,6 +20,7 @@ data: namespace: "radius-system" queueProvider: provider: "apiserver" + name: "radius" apiserver: context: "" namespace: "radius-system" @@ -50,10 +51,12 @@ data: zipkin: url: {{ .Values.global.zipkin.url }} {{- end }} + terraform: + path: "/terraform" - link-self-host.yaml: |- + portableresource-self-host.yaml: |- # Radius configuration file. - # See https://github.com/project-radius/radius/blob/main/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md for more information. + # See https://github.com/radius-project/radius/blob/main/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md for more information. environment: name: self-hosted roleLocation: "global" @@ -64,6 +67,7 @@ data: namespace: "radius-system" queueProvider: provider: "apiserver" + name: "radiusportable" apiserver: context: "" namespace: "radius-system" @@ -90,7 +94,7 @@ data: json: true {{- if and .Values.global.zipkin .Values.global.zipkin.url }} tracerProvider: - serviceName: "applications.link" + serviceName: "applications.datastores" zipkin: url: {{ .Values.global.zipkin.url }} {{- end }} diff --git a/deploy/Chart/templates/rp/deployment.yaml b/deploy/Chart/templates/rp/deployment.yaml index f934e0b517..d3ee662bd9 100644 --- a/deploy/Chart/templates/rp/deployment.yaml +++ b/deploy/Chart/templates/rp/deployment.yaml @@ -32,8 +32,7 @@ spec: image: "{{ .Values.rp.image }}:{{ .Values.rp.tag | default $appversion }}" args: - --config-file=/etc/config/radius-self-host.yaml - - --run-link - - --link-config=/etc/config/link-self-host.yaml + - --portableresource-config=/etc/config/portableresource-self-host.yaml env: - name: SKIP_ARM value: 'false' @@ -52,7 +51,7 @@ spec: name: applications-rp protocol: TCP - containerPort: 5444 - name: applink-rp + name: app-pr-rp protocol: TCP {{- if eq .Values.global.prometheus.enabled true }} - containerPort: {{ .Values.global.prometheus.port }} diff --git a/deploy/Chart/templates/rp/service.yaml b/deploy/Chart/templates/rp/service.yaml index 3451fed1ce..252347b942 100644 --- a/deploy/Chart/templates/rp/service.yaml +++ b/deploy/Chart/templates/rp/service.yaml @@ -13,7 +13,7 @@ spec: protocol: TCP targetPort: 5443 - port: 5444 - name: link-http + name: portablers-http protocol: TCP targetPort: 5444 selector: diff --git a/deploy/Chart/templates/ucp/configmaps.yaml b/deploy/Chart/templates/ucp/configmaps.yaml index 608c710894..95b27be087 100644 --- a/deploy/Chart/templates/ucp/configmaps.yaml +++ b/deploy/Chart/templates/ucp/configmaps.yaml @@ -9,7 +9,7 @@ metadata: data: ucp-config.yaml: |- # Radius configuration file. - # See https://github.com/project-radius/radius/blob/main/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md for more information. + # See https://github.com/radius-project/radius/blob/main/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md for more information. storageProvider: provider: "apiserver" apiserver: @@ -20,7 +20,11 @@ data: provider: kubernetes queueProvider: - provider: inmemory + provider: "apiserver" + name: "ucp" + apiserver: + context: "" + namespace: "radius-system" profilerProvider: enabled: true @@ -31,7 +35,6 @@ data: properties: resourceProviders: Applications.Core: "http://applications-rp.radius-system:5443" - Applications.Link: "http://applications-rp.radius-system:5444" Applications.Dapr: "http://applications-rp.radius-system:5444" Applications.Datastores: "http://applications-rp.radius-system:5444" Applications.Messaging: "http://applications-rp.radius-system:5444" diff --git a/deploy/install.sh b/deploy/install.sh index 1ee9697407..1395bc61df 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -71,7 +71,7 @@ runAsRoot() { local CMD="$*" if [ $EUID -ne 0 -a $USE_SUDO = "true" ]; then - echo "Additional permissions needed. Please enter your sudo password..." + echo "Additional permission needed. Please enter your sudo password if prompted..." CMD="sudo $CMD" fi @@ -185,7 +185,7 @@ fail_trap() { result=$? if [ "$result" != "0" ]; then echo "Failed to install Radius CLI" - echo "For support, go to https://github.com/project-radius/radius" + echo "For support, go to https://github.com/radius-project/radius" fi cleanup exit $result diff --git a/docs/README.md b/docs/README.md index c5dc472e00..92c42bd19e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # Radius documentation -The documentation for Radius is at https://radapp.dev, with the source in the [project-radius/docs repo](https://github.com/project-radius/docs). +The documentation for Radius is at https://radapp.dev, with the source in the [radius-project/docs repo](https://github.com/radius-project/docs). ## Contributing to Radius diff --git a/docs/contributing/contributing-code/contributing-code-building/README.md b/docs/contributing/contributing-code/contributing-code-building/README.md index 41ae02e980..9973867b23 100644 --- a/docs/contributing/contributing-code/contributing-code-building/README.md +++ b/docs/contributing/contributing-code/contributing-code-building/README.md @@ -50,7 +50,7 @@ make generate This may take a few minutes as there are several steps. -If you encounter problems please [open an issue](https://github.com/project-radius/radius/issues/new/choose) so we can help. We're trying to make these instructions as streamlined as possible for contributors, your help in identifying problems with the tools and instructions is very much appreciated! +If you encounter problems please [open an issue](https://github.com/radius-project/radius/issues/new/choose) so we can help. We're trying to make these instructions as streamlined as possible for contributors, your help in identifying problems with the tools and instructions is very much appreciated! ## Troubleshooting and getting help diff --git a/docs/contributing/contributing-code/contributing-code-cli/README.md b/docs/contributing/contributing-code/contributing-code-cli/README.md index 244d835888..461305517e 100644 --- a/docs/contributing/contributing-code/contributing-code-cli/README.md +++ b/docs/contributing/contributing-code/contributing-code-cli/README.md @@ -41,10 +41,10 @@ Create the following script and place it on your path with a name like `dev-rad` ```sh #!/bin/sh set -eu -go run ~/github.com/project-radius/radius/cmd/rad/main.go $@ +go run ~/github.com/radius-project/radius/cmd/rad/main.go $@ ``` -Replace `~/github.com/project-radius/radius` with the path to your repository root. +Replace `~/github.com/radius-project/radius` with the path to your repository root. Run `chmod +x dev-rad` to mark it executable diff --git a/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md b/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md index b782ff2021..2043051d22 100644 --- a/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md +++ b/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md @@ -2,13 +2,13 @@ ## Summary -Configuration schemas are used to define the service configuration for the resource provider's execution. The default configurations use the `Applications.Core RP` but configurations can also be set to run the `Applications.Link RP` for private preview and dev/test purposes. +Configuration schemas are used to define the service configuration for the resource provider's execution. The default configurations use the `Applications.Core RP` but configurations can also be set to run `Portable Resources' Providers` for private preview and dev/test purposes. If you wanted to locally run Radius with specific configurations, `yaml` files can be created and stored in the `cmd` folder for the corresponding UCP or resource provider. ![Local Config](./configExamples/localConfig.png) -If you wanted to run Radius on Kubernetes with specific configurations, `yaml` files can be created and stored in the `deploy/Chart/charts` folder for `Applications.Core RP`, `Applications.Link RP`, or `UCP`. +If you wanted to run Radius on Kubernetes with specific configurations, `yaml` files can be created and stored in the `deploy/Chart/charts` folder for `Applications.Core RP`, `Portable Resources' Providers`, or `UCP`. ![Kubernetes Config](./configExamples/kubeConfig.png) @@ -29,7 +29,7 @@ The following properties can be specified in configuration for all services: ----- -The following are properties that can be specified for the `Applications.Core RP` and the `Applications.Link RP`: +The following are properties that can be specified for the `Applications.Core RP` and `Portable Resources`: | Key | Description | Example | |-----|-------------|---------| | ucp | Configuration options for connecting to UCP's API | [**See below**](#ucp) @@ -108,7 +108,7 @@ The following are properties that can be specified for UCP: ### ucp -This section configures the connection from either the `Applications.Core RP` or the `Applications.Link RP` to UCP's API. As the UCP service does not need to connect to itself, these settings do not apply in UCP's configuration files. +This section configures the connection from either the `Applications.Core RP` or the `Portable Resources' Providers` to UCP's API. As the UCP service does not need to connect to itself, these settings do not apply in UCP's configuration files. | Key | Description | Example | |-----|-------------|---------| @@ -185,7 +185,7 @@ ucp: Below are completed examples of possible configurations: -### Applications.Core and Applications.Link +### Applications.Core and Portable Resources' Providers ```yaml environment: name: self-hosted @@ -197,6 +197,7 @@ storageProvider: namespace: "radius-system" queueProvider: provider: "apiserver" + name: "radius" apiserver: context: "" namespace: "radius-system" @@ -229,7 +230,6 @@ planes: properties: resourceProviders: Applications.Core: "http://applications-rp.radius-system:5443" - Applications.Link: "http://applications-rp.radius-system:5444" Applications.Dapr: "http://applications-rp.radius-system:5444" Applications.Datastores: "http://applications-rp.radius-system:5444" Applications.Messaging: "http://applications-rp.radius-system:5444" diff --git a/docs/contributing/contributing-code/contributing-code-control-plane/running-controlplane-locally.md b/docs/contributing/contributing-code/contributing-code-control-plane/running-controlplane-locally.md index 2324832547..2a3d61744f 100644 --- a/docs/contributing/contributing-code/contributing-code-control-plane/running-controlplane-locally.md +++ b/docs/contributing/contributing-code/contributing-code-control-plane/running-controlplane-locally.md @@ -8,7 +8,7 @@ Radius consists of a few processes that get deployed inside a Kubernetes cluster This includes: -- Applications.Core RP / Applications.Link RP (applications-rp) - The resource provider that handles processing of core resources as well as recipes. +- Applications.Core RP / Portable Resources' Providers (applications-rp) - The resource provider that handles processing of core resources as well as recipes. - Universal Control Plane (ucp) - Acts as a proxy between the other services, also manages deployments of AWS resources. - Deployment Engine (bicep-de) - Handles deployment orchestration for bicep files. @@ -22,13 +22,13 @@ If you need to manually test APIs you can reach them at the following endpoints - UCP: port 9000 - AppCore Namespace: port 8080 -- AppLink Namespace: port 8081 +- AppPortableResource Namespace: port 8081 (Applications.Datastores, Applications.Dapr and Applications.Messaging are hosted) - Deployment Engine: port 5017 ## Prerequisites 1. Create a Kubernetes cluster, or set your current context to a cluster you want to use. The debug configuration will use your current cluster for storing data. -2. Clone the `project-radius/radius` and `project-radius/deployment-engine` repo next to each other. +2. Clone the `radius-project/radius` and `radius-project/deployment-engine` repo next to each other. 3. Run `git submodule update --init` in the `deployment-engine` repo 4. Install .NET 6.0 SDK - https://dotnet.microsoft.com/en-us/download/dotnet/6.0 5. Install C# VS Code extension - https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp @@ -44,10 +44,10 @@ Run one of the following two commands: ```sh # Choose this by default -rad init --dev +rad init # Choose this if you want to do advanced setup -rad init +rad init --full ``` This will install Radius and configure an environment for you. The database that's used **will NOT** be shared with your debug setup, so it mostly doesn't matter what choices you make. @@ -141,7 +141,7 @@ Now you can launch the Radius locally through the VSCode menu. ### I got an error saying I need to clone the deployment engine -> The project-radius/deployment-engine is not cloned as a sibling to the radius repo. Please clone the project-radius/deployment-engine repo next to the Radius repo and try again. +> The radius-project/deployment-engine is not cloned as a sibling to the radius repo. Please clone the radius-project/deployment-engine repo next to the Radius repo and try again. You should be to successfully the following commands from the Radius repository root: @@ -165,4 +165,4 @@ dotnet --list-sdks Make sure you see a `6.0` entry in `--list-runtimes` for `Microsoft.AspNetCore.App` and a `6.0` or newer entry for `--list-sdks`. -If you run into issues here, please re-read the prerequisites related to installing .NET. \ No newline at end of file +If you run into issues here, please re-read the prerequisites related to installing .NET. diff --git a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-05-running-tests/index.md b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-05-running-tests/index.md index c827f589d5..18f9532339 100644 --- a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-05-running-tests/index.md +++ b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-05-running-tests/index.md @@ -12,23 +12,23 @@ After tests run, you should see a big list of all of the project's packages: ```txt go test ./pkg/... -ok github.com/project-radius/radius/pkg/cli 0.250s -? github.com/project-radius/radius/pkg/azure/azcli [no test files] -? github.com/project-radius/radius/pkg/cli/azure [no test files] -? github.com/project-radius/radius/pkg/cli/bicep [no test files] -? github.com/project-radius/radius/pkg/cli/environments [no test files] -? github.com/project-radius/radius/pkg/cli/logger [no test files] -? github.com/project-radius/radius/pkg/cli/namegenerator [no test files] -? github.com/project-radius/radius/pkg/cli/prompt [no test files] -? github.com/project-radius/radius/pkg/cli/util [no test files] -? github.com/project-radius/radius/pkg/azure/radclient [no test files] -? github.com/project-radius/radius/pkg/renderers [no test files] -ok github.com/project-radius/radius/pkg/renderers/containerv1alpha3 -ok github.com/project-radius/radius/pkg/renderers/cosmosdbmongov1alpha3 -ok github.com/project-radius/radius/pkg/renderers/dapr -ok github.com/project-radius/radius/pkg/renderers/daprpubsubv1alpha3 -ok github.com/project-radius/radius/pkg/renderers/daprstatestorev1alpha3 -ok github.com/project-radius/radius/pkg/renderers/servicebusqueuev1alpha3 +ok github.com/radius-project/radius/pkg/cli 0.250s +? github.com/radius-project/radius/pkg/azure/azcli [no test files] +? github.com/radius-project/radius/pkg/cli/azure [no test files] +? github.com/radius-project/radius/pkg/cli/bicep [no test files] +? github.com/radius-project/radius/pkg/cli/environments [no test files] +? github.com/radius-project/radius/pkg/cli/logger [no test files] +? github.com/radius-project/radius/pkg/cli/namegenerator [no test files] +? github.com/radius-project/radius/pkg/cli/prompt [no test files] +? github.com/radius-project/radius/pkg/cli/util [no test files] +? github.com/radius-project/radius/pkg/azure/radclient [no test files] +? github.com/radius-project/radius/pkg/renderers [no test files] +ok github.com/radius-project/radius/pkg/renderers/containerv1alpha3 +ok github.com/radius-project/radius/pkg/renderers/cosmosdbmongov1alpha3 +ok github.com/radius-project/radius/pkg/renderers/dapr +ok github.com/radius-project/radius/pkg/renderers/daprpubsubv1alpha3 +ok github.com/radius-project/radius/pkg/renderers/daprstatestorev1alpha3 +ok github.com/radius-project/radius/pkg/renderers/servicebusqueuev1alpha3 ``` The Go test tools do not make much fanfare when all the tests pass - it just says `ok` for every package that has tests. diff --git a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/compare.png b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/compare.png new file mode 100644 index 0000000000..44269b6e17 Binary files /dev/null and b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/compare.png differ diff --git a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/fork.png b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/fork.png new file mode 100644 index 0000000000..88d8b69832 Binary files /dev/null and b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/fork.png differ diff --git a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/index.md b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/index.md new file mode 100644 index 0000000000..800d8882b5 --- /dev/null +++ b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-forked-repo/index.md @@ -0,0 +1,46 @@ +# Your first commit: Creating a forked repo + +In order to limit the branches on the main repo, Radius enforces code contributions via forked repos. + +## Creating a forked repo + +In order to fork a repo, go to the main radius repo page in GitHub and select the "fork" option: + +Creating a fork of the main repo + +## Clone the forked repo + +Now clone the forked repo and navigate there in your command shell. + +``` +git clone +``` + +## Configuring remote repositories + +Configure the remote repositories, referring to the forked repo as `origin` and the main repo as `upstream` (you may choose your own custom names if desired). + +### Adding remote repositories + +``` +git remote add origin +git remote add upstream +``` + +### Verify new remote + +``` +git remote -v +``` + +## Workflow to follow +1. Push your local code changes to the forked repo + ``` + git push origin + ``` + +2. Go to the main radius repo and create a pull request using the _compare against forks_ option: + + Creating a pull request across forks + + Make sure you select the fields (shown in red) "head repository" as your fork (/radius) and "compare" as your branch with the code changes. \ No newline at end of file diff --git a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-pr/index.md b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-pr/index.md deleted file mode 100644 index a638bbf02a..0000000000 --- a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-pr/index.md +++ /dev/null @@ -1,65 +0,0 @@ -# Your first commit: Creating a pull request - -## Your first pull request - -At this point you've experienced the basic dev flow for the `rad` CLI. - -It's time to pick an issue to work on! You can find a query [here](https://github.com/project-radius/radius/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). - -## Etiquette for issues - -If you find an issue you want to help with, then please comment on that issue and ask for one of the maintainers to assign it to you. If you have questions or anything you want to discuss, use the issue to communicate about it. - -Now you've got something to work on. Once you've developed and tested your change resume this guide. - -## One last check - -Before proceeding, make sure your changes pass all the unit tests as well as [golint](https://golangci-lint.run/usage/install/#local-installation). - -```sh -make build lint test -``` - -It is best if you can resolve problems identified here before submitting. - -## Writing a good commit message - -To make it easier for us to track history, write a good commit message. - -The format preferred for the project is formatted like: - -```txt - - -Fixes: # - - -``` - -Here's an [example](https://github.com/project-radius/radius/commit/8e95d07a66e6aa91dfb40217318649ca43ec4bd7). - -Include a level of detail that makese sense based on the complexity of problem and solution. - -## Creating the pull request - -Push your changes and then [open a pull request](https://github.com/project-radius/radius/compare). - -If you formatted your commit message correctly then everything should be good to go. - -Go ahead and create your PR. - -## The PR process - -At this point you should review the PR checks and make sure they pass. Failing PR checks will prevent your change from being merged. - -Reviewing pull request checks - -If you have any failing checks try to investigate the details and solve them if possible. If you get stuck and need to know the reason for failure, ask a maintainer. - -At this point one or more core team members will review your code changes. - -Reviewers will leave their feedback via comments. Discuss as needed and resolve the feedback when both you and the reviewers are happy. - -Once you've resolved all the feedback, your reviewers will make the pull request as approved. - -From this point on you don't need to do anything. The maintainers will merge your pull request. \ No newline at end of file diff --git a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-07-creating-a-pr/index.md b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-07-creating-a-pr/index.md new file mode 100644 index 0000000000..51d8948df1 --- /dev/null +++ b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-07-creating-a-pr/index.md @@ -0,0 +1,67 @@ +# Your first commit: Creating a pull request + +## Your first pull request + +At this point you've experienced the basic dev flow for the `rad` CLI. + +It's time to pick an issue to work on! You can find a query [here](https://github.com/radius-project/radius/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). + +## Etiquette for issues + +If you find an issue you want to help with, then please comment on that issue and ask for one of the maintainers to assign it to you. If you have questions or anything you want to discuss, use the issue to communicate about it. + +Now you've got something to work on. Once you've developed and tested your change resume this guide. + +## One last check + +Before proceeding, make sure your changes pass all the unit tests as well as [golint](https://golangci-lint.run/usage/install/#local-installation). + +```sh +make build lint test +``` + +It is best if you can resolve problems identified here before submitting. + +## Writing a good commit message + +To make it easier for us to track history, write a good commit message. + +The format preferred for the project is formatted like: + +```txt + + +Fixes: # + + +``` + +Here's an [example](https://github.com/radius-project/radius/commit/8e95d07a66e6aa91dfb40217318649ca43ec4bd7). + +Include a level of detail that makese sense based on the complexity of problem and solution. + +## Creating the pull request + +At this point, you have reviewed the forked repo workflow. + +Push your changes to your forked repo and then [open a pull request](https://github.com/radius-project/radius/compare). + +If you formatted your commit message correctly then everything should be good to go. + +Go ahead and create your PR. + +## The PR process + +At this point you should review the PR checks and make sure they pass. Failing PR checks will prevent your change from being merged. + +Reviewing pull request checks + +If you have any failing checks try to investigate the details and solve them if possible. If you get stuck and need to know the reason for failure, ask a maintainer. + +At this point one or more core team members will review your code changes. + +Reviewers will leave their feedback via comments. Discuss as needed and resolve the feedback when both you and the reviewers are happy. + +Once you've resolved all the feedback, your reviewers will make the pull request as approved. + +From this point on you don't need to do anything. The maintainers will merge your pull request. \ No newline at end of file diff --git a/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-pr/pr-checks.png b/docs/contributing/contributing-code/contributing-code-first-commit/first-commit-07-creating-a-pr/pr-checks.png similarity index 100% rename from docs/contributing/contributing-code/contributing-code-first-commit/first-commit-06-creating-a-pr/pr-checks.png rename to docs/contributing/contributing-code/contributing-code-first-commit/first-commit-07-creating-a-pr/pr-checks.png diff --git a/docs/contributing/contributing-code/contributing-code-organization/README.md b/docs/contributing/contributing-code/contributing-code-organization/README.md index f26d2eaadd..4784b79b29 100644 --- a/docs/contributing/contributing-code/contributing-code-organization/README.md +++ b/docs/contributing/contributing-code/contributing-code-organization/README.md @@ -10,7 +10,7 @@ In general you should ask for guidance before creating a new top-level folder in | ---------- | --------------------------------------------------------------------------------------| | `build/` | Makefiles and scripts referenced from the root Makefile | | `cmd/` | Entry points for executables built in the repository | -| `cadl/` | Definitions for generating Radius swagger files. | +| `typespec/` | Definitions for generating Radius swagger files. | | `deploy/` | Assets used to package, deploy, and install Radius | | `docs/` | All project documentation | | `hack/` | Utility code to generate Radius bicep types | @@ -21,31 +21,29 @@ In general you should ask for guidance before creating a new top-level folder in ## Pkg folders -| Folder | Description | -| ----------------- | --------------------------------------------------------------------------------------- | -| `algorithm/` | General purpose algorithms and data structures | -| `armrpc/` | Implementation containing shared functionality and utility for all Radius RP | -| `aws/` | Utility code and library integrations for working with AWS | -| `azure/` | Utility code and library integrations for working with Azure | -| `cli/` | Implementation code for the `rad` CLI | -| `corerp/` | Resource Provider implementation for `Applications.Core` resources | -| `daprrp/` | Resource Provider implementation for `Applications.Dapr` resources | -| `datastoresrp/` | Resource Provider implementation for `Applications.Datastores` resources | -| `kubernetes/` | Utility code and library integrations for working with Kubernetes | -| `kubeutil/` | Utility code and working with Kubernetes on client side | -| `linkrp/` | Resource Provider implementation for `Applications.Link` resources | -| `logging/` | Utility code for Radius logging | -| `messagingrp/` | Resource Provider implementation for `Applications.Messaging` resources | -| `middleware/` | Implementation for all Radius middleware | -| `metrics/` | Code generating Radius metrics | -| `profiler/` | Code and configs for Radius profiler | -| `recipes/` | Implementation for Radius Recipes | -| `resourcekinds/` | Definition of Radius resources | -| `resourcemodels/` | Code for identifying Radius resources in underlying system | -| `rp/` | Code shared by multiple rps | -| `sdk/` | Code for interfacing with Radius as a client | -| `to/` | Code for pointer to value conversions | -| `trace/` | Utility code for generating Radius traces | -| `ucp/` | Implementation of Universal Control Plane | -| `validator/` | OpenAPI spec loader and validator | -| `version/` | Infrastructure for how to version the Radius implementations | \ No newline at end of file +| Folder | Description | +| ---------------------- | --------------------------------------------------------------------------------------- | +| `algorithm/` | General purpose algorithms and data structures | +| `armrpc/` | Implementation containing shared functionality and utility for all Radius RP | +| `aws/` | Utility code and library integrations for working with AWS | +| `azure/` | Utility code and library integrations for working with Azure | +| `cli/` | Implementation code for the `rad` CLI | +| `corerp/` | Resource Provider implementation for `Applications.Core` resources | +| `daprrp/` | Resource Provider implementation for `Applications.Dapr` resources | +| `datastoresrp/` | Resource Provider implementation for `Applications.Datastores` resources | +| `kubernetes/` | Utility code and library integrations for working with Kubernetes | +| `kubeutil/` | Utility code and working with Kubernetes on client side | +| `portableresources/` | Shared Resource Provider implementation for portable resources | +| `logging/` | Utility code for Radius logging | +| `messagingrp/` | Resource Provider implementation for `Applications.Messaging` resources | +| `middleware/` | Implementation for all Radius middleware | +| `metrics/` | Code generating Radius metrics | +| `profiler/` | Code and configs for Radius profiler | +| `recipes/` | Implementation for Radius Recipes | +| `rp/` | Code shared by multiple rps | +| `sdk/` | Code for interfacing with Radius as a client | +| `to/` | Code for pointer to value conversions | +| `trace/` | Utility code for generating Radius traces | +| `ucp/` | Implementation of Universal Control Plane | +| `validator/` | OpenAPI spec loader and validator | +| `version/` | Infrastructure for how to version the Radius implementations | \ No newline at end of file diff --git a/docs/contributing/contributing-code/contributing-code-prerequisites/README.md b/docs/contributing/contributing-code/contributing-code-prerequisites/README.md index 9d4c917b5b..1c46a696ff 100644 --- a/docs/contributing/contributing-code/contributing-code-prerequisites/README.md +++ b/docs/contributing/contributing-code/contributing-code-prerequisites/README.md @@ -53,7 +53,7 @@ You can build the main outputs using `make`: make build && make lint ``` -Running these steps will run our build and lint steps and verify that the tools are installed correctly. If you get stuck or suspect something is not working in these instructions please [open an issue](https://github.com/project-radius/radius/issues/new/choose). +Running these steps will run our build and lint steps and verify that the tools are installed correctly. If you get stuck or suspect something is not working in these instructions please [open an issue](https://github.com/radius-project/radius/issues/new/choose). ### Editor @@ -111,7 +111,7 @@ If you were trying to run `make generate` and ran into an error, then one of the Enter the following commands to install all of the required tools. ```sh -cd cadl && npm ci +cd typespec && npm ci npm install -g autorest npm install -g oav go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.1 diff --git a/docs/contributing/contributing-code/contributing-code-schema-changes/README.md b/docs/contributing/contributing-code/contributing-code-schema-changes/README.md index 1d2cc864ab..5c8e73330b 100644 --- a/docs/contributing/contributing-code/contributing-code-schema-changes/README.md +++ b/docs/contributing/contributing-code/contributing-code-schema-changes/README.md @@ -1,11 +1,11 @@ # Contributing schema changes -This page will explain the process to make a change to Radius' REST API (eg: adding a new property, or adding a new resource type).The Radius application model and API are defined via a OpenAPI specification. Instead of manually defining each OpenAPI spec, [CADL](https://microsoft.github.io/typespec/) is used to generate the OpenAPI JSON files. You should read and follow these steps to make REST API changes. +This page will explain the process to make a change to Radius' REST API (eg: adding a new property, or adding a new resource type).The Radius application model and API are defined via a OpenAPI specification. Instead of manually defining each OpenAPI spec, [TypeSpec](https://microsoft.github.io/typespec/) is used to generate the OpenAPI JSON files. You should read and follow these steps to make REST API changes. -## Step 1: Update CADL and generate Bicep types and API client +## Step 1: Update TypeSpec and generate Bicep types and API client In order to update or create a new schema follow these steps: -1. Create or update the applicable CADL files (named after resource type) within the `cadl` directory in the root of the radius repo +1. Create or update the applicable TypeSpec files (named after resource type) within the `typespec` directory in the root of the radius repo 2. Run `make generate` to generate the OpenAPI spec and API clients: ```bash make generate @@ -17,13 +17,13 @@ In order to update or create a new schema follow these steps: 1. Run the following command to generate the OpenAPI spec with the newly added changes ```bash - npx cadl compile . + npx tsp compile . ``` 2. Generate the client code by running autorest - For example, to generate the LinkRP resources run: + For example, to generate the `Applications.Core` resources run: ```bash - autorest pkg/linkrp/api/README.md --tag=link-2022-03-15-privatepreview + autorest pkg/corerp/api/README.md --tag=link-2022-03-15-privatepreview ``` The autotrest configuration file (_i.e README.md_) is generally found in `pkg//api/` directory and has details on which tag to use. @@ -35,7 +35,7 @@ Creating a pull request in the radius repo that contains application model chang ## Step 2: Update docs and samples -Visit the [docs](https://github.com/project-radius/docs/) and [samples](https://github.com/project-radius/samples/) repository and open PRs with the changes to the resource(s). Some checks will fail until you begin merging PRs below. +Visit the [docs](https://github.com/radius-project/docs/) and [samples](https://github.com/radius-project/samples/) repository and open PRs with the changes to the resource(s). Some checks will fail until you begin merging PRs below. ## Step 3: Merge pull requests in order ⚠️ Make sure you have PRs open and ready to merge within the radius, bicep, docs, and samples repositories. Do not proceed until all the PRs are ready and approved. diff --git a/docs/contributing/contributing-code/contributing-code-tests/tests-logging.md b/docs/contributing/contributing-code/contributing-code-tests/tests-logging.md index ff5c9b7695..25b6899b42 100644 --- a/docs/contributing/contributing-code/contributing-code-tests/tests-logging.md +++ b/docs/contributing/contributing-code/contributing-code-tests/tests-logging.md @@ -5,7 +5,7 @@ The Radius tests redirect the Resource Provider logger output to the testing err ```go import ( ... - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/test/testcontext" ... ) diff --git a/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md b/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md index 709a4f1bb1..a75722808c 100644 --- a/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md +++ b/docs/contributing/contributing-code/contributing-code-tests/tests-naming-conventions.md @@ -1,5 +1,5 @@ # Radius functional test naming conventions -Today, the [functional tests](https://github.com/project-radius/radius/tree/main/test/functional/shared/resources) use some abbreviations to make sure that the resource labels will not exceed 63 characters (application + resource name). Here are a list of some of the abbreviations and patterns: +Today, the [functional tests](https://github.com/radius-project/radius/tree/main/test/functional/shared/resources) use some abbreviations to make sure that the resource labels will not exceed 63 characters (application + resource name). Here are a list of some of the abbreviations and patterns: |Keyword|Abbreviation| |-|-| diff --git a/docs/contributing/contributing-code/contributing-code-tests/writing-functional-tests.md b/docs/contributing/contributing-code/contributing-code-tests/writing-functional-tests.md index 6a2c723771..31d063e40a 100644 --- a/docs/contributing/contributing-code/contributing-code-tests/writing-functional-tests.md +++ b/docs/contributing/contributing-code/contributing-code-tests/writing-functional-tests.md @@ -17,7 +17,7 @@ For example a test for deploying an Azure Service Bus resource would be in `/tes Tests should look like the following. You can actually copy-paste this to create a new test! ```go -import "github.com/project-radius/radius/test/functional/azure" +import "github.com/radius-project/radius/test/functional/azure" func Test_DescriptiveTestName(t *testing.T) { application := "unique-application-name" diff --git a/docs/contributing/contributing-issues/README.md b/docs/contributing/contributing-issues/README.md index f952bc5b5f..d5fa019f78 100644 --- a/docs/contributing/contributing-issues/README.md +++ b/docs/contributing/contributing-issues/README.md @@ -1,6 +1,6 @@ # Contributing Issues -You can open an issue using the form [here](https://github.com/project-radius/radius/issues/new/choose). This form will ask you to fill out a template based on the kind of issue you choose. Please fill out the form as this will help us respond to your issue. +You can open an issue using the form [here](https://github.com/radius-project/radius/issues/new/choose). This form will ask you to fill out a template based on the kind of issue you choose. Please fill out the form as this will help us respond to your issue. ## Tips for creating good issues @@ -14,7 +14,7 @@ You will save us (the maintainers) time if you want to use the right template. ### Focus on the repro steps -Providing clear repro steps with code samples is the best way to get a good response to your issue. [here](https://github.com/project-radius/radius/issues?q=is%3Aissue+is%3Aclosed)'s an example. +Providing clear repro steps with code samples is the best way to get a good response to your issue. [here](https://github.com/radius-project/radius/issues?q=is%3Aissue+is%3Aclosed)'s an example. Remember that another human will need to read your instructions and try to reproduce your steps to understand the issue. diff --git a/docs/contributing/contributing-pull-requests/README.md b/docs/contributing/contributing-pull-requests/README.md index c0ec30e241..694310972e 100644 --- a/docs/contributing/contributing-pull-requests/README.md +++ b/docs/contributing/contributing-pull-requests/README.md @@ -5,7 +5,7 @@ We welcome small pull request contributions from anyone (docs improvements, bug fixes, minor features.) as long as they follow a few guidelines: - For very minor changes like correcting a typo feel free to just send a pull request without any ceremony. Otherwise ... -- Please start by [choosing an existing issue](https://github.com/project-radius/radius/issues), or [opening an issue](https://github.com/project-radius/radius/issues/new/choose) to work on. +- Please start by [choosing an existing issue](https://github.com/radius-project/radius/issues), or [opening an issue](https://github.com/radius-project/radius/issues/new/choose) to work on. - The maintainers will respond to your issue, please work with the maintainers to ensure that what you're doing is in scope for the project before writing any code. - If you have any doubt whether a contribution would be valuable, feel free to ask. @@ -15,7 +15,7 @@ We the maintainers have discretion over what features and pull requests we accep > 💡 If you're new to Go or new to open source, our [first commit guide](./../contributing-code/contributing-code-first-commit/) can walk you through the process of making code changes and submitting a pull request. -Please open pull requests against the `main` branch (the default) unless otherwise instructed. +Please submit pull requests using a forked repo and open pull requests against the `main` branch (the default) unless otherwise instructed. When opening a pull request, the form will be pre-populated with our template. Please fill out the template to provide structure to your PR message. If you've already written a good commit message (see below) it will be easy to use with our template. @@ -44,7 +44,7 @@ We use Task as a catch-all for changes that have no direct user-visible impact. Our pull-request template includes a summary from Github Copilot. This will generate a description of your changes as well as links to the most relevant files. -You can find an example [here](https://github.com/project-radius/radius/pull/5614). +You can find an example [here](https://github.com/radius-project/radius/pull/5614). ## Tips @@ -52,7 +52,7 @@ Keep reading for some tips about how to get your pull requests accepted! ## How to get help with a pull request -* Notify the Radius Core team by commenting with `@project-radius/radius-core-team ` on your pull-request. +* Notify the Radius Core team by commenting with `@radius-project/radius-core-team ` on your pull-request. * Post on Discord in the [#Forum channel](https://discord.gg/GJHN7kQrMh) to start a conversation. ## Writing a good commit message diff --git a/docs/contributing/how-to.md b/docs/contributing/how-to.md index 10699b162b..306ca0dbb7 100644 --- a/docs/contributing/how-to.md +++ b/docs/contributing/how-to.md @@ -4,9 +4,9 @@ We welcome and encourage users to contribute to the Radius open-source project i * Learn how: Browse our guides for how to [install repository prerequisites](./contributing-code/contributing-code-prerequisites/), [build the code](./contributing-code/contributing-code-building/), [understand the code](./contributing-code/contributing-code-organization/), [write code for the project](./contributing-code/contributing-code-writing/), and [run tests](./contributing-code/contributing-code-tests/). This is essential knowledge for working with the repository. -* Tackle small tasks: Start by addressing small issues or tasks labeled as ["good first issues"](https://github.com/project-radius/radius/issues?q=is:issue+is:open+label:%22good+first+issue%22) This allows you to familiarize yourself with the project and make valuable contributions without a steep learning curve. +* Tackle small tasks: Start by addressing small issues or tasks labeled as ["good first issues"](https://github.com/radius-project/radius/issues?q=is:issue+is:open+label:%22good+first+issue%22) This allows you to familiarize yourself with the project and make valuable contributions without a steep learning curve. -* Take on bigger projects: Issues that are groomed and ready to be picked up are labeled as ["triaged"](https://github.com/project-radius/radius/issues?q=is%3Aissue+is%3Aopen+label%3Atriaged). +* Take on bigger projects: Issues that are groomed and ready to be picked up are labeled as ["triaged"](https://github.com/radius-project/radius/issues?q=is%3Aissue+is%3Aopen+label%3Atriaged). * Fork the project: Create a personal copy (fork) of the Radius repository on GitHub. This enables you to make changes and experiment as well as submit pull requests. @@ -16,7 +16,7 @@ We welcome and encourage users to contribute to the Radius open-source project i * Test and report bugs: Assist in testing Radius by [identifying and reporting bugs](./contributing-issues/). Detailed bug reports help us address issues promptly and enhance the software's quality. -* Improve documentation: Enhance the project's [documentation](https://github.com/project-radius/docs) by updating existing content, adding guides, or adding examples. Well-documented projects are easier to use and attract more users. +* Improve documentation: Enhance the project's [documentation](https://github.com/radius-project/docs) by updating existing content, adding guides, or adding examples. Well-documented projects are easier to use and attract more users. * Spread the word: Share your positive experiences with Radius through blog posts, talks, or social media. Promote the project to attract more users and contributors. Star the project on GitHub! diff --git a/docs/release-notes/README.md b/docs/release-notes/README.md index f78e232d61..f95a5d0363 100644 --- a/docs/release-notes/README.md +++ b/docs/release-notes/README.md @@ -1,6 +1,6 @@ # Radius release notes -This directory contains the release notes for each Radius release. The release notes are written in Markdown and are included as the body of [each Radius release](https://github.com/project-radius/radius/releases). +This directory contains the release notes for each Radius release. The release notes are written in Markdown and are included as the body of [each Radius release](https://github.com/radius-project/radius/releases). ## Release process @@ -32,7 +32,7 @@ Within the template is the `## Full changelog` section, which is a complete list To generate the release notes: -1. Visit [Generate a new release](https://github.com/project-radius/radius/releases/new) in the radius repository. +1. Visit [Generate a new release](https://github.com/radius-project/radius/releases/new) in the radius repository. - _Note that you will not be creating the release through the UI, just generating the list of merged PRs. This could be automated in the future using the [GitHub API](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits)_ 2. Dropdown the `Choose a tag` menu and manually enter the tag for the upcoming release (_e.g. `v0.21.0`_). Keep `Target` as 'main'. 3. Dropdown the `Previous tag` menu and select the tag for the previous minor release (_e.g. `v0.20.0`_). Don't select patch or RC releases. diff --git a/docs/release-notes/v0.22.0.md b/docs/release-notes/v0.22.0.md index 3dc696f981..f5d5de4a5d 100644 --- a/docs/release-notes/v0.22.0.md +++ b/docs/release-notes/v0.22.0.md @@ -12,11 +12,11 @@ If you're new to Radius, check out our website, [radapp.dev](https://radapp.dev) ### Recipe support for all Application.Link resources -All Applications.Link resources now support Recipes. This allows operators to add their approved Bicep templates to a Radius environment and developers to deploy any Radius Link without needing to define or configure any infrastructure. Learn more in the [docs](https://docs.radapp.dev/author-apps/recipes/). +All portable resources now support Recipes. This allows operators to add their approved Bicep templates to a Radius environment and developers to deploy any Radius Link without needing to define or configure any infrastructure. Learn more in the [docs](https://docs.radapp.dev/author-apps/recipes/). ### Updated contribution guides -Interested in contributing to Project Radius? Check out our [updated contribution guides](https://github.com/project-radius/radius/blob/main/CONTRIBUTING.md) to learn how to get started and understand our code-base. +Interested in contributing to Project Radius? Check out our [updated contribution guides](https://github.com/radius-project/radius/blob/main/CONTRIBUTING.md) to learn how to get started and understand our code-base. ### Project Radius Discord server @@ -33,7 +33,7 @@ Thank you to the attendees of our latest community call! You can check out the r ## Breaking changes - The Radius Helm chart has been updated, requiring a full uninstall and install of the Radius control-plane. `rad install kubernetes --reinstall` will not work. See [Upgrading to Radius v0.22.0](#upgrading-to-radius-v0220) for more details. -- The schema of all Applications.Link resources have been updated to the new format which defaults to Recipes. Applications with Links need to: +- The schema of all portable resources have been updated to the new format which defaults to Recipes. Applications with Links need to: - Update from `mode: 'values'` to `resourceProvisioning: 'manual'` - Update from `mode: 'resource'` to either Recipes or `resourceProvisioning: 'manual'` - The schema of Radius Gateways has been updated to remove a duplicate 'hostname' field within the `tls` property. `tls.hostname` needs to be removed. @@ -42,7 +42,7 @@ Thank you to the attendees of our latest community call! You can check out the r Welcome to our new contributors who have merged their first PR in this release! -* @farazmsiddiqi made their first contribution in https://github.com/project-radius/radius/pull/5647 +* @farazmsiddiqi made their first contribution in https://github.com/radius-project/radius/pull/5647 ## Upgrading to Radius v0.22.0 @@ -64,84 +64,84 @@ During our preview stage, an upgrade to Radius v0.22.0 requires a full reinstall ## Full changelog -* Add copilot docs summary to PR template by @AaronCrawfis in https://github.com/project-radius/radius/pull/5588 -* Suppress etcd logs in integration test by @rynowak in https://github.com/project-radius/radius/pull/5589 -* Update documentation for running Radius locally by @rynowak in https://github.com/project-radius/radius/pull/5596 -* Fix test failure reporting by @youngbupark in https://github.com/project-radius/radius/pull/5590 -* Copyright spacing by @vinayada1 in https://github.com/project-radius/radius/pull/5595 -* Remove location from scaffolded app by @ytimocin in https://github.com/project-radius/radius/pull/5600 -* A fresh coat of paint for rad init by @rynowak in https://github.com/project-radius/radius/pull/5587 -* Clean up CoreRP controller using default controller by @youngbupark in https://github.com/project-radius/radius/pull/5478 -* Ensure resource group is deleted by @youngbupark in https://github.com/project-radius/radius/pull/5608 -* Use UUID validator for tenant id by @rynowak in https://github.com/project-radius/radius/pull/5613 -* Make validation tolerant of intermediate states by @rynowak in https://github.com/project-radius/radius/pull/5614 -* Add recipe support for Dapr State Store by @rynowak in https://github.com/project-radius/radius/pull/5598 -* Add tests for plane-scoped API scenarios by @rynowak in https://github.com/project-radius/radius/pull/5620 -* Cleanup of the docs folder and Contributing by @rynowak in https://github.com/project-radius/radius/pull/5619 -* Fix the wrong version of container tag for Radius installation by @nithyatsu in https://github.com/project-radius/radius/pull/5628 -* Enable repository_dispatcher trigger in functional test" by @vinayada1 in https://github.com/project-radius/radius/pull/5640 -* Mask credentials in `rad init` interactive mode by @willdavsmith in https://github.com/project-radius/radius/pull/5644 -* Recipe support for Dapr Secret Store resource by @vishwahiremat in https://github.com/project-radius/radius/pull/5637 -* Recipe support for rabbitmq resource by @vishwahiremat in https://github.com/project-radius/radius/pull/5615 -* Recipe support for Sql database resource by @vishwahiremat in https://github.com/project-radius/radius/pull/5572 -* Fix formatting of how-to by @rynowak in https://github.com/project-radius/radius/pull/5650 -* Update code of conduct to contributor covenant by @AaronCrawfis in https://github.com/project-radius/radius/pull/5642 -* Set Pod resource limit for Radius containers. by @youngbupark in https://github.com/project-radius/radius/pull/5663 -* Update Security advisory to focus on Radius by @AaronCrawfis in https://github.com/project-radius/radius/pull/5667 -* Assign Radius-Eng team to the functional test failure bug by @youngbupark in https://github.com/project-radius/radius/pull/5676 -* Add Recipe support for Dapr Pub Sub Brokers by @ytimocin in https://github.com/project-radius/radius/pull/5623 -* Add AWS access keys create instruction message by @youngbupark in https://github.com/project-radius/radius/pull/5687 -* Fix development configuration by @rynowak in https://github.com/project-radius/radius/pull/5679 -* Update recipe metadata name for default recipe by @kachawla in https://github.com/project-radius/radius/pull/5635 -* Add gotestsum to functional test by @rynowak in https://github.com/project-radius/radius/pull/5691 -* User Confirmation Prompt Before rad resource delete by @farazmsiddiqi in https://github.com/project-radius/radius/pull/5647 -* MongoDB default recipe experience by @sk593 in https://github.com/project-radius/radius/pull/5555 -* Refactor helm chart by @youngbupark in https://github.com/project-radius/radius/pull/5690 -* Add support for plane-scoped list operations by @rynowak in https://github.com/project-radius/radius/pull/5680 -* Check user membership for ok-to-test comment on PR and if active, then trigger e2e tests by @vinayada1 in https://github.com/project-radius/radius/pull/5660 -* change mentions of to just by @willtsai in https://github.com/project-radius/radius/pull/5696 -* Add docs on CodeQL by @AaronCrawfis in https://github.com/project-radius/radius/pull/5662 -* Fix for updating the dapr bicep files to remove mode. by @vishwahiremat in https://github.com/project-radius/radius/pull/5688 -* Removing mode from resources that are migrated to the new process by @ytimocin in https://github.com/project-radius/radius/pull/5692 -* Updating Redis username and Mongo database properties to read/write by @sk593 in https://github.com/project-radius/radius/pull/5708 -* Fix Kubernetes POD deployment goroutine leak by @vinayada1 in https://github.com/project-radius/radius/pull/5693 -* Rename READMD.md to README.md by @AaronCrawfis in https://github.com/project-radius/radius/pull/5709 -* Fix test failure issue creation by @youngbupark in https://github.com/project-radius/radius/pull/5710 -* Fix functional test by dispatch trigger by @youngbupark in https://github.com/project-radius/radius/pull/5712 -* add /lgtm command to approve PR by @youngbupark in https://github.com/project-radius/radius/pull/5711 -* Upgrade github-action version to v6 by @youngbupark in https://github.com/project-radius/radius/pull/5715 -* Revert /lgtm command by @youngbupark in https://github.com/project-radius/radius/pull/5718 -* Fix AWS credential bug by @willdavsmith in https://github.com/project-radius/radius/pull/5639 -* Filter out APIServer Auth headers in UCP by @youngbupark in https://github.com/project-radius/radius/pull/5719 -* Add appsettings to de configmap in chart by @youngbupark in https://github.com/project-radius/radius/pull/5720 -* Fix the chart formatting and clean up charts by @youngbupark in https://github.com/project-radius/radius/pull/5723 -* Ensure cache is synced before processing by @youngbupark in https://github.com/project-radius/radius/pull/5724 -* Fix RC release version tag in chart by @youngbupark in https://github.com/project-radius/radius/pull/5727 -* Update sqlDatabases resource to store secrets and new values by @vishwahiremat in https://github.com/project-radius/radius/pull/5707 -* Fix handling of --group for rad env create by @rynowak in https://github.com/project-radius/radius/pull/5697 -* Reduce deployment resync duration and fix invalid context usage by @youngbupark in https://github.com/project-radius/radius/pull/5728 -* Fix for Datamodel conversion error by @vishwahiremat in https://github.com/project-radius/radius/pull/5732 -* Updating the release process doc by @ytimocin in https://github.com/project-radius/radius/pull/5370 -* Revert "Reduce deployment resync duration" by @youngbupark in https://github.com/project-radius/radius/pull/5741 -* Fix for validate bicep for sql-recipe by @vishwahiremat in https://github.com/project-radius/radius/pull/5743 -* Adding a fix for nil pointer issue in converter. by @vishwahiremat in https://github.com/project-radius/radius/pull/5742 -* Populate Recipe Name during conversion by @vishwahiremat in https://github.com/project-radius/radius/pull/5730 -* Update install/uninstall commands by @rynowak in https://github.com/project-radius/radius/pull/5725 -* Simplify and document CLI error handling by @rynowak in https://github.com/project-radius/radius/pull/5700 -* Use plane-scoped environment list in CLI by @rynowak in https://github.com/project-radius/radius/pull/5746 -* Increase timeout of bubbletea UI tests by @rynowak in https://github.com/project-radius/radius/pull/5748 -* Remove DaprInvokeHttpRoute by @rynowak in https://github.com/project-radius/radius/pull/5750 -* Remove some dead code by @rynowak in https://github.com/project-radius/radius/pull/5749 -* Remove uses of deployment processor by @rynowak in https://github.com/project-radius/radius/pull/5751 -* Remove deployment processor for listsecrets apis by @rynowak in https://github.com/project-radius/radius/pull/5752 -* Remove linkrp deployment processor and secretvalueclient by @rynowak in https://github.com/project-radius/radius/pull/5753 -* Add address and pathbase properties to controller options by @rynowak in https://github.com/project-radius/radius/pull/5756 -* Add recipe support to extenders by @sk593 in https://github.com/project-radius/radius/pull/5706 -* Removing `hostname` from TLS spec by @willdavsmith in https://github.com/project-radius/radius/pull/5681 -* Fixing Gateways TLS minimumProtocolVersion bug by @willdavsmith in https://github.com/project-radius/radius/pull/5683 -* Disable flaky tests by @rynowak in https://github.com/project-radius/radius/pull/5763 -* Use armrpc options and handler definition by @rynowak in https://github.com/project-radius/radius/pull/5759 -* Populate the resource id on current context - Part1 by @vinayada1 in https://github.com/project-radius/radius/pull/5761 -* Update Recipe Definition Schema by @vishwahiremat in https://github.com/project-radius/radius/pull/5735 -* Add UUID validation to `rad env update` by @AaronCrawfis in https://github.com/project-radius/radius/pull/5758 -* Fix publicEndpointOverride reference (cherry-picked) by @youngbupark in https://github.com/project-radius/radius/pull/5780 +* Add copilot docs summary to PR template by @AaronCrawfis in https://github.com/radius-project/radius/pull/5588 +* Suppress etcd logs in integration test by @rynowak in https://github.com/radius-project/radius/pull/5589 +* Update documentation for running Radius locally by @rynowak in https://github.com/radius-project/radius/pull/5596 +* Fix test failure reporting by @youngbupark in https://github.com/radius-project/radius/pull/5590 +* Copyright spacing by @vinayada1 in https://github.com/radius-project/radius/pull/5595 +* Remove location from scaffolded app by @ytimocin in https://github.com/radius-project/radius/pull/5600 +* A fresh coat of paint for rad init by @rynowak in https://github.com/radius-project/radius/pull/5587 +* Clean up CoreRP controller using default controller by @youngbupark in https://github.com/radius-project/radius/pull/5478 +* Ensure resource group is deleted by @youngbupark in https://github.com/radius-project/radius/pull/5608 +* Use UUID validator for tenant id by @rynowak in https://github.com/radius-project/radius/pull/5613 +* Make validation tolerant of intermediate states by @rynowak in https://github.com/radius-project/radius/pull/5614 +* Add recipe support for Dapr State Store by @rynowak in https://github.com/radius-project/radius/pull/5598 +* Add tests for plane-scoped API scenarios by @rynowak in https://github.com/radius-project/radius/pull/5620 +* Cleanup of the docs folder and Contributing by @rynowak in https://github.com/radius-project/radius/pull/5619 +* Fix the wrong version of container tag for Radius installation by @nithyatsu in https://github.com/radius-project/radius/pull/5628 +* Enable repository_dispatcher trigger in functional test" by @vinayada1 in https://github.com/radius-project/radius/pull/5640 +* Mask credentials in `rad init` interactive mode by @willdavsmith in https://github.com/radius-project/radius/pull/5644 +* Recipe support for Dapr Secret Store resource by @vishwahiremat in https://github.com/radius-project/radius/pull/5637 +* Recipe support for rabbitmq resource by @vishwahiremat in https://github.com/radius-project/radius/pull/5615 +* Recipe support for Sql database resource by @vishwahiremat in https://github.com/radius-project/radius/pull/5572 +* Fix formatting of how-to by @rynowak in https://github.com/radius-project/radius/pull/5650 +* Update code of conduct to contributor covenant by @AaronCrawfis in https://github.com/radius-project/radius/pull/5642 +* Set Pod resource limit for Radius containers. by @youngbupark in https://github.com/radius-project/radius/pull/5663 +* Update Security advisory to focus on Radius by @AaronCrawfis in https://github.com/radius-project/radius/pull/5667 +* Assign Radius-Eng team to the functional test failure bug by @youngbupark in https://github.com/radius-project/radius/pull/5676 +* Add Recipe support for Dapr Pub Sub Brokers by @ytimocin in https://github.com/radius-project/radius/pull/5623 +* Add AWS access keys create instruction message by @youngbupark in https://github.com/radius-project/radius/pull/5687 +* Fix development configuration by @rynowak in https://github.com/radius-project/radius/pull/5679 +* Update recipe metadata name for default recipe by @kachawla in https://github.com/radius-project/radius/pull/5635 +* Add gotestsum to functional test by @rynowak in https://github.com/radius-project/radius/pull/5691 +* User Confirmation Prompt Before rad resource delete by @farazmsiddiqi in https://github.com/radius-project/radius/pull/5647 +* MongoDB default recipe experience by @sk593 in https://github.com/radius-project/radius/pull/5555 +* Refactor helm chart by @youngbupark in https://github.com/radius-project/radius/pull/5690 +* Add support for plane-scoped list operations by @rynowak in https://github.com/radius-project/radius/pull/5680 +* Check user membership for ok-to-test comment on PR and if active, then trigger e2e tests by @vinayada1 in https://github.com/radius-project/radius/pull/5660 +* change mentions of to just by @willtsai in https://github.com/radius-project/radius/pull/5696 +* Add docs on CodeQL by @AaronCrawfis in https://github.com/radius-project/radius/pull/5662 +* Fix for updating the dapr bicep files to remove mode. by @vishwahiremat in https://github.com/radius-project/radius/pull/5688 +* Removing mode from resources that are migrated to the new process by @ytimocin in https://github.com/radius-project/radius/pull/5692 +* Updating Redis username and Mongo database properties to read/write by @sk593 in https://github.com/radius-project/radius/pull/5708 +* Fix Kubernetes POD deployment goroutine leak by @vinayada1 in https://github.com/radius-project/radius/pull/5693 +* Rename READMD.md to README.md by @AaronCrawfis in https://github.com/radius-project/radius/pull/5709 +* Fix test failure issue creation by @youngbupark in https://github.com/radius-project/radius/pull/5710 +* Fix functional test by dispatch trigger by @youngbupark in https://github.com/radius-project/radius/pull/5712 +* add /lgtm command to approve PR by @youngbupark in https://github.com/radius-project/radius/pull/5711 +* Upgrade github-action version to v6 by @youngbupark in https://github.com/radius-project/radius/pull/5715 +* Revert /lgtm command by @youngbupark in https://github.com/radius-project/radius/pull/5718 +* Fix AWS credential bug by @willdavsmith in https://github.com/radius-project/radius/pull/5639 +* Filter out APIServer Auth headers in UCP by @youngbupark in https://github.com/radius-project/radius/pull/5719 +* Add appsettings to de configmap in chart by @youngbupark in https://github.com/radius-project/radius/pull/5720 +* Fix the chart formatting and clean up charts by @youngbupark in https://github.com/radius-project/radius/pull/5723 +* Ensure cache is synced before processing by @youngbupark in https://github.com/radius-project/radius/pull/5724 +* Fix RC release version tag in chart by @youngbupark in https://github.com/radius-project/radius/pull/5727 +* Update sqlDatabases resource to store secrets and new values by @vishwahiremat in https://github.com/radius-project/radius/pull/5707 +* Fix handling of --group for rad env create by @rynowak in https://github.com/radius-project/radius/pull/5697 +* Reduce deployment resync duration and fix invalid context usage by @youngbupark in https://github.com/radius-project/radius/pull/5728 +* Fix for Datamodel conversion error by @vishwahiremat in https://github.com/radius-project/radius/pull/5732 +* Updating the release process doc by @ytimocin in https://github.com/radius-project/radius/pull/5370 +* Revert "Reduce deployment resync duration" by @youngbupark in https://github.com/radius-project/radius/pull/5741 +* Fix for validate bicep for sql-recipe by @vishwahiremat in https://github.com/radius-project/radius/pull/5743 +* Adding a fix for nil pointer issue in converter. by @vishwahiremat in https://github.com/radius-project/radius/pull/5742 +* Populate Recipe Name during conversion by @vishwahiremat in https://github.com/radius-project/radius/pull/5730 +* Update install/uninstall commands by @rynowak in https://github.com/radius-project/radius/pull/5725 +* Simplify and document CLI error handling by @rynowak in https://github.com/radius-project/radius/pull/5700 +* Use plane-scoped environment list in CLI by @rynowak in https://github.com/radius-project/radius/pull/5746 +* Increase timeout of bubbletea UI tests by @rynowak in https://github.com/radius-project/radius/pull/5748 +* Remove DaprInvokeHttpRoute by @rynowak in https://github.com/radius-project/radius/pull/5750 +* Remove some dead code by @rynowak in https://github.com/radius-project/radius/pull/5749 +* Remove uses of deployment processor by @rynowak in https://github.com/radius-project/radius/pull/5751 +* Remove deployment processor for listsecrets apis by @rynowak in https://github.com/radius-project/radius/pull/5752 +* Remove linkrp deployment processor and secretvalueclient by @rynowak in https://github.com/radius-project/radius/pull/5753 +* Add address and pathbase properties to controller options by @rynowak in https://github.com/radius-project/radius/pull/5756 +* Add recipe support to extenders by @sk593 in https://github.com/radius-project/radius/pull/5706 +* Removing `hostname` from TLS spec by @willdavsmith in https://github.com/radius-project/radius/pull/5681 +* Fixing Gateways TLS minimumProtocolVersion bug by @willdavsmith in https://github.com/radius-project/radius/pull/5683 +* Disable flaky tests by @rynowak in https://github.com/radius-project/radius/pull/5763 +* Use armrpc options and handler definition by @rynowak in https://github.com/radius-project/radius/pull/5759 +* Populate the resource id on current context - Part1 by @vinayada1 in https://github.com/radius-project/radius/pull/5761 +* Update Recipe Definition Schema by @vishwahiremat in https://github.com/radius-project/radius/pull/5735 +* Add UUID validation to `rad env update` by @AaronCrawfis in https://github.com/radius-project/radius/pull/5758 +* Fix publicEndpointOverride reference (cherry-picked) by @youngbupark in https://github.com/radius-project/radius/pull/5780 diff --git a/docs/release-notes/v0.23.0.md b/docs/release-notes/v0.23.0.md index f276d3be81..6657951517 100644 --- a/docs/release-notes/v0.23.0.md +++ b/docs/release-notes/v0.23.0.md @@ -17,7 +17,7 @@ If you're new to Radius, check out our website, [radapp.dev](https://radapp.dev) Welcome to our new contributors who have merged their first PR in this release! -* @shriraml-ms made their first contribution in https://github.com/project-radius/radius/pull/5531 +* @shriraml-ms made their first contribution in https://github.com/radius-project/radius/pull/5531 ## Upgrading to Radius v0.23.0 @@ -39,63 +39,63 @@ During our preview stage, an upgrade to Radius v0.23.0 requires a full reinstall ## Full changelog -* Update rad init prompt for AWS provider by @kachawla in https://github.com/project-radius/radius/pull/5771 -* Fix publicEndpointOverride reference by @youngbupark in https://github.com/project-radius/radius/pull/5777 -* Add remaining types to dev recipes processing by @AaronCrawfis in https://github.com/project-radius/radius/pull/5778 -* Add mongodb resource limits by @sk593 in https://github.com/project-radius/radius/pull/5789 -* Update build.yaml concurrency group to include the GitHub ref by @willdavsmith in https://github.com/project-radius/radius/pull/5779 -* Readme.md for radius repo by @nithyatsu in https://github.com/project-radius/radius/pull/5703 -* Mount directory for Terraform execution by @kachawla in https://github.com/project-radius/radius/pull/5797 -* Rename appcore-rp to applications-rp and clean up unused files. by @youngbupark in https://github.com/project-radius/radius/pull/5802 -* Update governance statement by @willtsai in https://github.com/project-radius/radius/pull/5770 -* Linkrp split namespace: messagingrp by @lakshmimsft in https://github.com/project-radius/radius/pull/5733 -* Fetch only radius-bot.js by @youngbupark in https://github.com/project-radius/radius/pull/5803 -* Make UCP routing modular by @rynowak in https://github.com/project-radius/radius/pull/5804 -* Update redis schema to include URL and SSL by @sk593 in https://github.com/project-radius/radius/pull/5791 -* Create Radius release automation by @willdavsmith in https://github.com/project-radius/radius/pull/5766 -* Release Radius v0.22.0-rc2 by @willdavsmith in https://github.com/project-radius/radius/pull/5811 -* Clean up go mods by @youngbupark in https://github.com/project-radius/radius/pull/5813 -* Add helm linter to workflow by @youngbupark in https://github.com/project-radius/radius/pull/5817 -* Update redis schema check by @sk593 in https://github.com/project-radius/radius/pull/5818 -* Cleaning up `release.yaml` by @willdavsmith in https://github.com/project-radius/radius/pull/5814 -* Update to pull request template by @rynowak in https://github.com/project-radius/radius/pull/5822 -* Streamline the test context creation by @youngbupark in https://github.com/project-radius/radius/pull/5816 -* Adding Terraform driver and integration with Terraform installation by @kachawla in https://github.com/project-radius/radius/pull/5805 -* Update old UCP tests by @rynowak in https://github.com/project-radius/radius/pull/5824 -* Release Radius v0.22.0 by @willdavsmith in https://github.com/project-radius/radius/pull/5826 -* Add AWS S3 recipe functional test by @willdavsmith in https://github.com/project-radius/radius/pull/5760 -* Add comments : Part 1 (pkg/cli/...) by @shriraml-ms in https://github.com/project-radius/radius/pull/5531 -* Add Comments: Part 3 (first of a few PRs for pkg/ucp) by @shriraml-ms in https://github.com/project-radius/radius/pull/5643 -* Add resource ID to ErrNotFound{} by @vinayada1 in https://github.com/project-radius/radius/pull/5768 -* Adding contibuting docs for app model changes by @vishwahiremat in https://github.com/project-radius/radius/pull/5773 -* Adding AWS region selection to rad init by @willdavsmith in https://github.com/project-radius/radius/pull/5815 -* Generate TF module config and integrate with init by @kachawla in https://github.com/project-radius/radius/pull/5841 -* Update contribution docs by @nithyatsu in https://github.com/project-radius/radius/pull/5721 -* Add Comments: Part 2 (pkg/arm-rpc) by @shriraml-ms in https://github.com/project-radius/radius/pull/5627 -* Migrate gorilla-mux to go-chi by @youngbupark in https://github.com/project-radius/radius/pull/5828 -* Add release notes instructions and template by @AaronCrawfis in https://github.com/project-radius/radius/pull/5847 -* Update contibuting docs for app model changes by @vishwahiremat in https://github.com/project-radius/radius/pull/5852 -* Add Comments: Part 5 (pkg/ucp/api to pkg/ucp/queue) by @shriraml-ms in https://github.com/project-radius/radius/pull/5835 -* Add Comments: Part 7 (pkg/armrpc - refinements) by @shriraml-ms in https://github.com/project-radius/radius/pull/5850 -* Fixing AWS connection URL to use Recipe output by @sk593 in https://github.com/project-radius/radius/pull/5862 -* Add Comments: Part 8 (pkg/azure) by @shriraml-ms in https://github.com/project-radius/radius/pull/5856 -* Add Comments: Part 10 (pkg/aws, pkg/version) by @shriraml-ms in https://github.com/project-radius/radius/pull/5865 -* Add Comments: Part 6 (pkg/linkrp) by @shriraml-ms in https://github.com/project-radius/radius/pull/5845 -* Link to contributing.md in the repo from readme. by @rynowak in https://github.com/project-radius/radius/pull/5870 -* Add `test-failure` label by @youngbupark in https://github.com/project-radius/radius/pull/5871 -* Add Comments: Part 11 (pkg/datastorerp) by @shriraml-ms in https://github.com/project-radius/radius/pull/5868 -* Adding Terraform Module Version to environment App Model by @vishwahiremat in https://github.com/project-radius/radius/pull/5854 -* Rename corerp functional tests to shared by @lakshmimsft in https://github.com/project-radius/radius/pull/5872 -* Reduce GC count in appcoreRP upon start up by @nithyatsu in https://github.com/project-radius/radius/pull/5855 -* Add Comments: Part 9 (pkg/ucp/resources to pkg/ucp/util) by @shriraml-ms in https://github.com/project-radius/radius/pull/5859 -* MessagingRP Functional Tests by @lakshmimsft in https://github.com/project-radius/radius/pull/5853 -* Update "dev recipes" to "local dev recipes" by @AaronCrawfis in https://github.com/project-radius/radius/pull/5879 -* Create env in current workspace if one exists by @vinayada1 in https://github.com/project-radius/radius/pull/5882 -* Move LinkRP output resource deletion logic to Bicep/Terraform drivers by @sk593 in https://github.com/project-radius/radius/pull/5875 -* Initial commit of Radius infra for Azure by @youngbupark in https://github.com/project-radius/radius/pull/5884 -* Fix for list recipes flakey unit test by @vishwahiremat in https://github.com/project-radius/radius/pull/5894 -* small improvements in aws deletion test code by @nithyatsu in https://github.com/project-radius/radius/pull/5885 -* Release v0.23.0-rc1 by @lakshmimsft in https://github.com/project-radius/radius/pull/5891 -* modify container swagger files to include port and scheme fields by @farazmsiddiqi in https://github.com/project-radius/radius/pull/5887 -* Fixes concurrency issue in build workflow by @willdavsmith in https://github.com/project-radius/radius/pull/5898 -* Initial commit of e2e test workflow on AKS with monitor by @youngbupark in https://github.com/project-radius/radius/pull/5886 +* Update rad init prompt for AWS provider by @kachawla in https://github.com/radius-project/radius/pull/5771 +* Fix publicEndpointOverride reference by @youngbupark in https://github.com/radius-project/radius/pull/5777 +* Add remaining types to dev recipes processing by @AaronCrawfis in https://github.com/radius-project/radius/pull/5778 +* Add mongodb resource limits by @sk593 in https://github.com/radius-project/radius/pull/5789 +* Update build.yaml concurrency group to include the GitHub ref by @willdavsmith in https://github.com/radius-project/radius/pull/5779 +* Readme.md for radius repo by @nithyatsu in https://github.com/radius-project/radius/pull/5703 +* Mount directory for Terraform execution by @kachawla in https://github.com/radius-project/radius/pull/5797 +* Rename appcore-rp to applications-rp and clean up unused files. by @youngbupark in https://github.com/radius-project/radius/pull/5802 +* Update governance statement by @willtsai in https://github.com/radius-project/radius/pull/5770 +* Linkrp split namespace: messagingrp by @lakshmimsft in https://github.com/radius-project/radius/pull/5733 +* Fetch only radius-bot.js by @youngbupark in https://github.com/radius-project/radius/pull/5803 +* Make UCP routing modular by @rynowak in https://github.com/radius-project/radius/pull/5804 +* Update redis schema to include URL and SSL by @sk593 in https://github.com/radius-project/radius/pull/5791 +* Create Radius release automation by @willdavsmith in https://github.com/radius-project/radius/pull/5766 +* Release Radius v0.22.0-rc2 by @willdavsmith in https://github.com/radius-project/radius/pull/5811 +* Clean up go mods by @youngbupark in https://github.com/radius-project/radius/pull/5813 +* Add helm linter to workflow by @youngbupark in https://github.com/radius-project/radius/pull/5817 +* Update redis schema check by @sk593 in https://github.com/radius-project/radius/pull/5818 +* Cleaning up `release.yaml` by @willdavsmith in https://github.com/radius-project/radius/pull/5814 +* Update to pull request template by @rynowak in https://github.com/radius-project/radius/pull/5822 +* Streamline the test context creation by @youngbupark in https://github.com/radius-project/radius/pull/5816 +* Adding Terraform driver and integration with Terraform installation by @kachawla in https://github.com/radius-project/radius/pull/5805 +* Update old UCP tests by @rynowak in https://github.com/radius-project/radius/pull/5824 +* Release Radius v0.22.0 by @willdavsmith in https://github.com/radius-project/radius/pull/5826 +* Add AWS S3 recipe functional test by @willdavsmith in https://github.com/radius-project/radius/pull/5760 +* Add comments : Part 1 (pkg/cli/...) by @shriraml-ms in https://github.com/radius-project/radius/pull/5531 +* Add Comments: Part 3 (first of a few PRs for pkg/ucp) by @shriraml-ms in https://github.com/radius-project/radius/pull/5643 +* Add resource ID to ErrNotFound{} by @vinayada1 in https://github.com/radius-project/radius/pull/5768 +* Adding contibuting docs for app model changes by @vishwahiremat in https://github.com/radius-project/radius/pull/5773 +* Adding AWS region selection to rad init by @willdavsmith in https://github.com/radius-project/radius/pull/5815 +* Generate TF module config and integrate with init by @kachawla in https://github.com/radius-project/radius/pull/5841 +* Update contribution docs by @nithyatsu in https://github.com/radius-project/radius/pull/5721 +* Add Comments: Part 2 (pkg/arm-rpc) by @shriraml-ms in https://github.com/radius-project/radius/pull/5627 +* Migrate gorilla-mux to go-chi by @youngbupark in https://github.com/radius-project/radius/pull/5828 +* Add release notes instructions and template by @AaronCrawfis in https://github.com/radius-project/radius/pull/5847 +* Update contibuting docs for app model changes by @vishwahiremat in https://github.com/radius-project/radius/pull/5852 +* Add Comments: Part 5 (pkg/ucp/api to pkg/ucp/queue) by @shriraml-ms in https://github.com/radius-project/radius/pull/5835 +* Add Comments: Part 7 (pkg/armrpc - refinements) by @shriraml-ms in https://github.com/radius-project/radius/pull/5850 +* Fixing AWS connection URL to use Recipe output by @sk593 in https://github.com/radius-project/radius/pull/5862 +* Add Comments: Part 8 (pkg/azure) by @shriraml-ms in https://github.com/radius-project/radius/pull/5856 +* Add Comments: Part 10 (pkg/aws, pkg/version) by @shriraml-ms in https://github.com/radius-project/radius/pull/5865 +* Add Comments: Part 6 (pkg/linkrp) by @shriraml-ms in https://github.com/radius-project/radius/pull/5845 +* Link to contributing.md in the repo from readme. by @rynowak in https://github.com/radius-project/radius/pull/5870 +* Add `test-failure` label by @youngbupark in https://github.com/radius-project/radius/pull/5871 +* Add Comments: Part 11 (pkg/datastorerp) by @shriraml-ms in https://github.com/radius-project/radius/pull/5868 +* Adding Terraform Module Version to environment App Model by @vishwahiremat in https://github.com/radius-project/radius/pull/5854 +* Rename corerp functional tests to shared by @lakshmimsft in https://github.com/radius-project/radius/pull/5872 +* Reduce GC count in appcoreRP upon start up by @nithyatsu in https://github.com/radius-project/radius/pull/5855 +* Add Comments: Part 9 (pkg/ucp/resources to pkg/ucp/util) by @shriraml-ms in https://github.com/radius-project/radius/pull/5859 +* MessagingRP Functional Tests by @lakshmimsft in https://github.com/radius-project/radius/pull/5853 +* Update "dev recipes" to "local dev recipes" by @AaronCrawfis in https://github.com/radius-project/radius/pull/5879 +* Create env in current workspace if one exists by @vinayada1 in https://github.com/radius-project/radius/pull/5882 +* Move LinkRP output resource deletion logic to Bicep/Terraform drivers by @sk593 in https://github.com/radius-project/radius/pull/5875 +* Initial commit of Radius infra for Azure by @youngbupark in https://github.com/radius-project/radius/pull/5884 +* Fix for list recipes flakey unit test by @vishwahiremat in https://github.com/radius-project/radius/pull/5894 +* small improvements in aws deletion test code by @nithyatsu in https://github.com/radius-project/radius/pull/5885 +* Release v0.23.0-rc1 by @lakshmimsft in https://github.com/radius-project/radius/pull/5891 +* modify container swagger files to include port and scheme fields by @farazmsiddiqi in https://github.com/radius-project/radius/pull/5887 +* Fixes concurrency issue in build workflow by @willdavsmith in https://github.com/radius-project/radius/pull/5898 +* Initial commit of e2e test workflow on AKS with monitor by @youngbupark in https://github.com/radius-project/radius/pull/5886 diff --git a/docs/release-notes/v0.24.0.md b/docs/release-notes/v0.24.0.md index bef6f3a633..d73693c1e2 100644 --- a/docs/release-notes/v0.24.0.md +++ b/docs/release-notes/v0.24.0.md @@ -48,91 +48,91 @@ During our preview stage, an upgrade to Radius v0.24.0 requires a full reinstall ## Full changelog -* Fix valid radius build window const by @youngbupark in https://github.com/project-radius/radius/pull/5901 -* Release v0.23.0 by @lakshmimsft in https://github.com/project-radius/radius/pull/5902 -* Generate Terraform Providers Config for Supported Required Providers by @kachawla in https://github.com/project-radius/radius/pull/5874 -* Remove deployments plane from Radius by @rynowak in https://github.com/project-radius/radius/pull/5821 -* Add terraform directory to gitignore by @rynowak in https://github.com/project-radius/radius/pull/5908 -* Improve table formatting for multi-line entries by @rynowak in https://github.com/project-radius/radius/pull/5899 -* Correction in docs URL by @lakshmimsft in https://github.com/project-radius/radius/pull/5905 -* Add publishing of terraform recipes for tests by @rynowak in https://github.com/project-radius/radius/pull/5909 -* Document release notes process and add 0.23.0 release notes by @AaronCrawfis in https://github.com/project-radius/radius/pull/5913 -* Skip MongoDB recipe test by @youngbupark in https://github.com/project-radius/radius/pull/5930 -* Add Comments: Part 4 (pkg/cli/cmd...) by @shriraml-ms in https://github.com/project-radius/radius/pull/5834 -* Add 'rad app connections' command by @rynowak in https://github.com/project-radius/radius/pull/5907 -* Add terraform recipes test infra by @rynowak in https://github.com/project-radius/radius/pull/5931 -* Add Comments: Part 14 (pkg/sdk, pkg/algorithm, pkg/middleware, pkg/to) by @shriraml-ms in https://github.com/project-radius/radius/pull/5927 -* Add Comments: Part 16 (pkg/metrics, pkg/trace, pkg/profiler) by @shriraml-ms in https://github.com/project-radius/radius/pull/5938 -* Add Comments: Part 13 (pkg/kube*) by @shriraml-ms in https://github.com/project-radius/radius/pull/5923 -* Use GHCR for container images by @youngbupark in https://github.com/project-radius/radius/pull/5915 -* Remove list output from rad CLI by @AaronCrawfis in https://github.com/project-radius/radius/pull/5945 -* Split Namespace: Applications.Dapr Types by @lakshmimsft in https://github.com/project-radius/radius/pull/5943 -* Update `rad run` port-forwarding logic by @willdavsmith in https://github.com/project-radius/radius/pull/5745 -* Allow functional test to set DE_IMAGE and DE_TAG by @willdavsmith in https://github.com/project-radius/radius/pull/5937 -* Cleanup todos by @vinayada1 in https://github.com/project-radius/radius/pull/5911 -* Fix undefined repo name in functional test run by @willdavsmith in https://github.com/project-radius/radius/pull/5951 -* Add az cli command for purging CDN by @youngbupark in https://github.com/project-radius/radius/pull/5955 -* Clean up sample resource groups and container images in 3 days by @youngbupark in https://github.com/project-radius/radius/pull/5957 -* Fail deployments based on pod status by @vinayada1 in https://github.com/project-radius/radius/pull/5823 -* Add Comments: Part 17 (pkg/daprrp) by @shriraml-ms in https://github.com/project-radius/radius/pull/5940 -* Upgrade all packages to resolve the security vulnerability by @youngbupark in https://github.com/project-radius/radius/pull/5960 -* Add Comments: Part 18 (pkg/messagingrp) by @shriraml-ms in https://github.com/project-radius/radius/pull/5942 -* Update the grafana dashboard to the latest by @youngbupark in https://github.com/project-radius/radius/pull/5965 -* Security vulnerability: Upgrade base container image and packages in magpiego by @youngbupark in https://github.com/project-radius/radius/pull/5966 -* Add functional test for Terraform recipes by @rynowak in https://github.com/project-radius/radius/pull/5939 -* disable pod unschedulable check by @vinayada1 in https://github.com/project-radius/radius/pull/5968 -* Skipping failing AWS tests by @willdavsmith in https://github.com/project-radius/radius/pull/5986 -* Fix DE_IMAGE and DE_TAG not being set by @willdavsmith in https://github.com/project-radius/radius/pull/5970 -* Fix rad debug-logs by @rynowak in https://github.com/project-radius/radius/pull/5989 -* Add TODO comment to enable new discovery client by @youngbupark in https://github.com/project-radius/radius/pull/5975 -* Improve failure reporting in CLI by @rynowak in https://github.com/project-radius/radius/pull/5990 -* Improve test/infra bicep template by @youngbupark in https://github.com/project-radius/radius/pull/5969 -* Add host, port, vhost, username, password, and uri to RabbitMQ resource by @vishwahiremat in https://github.com/project-radius/radius/pull/5863 -* fix multiple bugs with rad credential by @nithyatsu in https://github.com/project-radius/radius/pull/5900 -* Upgrade tool versions for functional tests by @youngbupark in https://github.com/project-radius/radius/pull/5956 -* Add Comments: Part 15 (pkg/recipes, pkg/rp, pkg/resourcemodel, pkg/validator) by @shriraml-ms in https://github.com/project-radius/radius/pull/5933 -* Add Comments: Part 12 (pkg/corerp) by @shriraml-ms in https://github.com/project-radius/radius/pull/5922 -* Generate Terraform Providers Credentials Config by @kachawla in https://github.com/project-radius/radius/pull/5961 -* DaprRP Functional Tests by @lakshmimsft in https://github.com/project-radius/radius/pull/5959 -* Add unit test for JSON Terraform config validation by @kachawla in https://github.com/project-radius/radius/pull/6000 -* Dapr Test Update (dapr_component_name_conflict_test) by @lakshmimsft in https://github.com/project-radius/radius/pull/6011 -* Add container changes to generate a k8s service when it exposes ports. by @farazmsiddiqi in https://github.com/project-radius/radius/pull/5857 -* Lower polling frequency for async operations by @rynowak in https://github.com/project-radius/radius/pull/6019 -* Update `rad init --dev` to be the main experience instead of a flag by @AaronCrawfis in https://github.com/project-radius/radius/pull/5665 -* Display HTTP response body on health check failure by @rynowak in https://github.com/project-radius/radius/pull/6010 -* Add Terraform Recipe functional test by @kachawla in https://github.com/project-radius/radius/pull/6012 -* Add Comments: Part 19 (test/...) by @shriraml-ms in https://github.com/project-radius/radius/pull/5979 -* Populate RecipeContext to Terraform module config by @youngbupark in https://github.com/project-radius/radius/pull/5999 -* Populate missing env namespace in recipe config by @youngbupark in https://github.com/project-radius/radius/pull/6025 -* Use Recipe context to kubernetes redis recipe by @youngbupark in https://github.com/project-radius/radius/pull/6030 -* Add E2E test for Terraform recipe with Azure storage by @kachawla in https://github.com/project-radius/radius/pull/6014 -* Fix TF recipe context test in long-running by @youngbupark in https://github.com/project-radius/radius/pull/6033 -* Standardize cloud provider table labels by @AaronCrawfis in https://github.com/project-radius/radius/pull/6036 -* update gateway for dns functionality by @farazmsiddiqi in https://github.com/project-radius/radius/pull/6024 -* Split Namespace: Applications.Datastores Types by @lakshmimsft in https://github.com/project-radius/radius/pull/6018 -* Enable tutorial test by @rynowak in https://github.com/project-radius/radius/pull/6049 -* Test improvements to AWS functional tests by @willdavsmith in https://github.com/project-radius/radius/pull/6035 -* Fix misuse of log verbosity by @rynowak in https://github.com/project-radius/radius/pull/6050 -* Publish rad cli to GitHub Release by @youngbupark in https://github.com/project-radius/radius/pull/6026 -* Application.Datastores Functional Tests by @lakshmimsft in https://github.com/project-radius/radius/pull/6043 -* Configuring Terraform Driver logs by @ytimocin in https://github.com/project-radius/radius/pull/6037 -* Add check for Bicep filename in `rad app delete` by @AaronCrawfis in https://github.com/project-radius/radius/pull/6039 -* Increase memory limit for applications-rp by @rynowak in https://github.com/project-radius/radius/pull/6067 -* Making template kind a discriminator by @vishwahiremat in https://github.com/project-radius/radius/pull/6029 -* Split Namespace: Applications.Core/extender type update by @lakshmimsft in https://github.com/project-radius/radius/pull/6057 -* Remove imagePullPolicy from being set by @AaronCrawfis in https://github.com/project-radius/radius/pull/6066 -* Fix spelling by @AaronCrawfis in https://github.com/project-radius/radius/pull/6072 -* Add functional tests for Bicep driver by @rynowak in https://github.com/project-radius/radius/pull/6048 -* Update Radius release automation versions file by @willdavsmith in https://github.com/project-radius/radius/pull/5917 -* Fix typo in release script by @willdavsmith in https://github.com/project-radius/radius/pull/6078 -* Update TF Logs Writer by @ytimocin in https://github.com/project-radius/radius/pull/6076 -* Recipe Engine and Driver Metrics by @ytimocin in https://github.com/project-radius/radius/pull/6041 -* Release: 0.24.0-rc1 by @willdavsmith in https://github.com/project-radius/radius/pull/6077 -* Remove Function Explanation heading from comments by @rynowak in https://github.com/project-radius/radius/pull/6075 -* Implement Terraform Recipe Outputs by @kachawla in https://github.com/project-radius/radius/pull/6062 -* Fix failures of GitHub Release by @youngbupark in https://github.com/project-radius/radius/pull/6084 -* Use Kubernetes Secret as backend by @vishwahiremat in https://github.com/project-radius/radius/pull/6038 -* Add the step to publish chart to GHCR by @youngbupark in https://github.com/project-radius/radius/pull/6071 - - -**Full Changelog**: https://github.com/project-radius/radius/compare/v0.23.0...v0.24.0 +* Fix valid radius build window const by @youngbupark in https://github.com/radius-project/radius/pull/5901 +* Release v0.23.0 by @lakshmimsft in https://github.com/radius-project/radius/pull/5902 +* Generate Terraform Providers Config for Supported Required Providers by @kachawla in https://github.com/radius-project/radius/pull/5874 +* Remove deployments plane from Radius by @rynowak in https://github.com/radius-project/radius/pull/5821 +* Add terraform directory to gitignore by @rynowak in https://github.com/radius-project/radius/pull/5908 +* Improve table formatting for multi-line entries by @rynowak in https://github.com/radius-project/radius/pull/5899 +* Correction in docs URL by @lakshmimsft in https://github.com/radius-project/radius/pull/5905 +* Add publishing of terraform recipes for tests by @rynowak in https://github.com/radius-project/radius/pull/5909 +* Document release notes process and add 0.23.0 release notes by @AaronCrawfis in https://github.com/radius-project/radius/pull/5913 +* Skip MongoDB recipe test by @youngbupark in https://github.com/radius-project/radius/pull/5930 +* Add Comments: Part 4 (pkg/cli/cmd...) by @shriraml-ms in https://github.com/radius-project/radius/pull/5834 +* Add 'rad app connections' command by @rynowak in https://github.com/radius-project/radius/pull/5907 +* Add terraform recipes test infra by @rynowak in https://github.com/radius-project/radius/pull/5931 +* Add Comments: Part 14 (pkg/sdk, pkg/algorithm, pkg/middleware, pkg/to) by @shriraml-ms in https://github.com/radius-project/radius/pull/5927 +* Add Comments: Part 16 (pkg/metrics, pkg/trace, pkg/profiler) by @shriraml-ms in https://github.com/radius-project/radius/pull/5938 +* Add Comments: Part 13 (pkg/kube*) by @shriraml-ms in https://github.com/radius-project/radius/pull/5923 +* Use GHCR for container images by @youngbupark in https://github.com/radius-project/radius/pull/5915 +* Remove list output from rad CLI by @AaronCrawfis in https://github.com/radius-project/radius/pull/5945 +* Split Namespace: Applications.Dapr Types by @lakshmimsft in https://github.com/radius-project/radius/pull/5943 +* Update `rad run` port-forwarding logic by @willdavsmith in https://github.com/radius-project/radius/pull/5745 +* Allow functional test to set DE_IMAGE and DE_TAG by @willdavsmith in https://github.com/radius-project/radius/pull/5937 +* Cleanup todos by @vinayada1 in https://github.com/radius-project/radius/pull/5911 +* Fix undefined repo name in functional test run by @willdavsmith in https://github.com/radius-project/radius/pull/5951 +* Add az cli command for purging CDN by @youngbupark in https://github.com/radius-project/radius/pull/5955 +* Clean up sample resource groups and container images in 3 days by @youngbupark in https://github.com/radius-project/radius/pull/5957 +* Fail deployments based on pod status by @vinayada1 in https://github.com/radius-project/radius/pull/5823 +* Add Comments: Part 17 (pkg/daprrp) by @shriraml-ms in https://github.com/radius-project/radius/pull/5940 +* Upgrade all packages to resolve the security vulnerability by @youngbupark in https://github.com/radius-project/radius/pull/5960 +* Add Comments: Part 18 (pkg/messagingrp) by @shriraml-ms in https://github.com/radius-project/radius/pull/5942 +* Update the grafana dashboard to the latest by @youngbupark in https://github.com/radius-project/radius/pull/5965 +* Security vulnerability: Upgrade base container image and packages in magpiego by @youngbupark in https://github.com/radius-project/radius/pull/5966 +* Add functional test for Terraform recipes by @rynowak in https://github.com/radius-project/radius/pull/5939 +* disable pod unschedulable check by @vinayada1 in https://github.com/radius-project/radius/pull/5968 +* Skipping failing AWS tests by @willdavsmith in https://github.com/radius-project/radius/pull/5986 +* Fix DE_IMAGE and DE_TAG not being set by @willdavsmith in https://github.com/radius-project/radius/pull/5970 +* Fix rad debug-logs by @rynowak in https://github.com/radius-project/radius/pull/5989 +* Add TODO comment to enable new discovery client by @youngbupark in https://github.com/radius-project/radius/pull/5975 +* Improve failure reporting in CLI by @rynowak in https://github.com/radius-project/radius/pull/5990 +* Improve test/infra bicep template by @youngbupark in https://github.com/radius-project/radius/pull/5969 +* Add host, port, vhost, username, password, and uri to RabbitMQ resource by @vishwahiremat in https://github.com/radius-project/radius/pull/5863 +* fix multiple bugs with rad credential by @nithyatsu in https://github.com/radius-project/radius/pull/5900 +* Upgrade tool versions for functional tests by @youngbupark in https://github.com/radius-project/radius/pull/5956 +* Add Comments: Part 15 (pkg/recipes, pkg/rp, pkg/resourcemodel, pkg/validator) by @shriraml-ms in https://github.com/radius-project/radius/pull/5933 +* Add Comments: Part 12 (pkg/corerp) by @shriraml-ms in https://github.com/radius-project/radius/pull/5922 +* Generate Terraform Providers Credentials Config by @kachawla in https://github.com/radius-project/radius/pull/5961 +* DaprRP Functional Tests by @lakshmimsft in https://github.com/radius-project/radius/pull/5959 +* Add unit test for JSON Terraform config validation by @kachawla in https://github.com/radius-project/radius/pull/6000 +* Dapr Test Update (dapr_component_name_conflict_test) by @lakshmimsft in https://github.com/radius-project/radius/pull/6011 +* Add container changes to generate a k8s service when it exposes ports. by @farazmsiddiqi in https://github.com/radius-project/radius/pull/5857 +* Lower polling frequency for async operations by @rynowak in https://github.com/radius-project/radius/pull/6019 +* Update `rad init --dev` to be the main experience instead of a flag by @AaronCrawfis in https://github.com/radius-project/radius/pull/5665 +* Display HTTP response body on health check failure by @rynowak in https://github.com/radius-project/radius/pull/6010 +* Add Terraform Recipe functional test by @kachawla in https://github.com/radius-project/radius/pull/6012 +* Add Comments: Part 19 (test/...) by @shriraml-ms in https://github.com/radius-project/radius/pull/5979 +* Populate RecipeContext to Terraform module config by @youngbupark in https://github.com/radius-project/radius/pull/5999 +* Populate missing env namespace in recipe config by @youngbupark in https://github.com/radius-project/radius/pull/6025 +* Use Recipe context to kubernetes redis recipe by @youngbupark in https://github.com/radius-project/radius/pull/6030 +* Add E2E test for Terraform recipe with Azure storage by @kachawla in https://github.com/radius-project/radius/pull/6014 +* Fix TF recipe context test in long-running by @youngbupark in https://github.com/radius-project/radius/pull/6033 +* Standardize cloud provider table labels by @AaronCrawfis in https://github.com/radius-project/radius/pull/6036 +* update gateway for dns functionality by @farazmsiddiqi in https://github.com/radius-project/radius/pull/6024 +* Split Namespace: Applications.Datastores Types by @lakshmimsft in https://github.com/radius-project/radius/pull/6018 +* Enable tutorial test by @rynowak in https://github.com/radius-project/radius/pull/6049 +* Test improvements to AWS functional tests by @willdavsmith in https://github.com/radius-project/radius/pull/6035 +* Fix misuse of log verbosity by @rynowak in https://github.com/radius-project/radius/pull/6050 +* Publish rad cli to GitHub Release by @youngbupark in https://github.com/radius-project/radius/pull/6026 +* Application.Datastores Functional Tests by @lakshmimsft in https://github.com/radius-project/radius/pull/6043 +* Configuring Terraform Driver logs by @ytimocin in https://github.com/radius-project/radius/pull/6037 +* Add check for Bicep filename in `rad app delete` by @AaronCrawfis in https://github.com/radius-project/radius/pull/6039 +* Increase memory limit for applications-rp by @rynowak in https://github.com/radius-project/radius/pull/6067 +* Making template kind a discriminator by @vishwahiremat in https://github.com/radius-project/radius/pull/6029 +* Split Namespace: Applications.Core/extender type update by @lakshmimsft in https://github.com/radius-project/radius/pull/6057 +* Remove imagePullPolicy from being set by @AaronCrawfis in https://github.com/radius-project/radius/pull/6066 +* Fix spelling by @AaronCrawfis in https://github.com/radius-project/radius/pull/6072 +* Add functional tests for Bicep driver by @rynowak in https://github.com/radius-project/radius/pull/6048 +* Update Radius release automation versions file by @willdavsmith in https://github.com/radius-project/radius/pull/5917 +* Fix typo in release script by @willdavsmith in https://github.com/radius-project/radius/pull/6078 +* Update TF Logs Writer by @ytimocin in https://github.com/radius-project/radius/pull/6076 +* Recipe Engine and Driver Metrics by @ytimocin in https://github.com/radius-project/radius/pull/6041 +* Release: 0.24.0-rc1 by @willdavsmith in https://github.com/radius-project/radius/pull/6077 +* Remove Function Explanation heading from comments by @rynowak in https://github.com/radius-project/radius/pull/6075 +* Implement Terraform Recipe Outputs by @kachawla in https://github.com/radius-project/radius/pull/6062 +* Fix failures of GitHub Release by @youngbupark in https://github.com/radius-project/radius/pull/6084 +* Use Kubernetes Secret as backend by @vishwahiremat in https://github.com/radius-project/radius/pull/6038 +* Add the step to publish chart to GHCR by @youngbupark in https://github.com/radius-project/radius/pull/6071 + + +**Full Changelog**: https://github.com/radius-project/radius/compare/v0.23.0...v0.24.0 diff --git a/docs/ucp/aws.md b/docs/ucp/aws.md index dda809aa63..ef855b5430 100644 --- a/docs/ucp/aws.md +++ b/docs/ucp/aws.md @@ -61,4 +61,4 @@ Many AWS resources have a generated name and the resource schema does not necess To address this issue, we will introduce state storage in UCP. The user will specify a friendly name for the resource in the bicep file that is unique in the deployment scope (which will be the Radius resource group). UCP will create a mapping between the friendly name and the actual AWS resource deployed. After this point, UCP will use this mapping to determine if the resource with the particular friendly name is being created or updated. -The details of this design can be found at: https://microsoft.sharepoint.com/:w:/t/radiuscoreteam/Ef0J0DM89-1Foyb36i4_a_EBn4zW61Dk8paVfJ9p9RUDOg?e=9tnaV1 +The details of this design can be found at: https://github.com/radius-project/design-notes/pull/21 diff --git a/docs/ucp/configuration.md b/docs/ucp/configuration.md index 0ff8ee7715..71965c1f2b 100644 --- a/docs/ucp/configuration.md +++ b/docs/ucp/configuration.md @@ -4,4 +4,4 @@ UCP is configured to communicate with the different planes that it supports, cur The configuration can be found in: deploy/Chart/charts/ucp/ucp-config.yaml. -Within each plane, the configuration specifies a URL to communicate with every supported resource provider. For example, separate URLs are specified for Applications.Core and Applications.Link providers within the Radius plane. +Within each plane, the configuration specifies a URL to communicate with every supported resource provider. For example, separate URLs are specified for Applications.Core and portable resource providers within the Radius plane. diff --git a/docs/ucp/references.md b/docs/ucp/references.md deleted file mode 100644 index 5a758899f2..0000000000 --- a/docs/ucp/references.md +++ /dev/null @@ -1,9 +0,0 @@ -## References - -[UCP Summary](https://microsoft.sharepoint.com/:w:/r/teams/radiuscoreteam/_layouts/15/Doc.aspx?sourcedoc=%7B00979177-9BF7-4D93-A730-B1CC5AB55E3E%7D&file=2022-04%20UCP%20Summary.docx&action=default&mobileredirect=true&share=IQF3kZcA95uTTacwscxatV4-AVk2opS7WrAGFzv-sQ0k0Do) - -[UCP Vision](https://microsoft.sharepoint.com/:w:/r/teams/radiuscoreteam/_layouts/15/Doc.aspx?sourcedoc=%7B217B9C83-6D8D-47EC-AFDE-537FC1A20D27%7D&file=2022-04-01%20UCP%20Vision.docx&action=default&mobileredirect=true&share=IQGDnHshjW3sR6_eU3_Bog0nAfOFmzuio1X1alZMQvxukxU) - -[AWS Non-Idempotency Design](https://microsoft-my.sharepoint.com/:w:/p/willsmith/EWqUj9lGHL9Dk4s6aGfXVmQB0K9JicgimbP1gw8QRoAtiQ?e=TJvOhw) - -[UCP Credentials Design](https://microsoft.sharepoint.com/:w:/t/radiuscoreteam/EVAuQrRK6tRIqiOZmjnyxjoBUfaa2jF2uiV-jhibg5qB5A?e=2t2hef) \ No newline at end of file diff --git a/docs/ucp/resources.md b/docs/ucp/resources.md index af4001a948..8df4aaf6bb 100644 --- a/docs/ucp/resources.md +++ b/docs/ucp/resources.md @@ -8,4 +8,4 @@ UCP uses a Plane resource to support ids that come from different types of syste A resource group is used to organize user resources. Note that even though conceptually this is similar to an Azure resource group but it is not the same and is a UCP resource independent of Azure. ### Credentials -A user can configure provider credentials in UCP. Currently Azure and AWS credentials are supported. Please refer to [Credential Design Document](https://microsoft.sharepoint.com/:w:/t/radiuscoreteam/EVAuQrRK6tRIqiOZmjnyxjoBUfaa2jF2uiV-jhibg5qB5A?e=2t2hef) for details. +A user can configure provider credentials in UCP. Currently Azure and AWS credentials are supported and can be managed using "rad credential" CLI commands. diff --git a/go.mod b/go.mod index f5f0142375..213c5e4731 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/project-radius/radius +module github.com/radius-project/radius go 1.21 @@ -67,7 +67,6 @@ require ( github.com/wI2L/jsondiff v0.2.0 go.etcd.io/etcd/client/v3 v3.5.9 go.etcd.io/etcd/server/v3 v3.5.9 - go.mongodb.org/mongo-driver v1.12.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 go.opentelemetry.io/otel v1.16.0 @@ -98,6 +97,7 @@ require ( github.com/tidwall/gjson v1.14.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect + go.mongodb.org/mongo-driver v1.12.0 // indirect ) require ( diff --git a/grafana/radius-resource-provider-dashboard.json b/grafana/radius-resource-provider-dashboard.json index 71033d1169..334ac2d942 100644 --- a/grafana/radius-resource-provider-dashboard.json +++ b/grafana/radius-resource-provider-dashboard.json @@ -24,7 +24,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 42, + "id": 43, "links": [], "liveNow": false, "panels": [ @@ -482,15 +482,13 @@ "justifyMode": "auto", "orientation": "auto", "reduceOptions": { - "calcs": [ - "last" - ], + "calcs": ["last"], "fields": "", "values": false }, "textMode": "auto" }, - "pluginVersion": "9.4.12", + "pluginVersion": "9.5.6", "targets": [ { "datasource": { @@ -547,16 +545,14 @@ "options": { "orientation": "auto", "reduceOptions": { - "calcs": [ - "min" - ], + "calcs": ["min"], "fields": "", "values": false }, "showThresholdLabels": false, "showThresholdMarkers": true }, - "pluginVersion": "9.4.12", + "pluginVersion": "9.5.6", "targets": [ { "datasource": { @@ -903,7 +899,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] }, @@ -920,11 +917,7 @@ "id": 27, "options": { "legend": { - "calcs": [ - "min", - "max", - "mean" - ], + "calcs": ["min", "max", "mean"], "displayMode": "table", "placement": "bottom", "showLegend": true @@ -1036,7 +1029,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] }, @@ -1125,7 +1119,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] }, @@ -1142,11 +1137,7 @@ "id": 41, "options": { "legend": { - "calcs": [ - "min", - "max", - "mean" - ], + "calcs": ["min", "max", "mean"], "displayMode": "table", "placement": "bottom", "showLegend": true @@ -1219,7 +1210,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1240,10 +1232,7 @@ "id": 21, "options": { "legend": { - "calcs": [ - "min", - "max" - ], + "calcs": ["min", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true @@ -1339,7 +1328,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] }, @@ -1353,13 +1343,10 @@ "x": 12, "y": 42 }, - "id": 22, + "id": 51, "options": { "legend": { - "calcs": [ - "min", - "max" - ], + "calcs": ["min", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true @@ -1387,6 +1374,770 @@ ], "title": "Job execution time (p99) per operation", "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 51 + }, + "id": 42, + "panels": [], + "title": "Recipe Engine", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 99.5 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 6, + "x": 0, + "y": 52 + }, + "id": 43, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["max"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "9.5.6", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "expr": "sum(rate(recipe_operation_duration_count{operation_state=\"success\"}[$__rate_interval])) / sum(rate(recipe_operation_duration_count[$__rate_interval])) * 100", + "legendFormat": "__auto", + "range": true, + "refId": "A" + } + ], + "title": "Availability", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 9, + "x": 6, + "y": 52 + }, + "id": 44, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "expr": "sum(rate(recipe_operation_duration_count{}[$__rate_interval]))", + "hide": false, + "interval": "", + "legendFormat": "Incoming Requests", + "range": true, + "refId": "A" + } + ], + "title": "Incoming Requests per Second", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 9, + "x": 15, + "y": 52 + }, + "id": 45, + "options": { + "legend": { + "calcs": ["mean"], + "displayMode": "table", + "placement": "right", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "sum(rate(recipe_operation_duration_count{}[$__rate_interval])) by (recipe_driver, operation_type)", + "hide": false, + "interval": "", + "legendFormat": "{{recipe_driver}} | {{operation_type}}", + "range": true, + "refId": "A" + } + ], + "title": "Incoming Requests per Second by Driver and Operation Type", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 59 + }, + "id": 22, + "options": { + "legend": { + "calcs": ["min", "max"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "histogram_quantile(0.99, sum by (le, recipe_driver, operation_type, resource_type)(rate(recipe_operation_duration_bucket{operation_state=\"success\"}[$__rate_interval])))", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "{{recipe_driver}} | {{operation_type}} | {{resource_type}}", + "range": true, + "refId": "A" + } + ], + "title": "P99 Recipe Execution Time by [Driver - Operation Type - Resource Type]", + "transformations": [], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "description": "This graph tells us how long it takes to execute a recipe on average.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 59 + }, + "id": 48, + "options": { + "legend": { + "calcs": ["min", "max"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": false + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "histogram_quantile(0.99, sum by (le, recipe_template_path)(rate(recipe_operation_duration_bucket{operation_state=\"success\"}[$__rate_interval])))", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "{{recipe_template_path}}", + "range": true, + "refId": "A" + } + ], + "title": "P99 Recipe Execution Time by [Template Path]", + "transformations": [ + { + "id": "filterByRefId", + "options": { + "include": "" + } + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "series", + "axisLabel": "Failure Rate", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 14, + "w": 12, + "x": 0, + "y": 70 + }, + "id": 47, + "options": { + "legend": { + "calcs": ["min", "max"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "exemplar": false, + "expr": "(sum(rate(recipe_operation_duration_count{operation_state!=\"success\"}[$__rate_interval])) by (recipe_template_path, operation_type)) / (sum(rate(recipe_operation_duration_count[$__rate_interval])) by (recipe_template_path, operation_type))", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "{{recipe_template_path}} | {{operation_type}}", + "range": true, + "refId": "A" + } + ], + "title": "Failure Rate by Template Path and Operation Type", + "transformations": [], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 70 + }, + "id": 50, + "options": { + "legend": { + "calcs": ["min", "max"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "histogram_quantile(0.99, sum by (le)(rate(recipe_tf_init_duration_bucket{operation_state=\"success\"}[$__rate_interval])))", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "TF Init", + "range": true, + "refId": "A" + } + ], + "title": "P99 Terraform Initialization Duration", + "transformations": [ + { + "id": "filterByRefId", + "options": { + "include": "" + } + } + ], + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 77 + }, + "id": 49, + "options": { + "legend": { + "calcs": ["min", "max"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Max", + "sortDesc": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DATA_SOURCE}" + }, + "editorMode": "code", + "exemplar": true, + "expr": "histogram_quantile(0.99, sum by (le, terraform_version)(rate(recipe_tf_installation_duration_bucket{operation_state=\"success\"}[$__rate_interval])))", + "format": "time_series", + "instant": false, + "interval": "", + "legendFormat": "{{terraform_version}}", + "range": true, + "refId": "A" + } + ], + "title": "P99 Terraform Installation Duration", + "transformations": [], + "type": "timeseries" } ], "refresh": "10s", @@ -1425,13 +2176,13 @@ ] }, "time": { - "from": "now-30m", + "from": "now-3h", "to": "now" }, "timepicker": {}, "timezone": "utc", "title": "Radius Resource Provider", "uid": "Qw-xtsxVz", - "version": 2, + "version": 20, "weekStart": "" -} \ No newline at end of file +} diff --git a/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.json b/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.json index 2fdf52671f..b6cbae045f 100644 --- a/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.json +++ b/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.json @@ -1 +1 @@ -[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Core/environments"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/environments","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":22,"Flags":1,"Description":"Application environment properties"},"tags":{"Type":54,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":16,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":21,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[12,13,14,15]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[17,18,19,20]}},{"2":{"Name":"EnvironmentProperties","Properties":{"provisioningState":{"Type":30,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"compute":{"Type":31,"Flags":1,"Description":"Compute resource used by application environment resource."},"providers":{"Type":38,"Flags":0,"Description":"Cloud providers configuration"},"recipes":{"Type":47,"Flags":0,"Description":"Specifies Recipes linked to the Environment."},"extensions":{"Type":53,"Flags":0,"Description":"Extensions spec of the resource"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[23,24,25,26,27,28,29]}},{"7":{"Name":"EnvironmentCompute","Discriminator":"kind","BaseProperties":{"resourceId":{"Type":4,"Flags":0,"Description":"The resource id of the compute resource for application environment."},"identity":{"Type":32,"Flags":0}},"Elements":{"kubernetes":36}}},{"2":{"Name":"IdentitySettings","Properties":{"kind":{"Type":35,"Flags":1,"Description":"Configuration for supported external identity providers"},"oidcIssuer":{"Type":4,"Flags":0,"Description":"The URI for your compute platform's OIDC issuer"},"resource":{"Type":4,"Flags":0,"Description":"The resource ID of the provisioned identity"}}}},{"6":{"Value":"undefined"}},{"6":{"Value":"azure.com.workload"}},{"5":{"Elements":[33,34]}},{"2":{"Name":"KubernetesCompute","Properties":{"namespace":{"Type":4,"Flags":1,"Description":"The namespace to use for the environment."},"kind":{"Type":37,"Flags":1,"Description":"Type of compute resource."}}}},{"6":{"Value":"kubernetes"}},{"2":{"Name":"Providers","Properties":{"azure":{"Type":39,"Flags":0,"Description":"Azure cloud provider configuration"},"aws":{"Type":40,"Flags":0,"Description":"AWS cloud provider configuration"}}}},{"2":{"Name":"ProvidersAzure","Properties":{"scope":{"Type":4,"Flags":0,"Description":"Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup'"}}}},{"2":{"Name":"ProvidersAws","Properties":{"scope":{"Type":4,"Flags":0,"Description":"Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2'"}}}},{"7":{"Name":"EnvironmentRecipeProperties","Discriminator":"templateKind","BaseProperties":{"templatePath":{"Type":4,"Flags":1,"Description":"Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported."},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}},"Elements":{"bicep":42,"terraform":44}}},{"2":{"Name":"BicepRecipeProperties","Properties":{"templateKind":{"Type":43,"Flags":1,"Description":"Format of the template provided by the recipe. Allowed values: bicep, terraform."}}}},{"6":{"Value":"bicep"}},{"2":{"Name":"TerraformRecipeProperties","Properties":{"templateVersion":{"Type":4,"Flags":0,"Description":"Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources."},"templateKind":{"Type":45,"Flags":1,"Description":"Format of the template provided by the recipe. Allowed values: bicep, terraform."}}}},{"6":{"Value":"terraform"}},{"2":{"Name":"DictionaryOfEnvironmentRecipeProperties","Properties":{},"AdditionalProperties":41}},{"2":{"Name":"EnvironmentPropertiesRecipes","Properties":{},"AdditionalProperties":46}},{"7":{"Name":"EnvironmentExtension","Discriminator":"kind","BaseProperties":{},"Elements":{"kubernetesMetadata":49}}},{"2":{"Name":"EnvironmentKubernetesMetadataExtension","Properties":{"annotations":{"Type":50,"Flags":0,"Description":"Annotations to be applied to the Kubernetes resources output by the resource"},"labels":{"Type":51,"Flags":0,"Description":"Labels to be applied to the Kubernetes resources output by the resource"},"kind":{"Type":52,"Flags":1,"Description":"Specifies the extensions of a resource."}}}},{"2":{"Name":"EnvironmentKubernetesMetadataExtensionAnnotations","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"EnvironmentKubernetesMetadataExtensionLabels","Properties":{},"AdditionalProperties":4}},{"6":{"Value":"kubernetesMetadata"}},{"3":{"ItemType":48}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/environments@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"6":{"Value":"Applications.Core/applications"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/applications","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":56,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":57,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":59,"Flags":1,"Description":"Application properties"},"tags":{"Type":78,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"ApplicationProperties","Properties":{"provisioningState":{"Type":67,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"environment":{"Type":4,"Flags":1,"Description":"The resource id of the environment linked to application."},"extensions":{"Type":75,"Flags":0,"Description":"Extensions spec of the resource"},"status":{"Type":76,"Flags":2,"Description":"Status of a resource."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[60,61,62,63,64,65,66]}},{"7":{"Name":"ApplicationExtension","Discriminator":"kind","BaseProperties":{},"Elements":{"kubernetesMetadata":69,"kubernetesNamespace":73}}},{"2":{"Name":"ApplicationKubernetesMetadataExtension","Properties":{"annotations":{"Type":70,"Flags":0,"Description":"Annotations to be applied to the Kubernetes resources output by the resource"},"labels":{"Type":71,"Flags":0,"Description":"Labels to be applied to the Kubernetes resources output by the resource"},"kind":{"Type":72,"Flags":1,"Description":"Specifies the extensions of a resource."}}}},{"2":{"Name":"ApplicationKubernetesMetadataExtensionAnnotations","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"ApplicationKubernetesMetadataExtensionLabels","Properties":{},"AdditionalProperties":4}},{"6":{"Value":"kubernetesMetadata"}},{"2":{"Name":"ApplicationKubernetesNamespaceExtension","Properties":{"namespace":{"Type":4,"Flags":1,"Description":"The Kubernetes namespace to use for this application."},"kind":{"Type":74,"Flags":1,"Description":"Specifies the extensions of a resource."}}}},{"6":{"Value":"kubernetesNamespace"}},{"3":{"ItemType":68}},{"2":{"Name":"ResourceStatus","Properties":{"compute":{"Type":31,"Flags":0,"Description":"Compute resource used by application environment resource."},"outputResources":{"Type":77,"Flags":0,"Description":"Array of AnyObject"}}}},{"3":{"ItemType":0}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/applications@2022-03-15-privatepreview","ScopeType":0,"Body":58}},{"6":{"Value":"Applications.Core/httpRoutes"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/httpRoutes","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":80,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":81,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":83,"Flags":1,"Description":"HTTP Route properties"},"tags":{"Type":92,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"HttpRouteProperties","Properties":{"provisioningState":{"Type":91,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"hostname":{"Type":4,"Flags":0,"Description":"The internal hostname accepting traffic for the HTTP Route. Readonly."},"port":{"Type":3,"Flags":0,"Description":"The port number for the HTTP Route. Defaults to 80. Readonly."},"scheme":{"Type":4,"Flags":0,"Description":"The scheme used for traffic. Readonly."},"url":{"Type":4,"Flags":0,"Description":"A stable URL that that can be used to route traffic to a resource. Readonly."},"status":{"Type":76,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":0,"Description":"The resource id of the environment linked to the resource"},"application":{"Type":4,"Flags":1,"Description":"Specifies the resource id of the application"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[84,85,86,87,88,89,90]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/httpRoutes@2022-03-15-privatepreview","ScopeType":0,"Body":82}},{"6":{"Value":"Applications.Core/gateways"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/gateways","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":94,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":95,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":97,"Flags":1,"Description":"Gateway properties"},"tags":{"Type":113,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"GatewayProperties","Properties":{"provisioningState":{"Type":105,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"internal":{"Type":2,"Flags":0,"Description":"Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet)."},"hostname":{"Type":106,"Flags":0,"Description":"Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io."},"tls":{"Type":107,"Flags":0,"Description":"TLS configuration for the Gateway."},"routes":{"Type":112,"Flags":1,"Description":"Routes attached to this Gateway"},"url":{"Type":4,"Flags":2,"Description":"URL of the gateway resource. Readonly."},"status":{"Type":76,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":0,"Description":"The resource id of the environment linked to the resource"},"application":{"Type":4,"Flags":1,"Description":"Specifies the resource id of the application"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[98,99,100,101,102,103,104]}},{"2":{"Name":"GatewayPropertiesHostname","Properties":{"prefix":{"Type":4,"Flags":0,"Description":"Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined."},"fullyQualifiedHostname":{"Type":4,"Flags":0,"Description":"Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined."}}}},{"2":{"Name":"GatewayPropertiesTls","Properties":{"sslPassthrough":{"Type":2,"Flags":0,"Description":"If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption."},"minimumProtocolVersion":{"Type":110,"Flags":0,"Description":"TLS minimum protocol version (defaults to 1.2)."},"certificateFrom":{"Type":4,"Flags":0,"Description":"Declares which Kubernetes TLS secret will be used."}}}},{"6":{"Value":"1.2"}},{"6":{"Value":"1.3"}},{"5":{"Elements":[108,109]}},{"2":{"Name":"GatewayRoute","Properties":{"path":{"Type":4,"Flags":0,"Description":"The path to match the incoming request path on. Ex - /myservice."},"destination":{"Type":4,"Flags":0,"Description":"The HttpRoute to route to. Ex - myserviceroute.id."},"replacePrefix":{"Type":4,"Flags":0,"Description":"Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute'"}}}},{"3":{"ItemType":111}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/gateways@2022-03-15-privatepreview","ScopeType":0,"Body":96}},{"6":{"Value":"Applications.Core/containers"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/containers","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":115,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":116,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":118,"Flags":1,"Description":"Container properties"},"tags":{"Type":178,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"ContainerProperties","Properties":{"provisioningState":{"Type":126,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"connections":{"Type":131,"Flags":0,"Description":"Dictionary of "},"container":{"Type":132,"Flags":1,"Description":"Definition of a container."},"identity":{"Type":32,"Flags":0},"extensions":{"Type":177,"Flags":0,"Description":"Extensions spec of the resource"},"status":{"Type":76,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":0,"Description":"The resource id of the environment linked to the resource"},"application":{"Type":4,"Flags":1,"Description":"Specifies the resource id of the application"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[119,120,121,122,123,124,125]}},{"2":{"Name":"ConnectionProperties","Properties":{"source":{"Type":4,"Flags":1,"Description":"The source of the connection"},"disableDefaultEnvVars":{"Type":2,"Flags":0},"iam":{"Type":128,"Flags":0,"Description":"The properties of IAM"}}}},{"2":{"Name":"IamProperties","Properties":{"kind":{"Type":129,"Flags":1,"Description":"The kind of IAM provider to configure"},"roles":{"Type":130,"Flags":0,"Description":"RBAC permissions to be assigned on the source resource"}}}},{"6":{"Value":"azure"}},{"3":{"ItemType":4}},{"2":{"Name":"ContainerPropertiesConnections","Properties":{},"AdditionalProperties":127}},{"2":{"Name":"Container","Properties":{"image":{"Type":4,"Flags":1,"Description":"The registry and image to download and run in your container"},"env":{"Type":133,"Flags":0,"Description":"Dictionary of "},"ports":{"Type":140,"Flags":0,"Description":"Dictionary of "},"readinessProbe":{"Type":141,"Flags":0,"Description":"Properties for readiness/liveness probe"},"livenessProbe":{"Type":141,"Flags":0,"Description":"Properties for readiness/liveness probe"},"volumes":{"Type":160,"Flags":0,"Description":"Dictionary of "},"command":{"Type":161,"Flags":0,"Description":"Entrypoint array. Overrides the container image's ENTRYPOINT"},"args":{"Type":162,"Flags":0,"Description":"Arguments to the entrypoint. Overrides the container image's CMD"},"workingDir":{"Type":4,"Flags":0,"Description":"Working directory for the container"}}}},{"2":{"Name":"ContainerEnv","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"ContainerPort","Properties":{"containerPort":{"Type":3,"Flags":1,"Description":"The listening port number"},"protocol":{"Type":139,"Flags":0,"Description":"Protocol in use by the port"},"provides":{"Type":4,"Flags":0,"Description":"Specifies a route provided by this port"},"scheme":{"Type":4,"Flags":0,"Description":"Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value."},"port":{"Type":3,"Flags":0,"Description":"Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired."}}}},{"6":{"Value":"TCP"}},{"6":{"Value":"UDP"}},{"6":{"Value":"http"}},{"6":{"Value":"grpc"}},{"5":{"Elements":[135,136,137,138]}},{"2":{"Name":"ContainerPorts","Properties":{},"AdditionalProperties":134}},{"7":{"Name":"HealthProbeProperties","Discriminator":"kind","BaseProperties":{"initialDelaySeconds":{"Type":3,"Flags":0,"Description":"Initial delay in seconds before probing for readiness/liveness"},"failureThreshold":{"Type":3,"Flags":0,"Description":"Threshold number of times the probe fails after which a failure would be reported"},"periodSeconds":{"Type":3,"Flags":0,"Description":"Interval for the readiness/liveness probe in seconds"},"timeoutSeconds":{"Type":3,"Flags":0,"Description":"Number of seconds after which the readiness/liveness probe times out. Defaults to 5 seconds"}},"Elements":{"exec":142,"httpGet":144,"tcp":147}}},{"2":{"Name":"ExecHealthProbeProperties","Properties":{"command":{"Type":4,"Flags":1,"Description":"Command to execute to probe readiness/liveness"},"kind":{"Type":143,"Flags":1,"Description":"The HealthProbeProperties kind"}}}},{"6":{"Value":"exec"}},{"2":{"Name":"HttpGetHealthProbeProperties","Properties":{"containerPort":{"Type":3,"Flags":1,"Description":"The listening port number"},"path":{"Type":4,"Flags":1,"Description":"The route to make the HTTP request on"},"headers":{"Type":145,"Flags":0,"Description":"Custom HTTP headers to add to the get request"},"kind":{"Type":146,"Flags":1,"Description":"The HealthProbeProperties kind"}}}},{"2":{"Name":"HttpGetHealthProbePropertiesHeaders","Properties":{},"AdditionalProperties":4}},{"6":{"Value":"httpGet"}},{"2":{"Name":"TcpHealthProbeProperties","Properties":{"containerPort":{"Type":3,"Flags":1,"Description":"The listening port number"},"kind":{"Type":148,"Flags":1,"Description":"The HealthProbeProperties kind"}}}},{"6":{"Value":"tcp"}},{"7":{"Name":"Volume","Discriminator":"kind","BaseProperties":{"mountPath":{"Type":4,"Flags":0,"Description":"The path where the volume is mounted"}},"Elements":{"ephemeral":150,"persistent":155}}},{"2":{"Name":"EphemeralVolume","Properties":{"managedStore":{"Type":153,"Flags":1,"Description":"Backing store for the ephemeral volume"},"kind":{"Type":154,"Flags":1,"Description":"The Volume kind"}}}},{"6":{"Value":"memory"}},{"6":{"Value":"disk"}},{"5":{"Elements":[151,152]}},{"6":{"Value":"ephemeral"}},{"2":{"Name":"PersistentVolume","Properties":{"permission":{"Type":158,"Flags":0,"Description":"Container read/write access to the volume"},"source":{"Type":4,"Flags":1,"Description":"The source of the volume"},"kind":{"Type":159,"Flags":1,"Description":"The Volume kind"}}}},{"6":{"Value":"read"}},{"6":{"Value":"write"}},{"5":{"Elements":[156,157]}},{"6":{"Value":"persistent"}},{"2":{"Name":"ContainerVolumes","Properties":{},"AdditionalProperties":149}},{"3":{"ItemType":4}},{"3":{"ItemType":4}},{"7":{"Name":"ContainerExtension","Discriminator":"kind","BaseProperties":{},"Elements":{"daprSidecar":164,"kubernetesMetadata":171,"manualScaling":175}}},{"2":{"Name":"DaprSidecarExtension","Properties":{"appPort":{"Type":3,"Flags":0,"Description":"The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar."},"appId":{"Type":4,"Flags":1,"Description":"The Dapr appId. Specifies the identifier used by Dapr for service invocation."},"config":{"Type":4,"Flags":0,"Description":"Specifies the Dapr configuration to use for the resource."},"protocol":{"Type":169,"Flags":0,"Description":"Protocol in use by the port"},"kind":{"Type":170,"Flags":1,"Description":"Specifies the extensions of a resource."}}}},{"6":{"Value":"TCP"}},{"6":{"Value":"UDP"}},{"6":{"Value":"http"}},{"6":{"Value":"grpc"}},{"5":{"Elements":[165,166,167,168]}},{"6":{"Value":"daprSidecar"}},{"2":{"Name":"ContainerKubernetesMetadataExtension","Properties":{"annotations":{"Type":172,"Flags":0,"Description":"Annotations to be applied to the Kubernetes resources output by the resource"},"labels":{"Type":173,"Flags":0,"Description":"Labels to be applied to the Kubernetes resources output by the resource"},"kind":{"Type":174,"Flags":1,"Description":"Specifies the extensions of a resource."}}}},{"2":{"Name":"ContainerKubernetesMetadataExtensionAnnotations","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"ContainerKubernetesMetadataExtensionLabels","Properties":{},"AdditionalProperties":4}},{"6":{"Value":"kubernetesMetadata"}},{"2":{"Name":"ManualScalingExtension","Properties":{"replicas":{"Type":3,"Flags":0,"Description":"Replica count."},"kind":{"Type":176,"Flags":1,"Description":"Specifies the extensions of a resource."}}}},{"6":{"Value":"manualScaling"}},{"3":{"ItemType":163}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/containers@2022-03-15-privatepreview","ScopeType":0,"Body":117}},{"6":{"Value":"Applications.Core/volumes"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/volumes","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":180,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":181,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":183,"Flags":1},"tags":{"Type":215,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"7":{"Name":"VolumeProperties","Discriminator":"kind","BaseProperties":{"provisioningState":{"Type":191,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"status":{"Type":76,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":0,"Description":"The resource id of the environment linked to the resource"},"application":{"Type":4,"Flags":1,"Description":"Specifies the resource id of the application"}},"Elements":{"azure.com.keyvault":192}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[184,185,186,187,188,189,190]}},{"2":{"Name":"AzureKeyVaultVolumeProperties","Properties":{"certificates":{"Type":205,"Flags":0,"Description":"The KeyVault certificates that this volume exposes"},"keys":{"Type":207,"Flags":0,"Description":"The KeyVault keys that this volume exposes"},"resource":{"Type":4,"Flags":1,"Description":"The ID of the keyvault to use for this volume resource"},"secrets":{"Type":213,"Flags":0,"Description":"The KeyVault secrets that this volume exposes"},"kind":{"Type":214,"Flags":1,"Description":"The volume kind"}}}},{"2":{"Name":"CertificateObjectProperties","Properties":{"alias":{"Type":4,"Flags":0,"Description":"File name when written to disk."},"encoding":{"Type":197,"Flags":0,"Description":"Encoding format. Default utf-8"},"format":{"Type":200,"Flags":0,"Description":"Certificate format. Default pem"},"name":{"Type":4,"Flags":1,"Description":"The name of the certificate"},"certType":{"Type":204,"Flags":0,"Description":"Certificate object type to be downloaded - the certificate itself, private key or public key of the certificate"},"version":{"Type":4,"Flags":0,"Description":"Certificate version"}}}},{"6":{"Value":"utf-8"}},{"6":{"Value":"hex"}},{"6":{"Value":"base64"}},{"5":{"Elements":[194,195,196]}},{"6":{"Value":"pem"}},{"6":{"Value":"pfx"}},{"5":{"Elements":[198,199]}},{"6":{"Value":"certificate"}},{"6":{"Value":"publickey"}},{"6":{"Value":"privatekey"}},{"5":{"Elements":[201,202,203]}},{"2":{"Name":"AzureKeyVaultVolumePropertiesCertificates","Properties":{},"AdditionalProperties":193}},{"2":{"Name":"KeyObjectProperties","Properties":{"alias":{"Type":4,"Flags":0,"Description":"File name when written to disk."},"name":{"Type":4,"Flags":1,"Description":"The name of the key"},"version":{"Type":4,"Flags":0,"Description":"Key version"}}}},{"2":{"Name":"AzureKeyVaultVolumePropertiesKeys","Properties":{},"AdditionalProperties":206}},{"2":{"Name":"SecretObjectProperties","Properties":{"alias":{"Type":4,"Flags":0,"Description":"File name when written to disk."},"encoding":{"Type":212,"Flags":0,"Description":"Encoding format. Default utf-8"},"name":{"Type":4,"Flags":1,"Description":"The name of the secret"},"version":{"Type":4,"Flags":0,"Description":"Secret version"}}}},{"6":{"Value":"utf-8"}},{"6":{"Value":"hex"}},{"6":{"Value":"base64"}},{"5":{"Elements":[209,210,211]}},{"2":{"Name":"AzureKeyVaultVolumePropertiesSecrets","Properties":{},"AdditionalProperties":208}},{"6":{"Value":"azure.com.keyvault"}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/volumes@2022-03-15-privatepreview","ScopeType":0,"Body":182}},{"6":{"Value":"Applications.Core/secretStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/secretStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":217,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":218,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":220,"Flags":1},"tags":{"Type":238,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"SecretStoreProperties","Properties":{"provisioningState":{"Type":228,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"type":{"Type":231,"Flags":0,"Description":"The type of secret store data"},"data":{"Type":237,"Flags":1,"Description":"An object to represent key-value type secrets"},"resource":{"Type":4,"Flags":0,"Description":"The resource id of external secret store."},"status":{"Type":76,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":0,"Description":"The resource id of the environment linked to the resource"},"application":{"Type":4,"Flags":1,"Description":"Specifies the resource id of the application"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[221,222,223,224,225,226,227]}},{"6":{"Value":"generic"}},{"6":{"Value":"certificate"}},{"5":{"Elements":[229,230]}},{"2":{"Name":"SecretValueProperties","Properties":{"encoding":{"Type":235,"Flags":0,"Description":"The encoding of value"},"value":{"Type":4,"Flags":0,"Description":"The value of secret."},"valueFrom":{"Type":236,"Flags":0}}}},{"6":{"Value":"raw"}},{"6":{"Value":"base64"}},{"5":{"Elements":[233,234]}},{"2":{"Name":"ValueFromProperties","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the referenced secret."},"version":{"Type":4,"Flags":0,"Description":"The version of the referenced secret."}}}},{"2":{"Name":"SecretStorePropertiesData","Properties":{},"AdditionalProperties":232}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/secretStores@2022-03-15-privatepreview","ScopeType":0,"Body":219}},{"6":{"Value":"Applications.Core/extenders"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/extenders","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":240,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":241,"Flags":10,"Description":"The resource api version"},"systemData":{"Type":11,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."},"properties":{"Type":243,"Flags":1,"Description":"Extender portable resource properties."},"tags":{"Type":257,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"}}}},{"2":{"Name":"ExtenderProperties","Properties":{"provisioningState":{"Type":251,"Flags":2,"Description":"Provisioning state of the resource at the time the operation was called."},"secrets":{"Type":252,"Flags":0,"Description":"The secret values for the given Extender portable resource."},"resourceProvisioning":{"Type":255,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"recipe":{"Type":256,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource."},"status":{"Type":76,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"The resource id of the environment linked to the resource"},"application":{"Type":4,"Flags":0,"Description":"Specifies the resource id of the application"}},"AdditionalProperties":0}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Accepted"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Provisioning"}},{"5":{"Elements":[244,245,246,247,248,249,250]}},{"2":{"Name":"ExtenderSecrets","Properties":{},"AdditionalProperties":0}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[253,254]}},{"2":{"Name":"ResourceRecipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use."},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/extenders@2022-03-15-privatepreview","ScopeType":0,"Body":242}},{"2":{"Name":"SecretStoreListSecretsResult","Properties":{"type":{"Type":262,"Flags":2,"Description":"The type of secret store data"},"data":{"Type":263,"Flags":2,"Description":"An object to represent key-value type secrets"}}}},{"6":{"Value":"generic"}},{"6":{"Value":"certificate"}},{"5":{"Elements":[260,261]}},{"2":{"Name":"SecretStoreListSecretsResultData","Properties":{},"AdditionalProperties":232}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Core/secretStores","ApiVersion":"2022-03-15-privatepreview","Output":259}},{"2":{"Name":"ExtenderSecrets","Properties":{},"AdditionalProperties":0}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Core/extenders","ApiVersion":"2022-03-15-privatepreview","Output":265}}] \ No newline at end of file +[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Core/applications"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/applications","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"Application properties"},"tags":{"Type":45,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"ApplicationProperties","Properties":{"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"extensions":{"Type":34,"Flags":0,"Description":"The application extension."},"status":{"Type":35,"Flags":2,"Description":"Status of a resource."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"7":{"Name":"Extension","Discriminator":"kind","BaseProperties":{},"Elements":{"daprSidecar":21,"kubernetesMetadata":26,"kubernetesNamespace":30,"manualScaling":32}}},{"2":{"Name":"DaprSidecarExtension","Properties":{"appPort":{"Type":3,"Flags":0,"Description":"The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar."},"appId":{"Type":4,"Flags":1,"Description":"The Dapr appId. Specifies the identifier used by Dapr for service invocation."},"config":{"Type":4,"Flags":0,"Description":"Specifies the Dapr configuration to use for the resource."},"protocol":{"Type":24,"Flags":0,"Description":"The Dapr sidecar extension protocol"},"kind":{"Type":25,"Flags":1,"Description":"Discriminator property for Extension."}}}},{"6":{"Value":"http"}},{"6":{"Value":"grpc"}},{"5":{"Elements":[22,23]}},{"6":{"Value":"daprSidecar"}},{"2":{"Name":"KubernetesMetadataExtension","Properties":{"annotations":{"Type":27,"Flags":0,"Description":"Annotations to be applied to the Kubernetes resources output by the resource"},"labels":{"Type":28,"Flags":0,"Description":"Labels to be applied to the Kubernetes resources output by the resource"},"kind":{"Type":29,"Flags":1,"Description":"Discriminator property for Extension."}}}},{"2":{"Name":"KubernetesMetadataExtensionAnnotations","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"KubernetesMetadataExtensionLabels","Properties":{},"AdditionalProperties":4}},{"6":{"Value":"kubernetesMetadata"}},{"2":{"Name":"KubernetesNamespaceExtension","Properties":{"namespace":{"Type":4,"Flags":1,"Description":"The namespace of the application environment."},"kind":{"Type":31,"Flags":1,"Description":"Discriminator property for Extension."}}}},{"6":{"Value":"kubernetesNamespace"}},{"2":{"Name":"ManualScalingExtension","Properties":{"replicas":{"Type":3,"Flags":1,"Description":"Replica count."},"kind":{"Type":33,"Flags":1,"Description":"Discriminator property for Extension."}}}},{"6":{"Value":"manualScaling"}},{"3":{"ItemType":20}},{"2":{"Name":"ResourceStatus","Properties":{"compute":{"Type":36,"Flags":0,"Description":"Represents backing compute resource"},"outputResources":{"Type":44,"Flags":0,"Description":"Properties of an output resource"}}}},{"7":{"Name":"EnvironmentCompute","Discriminator":"kind","BaseProperties":{"resourceId":{"Type":4,"Flags":0,"Description":"The resource id of the compute resource for application environment."},"identity":{"Type":37,"Flags":0,"Description":"IdentitySettings is the external identity setting."}},"Elements":{"kubernetes":41}}},{"2":{"Name":"IdentitySettings","Properties":{"kind":{"Type":40,"Flags":1,"Description":"IdentitySettingKind is the kind of supported external identity setting"},"oidcIssuer":{"Type":4,"Flags":0,"Description":"The URI for your compute platform's OIDC issuer"},"resource":{"Type":4,"Flags":0,"Description":"The resource ID of the provisioned identity"}}}},{"6":{"Value":"undefined"}},{"6":{"Value":"azure.com.workload"}},{"5":{"Elements":[38,39]}},{"2":{"Name":"KubernetesCompute","Properties":{"namespace":{"Type":4,"Flags":1,"Description":"The namespace to use for the environment."},"kind":{"Type":42,"Flags":1,"Description":"Discriminator property for EnvironmentCompute."}}}},{"6":{"Value":"kubernetes"}},{"2":{"Name":"OutputResource","Properties":{"localId":{"Type":4,"Flags":0,"Description":"The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships."},"id":{"Type":4,"Flags":0,"Description":"The UCP resource ID of the underlying resource."},"radiusManaged":{"Type":2,"Flags":0,"Description":"Determines whether Radius manages the lifecycle of the underlying resource."}}}},{"3":{"ItemType":43}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":51,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":56,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[47,48,49,50]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[52,53,54,55]}},{"4":{"Name":"Applications.Core/applications@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"6":{"Value":"Applications.Core/containers"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/containers","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":58,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":59,"Flags":10,"Description":"The resource api version"},"properties":{"Type":61,"Flags":0,"Description":"Container properties"},"tags":{"Type":112,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"ContainerProperties","Properties":{"environment":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)"},"application":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"},"provisioningState":{"Type":69,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":35,"Flags":2,"Description":"Status of a resource."},"container":{"Type":70,"Flags":1,"Description":"Definition of a container"},"connections":{"Type":107,"Flags":0,"Description":"Specifies a connection to another resource."},"identity":{"Type":37,"Flags":0,"Description":"IdentitySettings is the external identity setting."},"extensions":{"Type":108,"Flags":0,"Description":"Extensions spec of the resource"},"runtimes":{"Type":109,"Flags":0,"Description":"The properties for runtime configuration"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[62,63,64,65,66,67,68]}},{"2":{"Name":"Container","Properties":{"image":{"Type":4,"Flags":1,"Description":"The registry and image to download and run in your container"},"imagePullPolicy":{"Type":74,"Flags":0,"Description":"The image pull policy for the container"},"env":{"Type":75,"Flags":0,"Description":"environment"},"ports":{"Type":80,"Flags":0,"Description":"container ports"},"readinessProbe":{"Type":81,"Flags":0,"Description":"Properties for readiness/liveness probe"},"livenessProbe":{"Type":81,"Flags":0,"Description":"Properties for readiness/liveness probe"},"volumes":{"Type":100,"Flags":0,"Description":"container volumes"},"command":{"Type":101,"Flags":0,"Description":"Entrypoint array. Overrides the container image's ENTRYPOINT"},"args":{"Type":102,"Flags":0,"Description":"Arguments to the entrypoint. Overrides the container image's CMD"},"workingDir":{"Type":4,"Flags":0,"Description":"Working directory for the container"}}}},{"6":{"Value":"Always"}},{"6":{"Value":"IfNotPresent"}},{"6":{"Value":"Never"}},{"5":{"Elements":[71,72,73]}},{"2":{"Name":"ContainerEnv","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"ContainerPortProperties","Properties":{"containerPort":{"Type":3,"Flags":1,"Description":"The listening port number"},"protocol":{"Type":79,"Flags":0,"Description":"The protocol in use by the port"},"provides":{"Type":4,"Flags":0,"Description":"Specifies a route provided by this port"},"scheme":{"Type":4,"Flags":0,"Description":"Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value"},"port":{"Type":3,"Flags":0,"Description":"Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired"}}}},{"6":{"Value":"TCP"}},{"6":{"Value":"UDP"}},{"5":{"Elements":[77,78]}},{"2":{"Name":"ContainerPorts","Properties":{},"AdditionalProperties":76}},{"7":{"Name":"HealthProbeProperties","Discriminator":"kind","BaseProperties":{"initialDelaySeconds":{"Type":3,"Flags":0,"Description":"Initial delay in seconds before probing for readiness/liveness"},"failureThreshold":{"Type":3,"Flags":0,"Description":"Threshold number of times the probe fails after which a failure would be reported"},"periodSeconds":{"Type":3,"Flags":0,"Description":"Interval for the readiness/liveness probe in seconds"},"timeoutSeconds":{"Type":3,"Flags":0,"Description":"Number of seconds after which the readiness/liveness probe times out. Defaults to 5 seconds"}},"Elements":{"exec":82,"httpGet":84,"tcp":87}}},{"2":{"Name":"ExecHealthProbeProperties","Properties":{"command":{"Type":4,"Flags":1,"Description":"Command to execute to probe readiness/liveness"},"kind":{"Type":83,"Flags":1,"Description":"Discriminator property for HealthProbeProperties."}}}},{"6":{"Value":"exec"}},{"2":{"Name":"HttpGetHealthProbeProperties","Properties":{"containerPort":{"Type":3,"Flags":1,"Description":"The listening port number"},"path":{"Type":4,"Flags":1,"Description":"The route to make the HTTP request on"},"headers":{"Type":85,"Flags":0,"Description":"Custom HTTP headers to add to the get request"},"kind":{"Type":86,"Flags":1,"Description":"Discriminator property for HealthProbeProperties."}}}},{"2":{"Name":"HttpGetHealthProbePropertiesHeaders","Properties":{},"AdditionalProperties":4}},{"6":{"Value":"httpGet"}},{"2":{"Name":"TcpHealthProbeProperties","Properties":{"containerPort":{"Type":3,"Flags":1,"Description":"The listening port number"},"kind":{"Type":88,"Flags":1,"Description":"Discriminator property for HealthProbeProperties."}}}},{"6":{"Value":"tcp"}},{"7":{"Name":"Volume","Discriminator":"kind","BaseProperties":{"mountPath":{"Type":4,"Flags":0,"Description":"The path where the volume is mounted"}},"Elements":{"ephemeral":90,"persistent":95}}},{"2":{"Name":"EphemeralVolume","Properties":{"managedStore":{"Type":93,"Flags":1,"Description":"The managed store for the ephemeral volume"},"kind":{"Type":94,"Flags":1,"Description":"Discriminator property for Volume."}}}},{"6":{"Value":"memory"}},{"6":{"Value":"disk"}},{"5":{"Elements":[91,92]}},{"6":{"Value":"ephemeral"}},{"2":{"Name":"PersistentVolume","Properties":{"permission":{"Type":98,"Flags":0,"Description":"The persistent volume permission"},"source":{"Type":4,"Flags":1,"Description":"The source of the volume"},"kind":{"Type":99,"Flags":1,"Description":"Discriminator property for Volume."}}}},{"6":{"Value":"read"}},{"6":{"Value":"write"}},{"5":{"Elements":[96,97]}},{"6":{"Value":"persistent"}},{"2":{"Name":"ContainerVolumes","Properties":{},"AdditionalProperties":89}},{"3":{"ItemType":4}},{"3":{"ItemType":4}},{"2":{"Name":"ConnectionProperties","Properties":{"source":{"Type":4,"Flags":1,"Description":"The source of the connection"},"disableDefaultEnvVars":{"Type":2,"Flags":0,"Description":"default environment variable override"},"iam":{"Type":104,"Flags":0,"Description":"IAM properties"}}}},{"2":{"Name":"IamProperties","Properties":{"kind":{"Type":105,"Flags":1,"Description":"The kind of IAM provider to configure"},"roles":{"Type":106,"Flags":0,"Description":"RBAC permissions to be assigned on the source resource"}}}},{"6":{"Value":"azure"}},{"3":{"ItemType":4}},{"2":{"Name":"ContainerPropertiesConnections","Properties":{},"AdditionalProperties":103}},{"3":{"ItemType":20}},{"2":{"Name":"RuntimesProperties","Properties":{"kubernetes":{"Type":110,"Flags":0,"Description":"The runtime configuration properties for Kubernetes"}}}},{"2":{"Name":"KubernetesRuntimeProperties","Properties":{"base":{"Type":4,"Flags":0,"Description":"The serialized YAML manifest which represents the base Kubernetes resources to deploy, such as Deployment, Service, ServiceAccount, Secrets, and ConfigMaps."},"pod":{"Type":111,"Flags":0,"Description":"A strategic merge patch that will be applied to the PodSpec object when this container is being deployed."}}}},{"2":{"Name":"KubernetesPodSpec","Properties":{},"AdditionalProperties":0}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/containers@2022-03-15-privatepreview","ScopeType":0,"Body":60}},{"6":{"Value":"Applications.Core/environments"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/environments","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":114,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":115,"Flags":10,"Description":"The resource api version"},"properties":{"Type":117,"Flags":0,"Description":"Environment properties"},"tags":{"Type":137,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"EnvironmentProperties","Properties":{"provisioningState":{"Type":125,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"compute":{"Type":36,"Flags":1,"Description":"Represents backing compute resource"},"providers":{"Type":126,"Flags":0,"Description":"The Cloud providers configuration"},"recipes":{"Type":135,"Flags":0,"Description":"Specifies Recipes linked to the Environment."},"extensions":{"Type":136,"Flags":0,"Description":"The environment extension."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[118,119,120,121,122,123,124]}},{"2":{"Name":"Providers","Properties":{"azure":{"Type":127,"Flags":0,"Description":"The Azure cloud provider definition"},"aws":{"Type":128,"Flags":0,"Description":"The AWS cloud provider definition"}}}},{"2":{"Name":"ProvidersAzure","Properties":{"scope":{"Type":4,"Flags":1,"Description":"Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup'"}}}},{"2":{"Name":"ProvidersAws","Properties":{"scope":{"Type":4,"Flags":1,"Description":"Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2'"}}}},{"7":{"Name":"RecipeProperties","Discriminator":"templateKind","BaseProperties":{"templatePath":{"Type":4,"Flags":1,"Description":"Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported."},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}},"Elements":{"bicep":130,"terraform":132}}},{"2":{"Name":"BicepRecipeProperties","Properties":{"templateKind":{"Type":131,"Flags":1,"Description":"Discriminator property for RecipeProperties."}}}},{"6":{"Value":"bicep"}},{"2":{"Name":"TerraformRecipeProperties","Properties":{"templateVersion":{"Type":4,"Flags":0,"Description":"Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources."},"templateKind":{"Type":133,"Flags":1,"Description":"Discriminator property for RecipeProperties."}}}},{"6":{"Value":"terraform"}},{"2":{"Name":"DictionaryOfRecipeProperties","Properties":{},"AdditionalProperties":129}},{"2":{"Name":"EnvironmentPropertiesRecipes","Properties":{},"AdditionalProperties":134}},{"3":{"ItemType":20}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/environments@2022-03-15-privatepreview","ScopeType":0,"Body":116}},{"6":{"Value":"Applications.Core/extenders"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/extenders","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":139,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":140,"Flags":10,"Description":"The resource api version"},"properties":{"Type":142,"Flags":0,"Description":"ExtenderResource portable resource properties"},"tags":{"Type":155,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"ExtenderProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":150,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":35,"Flags":2,"Description":"Status of a resource."},"secrets":{"Type":0,"Flags":0,"Description":"Any object"},"recipe":{"Type":151,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":154,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}},"AdditionalProperties":0}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[143,144,145,146,147,148,149]}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[152,153]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/extenders@2022-03-15-privatepreview","ScopeType":0,"Body":141}},{"6":{"Value":"Applications.Core/gateways"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/gateways","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":157,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":158,"Flags":10,"Description":"The resource api version"},"properties":{"Type":160,"Flags":0,"Description":"Gateway properties"},"tags":{"Type":176,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"GatewayProperties","Properties":{"environment":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)"},"application":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"},"provisioningState":{"Type":168,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":35,"Flags":2,"Description":"Status of a resource."},"internal":{"Type":2,"Flags":0,"Description":"Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet)."},"hostname":{"Type":169,"Flags":0,"Description":"Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io."},"routes":{"Type":171,"Flags":1,"Description":"Routes attached to this Gateway"},"tls":{"Type":172,"Flags":0,"Description":"TLS configuration definition for Gateway resource."},"url":{"Type":4,"Flags":2,"Description":"URL of the gateway resource. Readonly"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[161,162,163,164,165,166,167]}},{"2":{"Name":"GatewayHostname","Properties":{"prefix":{"Type":4,"Flags":0,"Description":"Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined."},"fullyQualifiedHostname":{"Type":4,"Flags":0,"Description":"Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined."}}}},{"2":{"Name":"GatewayRoute","Properties":{"path":{"Type":4,"Flags":0,"Description":"The path to match the incoming request path on. Ex - /myservice."},"destination":{"Type":4,"Flags":0,"Description":"The HttpRoute to route to. Ex - myserviceroute.id."},"replacePrefix":{"Type":4,"Flags":0,"Description":"Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute'"}}}},{"3":{"ItemType":170}},{"2":{"Name":"GatewayTls","Properties":{"sslPassthrough":{"Type":2,"Flags":0,"Description":"If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption."},"minimumProtocolVersion":{"Type":175,"Flags":0,"Description":"Tls Minimum versions for Gateway resource."},"certificateFrom":{"Type":4,"Flags":0,"Description":"The resource id for the secret containing the TLS certificate and key for the gateway."}}}},{"6":{"Value":"1.2"}},{"6":{"Value":"1.3"}},{"5":{"Elements":[173,174]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/gateways@2022-03-15-privatepreview","ScopeType":0,"Body":159}},{"6":{"Value":"Applications.Core/httpRoutes"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/httpRoutes","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":178,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":179,"Flags":10,"Description":"The resource api version"},"properties":{"Type":181,"Flags":0,"Description":"HTTPRoute properties"},"tags":{"Type":190,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"HttpRouteProperties","Properties":{"environment":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)"},"application":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"},"provisioningState":{"Type":189,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":35,"Flags":2,"Description":"Status of a resource."},"hostname":{"Type":4,"Flags":0,"Description":"The internal hostname accepting traffic for the HTTP Route. Readonly."},"port":{"Type":3,"Flags":0,"Description":"The port number for the HTTP Route. Defaults to 80. Readonly."},"scheme":{"Type":4,"Flags":2,"Description":"The scheme used for traffic. Readonly."},"url":{"Type":4,"Flags":2,"Description":"A stable URL that that can be used to route traffic to a resource. Readonly."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[182,183,184,185,186,187,188]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/httpRoutes@2022-03-15-privatepreview","ScopeType":0,"Body":180}},{"6":{"Value":"Applications.Core/secretStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/secretStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":192,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":193,"Flags":10,"Description":"The resource api version"},"properties":{"Type":195,"Flags":0,"Description":"The properties of SecretStore"},"tags":{"Type":213,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"SecretStoreProperties","Properties":{"environment":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)"},"application":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"},"provisioningState":{"Type":203,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":35,"Flags":2,"Description":"Status of a resource."},"type":{"Type":206,"Flags":0,"Description":"The type of SecretStore data"},"data":{"Type":212,"Flags":1,"Description":"An object to represent key-value type secrets"},"resource":{"Type":4,"Flags":0,"Description":"The resource id of external secret store."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[196,197,198,199,200,201,202]}},{"6":{"Value":"generic"}},{"6":{"Value":"certificate"}},{"5":{"Elements":[204,205]}},{"2":{"Name":"SecretValueProperties","Properties":{"encoding":{"Type":210,"Flags":0,"Description":"The type of SecretValue Encoding"},"value":{"Type":4,"Flags":0,"Description":"The value of secret."},"valueFrom":{"Type":211,"Flags":0,"Description":"The Secret value source properties"}}}},{"6":{"Value":"raw"}},{"6":{"Value":"base64"}},{"5":{"Elements":[208,209]}},{"2":{"Name":"ValueFromProperties","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the referenced secret."},"version":{"Type":4,"Flags":0,"Description":"The version of the referenced secret."}}}},{"2":{"Name":"SecretStorePropertiesData","Properties":{},"AdditionalProperties":207}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/secretStores@2022-03-15-privatepreview","ScopeType":0,"Body":194}},{"6":{"Value":"Applications.Core/volumes"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Core/volumes","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":215,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":216,"Flags":10,"Description":"The resource api version"},"properties":{"Type":218,"Flags":0,"Description":"Volume properties"},"tags":{"Type":250,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":46,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"7":{"Name":"VolumeProperties","Discriminator":"kind","BaseProperties":{"environment":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)"},"application":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"},"provisioningState":{"Type":226,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":35,"Flags":2,"Description":"Status of a resource."}},"Elements":{"azure.com.keyvault":227}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[219,220,221,222,223,224,225]}},{"2":{"Name":"AzureKeyVaultVolumeProperties","Properties":{"certificates":{"Type":240,"Flags":0,"Description":"The KeyVault certificates that this volume exposes"},"keys":{"Type":242,"Flags":0,"Description":"The KeyVault keys that this volume exposes"},"resource":{"Type":4,"Flags":1,"Description":"The ID of the keyvault to use for this volume resource"},"secrets":{"Type":248,"Flags":0,"Description":"The KeyVault secrets that this volume exposes"},"kind":{"Type":249,"Flags":1,"Description":"Discriminator property for VolumeProperties."}}}},{"2":{"Name":"CertificateObjectProperties","Properties":{"alias":{"Type":4,"Flags":0,"Description":"File name when written to disk"},"encoding":{"Type":232,"Flags":0,"Description":"Represents secret encodings"},"format":{"Type":235,"Flags":0,"Description":"Represents certificate formats"},"name":{"Type":4,"Flags":1,"Description":"The name of the certificate"},"certType":{"Type":239,"Flags":0,"Description":"Represents certificate types"},"version":{"Type":4,"Flags":0,"Description":"Certificate version"}}}},{"6":{"Value":"utf-8"}},{"6":{"Value":"hex"}},{"6":{"Value":"base64"}},{"5":{"Elements":[229,230,231]}},{"6":{"Value":"pem"}},{"6":{"Value":"pfx"}},{"5":{"Elements":[233,234]}},{"6":{"Value":"certificate"}},{"6":{"Value":"privatekey"}},{"6":{"Value":"publickey"}},{"5":{"Elements":[236,237,238]}},{"2":{"Name":"AzureKeyVaultVolumePropertiesCertificates","Properties":{},"AdditionalProperties":228}},{"2":{"Name":"KeyObjectProperties","Properties":{"alias":{"Type":4,"Flags":0,"Description":"File name when written to disk"},"name":{"Type":4,"Flags":1,"Description":"The name of the key"},"version":{"Type":4,"Flags":0,"Description":"Key version"}}}},{"2":{"Name":"AzureKeyVaultVolumePropertiesKeys","Properties":{},"AdditionalProperties":241}},{"2":{"Name":"SecretObjectProperties","Properties":{"alias":{"Type":4,"Flags":0,"Description":"File name when written to disk"},"encoding":{"Type":247,"Flags":0,"Description":"Represents secret encodings"},"name":{"Type":4,"Flags":1,"Description":"The name of the secret"},"version":{"Type":4,"Flags":0,"Description":"secret version"}}}},{"6":{"Value":"utf-8"}},{"6":{"Value":"hex"}},{"6":{"Value":"base64"}},{"5":{"Elements":[244,245,246]}},{"2":{"Name":"AzureKeyVaultVolumePropertiesSecrets","Properties":{},"AdditionalProperties":243}},{"6":{"Value":"azure.com.keyvault"}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Core/volumes@2022-03-15-privatepreview","ScopeType":0,"Body":217}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Core/extenders","ApiVersion":"2022-03-15-privatepreview","Output":0,"Input":0}},{"2":{"Name":"SecretStoreListSecretsResult","Properties":{"type":{"Type":256,"Flags":2,"Description":"The type of SecretStore data"},"data":{"Type":257,"Flags":2,"Description":"An object to represent key-value type secrets"}}}},{"6":{"Value":"generic"}},{"6":{"Value":"certificate"}},{"5":{"Elements":[254,255]}},{"2":{"Name":"SecretStoreListSecretsResultData","Properties":{},"AdditionalProperties":207}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Core/secretStores","ApiVersion":"2022-03-15-privatepreview","Output":253,"Input":0}}] \ No newline at end of file diff --git a/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.md b/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.md index f470ba43e4..104bac72fb 100644 --- a/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.md +++ b/hack/bicep-types-radius/generated/applications/applications.core/2022-03-15-privatepreview/types.md @@ -7,7 +7,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [ApplicationProperties](#applicationproperties) (Required): Application properties +* **properties**: [ApplicationProperties](#applicationproperties): Application properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/applications' (ReadOnly, DeployTimeConstant): The resource type @@ -19,7 +19,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [ContainerProperties](#containerproperties) (Required): Container properties +* **properties**: [ContainerProperties](#containerproperties): Container properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/containers' (ReadOnly, DeployTimeConstant): The resource type @@ -31,7 +31,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [EnvironmentProperties](#environmentproperties) (Required): Application environment properties +* **properties**: [EnvironmentProperties](#environmentproperties): Environment properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/environments' (ReadOnly, DeployTimeConstant): The resource type @@ -43,7 +43,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [ExtenderProperties](#extenderproperties) (Required): Extender portable resource properties. +* **properties**: [ExtenderProperties](#extenderproperties): ExtenderResource portable resource properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/extenders' (ReadOnly, DeployTimeConstant): The resource type @@ -55,7 +55,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [GatewayProperties](#gatewayproperties) (Required): Gateway properties +* **properties**: [GatewayProperties](#gatewayproperties): Gateway properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/gateways' (ReadOnly, DeployTimeConstant): The resource type @@ -67,7 +67,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [HttpRouteProperties](#httprouteproperties) (Required): HTTP Route properties +* **properties**: [HttpRouteProperties](#httprouteproperties): HTTPRoute properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/httpRoutes' (ReadOnly, DeployTimeConstant): The resource type @@ -79,7 +79,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [SecretStoreProperties](#secretstoreproperties) (Required) +* **properties**: [SecretStoreProperties](#secretstoreproperties): The properties of SecretStore * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/secretStores' (ReadOnly, DeployTimeConstant): The resource type @@ -91,77 +91,98 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [VolumeProperties](#volumeproperties) (Required) +* **properties**: [VolumeProperties](#volumeproperties): Volume properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Core/volumes' (ReadOnly, DeployTimeConstant): The resource type +## Function listSecrets (Applications.Core/extenders@2022-03-15-privatepreview) +* **Resource**: Applications.Core/extenders +* **ApiVersion**: 2022-03-15-privatepreview +* **Input**: any +* **Output**: any + ## Function listSecrets (Applications.Core/secretStores@2022-03-15-privatepreview) * **Resource**: Applications.Core/secretStores * **ApiVersion**: 2022-03-15-privatepreview +* **Input**: any * **Output**: [SecretStoreListSecretsResult](#secretstorelistsecretsresult) -## Function listSecrets (Applications.Core/extenders@2022-03-15-privatepreview) -* **Resource**: Applications.Core/extenders -* **ApiVersion**: 2022-03-15-privatepreview -* **Output**: [ExtenderSecrets](#extendersecrets) - ## ApplicationProperties ### Properties -* **environment**: string (Required): The resource id of the environment linked to application. -* **extensions**: [ApplicationExtension](#applicationextension)[]: Extensions spec of the resource -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. +* **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to +* **extensions**: [Extension](#extension)[]: The application extension. +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -## ApplicationExtension +## Extension * **Discriminator**: kind ### Base Properties -### ApplicationKubernetesMetadataExtension +### DaprSidecarExtension +#### Properties +* **appId**: string (Required): The Dapr appId. Specifies the identifier used by Dapr for service invocation. +* **appPort**: int: The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. +* **config**: string: Specifies the Dapr configuration to use for the resource. +* **kind**: 'daprSidecar' (Required): Discriminator property for Extension. +* **protocol**: 'grpc' | 'http': The Dapr sidecar extension protocol + +### KubernetesMetadataExtension +#### Properties +* **annotations**: [KubernetesMetadataExtensionAnnotations](#kubernetesmetadataextensionannotations): Annotations to be applied to the Kubernetes resources output by the resource +* **kind**: 'kubernetesMetadata' (Required): Discriminator property for Extension. +* **labels**: [KubernetesMetadataExtensionLabels](#kubernetesmetadataextensionlabels): Labels to be applied to the Kubernetes resources output by the resource + +### KubernetesNamespaceExtension #### Properties -* **annotations**: [ApplicationKubernetesMetadataExtensionAnnotations](#applicationkubernetesmetadataextensionannotations): Annotations to be applied to the Kubernetes resources output by the resource -* **kind**: 'kubernetesMetadata' (Required): Specifies the extensions of a resource. -* **labels**: [ApplicationKubernetesMetadataExtensionLabels](#applicationkubernetesmetadataextensionlabels): Labels to be applied to the Kubernetes resources output by the resource +* **kind**: 'kubernetesNamespace' (Required): Discriminator property for Extension. +* **namespace**: string (Required): The namespace of the application environment. -### ApplicationKubernetesNamespaceExtension +### ManualScalingExtension #### Properties -* **kind**: 'kubernetesNamespace' (Required): Specifies the extensions of a resource. -* **namespace**: string (Required): The Kubernetes namespace to use for this application. +* **kind**: 'manualScaling' (Required): Discriminator property for Extension. +* **replicas**: int (Required): Replica count. -## ApplicationKubernetesMetadataExtensionAnnotations +## KubernetesMetadataExtensionAnnotations ### Properties ### Additional Properties * **Additional Properties Type**: string -## ApplicationKubernetesMetadataExtensionLabels +## KubernetesMetadataExtensionLabels ### Properties ### Additional Properties * **Additional Properties Type**: string ## ResourceStatus ### Properties -* **compute**: [EnvironmentCompute](#environmentcompute): Compute resource used by application environment resource. -* **outputResources**: any[]: Array of AnyObject +* **compute**: [EnvironmentCompute](#environmentcompute): Represents backing compute resource +* **outputResources**: [OutputResource](#outputresource)[]: Properties of an output resource ## EnvironmentCompute * **Discriminator**: kind ### Base Properties -* **identity**: [IdentitySettings](#identitysettings) +* **identity**: [IdentitySettings](#identitysettings): IdentitySettings is the external identity setting. * **resourceId**: string: The resource id of the compute resource for application environment. ### KubernetesCompute #### Properties -* **kind**: 'kubernetes' (Required): Type of compute resource. +* **kind**: 'kubernetes' (Required): Discriminator property for EnvironmentCompute. * **namespace**: string (Required): The namespace to use for the environment. ## IdentitySettings ### Properties -* **kind**: 'azure.com.workload' | 'undefined' (Required): Configuration for supported external identity providers +* **kind**: 'azure.com.workload' | 'undefined' (Required): IdentitySettingKind is the kind of supported external identity setting * **oidcIssuer**: string: The URI for your compute platform's OIDC issuer * **resource**: string: The resource ID of the provisioned identity +## OutputResource +### Properties +* **id**: string: The UCP resource ID of the underlying resource. +* **localId**: string: The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships. +* **radiusManaged**: bool: Determines whether Radius manages the lifecycle of the underlying resource. + ## SystemData ### Properties * **createdAt**: string: The timestamp of resource creation (UTC). @@ -178,13 +199,14 @@ ## ContainerProperties ### Properties -* **application**: string (Required): Specifies the resource id of the application -* **connections**: [ContainerPropertiesConnections](#containerpropertiesconnections): Dictionary of -* **container**: [Container](#container) (Required): Definition of a container. -* **environment**: string: The resource id of the environment linked to the resource -* **extensions**: [ContainerExtension](#containerextension)[]: Extensions spec of the resource -* **identity**: [IdentitySettings](#identitysettings) -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. +* **application**: string (Required): Fully qualified resource ID for the application that the portable resource is consumed by +* **connections**: [ContainerPropertiesConnections](#containerpropertiesconnections): Specifies a connection to another resource. +* **container**: [Container](#container) (Required): Definition of a container +* **environment**: string: Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) +* **extensions**: [Extension](#extension)[]: Extensions spec of the resource +* **identity**: [IdentitySettings](#identitysettings): IdentitySettings is the external identity setting. +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called +* **runtimes**: [RuntimesProperties](#runtimesproperties): The properties for runtime configuration * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. ## ContainerPropertiesConnections @@ -194,8 +216,8 @@ ## ConnectionProperties ### Properties -* **disableDefaultEnvVars**: bool -* **iam**: [IamProperties](#iamproperties): The properties of IAM +* **disableDefaultEnvVars**: bool: default environment variable override +* **iam**: [IamProperties](#iamproperties): IAM properties * **source**: string (Required): The source of the connection ## IamProperties @@ -207,12 +229,13 @@ ### Properties * **args**: string[]: Arguments to the entrypoint. Overrides the container image's CMD * **command**: string[]: Entrypoint array. Overrides the container image's ENTRYPOINT -* **env**: [ContainerEnv](#containerenv): Dictionary of +* **env**: [ContainerEnv](#containerenv): environment * **image**: string (Required): The registry and image to download and run in your container +* **imagePullPolicy**: 'Always' | 'IfNotPresent' | 'Never': The image pull policy for the container * **livenessProbe**: [HealthProbeProperties](#healthprobeproperties): Properties for readiness/liveness probe -* **ports**: [ContainerPorts](#containerports): Dictionary of +* **ports**: [ContainerPorts](#containerports): container ports * **readinessProbe**: [HealthProbeProperties](#healthprobeproperties): Properties for readiness/liveness probe -* **volumes**: [ContainerVolumes](#containervolumes): Dictionary of +* **volumes**: [ContainerVolumes](#containervolumes): container volumes * **workingDir**: string: Working directory for the container ## ContainerEnv @@ -231,19 +254,19 @@ ### ExecHealthProbeProperties #### Properties * **command**: string (Required): Command to execute to probe readiness/liveness -* **kind**: 'exec' (Required): The HealthProbeProperties kind +* **kind**: 'exec' (Required): Discriminator property for HealthProbeProperties. ### HttpGetHealthProbeProperties #### Properties * **containerPort**: int (Required): The listening port number * **headers**: [HttpGetHealthProbePropertiesHeaders](#httpgethealthprobepropertiesheaders): Custom HTTP headers to add to the get request -* **kind**: 'httpGet' (Required): The HealthProbeProperties kind +* **kind**: 'httpGet' (Required): Discriminator property for HealthProbeProperties. * **path**: string (Required): The route to make the HTTP request on ### TcpHealthProbeProperties #### Properties * **containerPort**: int (Required): The listening port number -* **kind**: 'tcp' (Required): The HealthProbeProperties kind +* **kind**: 'tcp' (Required): Discriminator property for HealthProbeProperties. ## HttpGetHealthProbePropertiesHeaders @@ -254,15 +277,15 @@ ## ContainerPorts ### Properties ### Additional Properties -* **Additional Properties Type**: [ContainerPort](#containerport) +* **Additional Properties Type**: [ContainerPortProperties](#containerportproperties) -## ContainerPort +## ContainerPortProperties ### Properties * **containerPort**: int (Required): The listening port number -* **port**: int: Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired. -* **protocol**: 'TCP' | 'UDP' | 'grpc' | 'http': Protocol in use by the port +* **port**: int: Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired +* **protocol**: 'TCP' | 'UDP': The protocol in use by the port * **provides**: string: Specifies a route provided by this port -* **scheme**: string: Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value. +* **scheme**: string: Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value ## ContainerVolumes ### Properties @@ -276,49 +299,29 @@ * **mountPath**: string: The path where the volume is mounted ### EphemeralVolume #### Properties -* **kind**: 'ephemeral' (Required): The Volume kind -* **managedStore**: 'disk' | 'memory' (Required): Backing store for the ephemeral volume +* **kind**: 'ephemeral' (Required): Discriminator property for Volume. +* **managedStore**: 'disk' | 'memory' (Required): The managed store for the ephemeral volume ### PersistentVolume #### Properties -* **kind**: 'persistent' (Required): The Volume kind -* **permission**: 'read' | 'write': Container read/write access to the volume +* **kind**: 'persistent' (Required): Discriminator property for Volume. +* **permission**: 'read' | 'write': The persistent volume permission * **source**: string (Required): The source of the volume -## ContainerExtension -* **Discriminator**: kind - -### Base Properties -### DaprSidecarExtension -#### Properties -* **appId**: string (Required): The Dapr appId. Specifies the identifier used by Dapr for service invocation. -* **appPort**: int: The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. -* **config**: string: Specifies the Dapr configuration to use for the resource. -* **kind**: 'daprSidecar' (Required): Specifies the extensions of a resource. -* **protocol**: 'TCP' | 'UDP' | 'grpc' | 'http': Protocol in use by the port - -### ContainerKubernetesMetadataExtension -#### Properties -* **annotations**: [ContainerKubernetesMetadataExtensionAnnotations](#containerkubernetesmetadataextensionannotations): Annotations to be applied to the Kubernetes resources output by the resource -* **kind**: 'kubernetesMetadata' (Required): Specifies the extensions of a resource. -* **labels**: [ContainerKubernetesMetadataExtensionLabels](#containerkubernetesmetadataextensionlabels): Labels to be applied to the Kubernetes resources output by the resource - -### ManualScalingExtension -#### Properties -* **kind**: 'manualScaling' (Required): Specifies the extensions of a resource. -* **replicas**: int: Replica count. - +## RuntimesProperties +### Properties +* **kubernetes**: [KubernetesRuntimeProperties](#kubernetesruntimeproperties): The runtime configuration properties for Kubernetes -## ContainerKubernetesMetadataExtensionAnnotations +## KubernetesRuntimeProperties ### Properties -### Additional Properties -* **Additional Properties Type**: string +* **base**: string: The serialized YAML manifest which represents the base Kubernetes resources to deploy, such as Deployment, Service, ServiceAccount, Secrets, and ConfigMaps. +* **pod**: [KubernetesPodSpec](#kubernetespodspec): A strategic merge patch that will be applied to the PodSpec object when this container is being deployed. -## ContainerKubernetesMetadataExtensionLabels +## KubernetesPodSpec ### Properties ### Additional Properties -* **Additional Properties Type**: string +* **Additional Properties Type**: any ## TrackedResourceTags ### Properties @@ -327,57 +330,36 @@ ## EnvironmentProperties ### Properties -* **compute**: [EnvironmentCompute](#environmentcompute) (Required): Compute resource used by application environment resource. -* **extensions**: [EnvironmentExtension](#environmentextension)[]: Extensions spec of the resource -* **providers**: [Providers](#providers): Cloud providers configuration -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. +* **compute**: [EnvironmentCompute](#environmentcompute) (Required): Represents backing compute resource +* **extensions**: [Extension](#extension)[]: The environment extension. +* **providers**: [Providers](#providers): The Cloud providers configuration +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **recipes**: [EnvironmentPropertiesRecipes](#environmentpropertiesrecipes): Specifies Recipes linked to the Environment. -## EnvironmentExtension -* **Discriminator**: kind - -### Base Properties -### EnvironmentKubernetesMetadataExtension -#### Properties -* **annotations**: [EnvironmentKubernetesMetadataExtensionAnnotations](#environmentkubernetesmetadataextensionannotations): Annotations to be applied to the Kubernetes resources output by the resource -* **kind**: 'kubernetesMetadata' (Required): Specifies the extensions of a resource. -* **labels**: [EnvironmentKubernetesMetadataExtensionLabels](#environmentkubernetesmetadataextensionlabels): Labels to be applied to the Kubernetes resources output by the resource - - -## EnvironmentKubernetesMetadataExtensionAnnotations -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## EnvironmentKubernetesMetadataExtensionLabels -### Properties -### Additional Properties -* **Additional Properties Type**: string - ## Providers ### Properties -* **aws**: [ProvidersAws](#providersaws): AWS cloud provider configuration -* **azure**: [ProvidersAzure](#providersazure): Azure cloud provider configuration +* **aws**: [ProvidersAws](#providersaws): The AWS cloud provider definition +* **azure**: [ProvidersAzure](#providersazure): The Azure cloud provider definition ## ProvidersAws ### Properties -* **scope**: string: Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2' +* **scope**: string (Required): Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2' ## ProvidersAzure ### Properties -* **scope**: string: Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup' +* **scope**: string (Required): Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup' ## EnvironmentPropertiesRecipes ### Properties ### Additional Properties -* **Additional Properties Type**: [DictionaryOfEnvironmentRecipeProperties](#dictionaryofenvironmentrecipeproperties) +* **Additional Properties Type**: [DictionaryOfRecipeProperties](#dictionaryofrecipeproperties) -## DictionaryOfEnvironmentRecipeProperties +## DictionaryOfRecipeProperties ### Properties ### Additional Properties -* **Additional Properties Type**: [EnvironmentRecipeProperties](#environmentrecipeproperties) +* **Additional Properties Type**: [RecipeProperties](#recipeproperties) -## EnvironmentRecipeProperties +## RecipeProperties * **Discriminator**: templateKind ### Base Properties @@ -385,11 +367,11 @@ * **templatePath**: string (Required): Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. ### BicepRecipeProperties #### Properties -* **templateKind**: 'bicep' (Required): Format of the template provided by the recipe. Allowed values: bicep, terraform. +* **templateKind**: 'bicep' (Required): Discriminator property for RecipeProperties. ### TerraformRecipeProperties #### Properties -* **templateKind**: 'terraform' (Required): Format of the template provided by the recipe. Allowed values: bicep, terraform. +* **templateKind**: 'terraform' (Required): Discriminator property for RecipeProperties. * **templateVersion**: string: Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources. @@ -400,26 +382,21 @@ ## ExtenderProperties ### Properties -* **application**: string: Specifies the resource id of the application -* **environment**: string (Required): The resource id of the environment linked to the resource -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. -* **recipe**: [ResourceRecipe](#resourcerecipe): The recipe used to automatically deploy underlying infrastructure for a portable resource. +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) +* **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called +* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **secrets**: [ExtenderSecrets](#extendersecrets): The secret values for the given Extender portable resource. +* **secrets**: any: Any object * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. ### Additional Properties * **Additional Properties Type**: any -## ResourceRecipe +## Recipe ### Properties -* **name**: string (Required): The name of the recipe within the environment to use. +* **name**: string (Required): The name of the recipe within the environment to use * **parameters**: any: Any object -## ExtenderSecrets -### Properties -### Additional Properties -* **Additional Properties Type**: any - ## TrackedResourceTags ### Properties ### Additional Properties @@ -427,17 +404,17 @@ ## GatewayProperties ### Properties -* **application**: string (Required): Specifies the resource id of the application -* **environment**: string: The resource id of the environment linked to the resource -* **hostname**: [GatewayPropertiesHostname](#gatewaypropertieshostname): Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io. +* **application**: string (Required): Fully qualified resource ID for the application that the portable resource is consumed by +* **environment**: string: Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) +* **hostname**: [GatewayHostname](#gatewayhostname): Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io. * **internal**: bool: Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet). -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **routes**: [GatewayRoute](#gatewayroute)[] (Required): Routes attached to this Gateway * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **tls**: [GatewayPropertiesTls](#gatewaypropertiestls): TLS configuration for the Gateway. -* **url**: string (ReadOnly): URL of the gateway resource. Readonly. +* **tls**: [GatewayTls](#gatewaytls): TLS configuration definition for Gateway resource. +* **url**: string (ReadOnly): URL of the gateway resource. Readonly -## GatewayPropertiesHostname +## GatewayHostname ### Properties * **fullyQualifiedHostname**: string: Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined. * **prefix**: string: Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined. @@ -448,10 +425,10 @@ * **path**: string: The path to match the incoming request path on. Ex - /myservice. * **replacePrefix**: string: Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute' -## GatewayPropertiesTls +## GatewayTls ### Properties -* **certificateFrom**: string: Declares which Kubernetes TLS secret will be used. -* **minimumProtocolVersion**: '1.2' | '1.3': TLS minimum protocol version (defaults to 1.2). +* **certificateFrom**: string: The resource id for the secret containing the TLS certificate and key for the gateway. +* **minimumProtocolVersion**: '1.2' | '1.3': Tls Minimum versions for Gateway resource. * **sslPassthrough**: bool: If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption. ## TrackedResourceTags @@ -461,14 +438,14 @@ ## HttpRouteProperties ### Properties -* **application**: string (Required): Specifies the resource id of the application -* **environment**: string: The resource id of the environment linked to the resource +* **application**: string (Required): Fully qualified resource ID for the application that the portable resource is consumed by +* **environment**: string: Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) * **hostname**: string: The internal hostname accepting traffic for the HTTP Route. Readonly. * **port**: int: The port number for the HTTP Route. Defaults to 80. Readonly. -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. -* **scheme**: string: The scheme used for traffic. Readonly. +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called +* **scheme**: string (ReadOnly): The scheme used for traffic. Readonly. * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **url**: string: A stable URL that that can be used to route traffic to a resource. Readonly. +* **url**: string (ReadOnly): A stable URL that that can be used to route traffic to a resource. Readonly. ## TrackedResourceTags ### Properties @@ -477,13 +454,13 @@ ## SecretStoreProperties ### Properties -* **application**: string (Required): Specifies the resource id of the application +* **application**: string (Required): Fully qualified resource ID for the application that the portable resource is consumed by * **data**: [SecretStorePropertiesData](#secretstorepropertiesdata) (Required): An object to represent key-value type secrets -* **environment**: string: The resource id of the environment linked to the resource -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. +* **environment**: string: Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **resource**: string: The resource id of external secret store. * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **type**: 'certificate' | 'generic': The type of secret store data +* **type**: 'certificate' | 'generic': The type of SecretStore data ## SecretStorePropertiesData ### Properties @@ -492,9 +469,9 @@ ## SecretValueProperties ### Properties -* **encoding**: 'base64' | 'raw': The encoding of value +* **encoding**: 'base64' | 'raw': The type of SecretValue Encoding * **value**: string: The value of secret. -* **valueFrom**: [ValueFromProperties](#valuefromproperties) +* **valueFrom**: [ValueFromProperties](#valuefromproperties): The Secret value source properties ## ValueFromProperties ### Properties @@ -510,15 +487,15 @@ * **Discriminator**: kind ### Base Properties -* **application**: string (Required): Specifies the resource id of the application -* **environment**: string: The resource id of the environment linked to the resource -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the resource at the time the operation was called. +* **application**: string (Required): Fully qualified resource ID for the application that the portable resource is consumed by +* **environment**: string: Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) +* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. ### AzureKeyVaultVolumeProperties #### Properties * **certificates**: [AzureKeyVaultVolumePropertiesCertificates](#azurekeyvaultvolumepropertiescertificates): The KeyVault certificates that this volume exposes * **keys**: [AzureKeyVaultVolumePropertiesKeys](#azurekeyvaultvolumepropertieskeys): The KeyVault keys that this volume exposes -* **kind**: 'azure.com.keyvault' (Required): The volume kind +* **kind**: 'azure.com.keyvault' (Required): Discriminator property for VolumeProperties. * **resource**: string (Required): The ID of the keyvault to use for this volume resource * **secrets**: [AzureKeyVaultVolumePropertiesSecrets](#azurekeyvaultvolumepropertiessecrets): The KeyVault secrets that this volume exposes @@ -530,10 +507,10 @@ ## CertificateObjectProperties ### Properties -* **alias**: string: File name when written to disk. -* **certType**: 'certificate' | 'privatekey' | 'publickey': Certificate object type to be downloaded - the certificate itself, private key or public key of the certificate -* **encoding**: 'base64' | 'hex' | 'utf-8': Encoding format. Default utf-8 -* **format**: 'pem' | 'pfx': Certificate format. Default pem +* **alias**: string: File name when written to disk +* **certType**: 'certificate' | 'privatekey' | 'publickey': Represents certificate types +* **encoding**: 'base64' | 'hex' | 'utf-8': Represents secret encodings +* **format**: 'pem' | 'pfx': Represents certificate formats * **name**: string (Required): The name of the certificate * **version**: string: Certificate version @@ -544,7 +521,7 @@ ## KeyObjectProperties ### Properties -* **alias**: string: File name when written to disk. +* **alias**: string: File name when written to disk * **name**: string (Required): The name of the key * **version**: string: Key version @@ -555,10 +532,10 @@ ## SecretObjectProperties ### Properties -* **alias**: string: File name when written to disk. -* **encoding**: 'base64' | 'hex' | 'utf-8': Encoding format. Default utf-8 +* **alias**: string: File name when written to disk +* **encoding**: 'base64' | 'hex' | 'utf-8': Represents secret encodings * **name**: string (Required): The name of the secret -* **version**: string: Secret version +* **version**: string: secret version ## TrackedResourceTags ### Properties @@ -568,15 +545,10 @@ ## SecretStoreListSecretsResult ### Properties * **data**: [SecretStoreListSecretsResultData](#secretstorelistsecretsresultdata) (ReadOnly): An object to represent key-value type secrets -* **type**: 'certificate' | 'generic' (ReadOnly): The type of secret store data +* **type**: 'certificate' | 'generic' (ReadOnly): The type of SecretStore data ## SecretStoreListSecretsResultData ### Properties ### Additional Properties * **Additional Properties Type**: [SecretValueProperties](#secretvalueproperties) -## ExtenderSecrets -### Properties -### Additional Properties -* **Additional Properties Type**: any - diff --git a/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.json b/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.json index c755326474..f1553f9ea4 100644 --- a/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.json +++ b/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.json @@ -1 +1 @@ -[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Dapr/pubSubBrokers"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Dapr/pubSubBrokers","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"Dapr PubSubBroker portable resource properties"},"tags":{"Type":28,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprPubSubBrokerProperties","Properties":{"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"resourceProvisioning":{"Type":22,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resources":{"Type":25,"Flags":0,"Description":"A collection of references to resources associated with the Dapr PubSubBroker"},"type":{"Type":4,"Flags":0,"Description":"Dapr PubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format."},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[20,21]}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"2":{"Name":"ResourceReference","Properties":{"id":{"Type":4,"Flags":1,"Description":"Resource id of an existing resource"}}}},{"3":{"ItemType":24}},{"2":{"Name":"ResourceStatus","Properties":{"outputResources":{"Type":27,"Flags":0,"Description":"Properties of an output resource"}}}},{"3":{"ItemType":0}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":34,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":39,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[30,31,32,33]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[35,36,37,38]}},{"4":{"Name":"Applications.Dapr/pubSubBrokers@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"6":{"Value":"Applications.Dapr/secretStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Dapr/secretStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":41,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":42,"Flags":10,"Description":"The resource api version"},"properties":{"Type":44,"Flags":0,"Description":"Dapr SecretStore portable resource properties"},"tags":{"Type":56,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprSecretStoreProperties","Properties":{"provisioningState":{"Type":52,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"type":{"Type":4,"Flags":0,"Description":"Dapr SecretStore type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/"},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":55,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[45,46,47,48,49,50,51]}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[53,54]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Dapr/secretStores@2022-03-15-privatepreview","ScopeType":0,"Body":43}},{"6":{"Value":"Applications.Dapr/stateStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Dapr/stateStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":58,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":59,"Flags":10,"Description":"The resource api version"},"properties":{"Type":61,"Flags":0,"Description":"Dapr StateStore portable resource properties"},"tags":{"Type":74,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprStateStoreProperties","Properties":{"provisioningState":{"Type":69,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"resourceProvisioning":{"Type":72,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resources":{"Type":73,"Flags":0,"Description":"A collection of references to resources associated with the Dapr StateStore"},"type":{"Type":4,"Flags":0,"Description":"Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format."},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[62,63,64,65,66,67,68]}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[70,71]}},{"3":{"ItemType":24}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Dapr/stateStores@2022-03-15-privatepreview","ScopeType":0,"Body":60}}] \ No newline at end of file +[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Dapr/pubSubBrokers"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Dapr/pubSubBrokers","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"Dapr PubSubBroker portable resource properties"},"tags":{"Type":36,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":37,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprPubSubBrokerProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":20,"Flags":2,"Description":"Status of a resource."},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"type":{"Type":4,"Flags":0,"Description":"Dapr component type which must matches the format used by Dapr Kubernetes configuration format"},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"resources":{"Type":31,"Flags":0,"Description":"A collection of references to resources associated with the pubSubBroker"},"recipe":{"Type":32,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":35,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"2":{"Name":"ResourceStatus","Properties":{"compute":{"Type":21,"Flags":0,"Description":"Represents backing compute resource"},"outputResources":{"Type":29,"Flags":0,"Description":"Properties of an output resource"}}}},{"7":{"Name":"EnvironmentCompute","Discriminator":"kind","BaseProperties":{"resourceId":{"Type":4,"Flags":0,"Description":"The resource id of the compute resource for application environment."},"identity":{"Type":22,"Flags":0,"Description":"IdentitySettings is the external identity setting."}},"Elements":{"kubernetes":26}}},{"2":{"Name":"IdentitySettings","Properties":{"kind":{"Type":25,"Flags":1,"Description":"IdentitySettingKind is the kind of supported external identity setting"},"oidcIssuer":{"Type":4,"Flags":0,"Description":"The URI for your compute platform's OIDC issuer"},"resource":{"Type":4,"Flags":0,"Description":"The resource ID of the provisioned identity"}}}},{"6":{"Value":"undefined"}},{"6":{"Value":"azure.com.workload"}},{"5":{"Elements":[23,24]}},{"2":{"Name":"KubernetesCompute","Properties":{"namespace":{"Type":4,"Flags":1,"Description":"The namespace to use for the environment."},"kind":{"Type":27,"Flags":1,"Description":"Discriminator property for EnvironmentCompute."}}}},{"6":{"Value":"kubernetes"}},{"2":{"Name":"OutputResource","Properties":{"localId":{"Type":4,"Flags":0,"Description":"The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships."},"id":{"Type":4,"Flags":0,"Description":"The UCP resource ID of the underlying resource."},"radiusManaged":{"Type":2,"Flags":0,"Description":"Determines whether Radius manages the lifecycle of the underlying resource."}}}},{"3":{"ItemType":28}},{"2":{"Name":"ResourceReference","Properties":{"id":{"Type":4,"Flags":1,"Description":"Resource id of an existing resource"}}}},{"3":{"ItemType":30}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[33,34]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":42,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":47,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[38,39,40,41]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[43,44,45,46]}},{"4":{"Name":"Applications.Dapr/pubSubBrokers@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"6":{"Value":"Applications.Dapr/secretStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Dapr/secretStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":49,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":50,"Flags":10,"Description":"The resource api version"},"properties":{"Type":52,"Flags":0,"Description":"Dapr SecretStore portable resource properties"},"tags":{"Type":64,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":37,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprSecretStoreProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":60,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":20,"Flags":2,"Description":"Status of a resource."},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"type":{"Type":4,"Flags":0,"Description":"Dapr component type which must matches the format used by Dapr Kubernetes configuration format"},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"recipe":{"Type":32,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":63,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[53,54,55,56,57,58,59]}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[61,62]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Dapr/secretStores@2022-03-15-privatepreview","ScopeType":0,"Body":51}},{"6":{"Value":"Applications.Dapr/stateStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Dapr/stateStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":66,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":67,"Flags":10,"Description":"The resource api version"},"properties":{"Type":69,"Flags":0,"Description":"Dapr StateStore portable resource properties"},"tags":{"Type":82,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":37,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprStateStoreProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":77,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":20,"Flags":2,"Description":"Status of a resource."},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"type":{"Type":4,"Flags":0,"Description":"Dapr component type which must matches the format used by Dapr Kubernetes configuration format"},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"resources":{"Type":78,"Flags":0,"Description":"A collection of references to resources associated with the state store"},"recipe":{"Type":32,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":81,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[70,71,72,73,74,75,76]}},{"3":{"ItemType":30}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[79,80]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Dapr/stateStores@2022-03-15-privatepreview","ScopeType":0,"Body":68}}] \ No newline at end of file diff --git a/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.md b/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.md index 5d4c9ca5e6..7eb90e7ee1 100644 --- a/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.md +++ b/hack/bicep-types-radius/generated/applications/applications.dapr/2022-03-15-privatepreview/types.md @@ -38,16 +38,16 @@ ## DaprPubSubBrokerProperties ### Properties -* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) * **componentName**: string (ReadOnly): The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component. * **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to * **metadata**: any: Any object * **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: A collection of references to resources associated with the Dapr PubSubBroker +* **resources**: [ResourceReference](#resourcereference)[]: A collection of references to resources associated with the pubSubBroker * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **type**: string: Dapr PubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format. +* **type**: string: Dapr component type which must matches the format used by Dapr Kubernetes configuration format * **version**: string: Dapr component version ## Recipe @@ -61,7 +61,32 @@ ## ResourceStatus ### Properties -* **outputResources**: any[]: Properties of an output resource +* **compute**: [EnvironmentCompute](#environmentcompute): Represents backing compute resource +* **outputResources**: [OutputResource](#outputresource)[]: Properties of an output resource + +## EnvironmentCompute +* **Discriminator**: kind + +### Base Properties +* **identity**: [IdentitySettings](#identitysettings): IdentitySettings is the external identity setting. +* **resourceId**: string: The resource id of the compute resource for application environment. +### KubernetesCompute +#### Properties +* **kind**: 'kubernetes' (Required): Discriminator property for EnvironmentCompute. +* **namespace**: string (Required): The namespace to use for the environment. + + +## IdentitySettings +### Properties +* **kind**: 'azure.com.workload' | 'undefined' (Required): IdentitySettingKind is the kind of supported external identity setting +* **oidcIssuer**: string: The URI for your compute platform's OIDC issuer +* **resource**: string: The resource ID of the provisioned identity + +## OutputResource +### Properties +* **id**: string: The UCP resource ID of the underlying resource. +* **localId**: string: The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships. +* **radiusManaged**: bool: Determines whether Radius manages the lifecycle of the underlying resource. ## SystemData ### Properties @@ -79,7 +104,7 @@ ## DaprSecretStoreProperties ### Properties -* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) * **componentName**: string (ReadOnly): The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component. * **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to * **metadata**: any: Any object @@ -87,7 +112,7 @@ * **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **type**: string: Dapr SecretStore type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/ +* **type**: string: Dapr component type which must matches the format used by Dapr Kubernetes configuration format * **version**: string: Dapr component version ## TrackedResourceTags @@ -97,16 +122,16 @@ ## DaprStateStoreProperties ### Properties -* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) * **componentName**: string (ReadOnly): The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component. * **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to * **metadata**: any: Any object * **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: A collection of references to resources associated with the Dapr StateStore +* **resources**: [ResourceReference](#resourcereference)[]: A collection of references to resources associated with the state store * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **type**: string: Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format. +* **type**: string: Dapr component type which must matches the format used by Dapr Kubernetes configuration format * **version**: string: Dapr component version ## TrackedResourceTags diff --git a/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.json b/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.json index 0034117fb4..63ac3ae3a4 100644 --- a/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.json +++ b/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.json @@ -1 +1 @@ -[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Datastores/mongoDatabases"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Datastores/mongoDatabases","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"Mongo database portable resource properties"},"tags":{"Type":29,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":30,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"MongoDatabaseProperties","Properties":{"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"secrets":{"Type":20,"Flags":0,"Description":"The secret values for the given Mongo database resource"},"host":{"Type":4,"Flags":0,"Description":"Host name of the target Mongo database"},"port":{"Type":3,"Flags":0,"Description":"Port value of the target Mongo database"},"database":{"Type":4,"Flags":0,"Description":"Database name of the target Mongo database"},"recipe":{"Type":21,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resources":{"Type":23,"Flags":0,"Description":"List of the resource IDs that support the Mongo database resource"},"resourceProvisioning":{"Type":26,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"username":{"Type":4,"Flags":0,"Description":"Username to use when connecting to the target Mongo database"},"status":{"Type":27,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"2":{"Name":"MongoDatabaseSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"Password to use when connecting to the target Mongo database"},"connectionString":{"Type":4,"Flags":0,"Description":"Connection string used to connect to the target Mongo database"}}}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"2":{"Name":"ResourceReference","Properties":{"id":{"Type":4,"Flags":1,"Description":"Resource id of an existing resource"}}}},{"3":{"ItemType":22}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[24,25]}},{"2":{"Name":"ResourceStatus","Properties":{"outputResources":{"Type":28,"Flags":0,"Description":"Properties of an output resource"}}}},{"3":{"ItemType":0}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":35,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":40,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[31,32,33,34]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[36,37,38,39]}},{"4":{"Name":"Applications.Datastores/mongoDatabases@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"6":{"Value":"Applications.Datastores/redisCaches"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Datastores/redisCaches","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":42,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":43,"Flags":10,"Description":"The resource api version"},"properties":{"Type":45,"Flags":0,"Description":"Redis cache portable resource properties"},"tags":{"Type":59,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":30,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"RedisCacheProperties","Properties":{"provisioningState":{"Type":53,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"secrets":{"Type":54,"Flags":0,"Description":"The secret values for the given Redis cache resource"},"host":{"Type":4,"Flags":0,"Description":"The host name of the target Redis cache"},"port":{"Type":3,"Flags":0,"Description":"The port value of the target Redis cache"},"username":{"Type":4,"Flags":0,"Description":"The username for Redis cache"},"tls":{"Type":2,"Flags":0,"Description":"Specifies whether to enable SSL connections to the Redis cache"},"recipe":{"Type":21,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resources":{"Type":55,"Flags":0,"Description":"List of the resource IDs that support the Redis resource"},"resourceProvisioning":{"Type":58,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"status":{"Type":27,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[46,47,48,49,50,51,52]}},{"2":{"Name":"RedisCacheSecrets","Properties":{"connectionString":{"Type":4,"Flags":0,"Description":"The connection string used to connect to the Redis cache"},"password":{"Type":4,"Flags":0,"Description":"The password for this Redis cache instance"},"url":{"Type":4,"Flags":0,"Description":"The URL used to connect to the Redis cache"}}}},{"3":{"ItemType":22}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[56,57]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Datastores/redisCaches@2022-03-15-privatepreview","ScopeType":0,"Body":44}},{"6":{"Value":"Applications.Datastores/sqlDatabases"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Datastores/sqlDatabases","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":61,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":62,"Flags":10,"Description":"The resource api version"},"properties":{"Type":64,"Flags":0,"Description":"Sql database properties"},"tags":{"Type":78,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":30,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"SqlDatabaseProperties","Properties":{"provisioningState":{"Type":72,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"database":{"Type":4,"Flags":0,"Description":"The name of the SQL database."},"server":{"Type":4,"Flags":0,"Description":"The fully qualified domain name of the target SQL database."},"port":{"Type":3,"Flags":0,"Description":"Port value of the target SQL database"},"username":{"Type":4,"Flags":0,"Description":"Username to use when connecting to the target SQL database"},"recipe":{"Type":21,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resources":{"Type":73,"Flags":0,"Description":"List of the resource IDs that support the SQL database resource"},"resourceProvisioning":{"Type":76,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"secrets":{"Type":77,"Flags":0,"Description":"The secret values for the given SQL database resource"},"status":{"Type":27,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[65,66,67,68,69,70,71]}},{"3":{"ItemType":22}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[74,75]}},{"2":{"Name":"SqlDatabaseSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"Password to use when connecting to the target SQL database"},"connectionString":{"Type":4,"Flags":0,"Description":"Connection string used to connect to the target SQL database"}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Datastores/sqlDatabases@2022-03-15-privatepreview","ScopeType":0,"Body":63}},{"2":{"Name":"MongoDatabaseListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"Password to use when connecting to the target Mongo database"},"connectionString":{"Type":4,"Flags":2,"Description":"Connection string used to connect to the target Mongo database"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Datastores/mongoDatabases","ApiVersion":"2022-03-15-privatepreview","Output":80}},{"2":{"Name":"RedisCacheListSecretsResult","Properties":{"connectionString":{"Type":4,"Flags":2,"Description":"The connection string used to connect to the Redis cache"},"password":{"Type":4,"Flags":2,"Description":"The password for this Redis cache instance"},"url":{"Type":4,"Flags":2,"Description":"The URL used to connect to the Redis cache"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Datastores/redisCaches","ApiVersion":"2022-03-15-privatepreview","Output":82}},{"2":{"Name":"SqlDatabaseListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"Password to use when connecting to the target SQL database"},"connectionString":{"Type":4,"Flags":2,"Description":"Connection string used to connect to the target SQL database"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Datastores/sqlDatabases","ApiVersion":"2022-03-15-privatepreview","Output":84}}] \ No newline at end of file +[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Datastores/mongoDatabases"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Datastores/mongoDatabases","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"MongoDatabase portable resource properties"},"tags":{"Type":37,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":38,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"MongoDatabaseProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":20,"Flags":2,"Description":"Status of a resource."},"secrets":{"Type":30,"Flags":0,"Description":"The secret values for the given MongoDatabase resource"},"host":{"Type":4,"Flags":0,"Description":"Host name of the target Mongo database"},"port":{"Type":3,"Flags":0,"Description":"Port value of the target Mongo database"},"database":{"Type":4,"Flags":0,"Description":"Database name of the target Mongo database"},"resources":{"Type":32,"Flags":0,"Description":"List of the resource IDs that support the MongoDB resource"},"username":{"Type":4,"Flags":0,"Description":"Username to use when connecting to the target Mongo database"},"recipe":{"Type":33,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":36,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"2":{"Name":"ResourceStatus","Properties":{"compute":{"Type":21,"Flags":0,"Description":"Represents backing compute resource"},"outputResources":{"Type":29,"Flags":0,"Description":"Properties of an output resource"}}}},{"7":{"Name":"EnvironmentCompute","Discriminator":"kind","BaseProperties":{"resourceId":{"Type":4,"Flags":0,"Description":"The resource id of the compute resource for application environment."},"identity":{"Type":22,"Flags":0,"Description":"IdentitySettings is the external identity setting."}},"Elements":{"kubernetes":26}}},{"2":{"Name":"IdentitySettings","Properties":{"kind":{"Type":25,"Flags":1,"Description":"IdentitySettingKind is the kind of supported external identity setting"},"oidcIssuer":{"Type":4,"Flags":0,"Description":"The URI for your compute platform's OIDC issuer"},"resource":{"Type":4,"Flags":0,"Description":"The resource ID of the provisioned identity"}}}},{"6":{"Value":"undefined"}},{"6":{"Value":"azure.com.workload"}},{"5":{"Elements":[23,24]}},{"2":{"Name":"KubernetesCompute","Properties":{"namespace":{"Type":4,"Flags":1,"Description":"The namespace to use for the environment."},"kind":{"Type":27,"Flags":1,"Description":"Discriminator property for EnvironmentCompute."}}}},{"6":{"Value":"kubernetes"}},{"2":{"Name":"OutputResource","Properties":{"localId":{"Type":4,"Flags":0,"Description":"The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships."},"id":{"Type":4,"Flags":0,"Description":"The UCP resource ID of the underlying resource."},"radiusManaged":{"Type":2,"Flags":0,"Description":"Determines whether Radius manages the lifecycle of the underlying resource."}}}},{"3":{"ItemType":28}},{"2":{"Name":"MongoDatabaseSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"Password to use when connecting to the target Mongo database"},"connectionString":{"Type":4,"Flags":0,"Description":"Connection string used to connect to the target Mongo database"}}}},{"2":{"Name":"ResourceReference","Properties":{"id":{"Type":4,"Flags":1,"Description":"Resource id of an existing resource"}}}},{"3":{"ItemType":31}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[34,35]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":43,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":48,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[39,40,41,42]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[44,45,46,47]}},{"4":{"Name":"Applications.Datastores/mongoDatabases@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"6":{"Value":"Applications.Datastores/redisCaches"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Datastores/redisCaches","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":50,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":51,"Flags":10,"Description":"The resource api version"},"properties":{"Type":53,"Flags":0,"Description":"RedisCache portable resource properties"},"tags":{"Type":67,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":38,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"RedisCacheProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":61,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":20,"Flags":2,"Description":"Status of a resource."},"secrets":{"Type":62,"Flags":0,"Description":"The secret values for the given RedisCache resource"},"host":{"Type":4,"Flags":0,"Description":"The host name of the target Redis cache"},"port":{"Type":3,"Flags":0,"Description":"The port value of the target Redis cache"},"username":{"Type":4,"Flags":0,"Description":"The username for Redis cache"},"tls":{"Type":2,"Flags":0,"Description":"Specifies whether to enable SSL connections to the Redis cache"},"resources":{"Type":63,"Flags":0,"Description":"List of the resource IDs that support the Redis resource"},"recipe":{"Type":33,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":66,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[54,55,56,57,58,59,60]}},{"2":{"Name":"RedisCacheSecrets","Properties":{"connectionString":{"Type":4,"Flags":0,"Description":"The connection string used to connect to the Redis cache"},"password":{"Type":4,"Flags":0,"Description":"The password for this Redis cache instance"},"url":{"Type":4,"Flags":0,"Description":"The URL used to connect to the Redis cache"}}}},{"3":{"ItemType":31}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[64,65]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Datastores/redisCaches@2022-03-15-privatepreview","ScopeType":0,"Body":52}},{"6":{"Value":"Applications.Datastores/sqlDatabases"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Datastores/sqlDatabases","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":69,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":70,"Flags":10,"Description":"The resource api version"},"properties":{"Type":72,"Flags":0,"Description":"SqlDatabase properties"},"tags":{"Type":86,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":38,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"SqlDatabaseProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":80,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":20,"Flags":2,"Description":"Status of a resource."},"database":{"Type":4,"Flags":0,"Description":"The name of the Sql database."},"server":{"Type":4,"Flags":0,"Description":"The fully qualified domain name of the Sql database."},"port":{"Type":3,"Flags":0,"Description":"Port value of the target Sql database"},"username":{"Type":4,"Flags":0,"Description":"Username to use when connecting to the target Sql database"},"resources":{"Type":81,"Flags":0,"Description":"List of the resource IDs that support the SqlDatabase resource"},"secrets":{"Type":82,"Flags":0,"Description":"The secret values for the given SqlDatabase resource"},"recipe":{"Type":33,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":85,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[73,74,75,76,77,78,79]}},{"3":{"ItemType":31}},{"2":{"Name":"SqlDatabaseSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"Password to use when connecting to the target Sql database"},"connectionString":{"Type":4,"Flags":0,"Description":"Connection string used to connect to the target Sql database"}}}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[83,84]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Datastores/sqlDatabases@2022-03-15-privatepreview","ScopeType":0,"Body":71}},{"2":{"Name":"MongoDatabaseListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"Password to use when connecting to the target Mongo database"},"connectionString":{"Type":4,"Flags":2,"Description":"Connection string used to connect to the target Mongo database"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Datastores/mongoDatabases","ApiVersion":"2022-03-15-privatepreview","Output":88,"Input":0}},{"2":{"Name":"RedisCacheListSecretsResult","Properties":{"connectionString":{"Type":4,"Flags":2,"Description":"The connection string used to connect to the Redis cache"},"password":{"Type":4,"Flags":2,"Description":"The password for this Redis cache instance"},"url":{"Type":4,"Flags":2,"Description":"The URL used to connect to the Redis cache"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Datastores/redisCaches","ApiVersion":"2022-03-15-privatepreview","Output":90,"Input":0}},{"2":{"Name":"SqlDatabaseListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"Password to use when connecting to the target Sql database"},"connectionString":{"Type":4,"Flags":2,"Description":"Connection string used to connect to the target Sql database"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Datastores/sqlDatabases","ApiVersion":"2022-03-15-privatepreview","Output":92,"Input":0}}] \ No newline at end of file diff --git a/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.md b/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.md index 856113971a..91c2ced2c5 100644 --- a/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.md +++ b/hack/bicep-types-radius/generated/applications/applications.datastores/2022-03-15-privatepreview/types.md @@ -7,7 +7,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [MongoDatabaseProperties](#mongodatabaseproperties): Mongo database portable resource properties +* **properties**: [MongoDatabaseProperties](#mongodatabaseproperties): MongoDatabase portable resource properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Datastores/mongoDatabases' (ReadOnly, DeployTimeConstant): The resource type @@ -19,7 +19,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [RedisCacheProperties](#rediscacheproperties): Redis cache portable resource properties +* **properties**: [RedisCacheProperties](#rediscacheproperties): RedisCache portable resource properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Datastores/redisCaches' (ReadOnly, DeployTimeConstant): The resource type @@ -31,7 +31,7 @@ * **id**: string (ReadOnly, DeployTimeConstant): The resource id * **location**: string (Required): The geo-location where the resource lives * **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [SqlDatabaseProperties](#sqldatabaseproperties): Sql database properties +* **properties**: [SqlDatabaseProperties](#sqldatabaseproperties): SqlDatabase properties * **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. * **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. * **type**: 'Applications.Datastores/sqlDatabases' (ReadOnly, DeployTimeConstant): The resource type @@ -39,21 +39,24 @@ ## Function listSecrets (Applications.Datastores/mongoDatabases@2022-03-15-privatepreview) * **Resource**: Applications.Datastores/mongoDatabases * **ApiVersion**: 2022-03-15-privatepreview +* **Input**: any * **Output**: [MongoDatabaseListSecretsResult](#mongodatabaselistsecretsresult) ## Function listSecrets (Applications.Datastores/redisCaches@2022-03-15-privatepreview) * **Resource**: Applications.Datastores/redisCaches * **ApiVersion**: 2022-03-15-privatepreview +* **Input**: any * **Output**: [RedisCacheListSecretsResult](#rediscachelistsecretsresult) ## Function listSecrets (Applications.Datastores/sqlDatabases@2022-03-15-privatepreview) * **Resource**: Applications.Datastores/sqlDatabases * **ApiVersion**: 2022-03-15-privatepreview +* **Input**: any * **Output**: [SqlDatabaseListSecretsResult](#sqldatabaselistsecretsresult) ## MongoDatabaseProperties ### Properties -* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) * **database**: string: Database name of the target Mongo database * **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to * **host**: string: Host name of the target Mongo database @@ -61,8 +64,8 @@ * **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the Mongo database resource -* **secrets**: [MongoDatabaseSecrets](#mongodatabasesecrets): The secret values for the given Mongo database resource +* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the MongoDB resource +* **secrets**: [MongoDatabaseSecrets](#mongodatabasesecrets): The secret values for the given MongoDatabase resource * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. * **username**: string: Username to use when connecting to the target Mongo database @@ -82,7 +85,32 @@ ## ResourceStatus ### Properties -* **outputResources**: any[]: Properties of an output resource +* **compute**: [EnvironmentCompute](#environmentcompute): Represents backing compute resource +* **outputResources**: [OutputResource](#outputresource)[]: Properties of an output resource + +## EnvironmentCompute +* **Discriminator**: kind + +### Base Properties +* **identity**: [IdentitySettings](#identitysettings): IdentitySettings is the external identity setting. +* **resourceId**: string: The resource id of the compute resource for application environment. +### KubernetesCompute +#### Properties +* **kind**: 'kubernetes' (Required): Discriminator property for EnvironmentCompute. +* **namespace**: string (Required): The namespace to use for the environment. + + +## IdentitySettings +### Properties +* **kind**: 'azure.com.workload' | 'undefined' (Required): IdentitySettingKind is the kind of supported external identity setting +* **oidcIssuer**: string: The URI for your compute platform's OIDC issuer +* **resource**: string: The resource ID of the provisioned identity + +## OutputResource +### Properties +* **id**: string: The UCP resource ID of the underlying resource. +* **localId**: string: The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships. +* **radiusManaged**: bool: Determines whether Radius manages the lifecycle of the underlying resource. ## SystemData ### Properties @@ -100,7 +128,7 @@ ## RedisCacheProperties ### Properties -* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) * **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to * **host**: string: The host name of the target Redis cache * **port**: int: The port value of the target Redis cache @@ -108,7 +136,7 @@ * **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. * **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the Redis resource -* **secrets**: [RedisCacheSecrets](#rediscachesecrets): The secret values for the given Redis cache resource +* **secrets**: [RedisCacheSecrets](#rediscachesecrets): The secret values for the given RedisCache resource * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. * **tls**: bool: Specifies whether to enable SSL connections to the Redis cache * **username**: string: The username for Redis cache @@ -126,23 +154,23 @@ ## SqlDatabaseProperties ### Properties -* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by -* **database**: string: The name of the SQL database. +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) +* **database**: string: The name of the Sql database. * **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to -* **port**: int: Port value of the target SQL database +* **port**: int: Port value of the target Sql database * **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the portable resource at the time the operation was called * **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the SQL database resource -* **secrets**: [SqlDatabaseSecrets](#sqldatabasesecrets): The secret values for the given SQL database resource -* **server**: string: The fully qualified domain name of the target SQL database. +* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the SqlDatabase resource +* **secrets**: [SqlDatabaseSecrets](#sqldatabasesecrets): The secret values for the given SqlDatabase resource +* **server**: string: The fully qualified domain name of the Sql database. * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **username**: string: Username to use when connecting to the target SQL database +* **username**: string: Username to use when connecting to the target Sql database ## SqlDatabaseSecrets ### Properties -* **connectionString**: string: Connection string used to connect to the target SQL database -* **password**: string: Password to use when connecting to the target SQL database +* **connectionString**: string: Connection string used to connect to the target Sql database +* **password**: string: Password to use when connecting to the target Sql database ## TrackedResourceTags ### Properties @@ -162,6 +190,6 @@ ## SqlDatabaseListSecretsResult ### Properties -* **connectionString**: string (ReadOnly): Connection string used to connect to the target SQL database -* **password**: string (ReadOnly): Password to use when connecting to the target SQL database +* **connectionString**: string (ReadOnly): Connection string used to connect to the target Sql database +* **password**: string (ReadOnly): Password to use when connecting to the target Sql database diff --git a/hack/bicep-types-radius/generated/applications/applications.link/2022-03-15-privatepreview/types.json b/hack/bicep-types-radius/generated/applications/applications.link/2022-03-15-privatepreview/types.json deleted file mode 100644 index 955d5a7757..0000000000 --- a/hack/bicep-types-radius/generated/applications/applications.link/2022-03-15-privatepreview/types.json +++ /dev/null @@ -1 +0,0 @@ -[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Link/daprPubSubBrokers"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/daprPubSubBrokers","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"DaprPubSubBroker link properties"},"tags":{"Type":28,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprPubSubBrokerProperties","Properties":{"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"resourceProvisioning":{"Type":22,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"resources":{"Type":25,"Flags":0,"Description":"A collection of references to resources associated with the daprPubSubBroker"},"type":{"Type":4,"Flags":0,"Description":"DaprPubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format."},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[20,21]}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"2":{"Name":"ResourceReference","Properties":{"id":{"Type":4,"Flags":1,"Description":"Resource id of an existing resource"}}}},{"3":{"ItemType":24}},{"2":{"Name":"ResourceStatus","Properties":{"outputResources":{"Type":27,"Flags":0,"Description":"Properties of an output resource"}}}},{"3":{"ItemType":0}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":34,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":39,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[30,31,32,33]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[35,36,37,38]}},{"4":{"Name":"Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"6":{"Value":"Applications.Link/daprSecretStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/daprSecretStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":41,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":42,"Flags":10,"Description":"The resource api version"},"properties":{"Type":44,"Flags":0,"Description":"DaprSecretStore link properties"},"tags":{"Type":56,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprSecretStoreProperties","Properties":{"provisioningState":{"Type":52,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"type":{"Type":4,"Flags":0,"Description":"Dapr Secret Store type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/"},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"resourceProvisioning":{"Type":55,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[45,46,47,48,49,50,51]}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[53,54]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Link/daprSecretStores@2022-03-15-privatepreview","ScopeType":0,"Body":43}},{"6":{"Value":"Applications.Link/daprStateStores"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/daprStateStores","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":58,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":59,"Flags":10,"Description":"The resource api version"},"properties":{"Type":61,"Flags":0,"Description":"DaprStateStore link properties"},"tags":{"Type":74,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"DaprStateStoreProperties","Properties":{"provisioningState":{"Type":69,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"resourceProvisioning":{"Type":72,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"metadata":{"Type":0,"Flags":0,"Description":"Any object"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"resources":{"Type":73,"Flags":0,"Description":"A collection of references to resources associated with the state store"},"type":{"Type":4,"Flags":0,"Description":"Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format."},"version":{"Type":4,"Flags":0,"Description":"Dapr component version"},"componentName":{"Type":4,"Flags":2,"Description":"The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component."},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[62,63,64,65,66,67,68]}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[70,71]}},{"3":{"ItemType":24}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Link/daprStateStores@2022-03-15-privatepreview","ScopeType":0,"Body":60}},{"6":{"Value":"Applications.Link/mongoDatabases"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/mongoDatabases","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":76,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":77,"Flags":10,"Description":"The resource api version"},"properties":{"Type":79,"Flags":0,"Description":"MongoDatabase link properties"},"tags":{"Type":93,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"MongoDatabaseProperties","Properties":{"provisioningState":{"Type":87,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"secrets":{"Type":88,"Flags":0,"Description":"The secret values for the given MongoDatabase resource"},"host":{"Type":4,"Flags":0,"Description":"Host name of the target Mongo database"},"port":{"Type":3,"Flags":0,"Description":"Port value of the target Mongo database"},"database":{"Type":4,"Flags":0,"Description":"Database name of the target Mongo database"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"resources":{"Type":89,"Flags":0,"Description":"List of the resource IDs that support the MongoDB resource"},"resourceProvisioning":{"Type":92,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"username":{"Type":4,"Flags":0,"Description":"Username to use when connecting to the target Mongo database"},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[80,81,82,83,84,85,86]}},{"2":{"Name":"MongoDatabaseSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"Password to use when connecting to the target Mongo database"},"connectionString":{"Type":4,"Flags":0,"Description":"Connection string used to connect to the target Mongo database"}}}},{"3":{"ItemType":24}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[90,91]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Link/mongoDatabases@2022-03-15-privatepreview","ScopeType":0,"Body":78}},{"6":{"Value":"Applications.Link/rabbitMQMessageQueues"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/rabbitMQMessageQueues","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":95,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":96,"Flags":10,"Description":"The resource api version"},"properties":{"Type":98,"Flags":0,"Description":"RabbitMQMessageQueue link properties"},"tags":{"Type":112,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"RabbitMQMessageQueueProperties","Properties":{"provisioningState":{"Type":106,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"secrets":{"Type":107,"Flags":0,"Description":"The secret values for the given RabbitMQMessageQueue resource"},"queue":{"Type":4,"Flags":0,"Description":"The name of the queue"},"host":{"Type":4,"Flags":0,"Description":"The hostname of the RabbitMQ instance"},"port":{"Type":3,"Flags":0,"Description":"The port of the RabbitMQ instance. Defaults to 5672"},"vHost":{"Type":4,"Flags":0,"Description":"The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost."},"username":{"Type":4,"Flags":0,"Description":"The username to use when connecting to the RabbitMQ instance"},"resources":{"Type":108,"Flags":0,"Description":"List of the resource IDs that support the rabbitMQ resource"},"resourceProvisioning":{"Type":111,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"tls":{"Type":2,"Flags":0,"Description":"Specifies whether to use SSL when connecting to the RabbitMQ instance"},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[99,100,101,102,103,104,105]}},{"2":{"Name":"RabbitMQSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"The password used to connect to the RabbitMQ instance"},"uri":{"Type":4,"Flags":0,"Description":"The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value"}}}},{"3":{"ItemType":24}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[109,110]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview","ScopeType":0,"Body":97}},{"6":{"Value":"Applications.Link/redisCaches"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/redisCaches","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":114,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":115,"Flags":10,"Description":"The resource api version"},"properties":{"Type":117,"Flags":0,"Description":"RedisCache link properties"},"tags":{"Type":131,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"RedisCacheProperties","Properties":{"provisioningState":{"Type":125,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"secrets":{"Type":126,"Flags":0,"Description":"The secret values for the given RedisCache resource"},"host":{"Type":4,"Flags":0,"Description":"The host name of the target Redis cache"},"port":{"Type":3,"Flags":0,"Description":"The port value of the target Redis cache"},"username":{"Type":4,"Flags":0,"Description":"The username for Redis cache"},"tls":{"Type":2,"Flags":0,"Description":"Specifies whether to enable SSL connections to the Redis cache"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"resources":{"Type":127,"Flags":0,"Description":"List of the resource IDs that support the Redis resource"},"resourceProvisioning":{"Type":130,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[118,119,120,121,122,123,124]}},{"2":{"Name":"RedisCacheSecrets","Properties":{"connectionString":{"Type":4,"Flags":0,"Description":"The connection string used to connect to the Redis cache"},"password":{"Type":4,"Flags":0,"Description":"The password for this Redis cache instance"},"url":{"Type":4,"Flags":0,"Description":"The URL used to connect to the Redis cache"}}}},{"3":{"ItemType":24}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[128,129]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Link/redisCaches@2022-03-15-privatepreview","ScopeType":0,"Body":116}},{"6":{"Value":"Applications.Link/sqlDatabases"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/sqlDatabases","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":133,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":134,"Flags":10,"Description":"The resource api version"},"properties":{"Type":136,"Flags":0,"Description":"SqlDatabase properties"},"tags":{"Type":150,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"SqlDatabaseProperties","Properties":{"provisioningState":{"Type":144,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"database":{"Type":4,"Flags":0,"Description":"The name of the Sql database."},"server":{"Type":4,"Flags":0,"Description":"The fully qualified domain name of the Sql database."},"port":{"Type":3,"Flags":0,"Description":"Port value of the target Sql database"},"username":{"Type":4,"Flags":0,"Description":"Username to use when connecting to the target Sql database"},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"resources":{"Type":145,"Flags":0,"Description":"List of the resource IDs that support the SqlDatabase resource"},"resourceProvisioning":{"Type":148,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"secrets":{"Type":149,"Flags":0,"Description":"The secret values for the given SqlDatabase resource"},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[137,138,139,140,141,142,143]}},{"3":{"ItemType":24}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[146,147]}},{"2":{"Name":"SqlDatabaseSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"Password to use when connecting to the target Sql database"},"connectionString":{"Type":4,"Flags":0,"Description":"Connection string used to connect to the target Sql database"}}}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Link/sqlDatabases@2022-03-15-privatepreview","ScopeType":0,"Body":135}},{"6":{"Value":"Applications.Link/extenders"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Link/extenders","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":152,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":153,"Flags":10,"Description":"The resource api version"},"properties":{"Type":155,"Flags":1,"Description":"Extender link properties"},"tags":{"Type":168,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":29,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"ExtenderProperties","Properties":{"provisioningState":{"Type":163,"Flags":2,"Description":"Provisioning state of the link at the time the operation was called"},"secrets":{"Type":164,"Flags":0,"Description":"The secret values for the given Extender resource"},"resourceProvisioning":{"Type":167,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"recipe":{"Type":23,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a link"},"status":{"Type":26,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the link is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the link is consumed by"}},"AdditionalProperties":0}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[156,157,158,159,160,161,162]}},{"2":{"Name":"ExtenderSecrets","Properties":{},"AdditionalProperties":0}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[165,166]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"4":{"Name":"Applications.Link/extenders@2022-03-15-privatepreview","ScopeType":0,"Body":154}},{"2":{"Name":"MongoDatabaseListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"Password to use when connecting to the target Mongo database"},"connectionString":{"Type":4,"Flags":2,"Description":"Connection string used to connect to the target Mongo database"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Link/mongoDatabases","ApiVersion":"2022-03-15-privatepreview","Output":170}},{"2":{"Name":"RabbitMQListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"The password used to connect to the RabbitMQ instance"},"uri":{"Type":4,"Flags":2,"Description":"The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Link/rabbitMQMessageQueues","ApiVersion":"2022-03-15-privatepreview","Output":172}},{"2":{"Name":"RedisCacheListSecretsResult","Properties":{"connectionString":{"Type":4,"Flags":2,"Description":"The connection string used to connect to the Redis cache"},"password":{"Type":4,"Flags":2,"Description":"The password for this Redis cache instance"},"url":{"Type":4,"Flags":2,"Description":"The URL used to connect to the Redis cache"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Link/redisCaches","ApiVersion":"2022-03-15-privatepreview","Output":174}},{"2":{"Name":"SqlDatabaseListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"Password to use when connecting to the target Sql database"},"connectionString":{"Type":4,"Flags":2,"Description":"Connection string used to connect to the target Sql database"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Link/sqlDatabases","ApiVersion":"2022-03-15-privatepreview","Output":176}},{"2":{"Name":"ExtenderSecrets","Properties":{},"AdditionalProperties":0}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Link/extenders","ApiVersion":"2022-03-15-privatepreview","Output":178}}] \ No newline at end of file diff --git a/hack/bicep-types-radius/generated/applications/applications.link/2022-03-15-privatepreview/types.md b/hack/bicep-types-radius/generated/applications/applications.link/2022-03-15-privatepreview/types.md deleted file mode 100644 index 1ae31cefde..0000000000 --- a/hack/bicep-types-radius/generated/applications/applications.link/2022-03-15-privatepreview/types.md +++ /dev/null @@ -1,352 +0,0 @@ -# Applications.Link @ 2022-03-15-privatepreview - -## Resource Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [DaprPubSubBrokerProperties](#daprpubsubbrokerproperties): DaprPubSubBroker link properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/daprPubSubBrokers' (ReadOnly, DeployTimeConstant): The resource type - -## Resource Applications.Link/daprSecretStores@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [DaprSecretStoreProperties](#daprsecretstoreproperties): DaprSecretStore link properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/daprSecretStores' (ReadOnly, DeployTimeConstant): The resource type - -## Resource Applications.Link/daprStateStores@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [DaprStateStoreProperties](#daprstatestoreproperties): DaprStateStore link properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/daprStateStores' (ReadOnly, DeployTimeConstant): The resource type - -## Resource Applications.Link/extenders@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [ExtenderProperties](#extenderproperties) (Required): Extender link properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/extenders' (ReadOnly, DeployTimeConstant): The resource type - -## Resource Applications.Link/mongoDatabases@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [MongoDatabaseProperties](#mongodatabaseproperties): MongoDatabase link properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/mongoDatabases' (ReadOnly, DeployTimeConstant): The resource type - -## Resource Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [RabbitMQMessageQueueProperties](#rabbitmqmessagequeueproperties): RabbitMQMessageQueue link properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/rabbitMQMessageQueues' (ReadOnly, DeployTimeConstant): The resource type - -## Resource Applications.Link/redisCaches@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [RedisCacheProperties](#rediscacheproperties): RedisCache link properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/redisCaches' (ReadOnly, DeployTimeConstant): The resource type - -## Resource Applications.Link/sqlDatabases@2022-03-15-privatepreview -* **Valid Scope(s)**: Unknown -### Properties -* **apiVersion**: '2022-03-15-privatepreview' (ReadOnly, DeployTimeConstant): The resource api version -* **id**: string (ReadOnly, DeployTimeConstant): The resource id -* **location**: string (Required): The geo-location where the resource lives -* **name**: string (Required, DeployTimeConstant): The resource name -* **properties**: [SqlDatabaseProperties](#sqldatabaseproperties): SqlDatabase properties -* **systemData**: [SystemData](#systemdata) (ReadOnly): Metadata pertaining to creation and last modification of the resource. -* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags. -* **type**: 'Applications.Link/sqlDatabases' (ReadOnly, DeployTimeConstant): The resource type - -## Function listSecrets (Applications.Link/mongoDatabases@2022-03-15-privatepreview) -* **Resource**: Applications.Link/mongoDatabases -* **ApiVersion**: 2022-03-15-privatepreview -* **Output**: [MongoDatabaseListSecretsResult](#mongodatabaselistsecretsresult) - -## Function listSecrets (Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview) -* **Resource**: Applications.Link/rabbitMQMessageQueues -* **ApiVersion**: 2022-03-15-privatepreview -* **Output**: [RabbitMQListSecretsResult](#rabbitmqlistsecretsresult) - -## Function listSecrets (Applications.Link/redisCaches@2022-03-15-privatepreview) -* **Resource**: Applications.Link/redisCaches -* **ApiVersion**: 2022-03-15-privatepreview -* **Output**: [RedisCacheListSecretsResult](#rediscachelistsecretsresult) - -## Function listSecrets (Applications.Link/sqlDatabases@2022-03-15-privatepreview) -* **Resource**: Applications.Link/sqlDatabases -* **ApiVersion**: 2022-03-15-privatepreview -* **Output**: [SqlDatabaseListSecretsResult](#sqldatabaselistsecretsresult) - -## Function listSecrets (Applications.Link/extenders@2022-03-15-privatepreview) -* **Resource**: Applications.Link/extenders -* **ApiVersion**: 2022-03-15-privatepreview -* **Output**: [ExtenderSecrets](#extendersecrets) - -## DaprPubSubBrokerProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **componentName**: string (ReadOnly): The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component. -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **metadata**: any: Any object -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: A collection of references to resources associated with the daprPubSubBroker -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **type**: string: DaprPubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format. -* **version**: string: Dapr component version - -## Recipe -### Properties -* **name**: string (Required): The name of the recipe within the environment to use -* **parameters**: any: Any object - -## ResourceReference -### Properties -* **id**: string (Required): Resource id of an existing resource - -## ResourceStatus -### Properties -* **outputResources**: any[]: Properties of an output resource - -## SystemData -### Properties -* **createdAt**: string: The timestamp of resource creation (UTC). -* **createdBy**: string: The identity that created the resource. -* **createdByType**: 'Application' | 'Key' | 'ManagedIdentity' | 'User': The type of identity that created the resource. -* **lastModifiedAt**: string: The timestamp of resource last modification (UTC) -* **lastModifiedBy**: string: The identity that last modified the resource. -* **lastModifiedByType**: 'Application' | 'Key' | 'ManagedIdentity' | 'User': The type of identity that created the resource. - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## DaprSecretStoreProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **componentName**: string (ReadOnly): The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component. -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **metadata**: any: Any object -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **type**: string: Dapr Secret Store type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/ -* **version**: string: Dapr component version - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## DaprStateStoreProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **componentName**: string (ReadOnly): The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component. -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **metadata**: any: Any object -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: A collection of references to resources associated with the state store -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **type**: string: Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format. -* **version**: string: Dapr component version - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## ExtenderProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **secrets**: [ExtenderSecrets](#extendersecrets): The secret values for the given Extender resource -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -### Additional Properties -* **Additional Properties Type**: any - -## ExtenderSecrets -### Properties -### Additional Properties -* **Additional Properties Type**: any - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## MongoDatabaseProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **database**: string: Database name of the target Mongo database -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **host**: string: Host name of the target Mongo database -* **port**: int: Port value of the target Mongo database -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the MongoDB resource -* **secrets**: [MongoDatabaseSecrets](#mongodatabasesecrets): The secret values for the given MongoDatabase resource -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **username**: string: Username to use when connecting to the target Mongo database - -## MongoDatabaseSecrets -### Properties -* **connectionString**: string: Connection string used to connect to the target Mongo database -* **password**: string: Password to use when connecting to the target Mongo database - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## RabbitMQMessageQueueProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **host**: string: The hostname of the RabbitMQ instance -* **port**: int: The port of the RabbitMQ instance. Defaults to 5672 -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **queue**: string: The name of the queue -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the rabbitMQ resource -* **secrets**: [RabbitMQSecrets](#rabbitmqsecrets): The secret values for the given RabbitMQMessageQueue resource -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **tls**: bool: Specifies whether to use SSL when connecting to the RabbitMQ instance -* **username**: string: The username to use when connecting to the RabbitMQ instance -* **vHost**: string: The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost. - -## RabbitMQSecrets -### Properties -* **password**: string: The password used to connect to the RabbitMQ instance -* **uri**: string: The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## RedisCacheProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **host**: string: The host name of the target Redis cache -* **port**: int: The port value of the target Redis cache -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the Redis resource -* **secrets**: [RedisCacheSecrets](#rediscachesecrets): The secret values for the given RedisCache resource -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **tls**: bool: Specifies whether to enable SSL connections to the Redis cache -* **username**: string: The username for Redis cache - -## RedisCacheSecrets -### Properties -* **connectionString**: string: The connection string used to connect to the Redis cache -* **password**: string: The password for this Redis cache instance -* **url**: string: The URL used to connect to the Redis cache - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## SqlDatabaseProperties -### Properties -* **application**: string: Fully qualified resource ID for the application that the link is consumed by -* **database**: string: The name of the Sql database. -* **environment**: string (Required): Fully qualified resource ID for the environment that the link is linked to -* **port**: int: Port value of the target Sql database -* **provisioningState**: 'Accepted' | 'Canceled' | 'Deleting' | 'Failed' | 'Provisioning' | 'Succeeded' | 'Updating' (ReadOnly): Provisioning state of the link at the time the operation was called -* **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a link -* **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. -* **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the SqlDatabase resource -* **secrets**: [SqlDatabaseSecrets](#sqldatabasesecrets): The secret values for the given SqlDatabase resource -* **server**: string: The fully qualified domain name of the Sql database. -* **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. -* **username**: string: Username to use when connecting to the target Sql database - -## SqlDatabaseSecrets -### Properties -* **connectionString**: string: Connection string used to connect to the target Sql database -* **password**: string: Password to use when connecting to the target Sql database - -## TrackedResourceTags -### Properties -### Additional Properties -* **Additional Properties Type**: string - -## MongoDatabaseListSecretsResult -### Properties -* **connectionString**: string (ReadOnly): Connection string used to connect to the target Mongo database -* **password**: string (ReadOnly): Password to use when connecting to the target Mongo database - -## RabbitMQListSecretsResult -### Properties -* **password**: string (ReadOnly): The password used to connect to the RabbitMQ instance -* **uri**: string (ReadOnly): The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value - -## RedisCacheListSecretsResult -### Properties -* **connectionString**: string (ReadOnly): The connection string used to connect to the Redis cache -* **password**: string (ReadOnly): The password for this Redis cache instance -* **url**: string (ReadOnly): The URL used to connect to the Redis cache - -## SqlDatabaseListSecretsResult -### Properties -* **connectionString**: string (ReadOnly): Connection string used to connect to the target Sql database -* **password**: string (ReadOnly): Password to use when connecting to the target Sql database - -## ExtenderSecrets -### Properties -### Additional Properties -* **Additional Properties Type**: any - diff --git a/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.json b/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.json index 69d0739ada..85196702ea 100644 --- a/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.json +++ b/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.json @@ -1 +1 @@ -[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Messaging/rabbitMQQueues"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Messaging/rabbitMQQueues","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"RabbitMQQueue portable resource properties"},"tags":{"Type":29,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":30,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"RabbitMQQueueProperties","Properties":{"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"secrets":{"Type":20,"Flags":0,"Description":"The secret values for the given RabbitMQQueue resource"},"queue":{"Type":4,"Flags":0,"Description":"The name of the queue"},"host":{"Type":4,"Flags":0,"Description":"The hostname of the RabbitMQ instance"},"port":{"Type":3,"Flags":0,"Description":"The port of the RabbitMQ instance. Defaults to 5672"},"vHost":{"Type":4,"Flags":0,"Description":"The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost."},"username":{"Type":4,"Flags":0,"Description":"The username to use when connecting to the RabbitMQ instance"},"resources":{"Type":22,"Flags":0,"Description":"List of the resource IDs that support the rabbitMQ resource"},"resourceProvisioning":{"Type":25,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."},"recipe":{"Type":26,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"tls":{"Type":2,"Flags":0,"Description":"Specifies whether to use SSL when connecting to the RabbitMQ instance"},"status":{"Type":27,"Flags":2,"Description":"Status of a resource."},"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by"}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"2":{"Name":"RabbitMQSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"The password used to connect to the RabbitMQ instance"},"uri":{"Type":4,"Flags":0,"Description":"The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value"}}}},{"2":{"Name":"ResourceReference","Properties":{"id":{"Type":4,"Flags":1,"Description":"Resource id of an existing resource"}}}},{"3":{"ItemType":21}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[23,24]}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"2":{"Name":"ResourceStatus","Properties":{"outputResources":{"Type":28,"Flags":0,"Description":"Properties of an output resource"}}}},{"3":{"ItemType":0}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":35,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":40,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[31,32,33,34]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[36,37,38,39]}},{"4":{"Name":"Applications.Messaging/rabbitMQQueues@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"2":{"Name":"RabbitMQListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"The password used to connect to the RabbitMQ instance"},"uri":{"Type":4,"Flags":2,"Description":"The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Messaging/rabbitMQQueues","ApiVersion":"2022-03-15-privatepreview","Output":42}}] \ No newline at end of file +[{"1":{"Kind":1}},{"1":{"Kind":2}},{"1":{"Kind":3}},{"1":{"Kind":4}},{"1":{"Kind":5}},{"1":{"Kind":6}},{"1":{"Kind":7}},{"1":{"Kind":8}},{"6":{"Value":"Applications.Messaging/rabbitMQQueues"}},{"6":{"Value":"2022-03-15-privatepreview"}},{"2":{"Name":"Applications.Messaging/rabbitMQQueues","Properties":{"id":{"Type":4,"Flags":10,"Description":"The resource id"},"name":{"Type":4,"Flags":9,"Description":"The resource name"},"type":{"Type":8,"Flags":10,"Description":"The resource type"},"apiVersion":{"Type":9,"Flags":10,"Description":"The resource api version"},"properties":{"Type":11,"Flags":0,"Description":"RabbitMQQueue portable resource properties"},"tags":{"Type":37,"Flags":0,"Description":"Resource tags."},"location":{"Type":4,"Flags":1,"Description":"The geo-location where the resource lives"},"systemData":{"Type":38,"Flags":2,"Description":"Metadata pertaining to creation and last modification of the resource."}}}},{"2":{"Name":"RabbitMQQueueProperties","Properties":{"environment":{"Type":4,"Flags":1,"Description":"Fully qualified resource ID for the environment that the portable resource is linked to"},"application":{"Type":4,"Flags":0,"Description":"Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)"},"provisioningState":{"Type":19,"Flags":2,"Description":"Provisioning state of the portable resource at the time the operation was called"},"status":{"Type":20,"Flags":2,"Description":"Status of a resource."},"secrets":{"Type":30,"Flags":0,"Description":"The connection secrets properties to the RabbitMQ instance"},"queue":{"Type":4,"Flags":0,"Description":"The name of the queue"},"host":{"Type":4,"Flags":0,"Description":"The hostname of the RabbitMQ instance"},"port":{"Type":3,"Flags":0,"Description":"The port of the RabbitMQ instance. Defaults to 5672"},"vHost":{"Type":4,"Flags":0,"Description":"The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost."},"username":{"Type":4,"Flags":0,"Description":"The username to use when connecting to the RabbitMQ instance"},"resources":{"Type":32,"Flags":0,"Description":"List of the resource IDs that support the rabbitMQ resource"},"tls":{"Type":2,"Flags":0,"Description":"Specifies whether to use SSL when connecting to the RabbitMQ instance"},"recipe":{"Type":33,"Flags":0,"Description":"The recipe used to automatically deploy underlying infrastructure for a portable resource"},"resourceProvisioning":{"Type":36,"Flags":0,"Description":"Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values."}}}},{"6":{"Value":"Succeeded"}},{"6":{"Value":"Failed"}},{"6":{"Value":"Canceled"}},{"6":{"Value":"Provisioning"}},{"6":{"Value":"Updating"}},{"6":{"Value":"Deleting"}},{"6":{"Value":"Accepted"}},{"5":{"Elements":[12,13,14,15,16,17,18]}},{"2":{"Name":"ResourceStatus","Properties":{"compute":{"Type":21,"Flags":0,"Description":"Represents backing compute resource"},"outputResources":{"Type":29,"Flags":0,"Description":"Properties of an output resource"}}}},{"7":{"Name":"EnvironmentCompute","Discriminator":"kind","BaseProperties":{"resourceId":{"Type":4,"Flags":0,"Description":"The resource id of the compute resource for application environment."},"identity":{"Type":22,"Flags":0,"Description":"IdentitySettings is the external identity setting."}},"Elements":{"kubernetes":26}}},{"2":{"Name":"IdentitySettings","Properties":{"kind":{"Type":25,"Flags":1,"Description":"IdentitySettingKind is the kind of supported external identity setting"},"oidcIssuer":{"Type":4,"Flags":0,"Description":"The URI for your compute platform's OIDC issuer"},"resource":{"Type":4,"Flags":0,"Description":"The resource ID of the provisioned identity"}}}},{"6":{"Value":"undefined"}},{"6":{"Value":"azure.com.workload"}},{"5":{"Elements":[23,24]}},{"2":{"Name":"KubernetesCompute","Properties":{"namespace":{"Type":4,"Flags":1,"Description":"The namespace to use for the environment."},"kind":{"Type":27,"Flags":1,"Description":"Discriminator property for EnvironmentCompute."}}}},{"6":{"Value":"kubernetes"}},{"2":{"Name":"OutputResource","Properties":{"localId":{"Type":4,"Flags":0,"Description":"The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships."},"id":{"Type":4,"Flags":0,"Description":"The UCP resource ID of the underlying resource."},"radiusManaged":{"Type":2,"Flags":0,"Description":"Determines whether Radius manages the lifecycle of the underlying resource."}}}},{"3":{"ItemType":28}},{"2":{"Name":"RabbitMQSecrets","Properties":{"password":{"Type":4,"Flags":0,"Description":"The password used to connect to the RabbitMQ instance"},"uri":{"Type":4,"Flags":0,"Description":"The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value"}}}},{"2":{"Name":"ResourceReference","Properties":{"id":{"Type":4,"Flags":1,"Description":"Resource id of an existing resource"}}}},{"3":{"ItemType":31}},{"2":{"Name":"Recipe","Properties":{"name":{"Type":4,"Flags":1,"Description":"The name of the recipe within the environment to use"},"parameters":{"Type":0,"Flags":0,"Description":"Any object"}}}},{"6":{"Value":"recipe"}},{"6":{"Value":"manual"}},{"5":{"Elements":[34,35]}},{"2":{"Name":"TrackedResourceTags","Properties":{},"AdditionalProperties":4}},{"2":{"Name":"SystemData","Properties":{"createdBy":{"Type":4,"Flags":0,"Description":"The identity that created the resource."},"createdByType":{"Type":43,"Flags":0,"Description":"The type of identity that created the resource."},"createdAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource creation (UTC)."},"lastModifiedBy":{"Type":4,"Flags":0,"Description":"The identity that last modified the resource."},"lastModifiedByType":{"Type":48,"Flags":0,"Description":"The type of identity that created the resource."},"lastModifiedAt":{"Type":4,"Flags":0,"Description":"The timestamp of resource last modification (UTC)"}}}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[39,40,41,42]}},{"6":{"Value":"User"}},{"6":{"Value":"Application"}},{"6":{"Value":"ManagedIdentity"}},{"6":{"Value":"Key"}},{"5":{"Elements":[44,45,46,47]}},{"4":{"Name":"Applications.Messaging/rabbitMQQueues@2022-03-15-privatepreview","ScopeType":0,"Body":10}},{"2":{"Name":"RabbitMQListSecretsResult","Properties":{"password":{"Type":4,"Flags":2,"Description":"The password used to connect to the RabbitMQ instance"},"uri":{"Type":4,"Flags":2,"Description":"The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value"}}}},{"8":{"Name":"listSecrets","ResourceType":"Applications.Messaging/rabbitMQQueues","ApiVersion":"2022-03-15-privatepreview","Output":50,"Input":0}}] \ No newline at end of file diff --git a/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.md b/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.md index 4111281c54..bca991e7e2 100644 --- a/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.md +++ b/hack/bicep-types-radius/generated/applications/applications.messaging/2022-03-15-privatepreview/types.md @@ -15,11 +15,12 @@ ## Function listSecrets (Applications.Messaging/rabbitMQQueues@2022-03-15-privatepreview) * **Resource**: Applications.Messaging/rabbitMQQueues * **ApiVersion**: 2022-03-15-privatepreview +* **Input**: any * **Output**: [RabbitMQListSecretsResult](#rabbitmqlistsecretsresult) ## RabbitMQQueueProperties ### Properties -* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by +* **application**: string: Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) * **environment**: string (Required): Fully qualified resource ID for the environment that the portable resource is linked to * **host**: string: The hostname of the RabbitMQ instance * **port**: int: The port of the RabbitMQ instance. Defaults to 5672 @@ -28,7 +29,7 @@ * **recipe**: [Recipe](#recipe): The recipe used to automatically deploy underlying infrastructure for a portable resource * **resourceProvisioning**: 'manual' | 'recipe': Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values. * **resources**: [ResourceReference](#resourcereference)[]: List of the resource IDs that support the rabbitMQ resource -* **secrets**: [RabbitMQSecrets](#rabbitmqsecrets): The secret values for the given RabbitMQQueue resource +* **secrets**: [RabbitMQSecrets](#rabbitmqsecrets): The connection secrets properties to the RabbitMQ instance * **status**: [ResourceStatus](#resourcestatus) (ReadOnly): Status of a resource. * **tls**: bool: Specifies whether to use SSL when connecting to the RabbitMQ instance * **username**: string: The username to use when connecting to the RabbitMQ instance @@ -50,7 +51,32 @@ ## ResourceStatus ### Properties -* **outputResources**: any[]: Properties of an output resource +* **compute**: [EnvironmentCompute](#environmentcompute): Represents backing compute resource +* **outputResources**: [OutputResource](#outputresource)[]: Properties of an output resource + +## EnvironmentCompute +* **Discriminator**: kind + +### Base Properties +* **identity**: [IdentitySettings](#identitysettings): IdentitySettings is the external identity setting. +* **resourceId**: string: The resource id of the compute resource for application environment. +### KubernetesCompute +#### Properties +* **kind**: 'kubernetes' (Required): Discriminator property for EnvironmentCompute. +* **namespace**: string (Required): The namespace to use for the environment. + + +## IdentitySettings +### Properties +* **kind**: 'azure.com.workload' | 'undefined' (Required): IdentitySettingKind is the kind of supported external identity setting +* **oidcIssuer**: string: The URI for your compute platform's OIDC issuer +* **resource**: string: The resource ID of the provisioned identity + +## OutputResource +### Properties +* **id**: string: The UCP resource ID of the underlying resource. +* **localId**: string: The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships. +* **radiusManaged**: bool: Determines whether Radius manages the lifecycle of the underlying resource. ## SystemData ### Properties diff --git a/hack/bicep-types-radius/generated/index.json b/hack/bicep-types-radius/generated/index.json index 0bb925d6f2..f00058f3dc 100644 --- a/hack/bicep-types-radius/generated/index.json +++ b/hack/bicep-types-radius/generated/index.json @@ -1 +1 @@ -{"Resources":{"Applications.Core/environments@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":55},"Applications.Core/applications@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":79},"Applications.Core/httpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":93},"Applications.Core/gateways@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":114},"Applications.Core/containers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":179},"Applications.Core/volumes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":216},"Applications.Core/secretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":239},"Applications.Core/extenders@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":258},"Applications.Dapr/pubSubBrokers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.dapr/2022-03-15-privatepreview/types.json","Index":40},"Applications.Dapr/secretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.dapr/2022-03-15-privatepreview/types.json","Index":57},"Applications.Dapr/stateStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.dapr/2022-03-15-privatepreview/types.json","Index":75},"Applications.Datastores/mongoDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":41},"Applications.Datastores/redisCaches@2022-03-15-privatepreview":{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":60},"Applications.Datastores/sqlDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":79},"Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":40},"Applications.Link/daprSecretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":57},"Applications.Link/daprStateStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":75},"Applications.Link/mongoDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":94},"Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":113},"Applications.Link/redisCaches@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":132},"Applications.Link/sqlDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":151},"Applications.Link/extenders@2022-03-15-privatepreview":{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":169},"Applications.Messaging/rabbitMQQueues@2022-03-15-privatepreview":{"RelativePath":"applications/applications.messaging/2022-03-15-privatepreview/types.json","Index":41}},"Functions":{"applications.core/secretstores":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":264}]},"applications.core/extenders":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":266}]},"applications.datastores/mongodatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":81}]},"applications.datastores/rediscaches":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":83}]},"applications.datastores/sqldatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":85}]},"applications.link/mongodatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":171}]},"applications.link/rabbitmqmessagequeues":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":173}]},"applications.link/rediscaches":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":175}]},"applications.link/sqldatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":177}]},"applications.link/extenders":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.link/2022-03-15-privatepreview/types.json","Index":179}]},"applications.messaging/rabbitmqqueues":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.messaging/2022-03-15-privatepreview/types.json","Index":43}]}}} \ No newline at end of file +{"Resources":{"Applications.Core/applications@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":57},"Applications.Core/containers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":113},"Applications.Core/environments@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":138},"Applications.Core/extenders@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":156},"Applications.Core/gateways@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":177},"Applications.Core/httpRoutes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":191},"Applications.Core/secretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":214},"Applications.Core/volumes@2022-03-15-privatepreview":{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":251},"Applications.Dapr/pubSubBrokers@2022-03-15-privatepreview":{"RelativePath":"applications/applications.dapr/2022-03-15-privatepreview/types.json","Index":48},"Applications.Dapr/secretStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.dapr/2022-03-15-privatepreview/types.json","Index":65},"Applications.Dapr/stateStores@2022-03-15-privatepreview":{"RelativePath":"applications/applications.dapr/2022-03-15-privatepreview/types.json","Index":83},"Applications.Datastores/mongoDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":49},"Applications.Datastores/redisCaches@2022-03-15-privatepreview":{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":68},"Applications.Datastores/sqlDatabases@2022-03-15-privatepreview":{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":87},"Applications.Messaging/rabbitMQQueues@2022-03-15-privatepreview":{"RelativePath":"applications/applications.messaging/2022-03-15-privatepreview/types.json","Index":49}},"Functions":{"applications.core/extenders":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":252}]},"applications.core/secretstores":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.core/2022-03-15-privatepreview/types.json","Index":258}]},"applications.datastores/mongodatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":89}]},"applications.datastores/rediscaches":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":91}]},"applications.datastores/sqldatabases":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.datastores/2022-03-15-privatepreview/types.json","Index":93}]},"applications.messaging/rabbitmqqueues":{"2022-03-15-privatepreview":[{"RelativePath":"applications/applications.messaging/2022-03-15-privatepreview/types.json","Index":51}]}}} \ No newline at end of file diff --git a/hack/bicep-types-radius/generated/index.md b/hack/bicep-types-radius/generated/index.md index a78a4699fa..abbb71ecff 100644 --- a/hack/bicep-types-radius/generated/index.md +++ b/hack/bicep-types-radius/generated/index.md @@ -44,31 +44,6 @@ ### applications.datastores/sqldatabases * [2022-03-15-privatepreview](applications/applications.datastores/2022-03-15-privatepreview/types.md#resource-applicationsdatastoressqldatabases2022-03-15-privatepreview) -## applications.link -### applications.link/daprpubsubbrokers -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinkdaprpubsubbrokers2022-03-15-privatepreview) - -### applications.link/daprsecretstores -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinkdaprsecretstores2022-03-15-privatepreview) - -### applications.link/daprstatestores -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinkdaprstatestores2022-03-15-privatepreview) - -### applications.link/extenders -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinkextenders2022-03-15-privatepreview) - -### applications.link/mongodatabases -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinkmongodatabases2022-03-15-privatepreview) - -### applications.link/rabbitmqmessagequeues -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinkrabbitmqmessagequeues2022-03-15-privatepreview) - -### applications.link/rediscaches -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinkrediscaches2022-03-15-privatepreview) - -### applications.link/sqldatabases -* [2022-03-15-privatepreview](applications/applications.link/2022-03-15-privatepreview/types.md#resource-applicationslinksqldatabases2022-03-15-privatepreview) - ## applications.messaging ### applications.messaging/rabbitmqqueues * [2022-03-15-privatepreview](applications/applications.messaging/2022-03-15-privatepreview/types.md#resource-applicationsmessagingrabbitmqqueues2022-03-15-privatepreview) diff --git a/hack/bicep-types-radius/src/autorest.bicep/package-lock.json b/hack/bicep-types-radius/src/autorest.bicep/package-lock.json index d5720f8236..96793d329e 100644 --- a/hack/bicep-types-radius/src/autorest.bicep/package-lock.json +++ b/hack/bicep-types-radius/src/autorest.bicep/package-lock.json @@ -152,9 +152,9 @@ } }, "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -202,9 +202,9 @@ } }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3165,9 +3165,9 @@ } }, "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -3921,9 +3921,9 @@ "dev": true }, "node_modules/json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, "bin": { "json5": "lib/cli.js" @@ -4025,9 +4025,9 @@ } }, "node_modules/make-dir/node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -4453,6 +4453,12 @@ "node": ">=6" } }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -4500,6 +4506,12 @@ "node": ">=0.10.0" } }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true + }, "node_modules/resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", @@ -4637,9 +4649,9 @@ } }, "node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -4920,14 +4932,15 @@ } }, "node_modules/tough-cookie": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", - "integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", "dev": true, "dependencies": { "psl": "^1.1.33", "punycode": "^2.1.1", - "universalify": "^0.1.2" + "universalify": "^0.2.0", + "url-parse": "^1.5.3" }, "engines": { "node": ">=6" @@ -5117,9 +5130,9 @@ } }, "node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", "dev": true, "engines": { "node": ">= 4.0.0" @@ -5134,6 +5147,16 @@ "punycode": "^2.1.0" } }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -5261,9 +5284,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -5492,9 +5515,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -5531,9 +5554,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -7776,9 +7799,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -8368,9 +8391,9 @@ "dev": true }, "json5": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", - "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "kleur": { @@ -8445,9 +8468,9 @@ }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true } } @@ -8771,6 +8794,12 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==", + "dev": true + }, "queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -8795,6 +8824,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true + }, "resolve": { "version": "1.22.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", @@ -8886,9 +8921,9 @@ } }, "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "requires": { "lru-cache": "^6.0.0" } @@ -9099,14 +9134,15 @@ } }, "tough-cookie": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", - "integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", "dev": true, "requires": { "psl": "^1.1.33", "punycode": "^2.1.1", - "universalify": "^0.1.2" + "universalify": "^0.2.0", + "url-parse": "^1.5.3" } }, "tr46": { @@ -9215,9 +9251,9 @@ "dev": true }, "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", "dev": true }, "uri-js": { @@ -9229,6 +9265,16 @@ "punycode": "^2.1.0" } }, + "url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dev": true, + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -9334,9 +9380,9 @@ } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true }, "wrap-ansi": { diff --git a/hack/bicep-types-radius/src/generator/package-lock.json b/hack/bicep-types-radius/src/generator/package-lock.json index fb29c34066..8e09f9e7c3 100644 --- a/hack/bicep-types-radius/src/generator/package-lock.json +++ b/hack/bicep-types-radius/src/generator/package-lock.json @@ -1622,9 +1622,9 @@ } }, "node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -1891,9 +1891,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3142,9 +3142,9 @@ } }, "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -3330,9 +3330,9 @@ } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true }, "wrap-ansi": { diff --git a/pkg/armrpc/api/v1/armrequestcontext.go b/pkg/armrpc/api/v1/armrequestcontext.go index fdaf29a7c0..16c5da5400 100644 --- a/pkg/armrpc/api/v1/armrequestcontext.go +++ b/pkg/armrpc/api/v1/armrequestcontext.go @@ -27,8 +27,8 @@ import ( "strings" "github.com/google/uuid" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // The below contants are the headers in request from ARM. diff --git a/pkg/armrpc/api/v1/armrequestcontext_test.go b/pkg/armrpc/api/v1/armrequestcontext_test.go index d06a0cee59..0c2c23d5ea 100644 --- a/pkg/armrpc/api/v1/armrequestcontext_test.go +++ b/pkg/armrpc/api/v1/armrequestcontext_test.go @@ -24,7 +24,7 @@ import ( "strings" "testing" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/api/v1/errorcodes.go b/pkg/armrpc/api/v1/errorcodes.go index 5519b72ef5..6d4b352c0b 100644 --- a/pkg/armrpc/api/v1/errorcodes.go +++ b/pkg/armrpc/api/v1/errorcodes.go @@ -26,6 +26,9 @@ const ( // Used for internal/unclassified failures. CodeInternal = "Internal" + // Used when a dependency to carry out current operation is missing. + CodeDependencyMissing = "DependencyMissing" + // Used for CodeNotFound error. CodeNotFound = "NotFound" diff --git a/pkg/armrpc/api/v1/errorresponse.go b/pkg/armrpc/api/v1/errorresponse.go index 5aaab9ccce..9ece54b6ae 100644 --- a/pkg/armrpc/api/v1/errorresponse.go +++ b/pkg/armrpc/api/v1/errorresponse.go @@ -32,6 +32,11 @@ type ErrorDetails struct { Details []ErrorDetails `json:"details,omitempty"` } +// Error returns error message in ErrorDetails to implement error interface. +func (e ErrorDetails) Error() string { + return e.Message +} + // ErrorAdditionalInfo represents abritrary additional information as part of an error as defined by the ARM API. type ErrorAdditionalInfo struct { Type string `json:"type"` diff --git a/pkg/armrpc/api/v1/time_util.go b/pkg/armrpc/api/v1/time_util.go new file mode 100644 index 0000000000..1a2b66741f --- /dev/null +++ b/pkg/armrpc/api/v1/time_util.go @@ -0,0 +1,85 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +// MarshalJSON is a method that converts the timeRFC3339 object into a JSON formatted byte array. +// It returns the JSON formatted byte array and an error if any occurred during the marshalling process. +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +// MarshalText converts the timeRFC3339 to text in the form of a byte slice. +// It returns the byte slice and an error if any occurred during the conversion. +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +// UnmarshalJSON is a method that implements the json.Unmarshaler interface. +// It takes a JSON-encoded byte slice and converts it into a timeRFC3339 value. +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +// UnmarshalText is a method of the timeRFC3339 type. +// The method attempts to parse the input data into a time value according to the RFC3339 standard. +// The method returns an error if the parsing fails. +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +// UnmarshalTimeString unmarshals a string representation of a time in RFC3339 format into a time.Time object. +func UnmarshalTimeString(ts string) *time.Time { + var tt timeRFC3339 + _ = tt.UnmarshalText([]byte(ts)) + return (*time.Time)(&tt) +} + +// Parse is a method of the timeRFC3339 type. It takes a layout and a value as strings, +// and attempts to parse the value into a time.Time object using the provided layout. +// The parsed time is then stored in the timeRFC3339 receiver. It returns any error produced by time.Parse. +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} diff --git a/pkg/armrpc/api/v1/time_util_test.go b/pkg/armrpc/api/v1/time_util_test.go new file mode 100644 index 0000000000..be825a76b7 --- /dev/null +++ b/pkg/armrpc/api/v1/time_util_test.go @@ -0,0 +1,164 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestTimeRFC3339_MarshalText(t *testing.T) { + tt := timeRFC3339(time.Now()) + text, err := tt.MarshalText() + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + if len(text) == 0 { + t.Errorf("Expected text time, got empty string") + } +} + +func TestTimeRFC3339_MarshalJSON(t *testing.T) { + tt := timeRFC3339(time.Now()) + json, err := tt.MarshalJSON() + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + if len(json) == 0 { + t.Errorf("Expected JSON time, got empty string") + } +} + +func TestUnmarshalTimeString(t *testing.T) { + parsedTime := UnmarshalTimeString("2021-09-24T19:09:00.000000Z") + require.NotNil(t, parsedTime) + + require.Equal(t, 2021, parsedTime.Year()) + require.Equal(t, time.Month(9), parsedTime.Month()) + require.Equal(t, 24, parsedTime.Day()) + + parsedTime = UnmarshalTimeString("") + require.NotNil(t, parsedTime) + require.Equal(t, 1, parsedTime.Year()) +} + +func TestTimeRFC3339_UnmarshalText(t *testing.T) { + tests := []struct { + name string + data string + wantErr bool + }{ + { + name: "Valid RFC3339Nano time", + data: time.Now().Format(time.RFC3339Nano), + wantErr: false, + }, + { + name: "Valid UTC time", + data: time.Now().UTC().Format(utcLayout), + wantErr: false, + }, + { + name: "Invalid time", + data: "invalid time", + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var tr timeRFC3339 + if err := tr.UnmarshalText([]byte(tt.data)); (err != nil) != tt.wantErr { + t.Errorf("timeRFC3339.UnmarshalText() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestTimeRFC3339_UnmarshalJSON(t *testing.T) { + testCases := []struct { + name string + data string + expected time.Time + }{ + { + name: "UTC time", + data: `"2023-01-01T00:00:00.000000000"`, + expected: time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC), + }, + { + name: "RFC3339Nano time", + data: `"2023-01-01T00:00:00.000000000Z"`, + expected: time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC), + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var tr timeRFC3339 + err := tr.UnmarshalJSON([]byte(tc.data)) + if err != nil { + t.Fatalf("UnmarshalJSON failed: %v", err) + } + + if !time.Time(tr).Equal(tc.expected) { + t.Errorf("Unmarshalled time does not match expected. Got: %v, Expected: %v", time.Time(tr), tc.expected) + } + }) + } +} + +func TestTimeRFC3339_Parse(t *testing.T) { + testCases := []struct { + name string + layout string + value string + want timeRFC3339 + wantErr bool + }{ + { + name: "valid RFC3339 time", + layout: time.RFC3339, + value: "2006-01-02T15:04:05Z", + want: timeRFC3339(time.Date(2006, 1, 2, 15, 4, 5, 0, time.UTC)), + wantErr: false, + }, + { + name: "invalid time", + layout: time.RFC3339, + value: "invalid time", + wantErr: true, + }, + // Add more test cases as needed + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var tr timeRFC3339 + err := tr.Parse(tc.layout, tc.value) + if (err != nil) != tc.wantErr { + t.Errorf("timeRFC3339.Parse() error = %v, wantErr %v", err, tc.wantErr) + return + } + if !tc.wantErr && time.Time(tr) != time.Time(tc.want) { + t.Errorf("timeRFC3339.Parse() = %v, want %v", tr, tc.want) + } + }) + } +} diff --git a/pkg/armrpc/api/v1/types.go b/pkg/armrpc/api/v1/types.go index 893c7d711d..623a2fafbc 100644 --- a/pkg/armrpc/api/v1/types.go +++ b/pkg/armrpc/api/v1/types.go @@ -44,17 +44,15 @@ var ( type OperationMethod string var operationMethodToHTTPMethod = map[OperationMethod]string{ - OperationList: http.MethodGet, - OperationGet: http.MethodGet, - OperationPut: http.MethodPut, - OperationPatch: http.MethodPatch, - OperationDelete: http.MethodDelete, + OperationPlaneScopeList: http.MethodGet, + OperationList: http.MethodGet, + OperationGet: http.MethodGet, + OperationPut: http.MethodPut, + OperationPatch: http.MethodPatch, + OperationDelete: http.MethodDelete, // ARM RPC specific operations. - OperationGetOperations: http.MethodGet, - OperationGetOperationStatuses: http.MethodGet, - OperationGetOperationResult: http.MethodGet, - OperationPutSubscriptions: http.MethodPut, + OperationPutSubscriptions: http.MethodPut, // Non-idempotent lifecycle operations. OperationGetImperative: http.MethodPost, @@ -72,7 +70,7 @@ func (o OperationMethod) HTTPMethod() string { if !ok { // ARM RPC defines CRUD_L operations of one resource type and the custom action should be defined as POST method. // For example, if we want to support `listSecret` API for mongodatabase, this API must be defined as POST method. - // POST /subscriptions/{subId}/resourcegroups/{rg}/applications.link/mongodatabases/{mongo}/listSecret + // POST /subscriptions/{subId}/resourcegroups/{rg}/applications.datastores/mongodatabases/{mongo}/listSecret return http.MethodPost } return m @@ -80,16 +78,14 @@ func (o OperationMethod) HTTPMethod() string { const ( // Predefined Operation methods. - OperationList OperationMethod = "LIST" - OperationGet OperationMethod = "GET" - OperationPut OperationMethod = "PUT" - OperationPatch OperationMethod = "PATCH" - OperationDelete OperationMethod = "DELETE" - OperationGetOperations OperationMethod = "GETOPERATIONS" - OperationGetOperationStatuses OperationMethod = "GETOPERATIONSTATUSES" - OperationGetOperationResult OperationMethod = "GETOPERATIONRESULT" - OperationPutSubscriptions OperationMethod = "PUTSUBSCRIPTIONS" - OperationPost OperationMethod = "POST" + OperationPlaneScopeList OperationMethod = "LISTPLANESCOPE" + OperationList OperationMethod = "LIST" + OperationGet OperationMethod = "GET" + OperationPut OperationMethod = "PUT" + OperationPatch OperationMethod = "PATCH" + OperationDelete OperationMethod = "DELETE" + OperationPutSubscriptions OperationMethod = "PUTSUBSCRIPTIONS" + OperationPost OperationMethod = "POST" // Imperative operation methods for non-idempotent lifecycle operations. // UCP extends the ARM resource lifecycle to support using POST for non-idempotent resource types. diff --git a/pkg/armrpc/api/v1/types_test.go b/pkg/armrpc/api/v1/types_test.go index 8b95b03049..94e55ff709 100644 --- a/pkg/armrpc/api/v1/types_test.go +++ b/pkg/armrpc/api/v1/types_test.go @@ -19,7 +19,7 @@ package v1 import ( "testing" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/asyncoperation/controller/controller.go b/pkg/armrpc/asyncoperation/controller/controller.go index 951ed5186a..3081b69511 100644 --- a/pkg/armrpc/asyncoperation/controller/controller.go +++ b/pkg/armrpc/asyncoperation/controller/controller.go @@ -19,9 +19,9 @@ package controller import ( "context" - "github.com/project-radius/radius/pkg/corerp/backend/deployment" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/corerp/backend/deployment" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/pkg/armrpc/asyncoperation/controller/request.go b/pkg/armrpc/asyncoperation/controller/request.go index 2e0b9752e2..dfcbf57ae7 100644 --- a/pkg/armrpc/asyncoperation/controller/request.go +++ b/pkg/armrpc/asyncoperation/controller/request.go @@ -21,8 +21,8 @@ import ( "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/resources" ) var ( diff --git a/pkg/armrpc/asyncoperation/controller/request_test.go b/pkg/armrpc/asyncoperation/controller/request_test.go index b26fce6fe4..770255bd02 100644 --- a/pkg/armrpc/asyncoperation/controller/request_test.go +++ b/pkg/armrpc/asyncoperation/controller/request_test.go @@ -23,9 +23,9 @@ import ( "time" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/asyncoperation/controller/result.go b/pkg/armrpc/asyncoperation/controller/result.go index b77ec8a1a6..ee7ee349b9 100644 --- a/pkg/armrpc/asyncoperation/controller/result.go +++ b/pkg/armrpc/asyncoperation/controller/result.go @@ -17,7 +17,7 @@ limitations under the License. package controller import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) // Result is the response of async operation controller. @@ -53,10 +53,7 @@ func (r *Result) SetFailed(err v1.ErrorDetails, requeue bool) { } r.Requeue = requeue r.SetProvisioningState(v1.ProvisioningStateFailed) - r.Error = &v1.ErrorDetails{ - Code: err.Code, - Message: err.Message, - } + r.Error = &err } // SetCanceled sets the Result's Requeue field to false, sets the ProvisioningState to Canceled and sets the Error field diff --git a/pkg/armrpc/asyncoperation/statusmanager/mock_statusmanager.go b/pkg/armrpc/asyncoperation/statusmanager/mock_statusmanager.go index 8ef35b142b..97d6a808b3 100644 --- a/pkg/armrpc/asyncoperation/statusmanager/mock_statusmanager.go +++ b/pkg/armrpc/asyncoperation/statusmanager/mock_statusmanager.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager (interfaces: StatusManager) +// Source: github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager (interfaces: StatusManager) // Package statusmanager is a generated GoMock package. package statusmanager @@ -11,8 +11,8 @@ import ( gomock "github.com/golang/mock/gomock" uuid "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - resources "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + resources "github.com/radius-project/radius/pkg/ucp/resources" ) // MockStatusManager is a mock of StatusManager interface. diff --git a/pkg/armrpc/asyncoperation/statusmanager/status.go b/pkg/armrpc/asyncoperation/statusmanager/status.go index c9b6abd9c5..cb7be2127b 100644 --- a/pkg/armrpc/asyncoperation/statusmanager/status.go +++ b/pkg/armrpc/asyncoperation/statusmanager/status.go @@ -19,7 +19,7 @@ package statusmanager import ( time "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) // Status is the datamodel for Async operation statuses. diff --git a/pkg/armrpc/asyncoperation/statusmanager/statusmanager.go b/pkg/armrpc/asyncoperation/statusmanager/statusmanager.go index 8743df7ef1..a51525c2ca 100644 --- a/pkg/armrpc/asyncoperation/statusmanager/statusmanager.go +++ b/pkg/armrpc/asyncoperation/statusmanager/statusmanager.go @@ -23,23 +23,23 @@ import ( "strings" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/metrics" - "github.com/project-radius/radius/pkg/trace" - queue "github.com/project-radius/radius/pkg/ucp/queue/client" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/metrics" + "github.com/radius-project/radius/pkg/trace" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/google/uuid" ) // statusManager includes the necessary functions to manage asynchronous operations. type statusManager struct { - storeClient store.StorageClient - queue queue.Client - providerName string - location string + storeProvider dataprovider.DataStorageProvider + queue queue.Client + location string } // QueueOperationOptions is the options type provided when queueing an async operation. @@ -50,7 +50,7 @@ type QueueOperationOptions struct { RetryAfter time.Duration } -//go:generate mockgen -destination=./mock_statusmanager.go -package=statusmanager -self_package github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager StatusManager +//go:generate mockgen -destination=./mock_statusmanager.go -package=statusmanager -self_package github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager StatusManager // StatusManager is an interface to manage async operation status. type StatusManager interface { @@ -65,12 +65,11 @@ type StatusManager interface { } // New creates statusManager instance. -func New(storeClient store.StorageClient, q queue.Client, providerName, location string) StatusManager { +func New(dataProvider dataprovider.DataStorageProvider, q queue.Client, location string) StatusManager { return &statusManager{ - storeClient: storeClient, - queue: q, - providerName: providerName, - location: location, + storeProvider: dataProvider, + queue: q, + location: location, } } @@ -79,6 +78,10 @@ func (aom *statusManager) operationStatusResourceID(id resources.ID, operationID return fmt.Sprintf("%s/providers/%s/locations/%s/operationstatuses/%s", id.PlaneScope(), strings.ToLower(id.ProviderNamespace()), aom.location, operationID) } +func (aom *statusManager) getClient(ctx context.Context, id resources.ID) (store.StorageClient, error) { + return aom.storeProvider.GetStorageClient(ctx, id.ProviderNamespace()+"/operationstatuses") +} + // QueueAsyncOperation creates and saves a new status resource with the given parameters in datastore, and queues // a request message. If an error occurs, the status is deleted using the storeClient. func (aom *statusManager) QueueAsyncOperation(ctx context.Context, sCtx *v1.ARMRequestContext, options QueueOperationOptions) error { @@ -108,7 +111,12 @@ func (aom *statusManager) QueueAsyncOperation(ctx context.Context, sCtx *v1.ARMR ClientObjectID: sCtx.ClientObjectID, } - err := aom.storeClient.Save(ctx, &store.Object{ + storeClient, err := aom.getClient(ctx, sCtx.ResourceID) + if err != nil { + return err + } + + err = storeClient.Save(ctx, &store.Object{ Metadata: store.Metadata{ID: opID}, Data: aos, }) @@ -118,7 +126,7 @@ func (aom *statusManager) QueueAsyncOperation(ctx context.Context, sCtx *v1.ARMR } if err = aom.queueRequestMessage(ctx, sCtx, aos, options.OperationTimeout); err != nil { - delErr := aom.storeClient.Delete(ctx, opID) + delErr := storeClient.Delete(ctx, opID) if delErr != nil { return delErr } @@ -132,7 +140,12 @@ func (aom *statusManager) QueueAsyncOperation(ctx context.Context, sCtx *v1.ARMR // Get gets a status object from the datastore or an error if the retrieval fails. func (aom *statusManager) Get(ctx context.Context, id resources.ID, operationID uuid.UUID) (*Status, error) { - obj, err := aom.storeClient.Get(ctx, aom.operationStatusResourceID(id, operationID)) + storeClient, err := aom.getClient(ctx, id) + if err != nil { + return nil, err + } + + obj, err := storeClient.Get(ctx, aom.operationStatusResourceID(id, operationID)) if err != nil { return nil, err } @@ -149,8 +162,12 @@ func (aom *statusManager) Get(ctx context.Context, id resources.ID, operationID // given parameters, and saves it back to the store. func (aom *statusManager) Update(ctx context.Context, id resources.ID, operationID uuid.UUID, state v1.ProvisioningState, endTime *time.Time, opError *v1.ErrorDetails) error { opID := aom.operationStatusResourceID(id, operationID) + storeClient, err := aom.getClient(ctx, id) + if err != nil { + return err + } - obj, err := aom.storeClient.Get(ctx, opID) + obj, err := storeClient.Get(ctx, opID) if err != nil { return err } @@ -173,13 +190,17 @@ func (aom *statusManager) Update(ctx context.Context, id resources.ID, operation obj.Data = s - return aom.storeClient.Save(ctx, obj, store.WithETag(obj.ETag)) + return storeClient.Save(ctx, obj, store.WithETag(obj.ETag)) } // Delete deletes the operation status resource associated with the given ID and // operationID, and returns an error if unsuccessful. func (aom *statusManager) Delete(ctx context.Context, id resources.ID, operationID uuid.UUID) error { - return aom.storeClient.Delete(ctx, aom.operationStatusResourceID(id, operationID)) + storeClient, err := aom.getClient(ctx, id) + if err != nil { + return err + } + return storeClient.Delete(ctx, aom.operationStatusResourceID(id, operationID)) } // queueRequestMessage function is to put the async operation message to the queue to be worked on. diff --git a/pkg/armrpc/asyncoperation/statusmanager/statusmanager_test.go b/pkg/armrpc/asyncoperation/statusmanager/statusmanager_test.go index 03f8eacc10..43b88d0482 100644 --- a/pkg/armrpc/asyncoperation/statusmanager/statusmanager_test.go +++ b/pkg/armrpc/asyncoperation/statusmanager/statusmanager_test.go @@ -24,18 +24,20 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - queue "github.com/project-radius/radius/pkg/ucp/queue/client" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) type asyncOperationsManagerTest struct { - manager StatusManager - storeClient *store.MockStorageClient - queue *queue.MockClient + manager StatusManager + storeProvider *dataprovider.MockDataStorageProvider + storeClient *store.MockStorageClient + queue *queue.MockClient } const ( @@ -51,13 +53,16 @@ const ( func setup(tb testing.TB) (asyncOperationsManagerTest, *gomock.Controller) { ctrl := gomock.NewController(tb) + dp := dataprovider.NewMockDataStorageProvider(ctrl) sc := store.NewMockStorageClient(ctrl) + dp.EXPECT().GetStorageClient(gomock.Any(), "Applications.Core/operationstatuses").Return(sc, nil) enq := queue.NewMockClient(ctrl) - aom := New(sc, enq, "Test-AsyncOperationsManager", "test-location") - return asyncOperationsManagerTest{manager: aom, storeClient: sc, queue: enq}, ctrl + aom := New(dp, enq, "test-location") + return asyncOperationsManagerTest{manager: aom, storeProvider: dp, storeClient: sc, queue: enq}, ctrl } var reqCtx = &v1.ARMRequestContext{ + ResourceID: resources.MustParse("/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Core/container/container0"), OperationID: uuid.Must(uuid.NewRandom()), HomeTenantID: "home-tenant-id", ClientObjectID: "client-object-id", @@ -99,7 +104,7 @@ func TestOperationStatusResourceID(t *testing.T) { }, } - sm := &statusManager{providerName: "applications.core", location: v1.LocationGlobal} + sm := &statusManager{location: v1.LocationGlobal} for _, tc := range resourceIDTests { t.Run(tc.resourceID, func(t *testing.T) { diff --git a/pkg/armrpc/asyncoperation/worker/registry.go b/pkg/armrpc/asyncoperation/worker/registry.go index 1b1b21f687..814fc85b6d 100644 --- a/pkg/armrpc/asyncoperation/worker/registry.go +++ b/pkg/armrpc/asyncoperation/worker/registry.go @@ -20,9 +20,9 @@ import ( "context" "sync" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/ucp/dataprovider" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/ucp/dataprovider" ) type ControllerFactoryFunc func(opts ctrl.Options) (ctrl.Controller, error) @@ -49,7 +49,7 @@ func (h *ControllerRegistry) Register(ctx context.Context, resourceType string, ot := v1.OperationType{Type: resourceType, Method: method} - storageClient, err := opts.DataProvider.GetStorageClient(ctx, resourceType) + storageClient, err := h.sp.GetStorageClient(ctx, resourceType) if err != nil { return err } diff --git a/pkg/armrpc/asyncoperation/worker/registry_test.go b/pkg/armrpc/asyncoperation/worker/registry_test.go index d35ed9bf7b..633fcecf82 100644 --- a/pkg/armrpc/asyncoperation/worker/registry_test.go +++ b/pkg/armrpc/asyncoperation/worker/registry_test.go @@ -21,10 +21,10 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/corerp/backend/deployment" - "github.com/project-radius/radius/pkg/ucp/dataprovider" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/corerp/backend/deployment" + "github.com/radius-project/radius/pkg/ucp/dataprovider" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/asyncoperation/worker/service.go b/pkg/armrpc/asyncoperation/worker/service.go index 4eb68f9358..4a04a19384 100644 --- a/pkg/armrpc/asyncoperation/worker/service.go +++ b/pkg/armrpc/asyncoperation/worker/service.go @@ -19,16 +19,12 @@ package worker import ( "context" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - queue "github.com/project-radius/radius/pkg/ucp/queue/client" - qprovider "github.com/project-radius/radius/pkg/ucp/queue/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" - - "k8s.io/client-go/kubernetes" - controller_runtime "sigs.k8s.io/controller-runtime/pkg/client" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" + qprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // Service is the base worker service implementation to initialize and start worker. @@ -45,39 +41,20 @@ type Service struct { Controllers *ControllerRegistry // RequestQueue is the queue client for async operation request message. RequestQueue queue.Client - // KubeClient is the Kubernetes controller runtime client. - KubeClient controller_runtime.Client - // KubeClientSet is the Kubernetes client. - KubeClientSet kubernetes.Interface } // Init initializes worker service - it initializes the StorageProvider, RequestQueue, OperationStatusManager, Controllers, KubeClient and // returns an error if any of these operations fail. func (s *Service) Init(ctx context.Context) error { s.StorageProvider = dataprovider.NewStorageProvider(s.Options.Config.StorageProvider) - qp := qprovider.New(s.ProviderName, s.Options.Config.QueueProvider) - opSC, err := s.StorageProvider.GetStorageClient(ctx, s.ProviderName+"/operationstatuses") - if err != nil { - return err - } + qp := qprovider.New(s.Options.Config.QueueProvider) + var err error s.RequestQueue, err = qp.GetClient(ctx) if err != nil { return err } - s.OperationStatusManager = manager.New(opSC, s.RequestQueue, s.ProviderName, s.Options.Config.Env.RoleLocation) + s.OperationStatusManager = manager.New(s.StorageProvider, s.RequestQueue, s.Options.Config.Env.RoleLocation) s.Controllers = NewControllerRegistry(s.StorageProvider) - - if s.Options.K8sConfig != nil { - s.KubeClient, err = kubeutil.NewRuntimeClient(s.Options.K8sConfig) - if err != nil { - return err - } - - s.KubeClientSet, err = kubernetes.NewForConfig(s.Options.K8sConfig) - if err != nil { - return err - } - } return nil } diff --git a/pkg/armrpc/asyncoperation/worker/worker.go b/pkg/armrpc/asyncoperation/worker/worker.go index 6642dcdafe..cc6a0626cd 100644 --- a/pkg/armrpc/asyncoperation/worker/worker.go +++ b/pkg/armrpc/asyncoperation/worker/worker.go @@ -26,16 +26,16 @@ import ( "strings" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - "github.com/project-radius/radius/pkg/logging" - "github.com/project-radius/radius/pkg/metrics" - "github.com/project-radius/radius/pkg/trace" - queue "github.com/project-radius/radius/pkg/ucp/queue/client" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/logging" + "github.com/radius-project/radius/pkg/metrics" + "github.com/radius-project/radius/pkg/trace" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/ucplog" "github.com/google/uuid" "golang.org/x/sync/semaphore" @@ -241,6 +241,7 @@ func (w *AsyncRequestProcessWorker) runOperation(ctx context.Context, message *q if err := recover(); err != nil { msg := fmt.Errorf("recovering from panic %v: %s", err, debug.Stack()) logger.Error(msg, "recovering from panic") + // When backend controller has a critical bug such as nil reference, asyncCtrl.Run() is panicking. // If this happens, the message is requeued after message lock time (5 mins). // After message lock is expired, message will be reprocessed 'w.options.MaxOperationRetryCount' times and diff --git a/pkg/armrpc/asyncoperation/worker/worker_runoperation_test.go b/pkg/armrpc/asyncoperation/worker/worker_runoperation_test.go index 1f3a01a821..c3db36fbe8 100644 --- a/pkg/armrpc/asyncoperation/worker/worker_runoperation_test.go +++ b/pkg/armrpc/asyncoperation/worker/worker_runoperation_test.go @@ -26,15 +26,15 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - "github.com/project-radius/radius/pkg/corerp/backend/deployment" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - queue "github.com/project-radius/radius/pkg/ucp/queue/client" - "github.com/project-radius/radius/pkg/ucp/queue/inmemory" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/corerp/backend/deployment" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/queue/inmemory" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" "go.uber.org/atomic" ) diff --git a/pkg/armrpc/asyncoperation/worker/worker_test.go b/pkg/armrpc/asyncoperation/worker/worker_test.go index 4b70f1bc9c..735125c157 100644 --- a/pkg/armrpc/asyncoperation/worker/worker_test.go +++ b/pkg/armrpc/asyncoperation/worker/worker_test.go @@ -23,8 +23,8 @@ import ( "time" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/authentication/certvalidator.go b/pkg/armrpc/authentication/certvalidator.go index 397d27d0cb..3b23b639ee 100644 --- a/pkg/armrpc/authentication/certvalidator.go +++ b/pkg/armrpc/authentication/certvalidator.go @@ -22,9 +22,9 @@ import ( "time" "github.com/go-logr/logr" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) const ( diff --git a/pkg/armrpc/authentication/certvalidator_test.go b/pkg/armrpc/authentication/certvalidator_test.go index d852837e7e..4edf84d630 100644 --- a/pkg/armrpc/authentication/certvalidator_test.go +++ b/pkg/armrpc/authentication/certvalidator_test.go @@ -32,7 +32,7 @@ import ( "github.com/go-chi/chi/v5" "github.com/go-logr/logr" - "github.com/project-radius/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/middleware" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/builder/builder.go b/pkg/armrpc/builder/builder.go new file mode 100644 index 0000000000..3284b7968a --- /dev/null +++ b/pkg/armrpc/builder/builder.go @@ -0,0 +1,184 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/go-chi/chi/v5" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + asyncctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + apictrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/validator" + "github.com/radius-project/radius/swagger" +) + +// Builder can be used to register operations and build HTTP routing paths and handlers for a resource namespace. +type Builder struct { + namespaceNode *Namespace + registrations []*OperationRegistration +} + +// defaultHandlerOptions returns HandlerOption for the default operations such as getting operationStatuses and +// operationResults. +func defaultHandlerOptions( + ctx context.Context, + rootRouter chi.Router, + rootScopePath string, + namespace string, + availableOperations []v1.Operation, + ctrlOpts apictrl.Options) []server.HandlerOptions { + namespace = strings.ToLower(namespace) + + handlers := []server.HandlerOptions{} + if len(availableOperations) > 0 { + // https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/proxy-api-reference.md#exposing-available-operations + handlers = append(handlers, server.HandlerOptions{ + ParentRouter: rootRouter, + Path: rootScopePath + "/providers/" + namespace + "/operations", + ResourceType: namespace + "/operations", + Method: v1.OperationGet, + ControllerFactory: func(op apictrl.Options) (apictrl.Controller, error) { + return defaultoperation.NewGetOperations(op, availableOperations) + }, + }) + } + + statusType := namespace + "/operationstatuses" + resultType := namespace + "/operationresults" + handlers = append(handlers, server.HandlerOptions{ + ParentRouter: rootRouter, + Path: fmt.Sprintf("%s/providers/%s/locations/{location}/operationstatuses/{operationId}", rootScopePath, namespace), + ResourceType: statusType, + Method: v1.OperationGet, + ControllerFactory: defaultoperation.NewGetOperationStatus, + }) + + handlers = append(handlers, server.HandlerOptions{ + ParentRouter: rootRouter, + Path: fmt.Sprintf("%s/providers/%s/locations/{location}/operationresults/{operationId}", rootScopePath, namespace), + ResourceType: resultType, + Method: v1.OperationGet, + ControllerFactory: defaultoperation.NewGetOperationResult, + }) + + return handlers +} + +func (b *Builder) Namespace() string { + return b.namespaceNode.Name +} + +const ( + UCPRootScopePath = "/planes/radius/{planeName}" + ResourceGroupPath = "/resourcegroups/{resourceGroupName}" +) + +// NewOpenAPIValidatorMiddleware creates a new OpenAPI validator middleware. +func NewOpenAPIValidator(ctx context.Context, base, namespace string) (func(h http.Handler) http.Handler, error) { + rootScopePath := base + UCPRootScopePath + + // URLs may use either the subscription/plane scope or resource group scope. + // These paths are order sensitive and the longer path MUST be registered first. + prefixes := []string{ + rootScopePath + ResourceGroupPath, + rootScopePath, + } + + specLoader, err := validator.LoadSpec(ctx, namespace, swagger.SpecFiles, prefixes, "rootScope") + if err != nil { + return nil, err + } + + return validator.APIValidator(validator.Options{ + SpecLoader: specLoader, + ResourceTypeGetter: validator.RadiusResourceTypeGetter, + }), nil +} + +// ApplyAPIHandlers builds HTTP routing paths and handlers for namespace. +func (b *Builder) ApplyAPIHandlers(ctx context.Context, r chi.Router, ctrlOpts apictrl.Options, middlewares ...func(h http.Handler) http.Handler) error { + rootScopePath := ctrlOpts.PathBase + UCPRootScopePath + + // Configure the default handlers. + handlerOptions := defaultHandlerOptions(ctx, r, rootScopePath, b.namespaceNode.Name, b.namespaceNode.availableOperations, ctrlOpts) + + routerMap := map[string]chi.Router{} + for _, h := range b.registrations { + if h == nil { + continue + } + + key := "" + route := "" + switch h.Method { + case v1.OperationPlaneScopeList: + route = fmt.Sprintf("%s/providers/%s", rootScopePath, strings.ToLower(h.ResourceType)) + key = "plane-" + h.ResourceType + case v1.OperationList: + route = fmt.Sprintf("%s/resourcegroups/{resourceGroupName}/providers/%s", rootScopePath, h.ResourceNamePattern) + key = "rg-" + h.ResourceType + default: + route = fmt.Sprintf("%s/resourcegroups/{resourceGroupName}/providers/%s", rootScopePath, h.ResourceNamePattern) + key = "resource-" + h.ResourceNamePattern + } + + if _, ok := routerMap[key]; !ok { + routerMap[key] = server.NewSubrouter(r, route, middlewares...) + } + + handlerOptions = append(handlerOptions, server.HandlerOptions{ + ParentRouter: routerMap[key], + Path: strings.ToLower(h.Path), + ResourceType: h.ResourceType, + Method: h.Method, + ControllerFactory: h.APIController, + }) + } + + for _, o := range handlerOptions { + if err := server.RegisterHandler(ctx, o, ctrlOpts); err != nil { + return err + } + } + + return nil +} + +// ApplyAsyncHandler registers asynchronous controllers from HandlerOutput. +func (b *Builder) ApplyAsyncHandler(ctx context.Context, registry *worker.ControllerRegistry, ctrlOpts asyncctrl.Options) error { + for _, h := range b.registrations { + if h == nil { + continue + } + + if h.AsyncController != nil { + err := registry.Register(ctx, h.ResourceType, h.Method, h.AsyncController, ctrlOpts) + if err != nil { + return err + } + } + } + return nil +} diff --git a/pkg/armrpc/builder/builder_test.go b/pkg/armrpc/builder/builder_test.go new file mode 100644 index 0000000000..480aa69765 --- /dev/null +++ b/pkg/armrpc/builder/builder_test.go @@ -0,0 +1,267 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "context" + "net/http" + "testing" + + "github.com/go-chi/chi/v5" + "github.com/golang/mock/gomock" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + asyncctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + apictrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testcontext" + "github.com/stretchr/testify/require" +) + +var handlerTests = []rpctest.HandlerTestSpec{ + // applications.compute/virtualMachines + { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.compute/virtualmachines", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.compute/virtualmachines", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.compute/virtualmachines/vm0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.compute/virtualmachines/vm0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.compute/virtualmachines/vm0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.compute/virtualmachines/vm0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: "ACTIONSTART"}, + Path: "/resourcegroups/testrg/providers/applications.compute/virtualmachines/vm0/start", + Method: http.MethodPost, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: "ACTIONSTOP"}, + Path: "/resourcegroups/testrg/providers/applications.compute/virtualmachines/vm0/stop", + Method: http.MethodPost, + }, + // applications.compute/containers + { + OperationType: v1.OperationType{Type: "Applications.Compute/containers", Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.compute/containers", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers", Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers", Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers", Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers", Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers", Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers", Method: "ACTIONGETRESOURCE"}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0/getresource", + Method: http.MethodPost, + }, + // applications.compute/containers/secrets + { + OperationType: v1.OperationType{Type: "Applications.Compute/containers/secrets", Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0/secrets", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers/secrets", Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0/secrets/secret0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers/secrets", Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0/secrets/secret0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers/secrets", Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0/secrets/secret0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/containers/secrets", Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.compute/containers/container0/secrets/secret0", + Method: http.MethodDelete, + }, + // applications.compute/webassemblies + { + OperationType: v1.OperationType{Type: "Applications.Compute/webassemblies", Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.compute/webassemblies", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/webassemblies", Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.compute/webassemblies", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/webassemblies", Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.compute/webassemblies/wasm0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/webassemblies", Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.compute/webassemblies/wasm0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/webassemblies", Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.compute/webassemblies/wasm0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/webassemblies", Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.compute/webassemblies/wasm0", + Method: http.MethodDelete, + }, +} + +var defaultHandlerTests = []rpctest.HandlerTestSpec{ + { + OperationType: v1.OperationType{Type: "Applications.Compute/operations", Method: v1.OperationGet}, + Path: "/providers/applications.compute/operations", + Method: http.MethodGet, + }, + // default operations + { + OperationType: v1.OperationType{Type: "Applications.Compute/operationStatuses", Method: v1.OperationGet}, + Path: "/providers/applications.compute/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Compute/operationResults", Method: v1.OperationGet}, + Path: "/providers/applications.compute/locations/global/operationresults/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, +} + +func setup(t *testing.T) (*dataprovider.MockDataStorageProvider, *store.MockStorageClient) { + mctrl := gomock.NewController(t) + + mockSP := dataprovider.NewMockDataStorageProvider(mctrl) + mockSC := store.NewMockStorageClient(mctrl) + + mockSC.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(&store.Object{}, nil).AnyTimes() + mockSC.EXPECT().Save(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + mockSC.EXPECT().Delete(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + mockSC.EXPECT().Query(gomock.Any(), gomock.Any(), gomock.Any()).Return(&store.ObjectQueryResult{}, nil).AnyTimes() + mockSP.EXPECT().GetStorageClient(gomock.Any(), gomock.Any()).Return(store.StorageClient(mockSC), nil).AnyTimes() + + return mockSP, mockSC +} + +func TestApplyAPIHandlers(t *testing.T) { + mockSP, _ := setup(t) + + runTests := func(t *testing.T, testSpecs []rpctest.HandlerTestSpec, b *Builder) { + rpctest.AssertRequests(t, testSpecs, "/api.ucp.dev", "/planes/radius/local", func(ctx context.Context) (chi.Router, error) { + r := chi.NewRouter() + return r, b.ApplyAPIHandlers(ctx, r, apictrl.Options{PathBase: "/api.ucp.dev", DataProvider: mockSP}) + }) + } + + t.Run("custom handlers", func(t *testing.T) { + ns := newTestNamespace(t) + builder := ns.GenerateBuilder() + runTests(t, handlerTests, &builder) + }) + + t.Run("default handlers", func(t *testing.T) { + ns := newTestNamespace(t) + builder := ns.GenerateBuilder() + ns.SetAvailableOperations([]v1.Operation{ + { + Name: "Applications.Compute/operations/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Compute", + Resource: "operations", + Operation: "Get operations", + Description: "Get the list of operations", + }, + IsDataAction: false, + }, + }) + runTests(t, defaultHandlerTests, &builder) + }) +} + +func TestApplyAPIHandlers_AvailableOperations(t *testing.T) { + mockSP, _ := setup(t) + ns := newTestNamespace(t) + + ns.SetAvailableOperations([]v1.Operation{ + { + Name: "Applications.Compute/operations/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Compute", + Resource: "operations", + Operation: "Get operations", + Description: "Get the list of operations", + }, + IsDataAction: false, + }, + }) + + builder := ns.GenerateBuilder() + rpctest.AssertRequests(t, handlerTests, "/api.ucp.dev", "/planes/radius/local", func(ctx context.Context) (chi.Router, error) { + r := chi.NewRouter() + return r, builder.ApplyAPIHandlers(ctx, r, apictrl.Options{PathBase: "/api.ucp.dev", DataProvider: mockSP}) + }) +} + +func TestApplyAsyncHandler(t *testing.T) { + mockSP, _ := setup(t) + ns := newTestNamespace(t) + builder := ns.GenerateBuilder() + registry := worker.NewControllerRegistry(mockSP) + ctx := testcontext.New(t) + err := builder.ApplyAsyncHandler(ctx, registry, asyncctrl.Options{}) + require.NoError(t, err) + + expectedOperations := []v1.OperationType{ + {Type: "Applications.Compute/virtualMachines", Method: v1.OperationPut}, + {Type: "Applications.Compute/virtualMachines", Method: v1.OperationPatch}, + {Type: "Applications.Compute/virtualMachines", Method: "ACTIONSTART"}, + {Type: "Applications.Compute/virtualMachines/disks", Method: v1.OperationPut}, + {Type: "Applications.Compute/virtualMachines/disks", Method: v1.OperationPatch}, + {Type: "Applications.Compute/webAssemblies", Method: v1.OperationPut}, + {Type: "Applications.Compute/webAssemblies", Method: v1.OperationPatch}, + } + + for _, op := range expectedOperations { + jobCtrl := registry.Get(op) + require.NotNil(t, jobCtrl) + } +} diff --git a/pkg/armrpc/builder/namespace.go b/pkg/armrpc/builder/namespace.go new file mode 100644 index 0000000000..e0791e04a0 --- /dev/null +++ b/pkg/armrpc/builder/namespace.go @@ -0,0 +1,84 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "strings" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" +) + +// Namespace represents the namespace of UCP. +type Namespace struct { + ResourceNode + + // availableOperations is the list of available operations for the namespace. + availableOperations []v1.Operation +} + +// NewNamespace creates a new namespace. +func NewNamespace(namespace string) *Namespace { + return &Namespace{ + ResourceNode: ResourceNode{ + Kind: NamespaceResourceKind, + Name: namespace, + children: make(map[string]*ResourceNode), + }, + } +} + +// SetAvailableOperations sets the available operations for the namespace. +func (p *Namespace) SetAvailableOperations(operations []v1.Operation) { + p.availableOperations = operations +} + +// GenerateBuilder Builder object by traversing resource nodes from namespace. +func (p *Namespace) GenerateBuilder() Builder { + return Builder{ + namespaceNode: p, + registrations: p.resolve(&p.ResourceNode, p.Name, strings.ToLower(p.Name)), + } +} + +func (p *Namespace) resolve(node *ResourceNode, qualifiedType string, qualifiedPattern string) []*OperationRegistration { + outputs := []*OperationRegistration{} + + newType := qualifiedType + newPattern := qualifiedPattern + + if node.Kind != NamespaceResourceKind { + newType = qualifiedType + "/" + node.Name + newPattern = qualifiedPattern + "/" + strings.ToLower(node.Name) + newParamName := "{" + node.option.ParamName() + "}" + + // This builds the handler outputs for each resource type. + ctrls := node.option.BuildHandlerOutputs(BuildOptions{ + ResourceType: newType, + ParameterName: newParamName, + ResourceNamePattern: newPattern, + }) + + newPattern += "/" + newParamName + outputs = append(outputs, ctrls...) + } + + for _, child := range node.children { + outputs = append(outputs, p.resolve(child, newType, newPattern)...) + } + + return outputs +} diff --git a/pkg/armrpc/builder/namespace_test.go b/pkg/armrpc/builder/namespace_test.go new file mode 100644 index 0000000000..b247c72810 --- /dev/null +++ b/pkg/armrpc/builder/namespace_test.go @@ -0,0 +1,445 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "context" + "net/http" + "testing" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + asyncctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + apictrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/stretchr/testify/require" +) + +type testAPIController struct { + apictrl.Operation[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel] +} + +func (e *testAPIController) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { + return nil, nil +} + +type testAsyncController struct { +} + +func (c *testAsyncController) Run(ctx context.Context, request *asyncctrl.Request) (asyncctrl.Result, error) { + return asyncctrl.Result{}, nil +} + +func (c *testAsyncController) StorageClient() store.StorageClient { + return nil +} + +func newTestController(opts apictrl.Options) (apictrl.Controller, error) { + return &testAPIController{ + apictrl.NewOperation(opts, + apictrl.ResourceOptions[rpctest.TestResourceDataModel]{ + RequestConverter: rpctest.TestResourceDataModelFromVersioned, + ResponseConverter: rpctest.TestResourceDataModelToVersioned, + }, + ), + }, nil +} + +func newTestNamespace(t *testing.T) *Namespace { + ns := NewNamespace("Applications.Compute") + require.Equal(t, NamespaceResourceKind, ns.Kind) + require.Equal(t, "Applications.Compute", ns.Name) + + asyncFunc := func(opts asyncctrl.Options) (asyncctrl.Controller, error) { + return &testAsyncController{}, nil + } + + // register virtualMachines resource + vmResource := ns.AddResource("virtualMachines", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + ResourceParamName: "virtualMachineName", + + RequestConverter: rpctest.TestResourceDataModelFromVersioned, + ResponseConverter: rpctest.TestResourceDataModelToVersioned, + + Put: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + AsyncJobController: asyncFunc, + }, + Patch: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + AsyncJobController: asyncFunc, + }, + Custom: map[string]Operation[rpctest.TestResourceDataModel]{ + "start": { + APIController: newTestController, + AsyncJobController: asyncFunc, + }, + "stop": { + APIController: newTestController, + }, + }, + }) + + require.NotNil(t, vmResource) + + // register virtualMachines/disks child resource + _ = vmResource.AddResource("disks", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + RequestConverter: rpctest.TestResourceDataModelFromVersioned, + ResponseConverter: rpctest.TestResourceDataModelToVersioned, + + Put: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + AsyncJobController: asyncFunc, + }, + Patch: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + AsyncJobController: asyncFunc, + }, + Custom: map[string]Operation[rpctest.TestResourceDataModel]{ + "replace": { + APIController: newTestController, + }, + }, + }) + + // register virtualMachines/networks child resource + _ = vmResource.AddResource("networks", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + RequestConverter: rpctest.TestResourceDataModelFromVersioned, + ResponseConverter: rpctest.TestResourceDataModelToVersioned, + + Put: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + }, + Patch: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + }, + Custom: map[string]Operation[rpctest.TestResourceDataModel]{ + "connect": { + APIController: newTestController, + }, + }, + }) + + // register containers resource + containerResource := ns.AddResource("containers", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + RequestConverter: rpctest.TestResourceDataModelFromVersioned, + ResponseConverter: rpctest.TestResourceDataModelToVersioned, + + Put: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + }, + Patch: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + }, + Custom: map[string]Operation[rpctest.TestResourceDataModel]{ + "getresource": { + APIController: newTestController, + }, + }, + }) + + require.NotNil(t, containerResource) + + // register containers/secrets child resource + _ = containerResource.AddResource("secrets", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + RequestConverter: rpctest.TestResourceDataModelFromVersioned, + ResponseConverter: rpctest.TestResourceDataModelToVersioned, + + Put: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + }, + Patch: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + }, + }) + + // register webAssemblies resource + wasmResource := ns.AddResource("webAssemblies", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + ResourceParamName: "webAssemblyName", + RequestConverter: rpctest.TestResourceDataModelFromVersioned, + ResponseConverter: rpctest.TestResourceDataModelToVersioned, + + Put: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + AsyncJobController: asyncFunc, + }, + Patch: Operation[rpctest.TestResourceDataModel]{ + APIController: newTestController, + AsyncJobController: asyncFunc, + }, + }) + + require.NotNil(t, wasmResource) + + return ns +} + +func TestNamespaceBuild(t *testing.T) { + ns := newTestNamespace(t) + builders := ns.GenerateBuilder() + require.NotNil(t, builders) + + builderTests := []struct { + resourceType string + resourceNamePattern string + path string + method v1.OperationMethod + found bool + }{ + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines", + path: "", + method: "LISTPLANESCOPE", + }, + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines", + path: "", + method: "LIST", + }, + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + path: "", + method: "GET", + }, + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + path: "", + method: "PUT", + }, + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + path: "", + method: "PATCH", + }, + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + path: "", + method: "DELETE", + }, + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + path: "/start", + method: "ACTIONSTART", + }, + { + resourceType: "Applications.Compute/virtualMachines", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + path: "/stop", + method: "ACTIONSTOP", + }, + { + resourceType: "Applications.Compute/virtualMachines/networks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/networks", + path: "", + method: "LIST", + }, + { + resourceType: "Applications.Compute/virtualMachines/networks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/networks/{networkName}", + path: "", + method: "GET", + }, + { + resourceType: "Applications.Compute/virtualMachines/networks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/networks/{networkName}", + path: "", + method: "PUT", + }, + { + resourceType: "Applications.Compute/virtualMachines/networks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/networks/{networkName}", + path: "", + method: "PATCH", + }, + { + resourceType: "Applications.Compute/virtualMachines/networks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/networks/{networkName}", + path: "", + method: "DELETE", + }, + { + resourceType: "Applications.Compute/virtualMachines/networks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/networks/{networkName}", + path: "/connect", + method: "ACTIONCONNECT", + }, + { + resourceType: "Applications.Compute/virtualMachines/disks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/disks", + path: "", + method: "LIST", + }, + { + resourceType: "Applications.Compute/virtualMachines/disks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/disks/{diskName}", + path: "", + method: "GET", + }, + { + resourceType: "Applications.Compute/virtualMachines/disks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/disks/{diskName}", + path: "", + method: "PUT", + }, + { + resourceType: "Applications.Compute/virtualMachines/disks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/disks/{diskName}", + path: "", + method: "PATCH", + }, + { + resourceType: "Applications.Compute/virtualMachines/disks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/disks/{diskName}", + path: "", + method: "DELETE", + }, + { + resourceType: "Applications.Compute/virtualMachines/disks", + resourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}/disks/{diskName}", + path: "/replace", + method: "ACTIONREPLACE", + }, + { + resourceType: "Applications.Compute/containers", + resourceNamePattern: "applications.compute/containers", + path: "", + method: "LISTPLANESCOPE", + }, + { + resourceType: "Applications.Compute/containers", + resourceNamePattern: "applications.compute/containers", + path: "", + method: "LIST", + }, + { + resourceType: "Applications.Compute/containers", + resourceNamePattern: "applications.compute/containers/{containerName}", + path: "", + method: "GET", + }, + { + resourceType: "Applications.Compute/containers", + resourceNamePattern: "applications.compute/containers/{containerName}", + path: "", + method: "PUT", + }, + { + resourceType: "Applications.Compute/containers", + resourceNamePattern: "applications.compute/containers/{containerName}", + path: "", + method: "PATCH", + }, + { + resourceType: "Applications.Compute/containers", + resourceNamePattern: "applications.compute/containers/{containerName}", + path: "", + method: "DELETE", + }, + { + resourceType: "Applications.Compute/containers", + resourceNamePattern: "applications.compute/containers/{containerName}", + path: "/getresource", + method: "ACTIONGETRESOURCE", + }, + { + resourceType: "Applications.Compute/containers/secrets", + resourceNamePattern: "applications.compute/containers/{containerName}/secrets", + path: "", + method: "LIST", + }, + { + resourceType: "Applications.Compute/containers/secrets", + resourceNamePattern: "applications.compute/containers/{containerName}/secrets/{secretName}", + path: "", + method: "GET", + }, + { + resourceType: "Applications.Compute/containers/secrets", + resourceNamePattern: "applications.compute/containers/{containerName}/secrets/{secretName}", + path: "", + method: "PUT", + }, + { + resourceType: "Applications.Compute/containers/secrets", + resourceNamePattern: "applications.compute/containers/{containerName}/secrets/{secretName}", + path: "", + method: "PATCH", + }, + { + resourceType: "Applications.Compute/containers/secrets", + resourceNamePattern: "applications.compute/containers/{containerName}/secrets/{secretName}", + path: "", + method: "DELETE", + }, + { + resourceType: "Applications.Compute/webAssemblies", + resourceNamePattern: "applications.compute/webassemblies", + path: "", + method: "LISTPLANESCOPE", + }, + { + resourceType: "Applications.Compute/webAssemblies", + resourceNamePattern: "applications.compute/webassemblies", + path: "", + method: "LIST", + }, + { + resourceType: "Applications.Compute/webAssemblies", + resourceNamePattern: "applications.compute/webassemblies/{webAssemblyName}", + path: "", + method: "GET", + }, + { + resourceType: "Applications.Compute/webAssemblies", + resourceNamePattern: "applications.compute/webassemblies/{webAssemblyName}", + path: "", + method: "PUT", + }, + { + resourceType: "Applications.Compute/webAssemblies", + resourceNamePattern: "applications.compute/webassemblies/{webAssemblyName}", + path: "", + method: "PATCH", + }, + { + resourceType: "Applications.Compute/webAssemblies", + resourceNamePattern: "applications.compute/webassemblies/{webAssemblyName}", + path: "", + method: "DELETE", + }, + } + + for _, b := range builders.registrations { + for i, bt := range builderTests { + if bt.resourceType == b.ResourceType && bt.resourceNamePattern == b.ResourceNamePattern && bt.path == b.Path && bt.method == b.Method { + builderTests[i].found = true + } + } + } + + for _, bt := range builderTests { + require.True(t, bt.found, "resource not found: %s %s %s %s", bt.resourceType, bt.resourceNamePattern, bt.path, bt.method) + } +} diff --git a/pkg/armrpc/builder/node.go b/pkg/armrpc/builder/node.go new file mode 100644 index 0000000000..06c54a493c --- /dev/null +++ b/pkg/armrpc/builder/node.go @@ -0,0 +1,73 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "errors" + "strings" +) + +var ( + // ErrResourceAlreadyExists represents an error when a resource already exists. + ErrResourceAlreadyExists = errors.New("resource already exists") +) + +// ResourceNode is a node in the resource tree. +type ResourceNode struct { + // Kind is the resource kind. + Kind ResourceKind + + // Name is the resource name. + Name string + + // option includes the resource handlers. + option ResourceOptionBuilder + + // children includes the child resources and custom actions of this resource. + children map[string]*ResourceNode +} + +// AddResource adds a new child resource type and API handlers and returns new resource node. +func (r *ResourceNode) AddResource(name string, option ResourceOptionBuilder) *ResourceNode { + normalized := strings.ToLower(name) + + if _, ok := r.children[normalized]; ok { + panic(ErrResourceAlreadyExists) + } + + child := &ResourceNode{ + Name: name, + children: make(map[string]*ResourceNode), + option: option, + } + + switch r.Kind { + case NamespaceResourceKind: + child.Kind = TrackedResourceKind + + case TrackedResourceKind: + child.Kind = ProxyResourceKind + + default: + child.Kind = ProxyResourceKind + } + + option.LinkResource(child) + r.children[normalized] = child + + return child +} diff --git a/pkg/armrpc/builder/node_test.go b/pkg/armrpc/builder/node_test.go new file mode 100644 index 0000000000..865f404198 --- /dev/null +++ b/pkg/armrpc/builder/node_test.go @@ -0,0 +1,47 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "testing" + + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/stretchr/testify/require" +) + +func TestAddResource(t *testing.T) { + r := &ResourceNode{ + Name: "Applications.Core", + Kind: NamespaceResourceKind, + children: make(map[string]*ResourceNode), + } + + child := r.AddResource("virtualMachines", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{}) + require.Equal(t, "virtualMachines", child.Name) + require.Equal(t, TrackedResourceKind, child.Kind, "child resource of namespace should be a tracked resource") + require.Len(t, r.children, 1, "should have one child resource") + + require.Panics(t, func() { + _ = r.AddResource("virtualMachines", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{}) + }, "panic when adding a resource with the same name") + + nested := child.AddResource("disks", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{}) + _ = child.AddResource("cpus", &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{}) + require.Equal(t, "disks", nested.Name) + require.Equal(t, ProxyResourceKind, nested.Kind, "nested resource should be a proxy resource") + require.Len(t, child.children, 2, "should have 2 child resource") +} diff --git a/pkg/armrpc/builder/operation.go b/pkg/armrpc/builder/operation.go new file mode 100644 index 0000000000..b491604525 --- /dev/null +++ b/pkg/armrpc/builder/operation.go @@ -0,0 +1,367 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "strings" + "time" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + asyncctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" +) + +const customActionPrefix = "ACTION" + +// Operation defines converters for request and response, update and delete filters, +// asynchronous operation controller, and the options for API operation. +type Operation[T any] struct { + // Disabled indicates that the operation is disabled. By default, all operations are enabled. + Disabled bool + + // UpdateFilters is a slice of filters that execute prior to updating a resource. + UpdateFilters []controller.UpdateFilter[T] + + // DeleteFilters is a slice of filters that execute prior to deleting a resource. + DeleteFilters []controller.DeleteFilter[T] + + // APIController is the controller function for the API controller frontend. + APIController server.ControllerFactoryFunc + + // AsyncJobController is the controller function for the async job worker. + AsyncJobController worker.ControllerFactoryFunc + + // AsyncOperationTimeout is the default timeout duration of async operations for the operation. + AsyncOperationTimeout time.Duration + + // AsyncOperationRetryAfter is the value of the Retry-After header that will be used for async operations. + // If this is 0 then the default value of v1.DefaultRetryAfter will be used. Consider setting this to a smaller + // value like 5 seconds if your operations will complete quickly. + AsyncOperationRetryAfter time.Duration +} + +// ResourceOption is the option for ResourceNode. It defines model converters for request and response +// and configures operation for each CRUDL and custom actions. +type ResourceOption[P interface { + *T + v1.ResourceDataModel +}, T any] struct { + // linkedNode references to ResourceNode linked to this option. + linkedNode *ResourceNode + + // ResourceParamName is the parameter name of the resource. This is optional. + // If not set, the parameter name will be generated by adding "Name" suffix to the resource name. + ResourceParamName string + + // RequestConverter is the request converter. + RequestConverter v1.ConvertToDataModel[T] + + // ResponseConverter is the response converter. + ResponseConverter v1.ConvertToAPIModel[T] + + // ListPlane defines the operation for listing resources by plane scope. + ListPlane Operation[T] + + // List defines the operation for listing resources by resource group scope. + List Operation[T] + + // Get defines the operation for getting a resource. + Get Operation[T] + + // Put defines the operation for creating or updating a resource. + Put Operation[T] + + // Patch defines the operation for updating a resource. + Patch Operation[T] + + // Delete defines the operation for deleting a resource. + Delete Operation[T] + + // Custom defines the custom actions. + Custom map[string]Operation[T] +} + +// LinkResource links the resource node to the resource option. +func (r *ResourceOption[P, T]) LinkResource(node *ResourceNode) { + r.linkedNode = node +} + +// ParamName returns the parameter name of the resource. +// If ResourceParamName is not set, the parameter name will be generated by adding "Name" suffix to the resource name. +func (r *ResourceOption[P, T]) ParamName() string { + if r.ResourceParamName == "" { + typeName := r.linkedNode.Name + if strings.HasSuffix(typeName, "s") { + return typeName[:len(typeName)-1] + "Name" + } else { + return typeName + "Name" + } + } + + return r.ResourceParamName +} + +// BuildHandlerOutputs builds the handler outputs for each operation. +func (r *ResourceOption[P, T]) BuildHandlerOutputs(opts BuildOptions) []*OperationRegistration { + handlerFuncs := []func(opts BuildOptions) *OperationRegistration{ + r.listPlaneOutput, + r.listOutput, + r.getOutput, + r.putOutput, + r.patchOutput, + r.deleteOutput, + } + + hs := []*OperationRegistration{} + for _, h := range handlerFuncs { + if out := h(opts); out != nil { + hs = append(hs, out) + } + } + + return append(hs, r.customActionOutputs(opts)...) +} + +func (r *ResourceOption[P, T]) listPlaneOutput(opts BuildOptions) *OperationRegistration { + if r.ListPlane.Disabled || r.linkedNode.Kind != TrackedResourceKind { + return nil + } + + h := &OperationRegistration{ + ResourceType: opts.ResourceType, + ResourceNamePattern: opts.ResourceNamePattern, + Method: v1.OperationPlaneScopeList, + } + + if r.ListPlane.APIController != nil { + h.APIController = r.ListPlane.APIController + } else { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewListResources[P, T](opt, + controller.ResourceOptions[T]{ + ResponseConverter: r.ResponseConverter, + ListRecursiveQuery: true, + }, + ) + } + } + + return h +} + +func (r *ResourceOption[P, T]) listOutput(opts BuildOptions) *OperationRegistration { + if r.List.Disabled { + return nil + } + + h := &OperationRegistration{ + ResourceType: opts.ResourceType, + ResourceNamePattern: opts.ResourceNamePattern, + Method: v1.OperationList, + } + + if r.List.APIController != nil { + h.APIController = r.List.APIController + } else { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewListResources[P, T](opt, + controller.ResourceOptions[T]{ + ResponseConverter: r.ResponseConverter, + }, + ) + } + } + + return h +} + +func (r *ResourceOption[P, T]) getOutput(opts BuildOptions) *OperationRegistration { + if r.Get.Disabled { + return nil + } + + h := &OperationRegistration{ + ResourceType: opts.ResourceType, + ResourceNamePattern: opts.ResourceNamePattern + "/" + opts.ParameterName, + Method: v1.OperationGet, + } + + if r.Get.APIController != nil { + h.APIController = r.Get.APIController + } else { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewGetResource[P, T](opt, + controller.ResourceOptions[T]{ + ResponseConverter: r.ResponseConverter, + }, + ) + } + } + + return h +} + +func getOrDefaultAsyncOperationTimeout(d time.Duration) time.Duration { + if d == 0 { + return asyncctrl.DefaultAsyncOperationTimeout + } + return d +} + +func getOrDefaultRetryAfter(d time.Duration) time.Duration { + if d == 0 { + return v1.DefaultRetryAfterDuration + } + return d +} + +func (r *ResourceOption[P, T]) putOutput(opts BuildOptions) *OperationRegistration { + if r.Put.Disabled { + return nil + } + + h := &OperationRegistration{ + ResourceType: opts.ResourceType, + ResourceNamePattern: opts.ResourceNamePattern + "/" + opts.ParameterName, + Method: v1.OperationPut, + AsyncController: r.Delete.AsyncJobController, + } + + if r.Put.APIController != nil { + h.APIController = r.Put.APIController + } else { + ro := controller.ResourceOptions[T]{ + RequestConverter: r.RequestConverter, + ResponseConverter: r.ResponseConverter, + UpdateFilters: r.Put.UpdateFilters, + AsyncOperationTimeout: getOrDefaultAsyncOperationTimeout(r.Put.AsyncOperationTimeout), + AsyncOperationRetryAfter: getOrDefaultRetryAfter(r.Put.AsyncOperationRetryAfter), + } + + if r.Put.AsyncJobController == nil { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewDefaultSyncPut[P, T](opt, ro) + } + } else { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewDefaultAsyncPut[P, T](opt, ro) + } + } + } + h.AsyncController = r.Put.AsyncJobController + + return h +} + +func (r *ResourceOption[P, T]) patchOutput(opts BuildOptions) *OperationRegistration { + if r.Patch.Disabled { + return nil + } + + h := &OperationRegistration{ + ResourceType: opts.ResourceType, + ResourceNamePattern: opts.ResourceNamePattern + "/" + opts.ParameterName, + Method: v1.OperationPatch, + AsyncController: r.Patch.AsyncJobController, + } + + if r.Patch.APIController != nil { + h.APIController = r.Patch.APIController + } else { + ro := controller.ResourceOptions[T]{ + RequestConverter: r.RequestConverter, + ResponseConverter: r.ResponseConverter, + UpdateFilters: r.Patch.UpdateFilters, + AsyncOperationTimeout: getOrDefaultAsyncOperationTimeout(r.Patch.AsyncOperationTimeout), + AsyncOperationRetryAfter: getOrDefaultRetryAfter(r.Patch.AsyncOperationRetryAfter), + } + + if r.Patch.AsyncJobController == nil { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewDefaultSyncPut[P, T](opt, ro) + } + } else { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewDefaultAsyncPut[P, T](opt, ro) + } + } + } + + return h +} + +func (r *ResourceOption[P, T]) deleteOutput(opts BuildOptions) *OperationRegistration { + if r.Delete.Disabled { + return nil + } + + h := &OperationRegistration{ + ResourceType: opts.ResourceType, + ResourceNamePattern: opts.ResourceNamePattern + "/" + opts.ParameterName, + Method: v1.OperationDelete, + AsyncController: r.Delete.AsyncJobController, + } + + if r.Delete.APIController != nil { + h.APIController = r.Delete.APIController + } else { + ro := controller.ResourceOptions[T]{ + RequestConverter: r.RequestConverter, + ResponseConverter: r.ResponseConverter, + DeleteFilters: r.Delete.DeleteFilters, + AsyncOperationTimeout: getOrDefaultAsyncOperationTimeout(r.Delete.AsyncOperationTimeout), + AsyncOperationRetryAfter: getOrDefaultRetryAfter(r.Delete.AsyncOperationRetryAfter), + } + + if r.Delete.AsyncJobController == nil { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewDefaultSyncDelete[P, T](opt, ro) + } + } else { + h.APIController = func(opt controller.Options) (controller.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete[P, T](opt, ro) + } + } + } + + return h +} + +func (r *ResourceOption[P, T]) customActionOutputs(opts BuildOptions) []*OperationRegistration { + handlers := []*OperationRegistration{} + + for name, handle := range r.Custom { + if handle.APIController == nil { + panic("APIController is required for custom action") + } + + h := &OperationRegistration{ + ResourceType: opts.ResourceType, + ResourceNamePattern: opts.ResourceNamePattern + "/" + opts.ParameterName, + Path: "/" + strings.ToLower(name), + Method: v1.OperationMethod(customActionPrefix + strings.ToUpper(name)), + APIController: handle.APIController, + AsyncController: handle.AsyncJobController, + } + handlers = append(handlers, h) + } + + return handlers +} diff --git a/pkg/armrpc/builder/operation_test.go b/pkg/armrpc/builder/operation_test.go new file mode 100644 index 0000000000..4c8141fe19 --- /dev/null +++ b/pkg/armrpc/builder/operation_test.go @@ -0,0 +1,512 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + "errors" + "testing" + "time" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + asyncctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/stretchr/testify/require" +) + +var ( + testBuildOptions = BuildOptions{ + ResourceType: "Applications.Compute/virtualMachines", + ResourceNamePattern: "applications.compute/virtualmachines", + } + + testBuildOptionsWithName = BuildOptions{ + ResourceType: "Applications.Compute/virtualMachines", + ResourceNamePattern: "applications.compute/virtualmachines", + ParameterName: "{virtualMachineName}", + } +) + +func TestGetOrDefaultAsyncOperationTimeout(t *testing.T) { + var zeroDuration time.Duration + require.Equal(t, time.Duration(120)*time.Second, getOrDefaultAsyncOperationTimeout(zeroDuration)) + require.Equal(t, time.Duration(1)*time.Minute, getOrDefaultAsyncOperationTimeout(time.Duration(1)*time.Minute)) +} + +func TestGetOrDefaultRetryAfter(t *testing.T) { + var zeroDuration time.Duration + require.Equal(t, time.Duration(60)*time.Second, getOrDefaultRetryAfter(zeroDuration)) + require.Equal(t, time.Duration(1)*time.Minute, getOrDefaultRetryAfter(time.Duration(1)*time.Minute)) +} + +func TestResourceOption_LinkResource(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{} + option.LinkResource(node) + require.Equal(t, node, option.linkedNode) +} + +func TestResourceOption_ParamName(t *testing.T) { + t.Run("custom parameter name", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + ResourceParamName: "virtualMachineName", + } + require.Equal(t, "virtualMachineName", option.ParamName()) + }) + + t.Run("plural resource type name", func(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{} + option.LinkResource(node) + require.Equal(t, "virtualMachineName", option.ParamName()) + }) + + t.Run("plural resource type name without s", func(t *testing.T) { + node := &ResourceNode{Name: "dice", Kind: TrackedResourceKind} + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{} + option.LinkResource(node) + require.Equal(t, "diceName", option.ParamName()) + }) +} + +func TestResourceOption_ListPlaneOutput(t *testing.T) { + t.Run("disabled is true", func(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + ListPlane: Operation[rpctest.TestResourceDataModel]{ + Disabled: true, + }, + } + require.Nil(t, option.listPlaneOutput(BuildOptions{})) + }) + + t.Run("non tracked resource disabled operation", func(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: ProxyResourceKind} + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + ListPlane: Operation[rpctest.TestResourceDataModel]{}, + } + require.Nil(t, option.listPlaneOutput(BuildOptions{})) + }) + + t.Run("custom controller", func(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + ListPlane: Operation[rpctest.TestResourceDataModel]{ + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, errors.New("ok") + }, + }, + } + h := option.listPlaneOutput(testBuildOptions) + require.NotNil(t, h) + _, err := h.APIController(controller.Options{}) + require.EqualError(t, err, "ok") + require.Equal(t, v1.OperationPlaneScopeList, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default controller", func(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + ListPlane: Operation[rpctest.TestResourceDataModel]{}, + } + h := option.listPlaneOutput(testBuildOptions) + require.NotNil(t, h) + require.NotNil(t, h.APIController) + require.Equal(t, v1.OperationPlaneScopeList, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) +} + +func TestResourceOption_ListOutput(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + t.Run("disabled is true", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + List: Operation[rpctest.TestResourceDataModel]{ + Disabled: true, + }, + } + require.Nil(t, option.listOutput(BuildOptions{})) + }) + + t.Run("custom controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + List: Operation[rpctest.TestResourceDataModel]{ + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, errors.New("ok") + }, + }, + } + h := option.listOutput(testBuildOptions) + require.NotNil(t, h) + _, err := h.APIController(controller.Options{}) + require.EqualError(t, err, "ok") + require.Equal(t, v1.OperationList, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + List: Operation[rpctest.TestResourceDataModel]{}, + } + h := option.listOutput(testBuildOptions) + require.NotNil(t, h) + require.NotNil(t, h.APIController) + require.Equal(t, v1.OperationList, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) +} + +func TestResourceOption_GetOutput(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + + t.Run("disabled is true", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Get: Operation[rpctest.TestResourceDataModel]{ + Disabled: true, + }, + } + require.Nil(t, option.getOutput(BuildOptions{})) + }) + + t.Run("custom controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Get: Operation[rpctest.TestResourceDataModel]{ + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, errors.New("ok") + }, + }, + } + h := option.getOutput(testBuildOptionsWithName) + require.NotNil(t, h) + _, err := h.APIController(controller.Options{}) + require.EqualError(t, err, "ok") + require.Equal(t, v1.OperationGet, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Get: Operation[rpctest.TestResourceDataModel]{}, + } + h := option.getOutput(testBuildOptionsWithName) + require.NotNil(t, h) + require.NotNil(t, h.APIController) + require.Equal(t, v1.OperationGet, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) +} + +func TestResourceOption_PutOutput(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + + t.Run("disabled is true", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Put: Operation[rpctest.TestResourceDataModel]{ + Disabled: true, + }, + } + require.Nil(t, option.putOutput(BuildOptions{})) + }) + + t.Run("custom controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Put: Operation[rpctest.TestResourceDataModel]{ + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, errors.New("ok") + }, + }, + } + h := option.putOutput(testBuildOptionsWithName) + require.NotNil(t, h) + _, err := h.APIController(controller.Options{}) + require.EqualError(t, err, "ok") + require.Equal(t, v1.OperationPut, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default sync controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Put: Operation[rpctest.TestResourceDataModel]{}, + } + h := option.putOutput(testBuildOptionsWithName) + require.NotNil(t, h) + require.Equal(t, v1.OperationPut, h.Method) + + api, err := h.APIController(controller.Options{}) + require.NoError(t, err) + _, ok := api.(*defaultoperation.DefaultSyncPut[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]) + require.True(t, ok) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default async controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Put: Operation[rpctest.TestResourceDataModel]{ + AsyncJobController: func(opts asyncctrl.Options) (asyncctrl.Controller, error) { + return nil, nil + }, + }, + } + h := option.putOutput(testBuildOptionsWithName) + require.NotNil(t, h) + require.Equal(t, v1.OperationPut, h.Method) + + api, err := h.APIController(controller.Options{}) + require.NoError(t, err) + _, ok := api.(*defaultoperation.DefaultAsyncPut[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]) + require.True(t, ok) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) +} + +func TestResourceOption_PatchOutput(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + + t.Run("disabled is true", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Patch: Operation[rpctest.TestResourceDataModel]{ + Disabled: true, + }, + } + require.Nil(t, option.patchOutput(BuildOptions{})) + }) + + t.Run("custom controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Patch: Operation[rpctest.TestResourceDataModel]{ + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, errors.New("ok") + }, + }, + } + h := option.patchOutput(testBuildOptionsWithName) + require.NotNil(t, h) + _, err := h.APIController(controller.Options{}) + require.EqualError(t, err, "ok") + require.Equal(t, v1.OperationPatch, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default sync controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Patch: Operation[rpctest.TestResourceDataModel]{}, + } + h := option.patchOutput(testBuildOptionsWithName) + require.NotNil(t, h) + require.Equal(t, v1.OperationPatch, h.Method) + + api, err := h.APIController(controller.Options{}) + require.NoError(t, err) + _, ok := api.(*defaultoperation.DefaultSyncPut[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]) + require.True(t, ok) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default async controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Patch: Operation[rpctest.TestResourceDataModel]{ + AsyncJobController: func(opts asyncctrl.Options) (asyncctrl.Controller, error) { + return nil, nil + }, + }, + } + h := option.patchOutput(testBuildOptionsWithName) + require.NotNil(t, h) + require.Equal(t, v1.OperationPatch, h.Method) + + api, err := h.APIController(controller.Options{}) + require.NoError(t, err) + _, ok := api.(*defaultoperation.DefaultAsyncPut[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]) + require.True(t, ok) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) +} + +func TestResourceOption_DeleteOutput(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + + t.Run("disabled is true", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Delete: Operation[rpctest.TestResourceDataModel]{ + Disabled: true, + }, + } + require.Nil(t, option.deleteOutput(BuildOptions{})) + }) + + t.Run("custom controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Delete: Operation[rpctest.TestResourceDataModel]{ + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, errors.New("ok") + }, + }, + } + h := option.deleteOutput(testBuildOptionsWithName) + require.NotNil(t, h) + _, err := h.APIController(controller.Options{}) + require.EqualError(t, err, "ok") + require.Equal(t, v1.OperationDelete, h.Method) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default sync controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Delete: Operation[rpctest.TestResourceDataModel]{}, + } + h := option.deleteOutput(testBuildOptionsWithName) + require.NotNil(t, h) + require.Equal(t, v1.OperationDelete, h.Method) + + api, err := h.APIController(controller.Options{}) + require.NoError(t, err) + _, ok := api.(*defaultoperation.DefaultSyncDelete[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]) + require.True(t, ok) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) + + t.Run("default async controller", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Delete: Operation[rpctest.TestResourceDataModel]{ + AsyncJobController: func(opts asyncctrl.Options) (asyncctrl.Controller, error) { + return nil, nil + }, + }, + } + h := option.deleteOutput(testBuildOptionsWithName) + require.NotNil(t, h) + require.Equal(t, v1.OperationDelete, h.Method) + + api, err := h.APIController(controller.Options{}) + require.NoError(t, err) + _, ok := api.(*defaultoperation.DefaultAsyncDelete[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]) + require.True(t, ok) + require.Equal(t, "Applications.Compute/virtualMachines", h.ResourceType) + require.Equal(t, "applications.compute/virtualmachines/{virtualMachineName}", h.ResourceNamePattern) + require.Empty(t, h.Path) + }) +} + +func TestResourceOption_CustomActionOutput(t *testing.T) { + node := &ResourceNode{Name: "virtualMachines", Kind: TrackedResourceKind} + t.Run("valid custom action", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Custom: map[string]Operation[rpctest.TestResourceDataModel]{ + "start": { + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, nil + }, + }, + "stop": { + APIController: func(opt controller.Options) (controller.Controller, error) { + return nil, nil + }, + }, + }, + } + + hs := option.customActionOutputs(testBuildOptionsWithName) + require.Len(t, hs, 2) + + require.NotNil(t, hs[0].APIController) + require.NotNil(t, hs[1].APIController) + + // Reset APIController to nil for comparison + hs[0].APIController = nil + hs[1].APIController = nil + + require.ElementsMatch(t, []*OperationRegistration{ + { + ResourceType: "Applications.Compute/virtualMachines", + ResourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + Path: "/start", + Method: "ACTIONSTART", + }, + { + ResourceType: "Applications.Compute/virtualMachines", + ResourceNamePattern: "applications.compute/virtualmachines/{virtualMachineName}", + Path: "/stop", + Method: "ACTIONSTOP", + }, + }, hs) + }) + + t.Run("APIController is not defined", func(t *testing.T) { + option := &ResourceOption[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel]{ + linkedNode: node, + Custom: map[string]Operation[rpctest.TestResourceDataModel]{ + "start": {}, + }, + } + require.Panics(t, func() { + _ = option.customActionOutputs(testBuildOptionsWithName) + }) + }) +} diff --git a/pkg/armrpc/builder/types.go b/pkg/armrpc/builder/types.go new file mode 100644 index 0000000000..4b265c964d --- /dev/null +++ b/pkg/armrpc/builder/types.go @@ -0,0 +1,82 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package builder + +import ( + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" +) + +// ResourceKind represents the kind of resource. +type ResourceKind string + +const ( + // NamespaceResourceKind represents the namespace resource kind. + NamespaceResourceKind ResourceKind = "Namespace" + + // TrackedResourceKind represents the tracked resource kind. + TrackedResourceKind ResourceKind = "TrackedResource" + + // ProxyResourceKind represents the proxy resource kind. + ProxyResourceKind ResourceKind = "ProxyResource" +) + +// ResourceOptionBuilder is the interface for resource option. +type ResourceOptionBuilder interface { + // LinkResource links the resource node to the resource option. + LinkResource(*ResourceNode) + + // ParamName gets the resource name for resource type. + ParamName() string + + // BuildHandlerOutputs builds the resource outputs which constructs the API routing path and handlers. + BuildHandlerOutputs(BuildOptions) []*OperationRegistration +} + +// BuildOptions is the options for building resource outputs. +type BuildOptions struct { + // ResourceType represents the resource type. + ResourceType string + + // ParameterName represents the resource name for resource type. + ParameterName string + + // ResourceNamePattern represents the resource name pattern used for HTTP routing path. + ResourceNamePattern string +} + +// OperationRegistration is the output for building resource outputs. +type OperationRegistration struct { + // ResourceType represents the resource type. + ResourceType string + + // ResourceNamePattern represents the resource name pattern used for HTTP routing path. + ResourceNamePattern string + + // Path represents additional custom action path after resource name. + Path string + + // Method represents the operation method. + Method v1.OperationMethod + + // APIController represents the API controller handler. + APIController server.ControllerFactoryFunc + + // AsyncController represents the async controller handler. + AsyncController worker.ControllerFactoryFunc +} diff --git a/pkg/armrpc/frontend/controller/controller.go b/pkg/armrpc/frontend/controller/controller.go index 7d51c71002..d7c8bab554 100644 --- a/pkg/armrpc/frontend/controller/controller.go +++ b/pkg/armrpc/frontend/controller/controller.go @@ -21,12 +21,12 @@ import ( "net/http" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - sm "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + sm "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -61,7 +61,7 @@ type Options struct { // KubeClient is the Kubernetes controller runtime client. KubeClient runtimeclient.Client - // ResourceType is the string that represents the resource type. May be empty of the controller + // ResourceType is the string that represents the resource type. May be empty if the controller // does not represent a single type of resource. ResourceType string diff --git a/pkg/armrpc/frontend/controller/controller_test.go b/pkg/armrpc/frontend/controller/controller_test.go index d2270acb36..d8435643e4 100644 --- a/pkg/armrpc/frontend/controller/controller_test.go +++ b/pkg/armrpc/frontend/controller/controller_test.go @@ -19,7 +19,7 @@ package controller import ( "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/frontend/controller/operation.go b/pkg/armrpc/frontend/controller/operation.go index 5fb45fabc1..db6d510148 100644 --- a/pkg/armrpc/frontend/controller/operation.go +++ b/pkg/armrpc/frontend/controller/operation.go @@ -23,12 +23,12 @@ import ( "net/http" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - sm "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + sm "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" ) const ( diff --git a/pkg/armrpc/frontend/controller/util.go b/pkg/armrpc/frontend/controller/util.go index d16e54984f..e673ce2526 100644 --- a/pkg/armrpc/frontend/controller/util.go +++ b/pkg/armrpc/frontend/controller/util.go @@ -26,7 +26,7 @@ import ( "strconv" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) var ( diff --git a/pkg/armrpc/frontend/controller/util_test.go b/pkg/armrpc/frontend/controller/util_test.go index 2147966ba2..759b11e943 100644 --- a/pkg/armrpc/frontend/controller/util_test.go +++ b/pkg/armrpc/frontend/controller/util_test.go @@ -24,7 +24,7 @@ import ( "testing" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription.go b/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription.go index 2538a472d9..35724d5803 100644 --- a/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription.go +++ b/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription.go @@ -21,10 +21,10 @@ import ( "encoding/json" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ ctrl.Controller = (*CreateOrUpdateSubscription)(nil) diff --git a/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription_test.go b/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription_test.go index 1215bda8d8..3dc9a2b884 100644 --- a/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription_test.go +++ b/pkg/armrpc/frontend/defaultoperation/createorupdatesubscription_test.go @@ -23,11 +23,11 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) diff --git a/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete.go b/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete.go index 75bcbca39f..a2c38bfe4e 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete.go @@ -20,9 +20,9 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" ) // DefaultAsyncDelete is the controller implementation to delete async resource. diff --git a/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete_test.go b/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete_test.go index 787173806d..b586602868 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete_test.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultasyncdelete_test.go @@ -24,12 +24,12 @@ import ( "testing" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/armrpc/frontend/defaultoperation/defaultasyncput.go b/pkg/armrpc/frontend/defaultoperation/defaultasyncput.go index 54f783927b..017720c500 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultasyncput.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultasyncput.go @@ -20,9 +20,9 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" ) // DefaultAsyncPut is the controller implementation to create or update async resource. diff --git a/pkg/armrpc/frontend/defaultoperation/defaultasyncput_test.go b/pkg/armrpc/frontend/defaultoperation/defaultasyncput_test.go index e65dcd6aaa..21db1d1937 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultasyncput_test.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultasyncput_test.go @@ -25,12 +25,12 @@ import ( "testing" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete.go b/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete.go index 3c1d341413..6971c3c74a 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete.go @@ -21,10 +21,10 @@ import ( "errors" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/store" ) // DefaultSyncDelete is the controller implementation to delete resource synchronously. diff --git a/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete_test.go b/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete_test.go index f9509c93a1..6d4547ade3 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete_test.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultsyncdelete_test.go @@ -23,10 +23,10 @@ import ( "net/http/httptest" "testing" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/armrpc/frontend/defaultoperation/defaultsyncput.go b/pkg/armrpc/frontend/defaultoperation/defaultsyncput.go index 6cf70b9629..d38703e5a5 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultsyncput.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultsyncput.go @@ -20,9 +20,9 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" ) // DefaultSyncPut is the controller implementation to create or update resource synchronously. diff --git a/pkg/armrpc/frontend/defaultoperation/defaultsyncput_test.go b/pkg/armrpc/frontend/defaultoperation/defaultsyncput_test.go index 85717df213..f7738850ea 100644 --- a/pkg/armrpc/frontend/defaultoperation/defaultsyncput_test.go +++ b/pkg/armrpc/frontend/defaultoperation/defaultsyncput_test.go @@ -24,11 +24,11 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/armrpc/frontend/defaultoperation/getavailableoperations.go b/pkg/armrpc/frontend/defaultoperation/getavailableoperations.go new file mode 100644 index 0000000000..6dcc1bab5b --- /dev/null +++ b/pkg/armrpc/frontend/defaultoperation/getavailableoperations.go @@ -0,0 +1,50 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package defaultoperation + +import ( + "context" + "net/http" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" +) + +var _ ctrl.Controller = (*GetOperations)(nil) + +// GetOperations is the controller implementation to get arm rpc available operations. +type GetOperations struct { + ctrl.BaseController + + availableOperations []any +} + +// NewGetOperations creates a new GetOperations controller and returns it, or returns an error if one occurs. +func NewGetOperations(opts ctrl.Options, opsList []v1.Operation) (ctrl.Controller, error) { + ops := []any{} + for _, o := range opsList { + ops = append(ops, o) + } + return &GetOperations{ctrl.NewBaseController(opts), ops}, nil +} + +// Run returns the list of available operations/permission for the resource provider at tenant level. +// Spec: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/proxy-api-reference.md#exposing-available-operations +func (opctrl *GetOperations) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { + return rest.NewOKResponse(&v1.PaginatedList{Value: opctrl.availableOperations}), nil +} diff --git a/pkg/armrpc/frontend/defaultoperation/getoperationresult.go b/pkg/armrpc/frontend/defaultoperation/getoperationresult.go index e162a2f4f0..e5f64effd8 100644 --- a/pkg/armrpc/frontend/defaultoperation/getoperationresult.go +++ b/pkg/armrpc/frontend/defaultoperation/getoperationresult.go @@ -23,12 +23,12 @@ import ( "net/http" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" ) var _ ctrl.Controller = (*GetOperationResult)(nil) @@ -56,12 +56,24 @@ func (e *GetOperationResult) Run(ctx context.Context, w http.ResponseWriter, req return rest.NewBadRequestResponse(err.Error()), nil } - os := &manager.Status{} - _, err = e.GetResource(ctx, id.String(), os) - if err != nil && errors.Is(&store.ErrNotFound{ID: id.String()}, err) { + // Avoid using GetResource or e.StorageClient since they will use a different + // storage client than the one we want. + storageClient, err := e.DataProvider().GetStorageClient(ctx, id.ProviderNamespace()+"/operationstatuses") + if err != nil { + return nil, err + } + + obj, err := storageClient.Get(ctx, id.String()) + if errors.Is(&store.ErrNotFound{ID: id.String()}, err) { return rest.NewNotFoundResponse(id), nil } + os := &manager.Status{} + err = obj.As(os) + if err != nil { + return nil, err + } + if !os.Status.IsTerminal() { headers := map[string]string{ "Location": req.URL.String(), diff --git a/pkg/armrpc/frontend/defaultoperation/getoperationresult_test.go b/pkg/armrpc/frontend/defaultoperation/getoperationresult_test.go index 2ccf396529..978e9f42aa 100644 --- a/pkg/armrpc/frontend/defaultoperation/getoperationresult_test.go +++ b/pkg/armrpc/frontend/defaultoperation/getoperationresult_test.go @@ -24,39 +24,48 @@ import ( "testing" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) func TestGetOperationResultRun(t *testing.T) { - mctrl := gomock.NewController(t) - defer mctrl.Finish() - - mStorageClient := store.NewMockStorageClient(mctrl) - ctx := context.Background() - rawDataModel := testutil.ReadFixture("operationstatus_datamodel.json") osDataModel := &manager.Status{} - _ = json.Unmarshal(rawDataModel, osDataModel) + err := json.Unmarshal(rawDataModel, osDataModel) + require.NoError(t, err) rawExpectedOutput := testutil.ReadFixture("operationstatus_output.json") expectedOutput := &v1.AsyncOperationStatus{} - _ = json.Unmarshal(rawExpectedOutput, expectedOutput) + err = json.Unmarshal(rawExpectedOutput, expectedOutput) + require.NoError(t, err) t.Run("get non-existing resource", func(t *testing.T) { + mctrl := gomock.NewController(t) + + operationResultStoreClient := store.NewMockStorageClient(mctrl) + operationStatusStoreClient := store.NewMockStorageClient(mctrl) + + dataProvider := dataprovider.NewMockDataStorageProvider(mctrl) + dataProvider.EXPECT(). + GetStorageClient(gomock.Any(), "Applications.Core/operationstatuses"). + Return(operationStatusStoreClient, nil). + Times(1) + w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, operationStatusTestHeaderFile, nil) + req, err := rpctest.NewHTTPRequestFromJSON(testcontext.New(t), http.MethodGet, operationStatusTestHeaderFile, nil) require.NoError(t, err) ctx := rpctest.NewARMRequestContext(req) - mStorageClient. + operationStatusStoreClient. EXPECT(). Get(gomock.Any(), gomock.Any()). DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { @@ -64,7 +73,8 @@ func TestGetOperationResultRun(t *testing.T) { }) ctl, err := NewGetOperationResult(ctrl.Options{ - StorageClient: mStorageClient, + DataProvider: dataProvider, + StorageClient: operationResultStoreClient, // Will not be used. }) require.NoError(t, err) @@ -114,15 +124,25 @@ func TestGetOperationResultRun(t *testing.T) { for _, tt := range opResTestCases { t.Run(tt.desc, func(t *testing.T) { + mctrl := gomock.NewController(t) + operationResultStoreClient := store.NewMockStorageClient(mctrl) + operationStatusStoreClient := store.NewMockStorageClient(mctrl) + + dataProvider := dataprovider.NewMockDataStorageProvider(mctrl) + dataProvider.EXPECT(). + GetStorageClient(gomock.Any(), "Applications.Core/operationstatuses"). + Return(operationStatusStoreClient, nil). + Times(1) + w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, operationStatusTestHeaderFile, nil) + req, err := rpctest.NewHTTPRequestFromJSON(testcontext.New(t), http.MethodGet, operationStatusTestHeaderFile, nil) require.NoError(t, err) ctx := rpctest.NewARMRequestContext(req) osDataModel.Status = tt.provisioningState osDataModel.RetryAfter = time.Second * 5 - mStorageClient. + operationStatusStoreClient. EXPECT(). Get(gomock.Any(), gomock.Any()). DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { @@ -133,7 +153,8 @@ func TestGetOperationResultRun(t *testing.T) { }) ctl, err := NewGetOperationResult(ctrl.Options{ - StorageClient: mStorageClient, + DataProvider: dataProvider, + StorageClient: operationResultStoreClient, // Will not be used. }) require.NoError(t, err) diff --git a/pkg/armrpc/frontend/defaultoperation/getoperationstatus.go b/pkg/armrpc/frontend/defaultoperation/getoperationstatus.go index c6116aa632..f83b31d4eb 100644 --- a/pkg/armrpc/frontend/defaultoperation/getoperationstatus.go +++ b/pkg/armrpc/frontend/defaultoperation/getoperationstatus.go @@ -21,11 +21,11 @@ import ( "errors" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/store" ) var _ ctrl.Controller = (*GetOperationStatus)(nil) diff --git a/pkg/armrpc/frontend/defaultoperation/getoperationstatus_test.go b/pkg/armrpc/frontend/defaultoperation/getoperationstatus_test.go index a6d02e8705..d9f908f846 100644 --- a/pkg/armrpc/frontend/defaultoperation/getoperationstatus_test.go +++ b/pkg/armrpc/frontend/defaultoperation/getoperationstatus_test.go @@ -23,12 +23,12 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/armrpc/frontend/defaultoperation/getresource.go b/pkg/armrpc/frontend/defaultoperation/getresource.go index d4ee091276..df19be5924 100644 --- a/pkg/armrpc/frontend/defaultoperation/getresource.go +++ b/pkg/armrpc/frontend/defaultoperation/getresource.go @@ -20,9 +20,9 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" ) // GetResource is the controller implementation to get a resource. @@ -43,7 +43,7 @@ func NewGetResource[P interface { }, nil } -// Run returns the requested resource from the datastore with etag. +// Run returns the requested resource from the datastore with etag. // If the resource does not exist, a not found response is returned. If an error occurs, an error is returned as an internal error. func (e *GetResource[P, T]) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { serviceCtx := v1.ARMRequestContextFromContext(ctx) diff --git a/pkg/armrpc/frontend/defaultoperation/getresource_test.go b/pkg/armrpc/frontend/defaultoperation/getresource_test.go index 17bd761117..9f910afa60 100644 --- a/pkg/armrpc/frontend/defaultoperation/getresource_test.go +++ b/pkg/armrpc/frontend/defaultoperation/getresource_test.go @@ -23,10 +23,10 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/armrpc/frontend/defaultoperation/listresources.go b/pkg/armrpc/frontend/defaultoperation/listresources.go index cf8d1d63c0..0329d6650e 100644 --- a/pkg/armrpc/frontend/defaultoperation/listresources.go +++ b/pkg/armrpc/frontend/defaultoperation/listresources.go @@ -20,10 +20,10 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/store" ) // ListResources is the controller implementation to get the list of resources in resource group. @@ -43,7 +43,7 @@ func NewListResources[P interface { return &ListResources[P, T]{ctrl.NewOperation[P](opts, ctrlOpts), ctrlOpts.ListRecursiveQuery}, nil } -// Run queries the resource data store with a given type and scope and returns the paginated resource list. An internal error +// Run queries the resource data store with a given type and scope and returns the paginated resource list. An internal error // is returned if the query fails. func (e *ListResources[P, T]) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { serviceCtx := v1.ARMRequestContextFromContext(ctx) diff --git a/pkg/armrpc/frontend/defaultoperation/listresources_test.go b/pkg/armrpc/frontend/defaultoperation/listresources_test.go index cc01173eae..549403ea45 100644 --- a/pkg/armrpc/frontend/defaultoperation/listresources_test.go +++ b/pkg/armrpc/frontend/defaultoperation/listresources_test.go @@ -24,10 +24,10 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/google/uuid" diff --git a/pkg/armrpc/frontend/defaultoperation/resource_test.go b/pkg/armrpc/frontend/defaultoperation/resource_test.go index 96ae277461..c07d305778 100644 --- a/pkg/armrpc/frontend/defaultoperation/resource_test.go +++ b/pkg/armrpc/frontend/defaultoperation/resource_test.go @@ -24,13 +24,13 @@ import ( "net/url" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" ) @@ -178,7 +178,7 @@ func testResourceDataModelFromVersioned(content []byte, version string) (*TestRe // testValidateRequest is an example resource filter. // // In this case we're validating that the application of an existing resource can't change. This is one of our scenarios -// for the corerp and linkrp. However we're avoiding calling into that code directly from here to avoid coupling. +// for the corerp and portable resource providers. However we're avoiding calling into that code directly from here to avoid coupling. func testValidateRequest(ctx context.Context, newResource *TestResourceDataModel, oldResource *TestResourceDataModel, options *controller.Options) (rest.Response, error) { if oldResource == nil { return nil, nil @@ -217,7 +217,7 @@ func setupTest(tb testing.TB) (func(testing.TB), *store.MockStorageClient, *stat }, mds, msm } -// TODO: Use Referer header instead of X-Forwarded-Proto by following ARM RPC spec - https://github.com/project-radius/radius/issues/3068 +// TODO: Use Referer header instead of X-Forwarded-Proto by following ARM RPC spec - https://github.com/radius-project/radius/issues/3068 func getAsyncLocationPath(sCtx *v1.ARMRequestContext, location string, resourceType string, req *http.Request) string { dest := url.URL{ Host: req.Host, diff --git a/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_datamodel.json b/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_datamodel.json index 95731f8d21..83bfbf97a2 100644 --- a/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_datamodel.json +++ b/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_datamodel.json @@ -5,8 +5,8 @@ "operationType": "PUT", "location": "West US", "status": "Succeeded", - "startTime": "2022-05-16T10:24:58+0000", - "endTime": "2022-05-16T17:24:58+0000", + "startTime": "2022-05-16T10:24:58.000000Z", + "endTime": "2022-05-16T17:24:58.000000Z", "percentComplete": "100", "properties": { "provisioningState": "Succeeded" diff --git a/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_output.json b/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_output.json index 65785327d9..42602e8d6f 100644 --- a/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_output.json +++ b/pkg/armrpc/frontend/defaultoperation/testdata/operationstatus_output.json @@ -5,8 +5,8 @@ "operationType": "PUT", "location": "West US", "status": "Succeeded", - "startTime": "2022-05-16T10:24:58+0000", - "endTime": "2022-05-16T17:24:58+0000", + "startTime": "2022-05-16T10:24:58.000000Z", + "endTime": "2022-05-16T17:24:58.000000Z", "percentComplete": "100", "properties": { "provisioningState": "Succeeded" diff --git a/pkg/armrpc/frontend/defaultoperation/testdata/resource-datamodel.json b/pkg/armrpc/frontend/defaultoperation/testdata/resource-datamodel.json index 05fc7bad79..a9d36db4c1 100644 --- a/pkg/armrpc/frontend/defaultoperation/testdata/resource-datamodel.json +++ b/pkg/armrpc/frontend/defaultoperation/testdata/resource-datamodel.json @@ -1,43 +1,33 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/resources/resource0", - "name": "resource0", - "type": "applications.core/resources", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/resources/resource0", + "name": "resource0", + "type": "applications.core/resources", + "location": "West US", + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "provisioningState": "Succeeded", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "provisioningState": "Succeeded", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "resources", - "Provider": "aks" - }, - "Resource": null, - "Identity": { - "data": null, - "resourceType": { - "Type": "resources", - "Provider": "aks" - } - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "propertyA": "propertyAValue", - "propertyB": "propertyBValue" - }, - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "propertyA": "propertyAValue", + "propertyB": "propertyBValue" + }, + "tenantId": "00000000-0000-0000-0000-000000000000", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroup": "radius-test-rg", + "createdApiVersion": "2022-03-15-privatepreview", + "updatedApiVersion": "2022-03-15-privatepreview" } \ No newline at end of file diff --git a/pkg/armrpc/frontend/defaultoperation/testdata/resource-response.json b/pkg/armrpc/frontend/defaultoperation/testdata/resource-response.json index 99ba1ee3da..bd3d2a8ef4 100644 --- a/pkg/armrpc/frontend/defaultoperation/testdata/resource-response.json +++ b/pkg/armrpc/frontend/defaultoperation/testdata/resource-response.json @@ -1,33 +1,29 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/resources/resource0", - "location": "global", - "name": "resource0", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "Provider": "aks", - "Identity": { - "aksClusterName": "", - "name": "", - "namespace": "" - } - }] - }, - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "propertyA": "propertyAValue", - "propertyB": "propertyBValue" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/resources/resource0", + "location": "global", + "name": "resource0", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "tags": {}, - "type": "applications.core/resources" + "provisioningState": "Succeeded", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "propertyA": "propertyAValue", + "propertyB": "propertyBValue" + }, + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "tags": {}, + "type": "applications.core/resources" } \ No newline at end of file diff --git a/pkg/armrpc/frontend/server/handler.go b/pkg/armrpc/frontend/server/handler.go index f80775e3d0..a32279f734 100644 --- a/pkg/armrpc/frontend/server/handler.go +++ b/pkg/armrpc/frontend/server/handler.go @@ -25,12 +25,11 @@ import ( "github.com/go-chi/chi/v5" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/servicecontext" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/ucplog" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "go.opentelemetry.io/otel/attribute" ) @@ -47,7 +46,7 @@ var ( ErrInvalidOperationTypeOption = errors.New("the resource type and method must be specified if the operation type is not specified") ) -type ControllerFunc func(ctrl.Options) (ctrl.Controller, error) +type ControllerFactoryFunc func(ctrl.Options) (ctrl.Controller, error) // HandlerOptions represents a controller to be registered with the server. // @@ -85,7 +84,7 @@ type HandlerOptions struct { OperationType *v1.OperationType // ControllerFactory is a function invoked to create the controller. Will be invoked once during server startup. - ControllerFactory ControllerFunc + ControllerFactory ControllerFactoryFunc // Middlewares are the middlewares to apply to the handler. Middlewares []func(http.Handler) http.Handler @@ -101,10 +100,16 @@ func NewSubrouter(parent chi.Router, path string, middlewares ...func(http.Handl // HandlerForController creates a http.HandlerFunc function that runs resource provider frontend controller, renders a // http response from the returned rest.Response, and handles the error as a default internal error if this controller returns error. -func HandlerForController(controller ctrl.Controller) http.HandlerFunc { +func HandlerForController(controller ctrl.Controller, operationType v1.OperationType) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { ctx := req.Context() - addRequestAttributes(ctx, req) + + rpcCtx := v1.ARMRequestContextFromContext(ctx) + // Set the operation type in the context. + rpcCtx.OperationType = operationType + + // Add OTEL labels for the telemetry. + withOtelLabelsForRequest(req) response, err := controller.Run(ctx, w, req) if err != nil { @@ -159,9 +164,8 @@ func RegisterHandler(ctx context.Context, opts HandlerOptions, ctrlOpts ctrl.Opt return nil } - middlewares := append(opts.Middlewares, servicecontext.WithOperationType(*opts.OperationType)) - handler := HandlerForController(ctrl) - namedRouter := opts.ParentRouter.With(middlewares...) + handler := HandlerForController(ctrl, *opts.OperationType) + namedRouter := opts.ParentRouter.With(opts.Middlewares...) if opts.Path == CatchAllPath { namedRouter.HandleFunc(opts.Path, handler) } else { @@ -171,13 +175,13 @@ func RegisterHandler(ctx context.Context, opts HandlerOptions, ctrlOpts ctrl.Opt return nil } -func addRequestAttributes(ctx context.Context, req *http.Request) { - labeler, ok := otelhttp.LabelerFromContext(ctx) +func withOtelLabelsForRequest(req *http.Request) { + labeler, ok := otelhttp.LabelerFromContext(req.Context()) if !ok { return } - armContext := v1.ARMRequestContextFromContext(ctx) + armContext := v1.ARMRequestContextFromContext(req.Context()) resourceID := armContext.ResourceID if resourceID.IsResource() || resourceID.IsResourceCollection() { @@ -193,7 +197,7 @@ func ConfigureDefaultHandlers( rootScopePath string, isAzureProvider bool, providerNamespace string, - operationCtrlFactory ControllerFunc, + operationCtrlFactory ControllerFactoryFunc, ctrlOpts ctrl.Options) error { providerNamespace = strings.ToLower(providerNamespace) rt := providerNamespace + "/providers" @@ -230,7 +234,7 @@ func ConfigureDefaultHandlers( ParentRouter: rootRouter, Path: opStatus, ResourceType: statusRT, - Method: v1.OperationGetOperationStatuses, + Method: v1.OperationGet, ControllerFactory: defaultoperation.NewGetOperationStatus, }, ctrlOpts) if err != nil { @@ -242,7 +246,7 @@ func ConfigureDefaultHandlers( ParentRouter: rootRouter, Path: opResult, ResourceType: statusRT, - Method: v1.OperationGetOperationResult, + Method: v1.OperationGet, ControllerFactory: defaultoperation.NewGetOperationResult, }, ctrlOpts) if err != nil { diff --git a/pkg/armrpc/frontend/server/handler_test.go b/pkg/armrpc/frontend/server/handler_test.go index 487ceebc04..d052c0be40 100644 --- a/pkg/armrpc/frontend/server/handler_test.go +++ b/pkg/armrpc/frontend/server/handler_test.go @@ -17,6 +17,7 @@ limitations under the License. package server import ( + "bytes" "context" "encoding/json" "errors" @@ -27,11 +28,13 @@ import ( "github.com/go-chi/chi/v5" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/middleware" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/test/testcontext" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) @@ -261,3 +264,28 @@ func Test_HandlerErrInternal(t *testing.T) { require.Equal(t, v1.CodeInternal, armerr.Error.Code) require.Equal(t, armerr.Error.Message, "Internal error") } + +type testAPIController struct { + ctrl.Operation[*rpctest.TestResourceDataModel, rpctest.TestResourceDataModel] +} + +func (e *testAPIController) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { + return nil, nil +} + +func Test_HandlerForController_OperationType(t *testing.T) { + expectedType := v1.OperationType{Type: "Applications.Compute/virtualMachines", Method: "GET"} + + handler := HandlerForController(&testAPIController{}, expectedType) + w := httptest.NewRecorder() + + req, err := http.NewRequest(http.MethodGet, "", bytes.NewBuffer([]byte{})) + require.NoError(t, err) + + rCtx := &v1.ARMRequestContext{} + req = req.WithContext(v1.WithARMRequestContext(context.Background(), rCtx)) + + handler.ServeHTTP(w, req) + + require.Equal(t, expectedType.String(), rCtx.OperationType.String()) +} diff --git a/pkg/armrpc/frontend/server/server.go b/pkg/armrpc/frontend/server/server.go index e93ab86590..95e5550333 100644 --- a/pkg/armrpc/frontend/server/server.go +++ b/pkg/armrpc/frontend/server/server.go @@ -21,11 +21,11 @@ import ( "net" "net/http" - "github.com/project-radius/radius/pkg/armrpc/authentication" - "github.com/project-radius/radius/pkg/armrpc/servicecontext" - "github.com/project-radius/radius/pkg/middleware" - "github.com/project-radius/radius/pkg/validator" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/armrpc/authentication" + "github.com/radius-project/radius/pkg/armrpc/servicecontext" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/validator" + "github.com/radius-project/radius/pkg/version" "github.com/go-chi/chi/v5" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" @@ -38,13 +38,13 @@ const ( ) type Options struct { - ProviderNamespace string - Location string - Address string - PathBase string - EnableArmAuth bool - Configure func(chi.Router) error - ArmCertMgr *authentication.ArmCertManager + ServiceName string + Location string + Address string + PathBase string + EnableArmAuth bool + Configure func(chi.Router) error + ArmCertMgr *authentication.ArmCertManager } // New creates a frontend server that can listen on the provided address and serve requests - it creates an HTTP server with a router, @@ -54,7 +54,7 @@ func New(ctx context.Context, options Options) (*http.Server, error) { r := chi.NewRouter() r.Use(middleware.Recoverer) - r.Use(middleware.WithLogger(options.ProviderNamespace)) + r.Use(middleware.WithLogger) r.NotFound(validator.APINotFoundHandler()) r.MethodNotAllowed(validator.APIMethodNotAllowedHandler()) @@ -77,7 +77,7 @@ func New(ctx context.Context, options Options) (*http.Server, error) { handlerFunc := otelhttp.NewHandler( middleware.LowercaseURLPath(r), - options.ProviderNamespace, + options.ServiceName, otelhttp.WithMeterProvider(otel.GetMeterProvider()), otelhttp.WithTracerProvider(otel.GetTracerProvider())) diff --git a/pkg/armrpc/frontend/server/service.go b/pkg/armrpc/frontend/server/service.go index 4bd958aede..f46244cfbe 100644 --- a/pkg/armrpc/frontend/server/service.go +++ b/pkg/armrpc/frontend/server/service.go @@ -21,13 +21,13 @@ import ( "fmt" "net/http" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - "github.com/project-radius/radius/pkg/armrpc/authentication" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - qprovider "github.com/project-radius/radius/pkg/ucp/queue/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/armrpc/authentication" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + qprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" controller_runtime "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -58,17 +58,12 @@ func (s *Service) Init(ctx context.Context) error { logger := ucplog.FromContextOrDiscard(ctx) s.StorageProvider = dataprovider.NewStorageProvider(s.Options.Config.StorageProvider) - qp := qprovider.New(s.ProviderName, s.Options.Config.QueueProvider) - opSC, err := s.StorageProvider.GetStorageClient(ctx, s.ProviderName+"/operationstatuses") - if err != nil { - return err - } + qp := qprovider.New(s.Options.Config.QueueProvider) reqQueueClient, err := qp.GetClient(ctx) if err != nil { return err } - s.OperationStatusManager = manager.New(opSC, reqQueueClient, s.ProviderName, s.Options.Config.Env.RoleLocation) - + s.OperationStatusManager = manager.New(s.StorageProvider, reqQueueClient, s.Options.Config.Env.RoleLocation) s.KubeClient, err = kubeutil.NewRuntimeClient(s.Options.K8sConfig) if err != nil { return err diff --git a/pkg/armrpc/hostoptions/hostoptions.go b/pkg/armrpc/hostoptions/hostoptions.go index 9d2a8ffded..83aaea0922 100644 --- a/pkg/armrpc/hostoptions/hostoptions.go +++ b/pkg/armrpc/hostoptions/hostoptions.go @@ -25,14 +25,14 @@ import ( "os" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/azure/armauth" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/ucp/config" - sdk_cred "github.com/project-radius/radius/pkg/ucp/credentials" - sprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/azure/armauth" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/ucp/config" + sdk_cred "github.com/radius-project/radius/pkg/ucp/credentials" + sprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" "gopkg.in/yaml.v3" corev1 "k8s.io/api/core/v1" @@ -149,7 +149,7 @@ func WithContext(ctx context.Context, cfg *ProviderConfig) context.Context { func getKubernetes() (*rest.Config, error) { cfg, err := kubeutil.NewClientConfig(&kubeutil.ConfigOptions{ - // TODO: Allow to use custom context via configuration. - https://github.com/project-radius/radius/issues/5433 + // TODO: Allow to use custom context via configuration. - https://github.com/radius-project/radius/issues/5433 ContextName: "", QPS: kubeutil.DefaultServerQPS, Burst: kubeutil.DefaultServerBurst, diff --git a/pkg/armrpc/hostoptions/providerconfig.go b/pkg/armrpc/hostoptions/providerconfig.go index 45d945ee4b..f192552202 100644 --- a/pkg/armrpc/hostoptions/providerconfig.go +++ b/pkg/armrpc/hostoptions/providerconfig.go @@ -17,14 +17,14 @@ limitations under the License. package hostoptions import ( - metricsprovider "github.com/project-radius/radius/pkg/metrics/provider" - profilerprovider "github.com/project-radius/radius/pkg/profiler/provider" - "github.com/project-radius/radius/pkg/trace" - "github.com/project-radius/radius/pkg/ucp/config" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - qprovider "github.com/project-radius/radius/pkg/ucp/queue/provider" - sprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + metricsprovider "github.com/radius-project/radius/pkg/metrics/provider" + profilerprovider "github.com/radius-project/radius/pkg/profiler/provider" + "github.com/radius-project/radius/pkg/trace" + "github.com/radius-project/radius/pkg/ucp/config" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + qprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + sprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // ProviderConfig includes the resource provider configuration. diff --git a/pkg/armrpc/rest/results.go b/pkg/armrpc/rest/results.go index 18845cfca8..33d3dc2578 100644 --- a/pkg/armrpc/rest/results.go +++ b/pkg/armrpc/rest/results.go @@ -27,12 +27,12 @@ import ( "github.com/go-playground/validator/v10" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/logging" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/logging" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) const ( @@ -407,6 +407,18 @@ func NewLinkedResourceUpdateErrorResponse(resourceID resources.ID, oldProp *rpv1 } } +// NewDependencyMissingResponse creates a DependencyMissingResponse with a given error message. +func NewDependencyMissingResponse(message string) Response { + return &BadRequestResponse{ + Body: v1.ErrorResponse{ + Error: v1.ErrorDetails{ + Code: v1.CodeDependencyMissing, + Message: message, + }, + }, + } +} + // NewBadRequestResponse creates a BadRequestResponse with a given error message. func NewBadRequestResponse(message string) Response { return &BadRequestResponse{ diff --git a/pkg/armrpc/rest/results_test.go b/pkg/armrpc/rest/results_test.go index dec3362866..de9d80ab9b 100644 --- a/pkg/armrpc/rest/results_test.go +++ b/pkg/armrpc/rest/results_test.go @@ -30,10 +30,10 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" ) func Test_NewLinkedResourceUpdateErrorResponse(t *testing.T) { diff --git a/pkg/armrpc/rpctest/controllers.go b/pkg/armrpc/rpctest/controllers.go index 2380eb428c..131ed3c5e6 100644 --- a/pkg/armrpc/rpctest/controllers.go +++ b/pkg/armrpc/rpctest/controllers.go @@ -22,9 +22,9 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" ) // ControllerContext represents the context of controller tests including common mocks. diff --git a/pkg/armrpc/rpctest/requests.go b/pkg/armrpc/rpctest/requests.go index 9a3a5c4a1c..de7344664f 100644 --- a/pkg/armrpc/rpctest/requests.go +++ b/pkg/armrpc/rpctest/requests.go @@ -23,7 +23,7 @@ import ( "net/http" "os" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) // MustParseOperationType parses the operation type or panics if it fails. diff --git a/pkg/armrpc/rpctest/routers.go b/pkg/armrpc/rpctest/routers.go index 303b0fa37c..4838eed556 100644 --- a/pkg/armrpc/rpctest/routers.go +++ b/pkg/armrpc/rpctest/routers.go @@ -25,8 +25,8 @@ import ( "testing" "github.com/go-chi/chi/v5" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/test/testcontext" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) @@ -52,9 +52,9 @@ func AssertRouters(t *testing.T, tests []HandlerTestSpec, pathBase, rootScope st r, err := configureRouter(ctx) require.NoError(t, err) - t.Log("Avaiable routes:") + t.Log("Available routes:") err = chi.Walk(r, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error { - t.Logf("Method: %s, Path: %s", method, route) + t.Logf("Method: %s, Path: %s, Middlewares: %+v", method, route, middlewares) return nil }) require.NoError(t, err) @@ -86,35 +86,48 @@ func AssertRouters(t *testing.T, tests []HandlerTestSpec, pathBase, rootScope st if tt.SkipOperationTypeValidation { return } + }) + } +} + +// AssertRequests asserts that the restful APIs matches the routes and its operation type matches the given test cases. +// This is working only for test controllers. If you want to validate the routes for the real controllers, use AssertRouters. +func AssertRequests(t *testing.T, tests []HandlerTestSpec, pathBase, rootScope string, configureRouter func(context.Context) (chi.Router, error)) { + ctx := testcontext.New(t) + r, err := configureRouter(ctx) + require.NoError(t, err) + + t.Log("Available routes:") + err = chi.Walk(r, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error { + t.Logf("Method: %s, Path: %s, Middlewares: %+v", method, route, middlewares) + return nil + }) + require.NoError(t, err) + + for _, tt := range tests { + pb := "" + if !tt.SkipPathBase { + pb = pathBase + } - err = chi.Walk(r, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error { - if tctx.RoutePattern() == route && tt.Method == method { - found := false - for _, m := range middlewares { - w := httptest.NewRecorder() - - // It will not validate body. - req, err := http.NewRequest(tt.Method, uri, bytes.NewBuffer([]byte{})) - require.NoError(t, err) - - rCtx := &v1.ARMRequestContext{} - req = req.WithContext(v1.WithARMRequestContext(context.Background(), rCtx)) - - // Pass empty router to validate operation type. - testr := chi.NewRouter() - m(testr).ServeHTTP(w, req) - if tt.OperationType.String() == rCtx.OperationType.String() { - t.Log("Found operation type") - found = true - break - } - } - require.True(t, found, "operation type not found") - } - return nil - }) + uri := pb + rootScope + tt.Path + if tt.WithoutRootScope { + uri = pb + tt.Path + } + + t.Run(tt.Method+"|"+tt.Path, func(t *testing.T) { + w := httptest.NewRecorder() + // It will not validate body. + req, err := http.NewRequest(tt.Method, uri, bytes.NewBuffer([]byte{})) require.NoError(t, err) + + rCtx := &v1.ARMRequestContext{} + req = req.WithContext(v1.WithARMRequestContext(context.Background(), rCtx)) + + r.ServeHTTP(w, req) + require.NotEqual(t, 404, w.Result().StatusCode) + require.Equal(t, tt.OperationType.String(), rCtx.OperationType.String(), "operation type not found: %s %s %s", uri, tt.Method, rCtx.OperationType.String()) }) } } diff --git a/pkg/armrpc/rpctest/testdatamodel.go b/pkg/armrpc/rpctest/testdatamodel.go new file mode 100644 index 0000000000..bc6183bec0 --- /dev/null +++ b/pkg/armrpc/rpctest/testdatamodel.go @@ -0,0 +1,166 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package rpctest + +import ( + "encoding/json" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" +) + +const ( + TestAPIVersion = "2022-03-15-privatepreview" +) + +// TestResourceDataModel represents test resource. +type TestResourceDataModel struct { + v1.BaseResource + + // Properties is the properties of the resource. + Properties *TestResourceDataModelProperties `json:"properties"` +} + +// ResourceTypeName returns the qualified name of the resource +func (r *TestResourceDataModel) ResourceTypeName() string { + return "Applications.Core/resources" +} + +// TestResourceDataModelProperties represents the properties of TestResourceDataModel. +type TestResourceDataModelProperties struct { + Application string `json:"application"` + Environment string `json:"environment"` + PropertyA string `json:"propertyA,omitempty"` + PropertyB string `json:"propertyB,omitempty"` +} + +// TestResource represents test resource for api version. +type TestResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SystemData *v1.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *TestResourceProperties `json:"properties,omitempty"` + Tags map[string]*string `json:"tags,omitempty"` +} + +// TestResourceProperties - HTTP Route properties +type TestResourceProperties struct { + ProvisioningState *v1.ProvisioningState `json:"provisioningState,omitempty"` + Environment *string `json:"environment,omitempty"` + Application *string `json:"application,omitempty"` + PropertyA *string `json:"propertyA,omitempty"` + PropertyB *string `json:"propertyB,omitempty"` +} + +// # Function Explanation +// +// ConvertTo converts a version specific TestResource into a version-agnostic resource, TestResourceDataModel. +func (src *TestResource) ConvertTo() (v1.DataModelInterface, error) { + converted := &TestResourceDataModel{ + BaseResource: v1.BaseResource{ + TrackedResource: v1.TrackedResource{ + ID: to.String(src.ID), + Name: to.String(src.Name), + Type: to.String(src.Type), + Location: to.String(src.Location), + Tags: to.StringMap(src.Tags), + }, + InternalMetadata: v1.InternalMetadata{ + UpdatedAPIVersion: TestAPIVersion, + AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), + }, + }, + Properties: &TestResourceDataModelProperties{ + Application: to.String(src.Properties.Application), + Environment: to.String(src.Properties.Environment), + PropertyA: to.String(src.Properties.PropertyA), + PropertyB: to.String(src.Properties.PropertyB), + }, + } + return converted, nil +} + +// # Function Explanation +// +// ConvertFrom converts src version agnostic model to versioned model, TestResource. +func (dst *TestResource) ConvertFrom(src v1.DataModelInterface) error { + dm, ok := src.(*TestResourceDataModel) + if !ok { + return v1.ErrInvalidModelConversion + } + + dst.ID = to.Ptr(dm.ID) + dst.Name = to.Ptr(dm.Name) + dst.Type = to.Ptr(dm.Type) + dst.SystemData = &dm.SystemData + dst.Location = to.Ptr(dm.Location) + dst.Tags = *to.StringMapPtr(dm.Tags) + dst.Properties = &TestResourceProperties{ + ProvisioningState: fromProvisioningStateDataModel(dm.InternalMetadata.AsyncProvisioningState), + Environment: to.Ptr(dm.Properties.Environment), + Application: to.Ptr(dm.Properties.Application), + PropertyA: to.Ptr(dm.Properties.PropertyA), + PropertyB: to.Ptr(dm.Properties.PropertyB), + } + + return nil +} + +func toProvisioningStateDataModel(state *v1.ProvisioningState) v1.ProvisioningState { + if state == nil { + return v1.ProvisioningStateAccepted + } + return *state +} + +func fromProvisioningStateDataModel(state v1.ProvisioningState) *v1.ProvisioningState { + converted := v1.ProvisioningStateAccepted + if state != "" { + converted = state + } + + return &converted +} + +func TestResourceDataModelToVersioned(model *TestResourceDataModel, version string) (v1.VersionedModelInterface, error) { + switch version { + case TestAPIVersion: + versioned := &TestResource{} + err := versioned.ConvertFrom(model) + return versioned, err + + default: + return nil, v1.ErrUnsupportedAPIVersion + } +} + +func TestResourceDataModelFromVersioned(content []byte, version string) (*TestResourceDataModel, error) { + switch version { + case TestAPIVersion: + am := &TestResource{} + if err := json.Unmarshal(content, am); err != nil { + return nil, err + } + dm, err := am.ConvertTo() + return dm.(*TestResourceDataModel), err + + default: + return nil, v1.ErrUnsupportedAPIVersion + } +} diff --git a/pkg/armrpc/servicecontext/middleware.go b/pkg/armrpc/servicecontext/middleware.go index 824333fc30..2563c63170 100644 --- a/pkg/armrpc/servicecontext/middleware.go +++ b/pkg/armrpc/servicecontext/middleware.go @@ -20,8 +20,8 @@ import ( "fmt" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rest" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rest" ) // ARMRequestCtx is a middleware handler that adds an ARM request context to an incoming request. It takes in a pathBase diff --git a/pkg/armrpc/servicecontext/middleware_test.go b/pkg/armrpc/servicecontext/middleware_test.go index 7bbfbd6e12..70dcc53cc4 100644 --- a/pkg/armrpc/servicecontext/middleware_test.go +++ b/pkg/armrpc/servicecontext/middleware_test.go @@ -25,7 +25,7 @@ import ( "testing" "github.com/go-chi/chi/v5" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/aws/operations/operations.go b/pkg/aws/operations/operations.go index c5f33d88b2..55fb25ef03 100644 --- a/pkg/aws/operations/operations.go +++ b/pkg/aws/operations/operations.go @@ -119,7 +119,7 @@ func UnflattenProperties(state map[string]any) map[string]any { // GeneratePatch takes in the current state, desired state and type schema of a resource and returns a JSON patch to update the // current state to the desired state, taking into account read-only, create-only and conditional-create-only properties. func GeneratePatch(currentState []byte, desiredState []byte, schema []byte) (jsondiff.Patch, error) { - // See: https://github.com/project-radius/radius/blob/main/docs/adr/ucp/001-aws-resource-updating.md + // See: https://github.com/radius-project/radius/blob/main/docs/adr/ucp/001-aws-resource-updating.md // Get the resource type schema - this will tell us the properties of the // resource as well as which properties are read-only, create-only, etc. diff --git a/pkg/azure/armauth/auth.go b/pkg/azure/armauth/auth.go index 4f34d0f087..1a01674e79 100644 --- a/pkg/azure/armauth/auth.go +++ b/pkg/azure/armauth/auth.go @@ -21,9 +21,9 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/project-radius/radius/pkg/azure/clientv2" - azcred "github.com/project-radius/radius/pkg/azure/credential" - sdk_cred "github.com/project-radius/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/azure/clientv2" + azcred "github.com/radius-project/radius/pkg/azure/credential" + sdk_cred "github.com/radius-project/radius/pkg/ucp/credentials" ) // Authentication methods diff --git a/pkg/azure/clientv2/customaction.go b/pkg/azure/clientv2/customaction.go index af1243f26a..4efc9a633a 100644 --- a/pkg/azure/clientv2/customaction.go +++ b/pkg/azure/clientv2/customaction.go @@ -26,7 +26,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/resources" ) // ClientCustomActionResponse is the response we get from invoking a custom action. diff --git a/pkg/azure/clientv2/unfold.go b/pkg/azure/clientv2/unfold.go index a81370fedc..9d625a2903 100644 --- a/pkg/azure/clientv2/unfold.go +++ b/pkg/azure/clientv2/unfold.go @@ -26,9 +26,9 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/google/go-cmp/cmp" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/to" ) // ServiceError conforms to the OData v4 error format. diff --git a/pkg/azure/clientv2/unfold_test.go b/pkg/azure/clientv2/unfold_test.go index 5b75b3036f..c035d395c3 100644 --- a/pkg/azure/clientv2/unfold_test.go +++ b/pkg/azure/clientv2/unfold_test.go @@ -24,7 +24,7 @@ import ( "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/azure/credential/ucpcredentials.go b/pkg/azure/credential/ucpcredentials.go index 32de619af7..b98eb5baf5 100644 --- a/pkg/azure/credential/ucpcredentials.go +++ b/pkg/azure/credential/ucpcredentials.go @@ -25,8 +25,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - sdk_cred "github.com/project-radius/radius/pkg/ucp/credentials" - "github.com/project-radius/radius/pkg/ucp/ucplog" + sdk_cred "github.com/radius-project/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/ucp/ucplog" "go.uber.org/atomic" ) diff --git a/pkg/azure/credential/ucpcredentials_test.go b/pkg/azure/credential/ucpcredentials_test.go index 3afa453ab1..7a94f58412 100644 --- a/pkg/azure/credential/ucpcredentials_test.go +++ b/pkg/azure/credential/ucpcredentials_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/require" - sdk_cred "github.com/project-radius/radius/pkg/ucp/credentials" + sdk_cred "github.com/radius-project/radius/pkg/ucp/credentials" ) type mockProvider struct { diff --git a/pkg/azure/roleassignment/roleassignment.go b/pkg/azure/roleassignment/roleassignment.go index 2e47b1649f..b09373f018 100644 --- a/pkg/azure/roleassignment/roleassignment.go +++ b/pkg/azure/roleassignment/roleassignment.go @@ -26,12 +26,13 @@ import ( armauthorization "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2" "github.com/google/uuid" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/to" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/clientv2" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // Create checks if a role assignment already exists for a given managed identity, and if not, creates a new role @@ -127,7 +128,7 @@ func Delete(ctx context.Context, armConfig *armauth.ArmConfig, roleID string) er return err } - subscriptionID := rID.FindScope(resources.SubscriptionsSegment) + subscriptionID := rID.FindScope(resources_azure.ScopeSubscriptions) if subscriptionID == "" { return fmt.Errorf("invalid role id: %s", roleID) } diff --git a/pkg/cli/aws/client.go b/pkg/cli/aws/client.go index 9e32e38f32..fdf0f7f717 100644 --- a/pkg/cli/aws/client.go +++ b/pkg/cli/aws/client.go @@ -23,7 +23,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/sts" ) -//go:generate mockgen -destination=./client_mock.go -package=aws -self_package github.com/project-radius/radius/pkg/cli/aws github.com/project-radius/radius/pkg/cli/aws Client +//go:generate mockgen -destination=./client_mock.go -package=aws -self_package github.com/radius-project/radius/pkg/cli/aws github.com/radius-project/radius/pkg/cli/aws Client // Client is an interface that abstracts `rad init`'s interactions with AWS. This is for testing purposes. This is only exported because mockgen requires it. type Client interface { diff --git a/pkg/cli/aws/client_mock.go b/pkg/cli/aws/client_mock.go index a7699831a6..e0852a7337 100644 --- a/pkg/cli/aws/client_mock.go +++ b/pkg/cli/aws/client_mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/aws (interfaces: Client) +// Source: github.com/radius-project/radius/pkg/cli/aws (interfaces: Client) // Package aws is a generated GoMock package. package aws diff --git a/pkg/cli/azure/client.go b/pkg/cli/azure/client.go index ce548aef63..41e90813ab 100644 --- a/pkg/cli/azure/client.go +++ b/pkg/cli/azure/client.go @@ -22,10 +22,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" - "github.com/project-radius/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/armauth" ) -//go:generate mockgen -destination=./client_mock.go -package=azure -self_package github.com/project-radius/radius/pkg/cli/azure github.com/project-radius/radius/pkg/cli/azure Client +//go:generate mockgen -destination=./client_mock.go -package=azure -self_package github.com/radius-project/radius/pkg/cli/azure github.com/radius-project/radius/pkg/cli/azure Client // Client is an interface that abstracts `rad init`'s interactions with Azure. This is for testing purposes. type Client interface { diff --git a/pkg/cli/azure/client_mock.go b/pkg/cli/azure/client_mock.go index f164bb10ea..9e6284f293 100644 --- a/pkg/cli/azure/client_mock.go +++ b/pkg/cli/azure/client_mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/azure (interfaces: Client) +// Source: github.com/radius-project/radius/pkg/cli/azure (interfaces: Client) // Package azure is a generated GoMock package. package azure diff --git a/pkg/cli/azure/subscriptions.go b/pkg/cli/azure/subscriptions.go index 7952fe45aa..d5c5f5ba1a 100644 --- a/pkg/cli/azure/subscriptions.go +++ b/pkg/cli/azure/subscriptions.go @@ -21,7 +21,7 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" - "github.com/project-radius/radius/pkg/azure/clientv2" + "github.com/radius-project/radius/pkg/azure/clientv2" ) // SubscriptionResult is the result of loading Azure subscriptions for the user. diff --git a/pkg/cli/bicep/bicep.go b/pkg/cli/bicep/bicep.go index 5715805a8c..11f7085f93 100644 --- a/pkg/cli/bicep/bicep.go +++ b/pkg/cli/bicep/bicep.go @@ -22,7 +22,7 @@ import ( "os" "time" - "github.com/project-radius/radius/pkg/cli/tools" + "github.com/radius-project/radius/pkg/cli/tools" ) const ( diff --git a/pkg/cli/bicep/build.go b/pkg/cli/bicep/build.go index 19d105e2ba..b28ec054e4 100644 --- a/pkg/cli/bicep/build.go +++ b/pkg/cli/bicep/build.go @@ -26,7 +26,7 @@ import ( "regexp" "strings" - "github.com/project-radius/radius/pkg/cli/tools" + "github.com/radius-project/radius/pkg/cli/tools" ) // Official regex for semver diff --git a/pkg/cli/bicep/deployment_parameters.go b/pkg/cli/bicep/deployment_parameters.go index cd92ff0823..d5161613b2 100644 --- a/pkg/cli/bicep/deployment_parameters.go +++ b/pkg/cli/bicep/deployment_parameters.go @@ -23,7 +23,7 @@ import ( "os" "strings" - "github.com/project-radius/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients" ) // ParameterParser is used to parse the parameters as part of the `rad deploy` command. See the docs for `rad deploy` for examples diff --git a/pkg/cli/bicep/deployment_parameters_test.go b/pkg/cli/bicep/deployment_parameters_test.go index baa7c47f0b..f348240984 100644 --- a/pkg/cli/bicep/deployment_parameters_test.go +++ b/pkg/cli/bicep/deployment_parameters_test.go @@ -23,7 +23,7 @@ import ( "testing" "testing/fstest" - "github.com/project-radius/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/bicep/mock_bicep.go b/pkg/cli/bicep/mock_bicep.go index 100e677547..15a178d229 100644 --- a/pkg/cli/bicep/mock_bicep.go +++ b/pkg/cli/bicep/mock_bicep.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/bicep (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/bicep (interfaces: Interface) // Package bicep is a generated GoMock package. package bicep diff --git a/pkg/cli/bicep/types.go b/pkg/cli/bicep/types.go index 3787e67ce2..2fb667f1e7 100644 --- a/pkg/cli/bicep/types.go +++ b/pkg/cli/bicep/types.go @@ -22,8 +22,8 @@ import ( "path" "strings" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/version" ) // Interface is the interface for preparing Bicep or ARM-JSON templates for deployment. This interface @@ -34,7 +34,7 @@ type Interface interface { var _ Interface = (*Impl)(nil) -//go:generate mockgen -destination=./mock_bicep.go -package=bicep -self_package github.com/project-radius/radius/pkg/cli/bicep github.com/project-radius/radius/pkg/cli/bicep Interface +//go:generate mockgen -destination=./mock_bicep.go -package=bicep -self_package github.com/radius-project/radius/pkg/cli/bicep github.com/radius-project/radius/pkg/cli/bicep Interface // Impl is the implementation of Interface. type Impl struct { diff --git a/pkg/cli/clients/clients.go b/pkg/cli/clients/clients.go index 6a877a9d4c..374c528ea5 100644 --- a/pkg/cli/clients/clients.go +++ b/pkg/cli/clients/clients.go @@ -21,10 +21,10 @@ import ( "io" "os" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - ucp_v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - ucpresources "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + ucp_v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + ucpresources "github.com/radius-project/radius/pkg/ucp/resources" ) // NOTE: parameters in the template engine follow the structure: @@ -88,7 +88,7 @@ type DeploymentClient interface { Deploy(ctx context.Context, options DeploymentOptions) (DeploymentResult, error) } -//go:generate mockgen -destination=./mock_diagnosticsclient.go -package=clients -self_package github.com/project-radius/radius/pkg/cli/clients github.com/project-radius/radius/pkg/cli/clients DiagnosticsClient +//go:generate mockgen -destination=./mock_diagnosticsclient.go -package=clients -self_package github.com/radius-project/radius/pkg/cli/clients github.com/radius-project/radius/pkg/cli/clients DiagnosticsClient // DiagnosticsClient is used to interface with diagnostics features like logs and port-forwards. type DiagnosticsClient interface { @@ -133,7 +133,7 @@ type LogStream struct { Stream io.ReadCloser } -//go:generate mockgen -destination=./mock_applicationsclient.go -package=clients -self_package github.com/project-radius/radius/pkg/cli/clients github.com/project-radius/radius/pkg/cli/clients ApplicationsManagementClient +//go:generate mockgen -destination=./mock_applicationsclient.go -package=clients -self_package github.com/radius-project/radius/pkg/cli/clients github.com/radius-project/radius/pkg/cli/clients ApplicationsManagementClient // ApplicationsManagementClient is used to interface with management features like listing resources by app, show details of a resource. type ApplicationsManagementClient interface { @@ -169,7 +169,7 @@ type ApplicationsManagementClient interface { ListUCPGroup(ctx context.Context, planeType string, planeName string) ([]ucp_v20220901privatepreview.ResourceGroupResource, error) // ShowRecipe shows recipe details including list of all parameters for a given recipe registered to an environment - ShowRecipe(ctx context.Context, environmentName string, recipe corerp.Recipe) (corerp.RecipeMetadataProperties, error) + ShowRecipe(ctx context.Context, environmentName string, recipe corerp.RecipeGetMetadata) (corerp.RecipeGetMetadataResponse, error) } // ShallowCopy creates a shallow copy of the DeploymentParameters object by iterating through the original object and diff --git a/pkg/cli/clients/errors.go b/pkg/cli/clients/errors.go index 6559595ba7..aecd0be627 100644 --- a/pkg/cli/clients/errors.go +++ b/pkg/cli/clients/errors.go @@ -21,8 +21,8 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" ) // Is404Error returns true if the error is a 404 payload from an autorest operation. diff --git a/pkg/cli/clients/management.go b/pkg/cli/clients/management.go index 81de3cc603..25963b3b8b 100644 --- a/pkg/cli/clients/management.go +++ b/pkg/cli/clients/management.go @@ -25,13 +25,14 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "golang.org/x/sync/errgroup" - "github.com/project-radius/radius/pkg/azure/clientv2" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - corerpv20220315 "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp" - ucpv20220901 "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/azure/clientv2" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + corerpv20220315 "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources" + ucpv20220901 "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" ) type UCPApplicationsManagementClient struct { @@ -43,23 +44,18 @@ var _ ApplicationsManagementClient = (*UCPApplicationsManagementClient)(nil) var ( ResourceTypesList = []string{ - linkrp.MongoDatabasesResourceType, - linkrp.RabbitMQMessageQueuesResourceType, - linkrp.RedisCachesResourceType, - linkrp.SqlDatabasesResourceType, - linkrp.DaprStateStoresResourceType, - linkrp.DaprSecretStoresResourceType, - linkrp.DaprPubSubBrokersResourceType, - linkrp.ExtendersResourceType, + portableresources.MongoDatabasesResourceType, + portableresources.RabbitMQQueuesResourceType, + portableresources.RedisCachesResourceType, + portableresources.SqlDatabasesResourceType, + portableresources.DaprStateStoresResourceType, + portableresources.DaprSecretStoresResourceType, + portableresources.DaprPubSubBrokersResourceType, + portableresources.ExtendersResourceType, "Applications.Core/gateways", "Applications.Core/httpRoutes", "Applications.Core/containers", "Applications.Core/secretStores", - // Resource Types after Splitting Linkrp Namespace - linkrp.N_RabbitMQQueuesResourceType, - linkrp.N_DaprStateStoresResourceType, - linkrp.N_DaprSecretStoresResourceType, - linkrp.N_DaprPubSubBrokersResourceType, } ) @@ -223,7 +219,7 @@ func (amc *UCPApplicationsManagementClient) ListApplications(ctx context.Context if err != nil { return results, err } - applicationList := nextPage.ApplicationResourceList.Value + applicationList := nextPage.ApplicationResourceListResult.Value for _, application := range applicationList { results = append(results, *application) } @@ -440,7 +436,7 @@ func (amc *UCPApplicationsManagementClient) ListEnvironmentsInResourceGroup(ctx if err != nil { return envResourceList, err } - applicationList := nextPage.EnvironmentResourceList.Value + applicationList := nextPage.EnvironmentResourceListResult.Value for _, application := range applicationList { envResourceList = append(envResourceList, *application) } @@ -460,7 +456,7 @@ func (amc *UCPApplicationsManagementClient) ListEnvironmentsAll(ctx context.Cont // // - /planes/radius/local // - /planes/radius/local/resourceGroups/my-group - if scope.FindScope(resources.ResourceGroupsSegment) != "" { + if scope.FindScope(resources_radius.ScopeResourceGroups) != "" { scope = scope.Truncate() } @@ -477,7 +473,7 @@ func (amc *UCPApplicationsManagementClient) ListEnvironmentsAll(ctx context.Cont return []corerpv20220315.EnvironmentResource{}, err } - for _, environment := range nextPage.EnvironmentResourceList.Value { + for _, environment := range nextPage.EnvironmentResourceListResult.Value { environments = append(environments, *environment) } } @@ -591,14 +587,14 @@ func (amc *UCPApplicationsManagementClient) ShowUCPGroup(ctx context.Context, pl // ListUCPGroup is a function that retrieves a list of resource groups from the UCP API and returns them as a slice of // ResourceGroupResource objects. It may return an error if there is an issue with the API request. func (amc *UCPApplicationsManagementClient) ListUCPGroup(ctx context.Context, planeType string, planeName string) ([]ucpv20220901.ResourceGroupResource, error) { - var resourceGroupOptions *ucpv20220901.ResourceGroupsClientListByRootScopeOptions + var resourceGroupOptions *ucpv20220901.ResourceGroupsClientListOptions resourceGroupResources := []ucpv20220901.ResourceGroupResource{} resourcegroupClient, err := ucpv20220901.NewResourceGroupsClient(&aztoken.AnonymousCredential{}, amc.ClientOptions) if err != nil { return resourceGroupResources, err } - pager := resourcegroupClient.NewListByRootScopePager(planeType, planeName, resourceGroupOptions) + pager := resourcegroupClient.NewListPager(planeType, planeName, resourceGroupOptions) for pager.More() { resp, err := pager.NextPage(ctx) @@ -618,16 +614,16 @@ func (amc *UCPApplicationsManagementClient) ListUCPGroup(ctx context.Context, pl // ShowRecipe creates a new EnvironmentsClient, gets the recipe metadata from the // environment, and returns the EnvironmentRecipeProperties or an error if one occurs. -func (amc *UCPApplicationsManagementClient) ShowRecipe(ctx context.Context, environmentName string, recipeName corerpv20220315.Recipe) (corerpv20220315.RecipeMetadataProperties, error) { +func (amc *UCPApplicationsManagementClient) ShowRecipe(ctx context.Context, environmentName string, recipeName corerpv20220315.RecipeGetMetadata) (corerpv20220315.RecipeGetMetadataResponse, error) { client, err := corerpv20220315.NewEnvironmentsClient(amc.RootScope, &aztoken.AnonymousCredential{}, amc.ClientOptions) if err != nil { - return corerpv20220315.RecipeMetadataProperties{}, err + return corerpv20220315.RecipeGetMetadataResponse{}, err } - resp, err := client.GetRecipeMetadata(ctx, environmentName, recipeName, &corerpv20220315.EnvironmentsClientGetRecipeMetadataOptions{}) + resp, err := client.GetMetadata(ctx, environmentName, recipeName, &corerpv20220315.EnvironmentsClientGetMetadataOptions{}) if err != nil { - return corerpv20220315.RecipeMetadataProperties{}, err + return corerpv20220315.RecipeGetMetadataResponse{}, err } - return corerpv20220315.RecipeMetadataProperties(resp.RecipeMetadataProperties), nil + return corerpv20220315.RecipeGetMetadataResponse(resp.RecipeGetMetadataResponse), nil } diff --git a/pkg/cli/clients/mock_applicationsclient.go b/pkg/cli/clients/mock_applicationsclient.go index 3a68526bb5..563fc52bc9 100644 --- a/pkg/cli/clients/mock_applicationsclient.go +++ b/pkg/cli/clients/mock_applicationsclient.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/clients (interfaces: ApplicationsManagementClient) +// Source: github.com/radius-project/radius/pkg/cli/clients (interfaces: ApplicationsManagementClient) // Package clients is a generated GoMock package. package clients @@ -9,9 +9,9 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - generated "github.com/project-radius/radius/pkg/cli/clients_new/generated" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + generated "github.com/radius-project/radius/pkg/cli/clients_new/generated" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) // MockApplicationsManagementClient is a mock of ApplicationsManagementClient interface. @@ -319,10 +319,10 @@ func (mr *MockApplicationsManagementClientMockRecorder) ShowApplication(arg0, ar } // ShowRecipe mocks base method. -func (m *MockApplicationsManagementClient) ShowRecipe(arg0 context.Context, arg1 string, arg2 v20220315privatepreview.Recipe) (v20220315privatepreview.RecipeMetadataProperties, error) { +func (m *MockApplicationsManagementClient) ShowRecipe(arg0 context.Context, arg1 string, arg2 v20220315privatepreview.RecipeGetMetadata) (v20220315privatepreview.RecipeGetMetadataResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ShowRecipe", arg0, arg1, arg2) - ret0, _ := ret[0].(v20220315privatepreview.RecipeMetadataProperties) + ret0, _ := ret[0].(v20220315privatepreview.RecipeGetMetadataResponse) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/pkg/cli/clients/mock_diagnosticsclient.go b/pkg/cli/clients/mock_diagnosticsclient.go index 52a9cf12a6..b51bfdd22e 100644 --- a/pkg/cli/clients/mock_diagnosticsclient.go +++ b/pkg/cli/clients/mock_diagnosticsclient.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/clients (interfaces: DiagnosticsClient) +// Source: github.com/radius-project/radius/pkg/cli/clients (interfaces: DiagnosticsClient) // Package clients is a generated GoMock package. package clients diff --git a/pkg/cli/clients_new/README.md b/pkg/cli/clients_new/README.md index 5b7bea9575..57fd28d3d7 100644 --- a/pkg/cli/clients_new/README.md +++ b/pkg/cli/clients_new/README.md @@ -47,4 +47,4 @@ output-folder: ./generated ``` ### Adding ResourceTypes: -All resource types are tracked in resourceTypesList in ucp package. Whenever a new core-rp or link type is added this list has to be updated. +All resource types are tracked in resourceTypesList in ucp package. Whenever a new core-rp or portable resource type is added this list has to be updated. diff --git a/pkg/cli/clivalidation.go b/pkg/cli/clivalidation.go index aeedee42cb..bc8e317995 100644 --- a/pkg/cli/clivalidation.go +++ b/pkg/cli/clivalidation.go @@ -23,12 +23,12 @@ import ( "strings" "github.com/google/uuid" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/config" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/config" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -41,7 +41,7 @@ type AzureResource struct { } const ( - LinkTypeFlag = "link-type" + ResourceTypeFlag = "resource-type" ) // RequireEnvironmentNameArgs checks if an environment name is provided as an argument or if a default environment is set @@ -261,7 +261,7 @@ func RequireResourceTypeAndName(args []string) (string, string, error) { return resourceType, resourceName, nil } -// example of resource Type: Applications.Core/httpRoutes, Applications.Link/redisCaches +// example of resource Type: Applications.Core/httpRoutes, Applications.Datastores/redisCaches // // RequireResourceType checks if the first argument provided is a valid resource type and returns it if it is. If the @@ -539,11 +539,11 @@ func RequireRecipeNameArgs(cmd *cobra.Command, args []string) (string, error) { return args[0], nil } -// RequireLinkType retrieves the link type flag from the given command and returns it, or an error if the flag is not set. -func RequireLinkType(cmd *cobra.Command) (string, error) { - linkType, err := cmd.Flags().GetString(LinkTypeFlag) +// GetResourceType retrieves the resource type flag from the given command and returns it, or an error if the flag is not set. +func GetResourceType(cmd *cobra.Command) (string, error) { + resourceType, err := cmd.Flags().GetString(ResourceTypeFlag) if err != nil { - return linkType, err + return resourceType, err } - return linkType, nil + return resourceType, nil } diff --git a/pkg/cli/cmd/README.md b/pkg/cli/cmd/README.md index 05e2607c6b..c73f92316e 100644 --- a/pkg/cli/cmd/README.md +++ b/pkg/cli/cmd/README.md @@ -39,11 +39,11 @@ package list import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) @@ -132,8 +132,8 @@ package show import ( "testing" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/test/radcli" ) func Test_CommandValidation(t *testing.T) { diff --git a/pkg/cli/cmd/app/appswitch/switch.go b/pkg/cli/cmd/app/appswitch/switch.go index 956abc0622..08adc56db5 100644 --- a/pkg/cli/cmd/app/appswitch/switch.go +++ b/pkg/cli/cmd/app/appswitch/switch.go @@ -20,14 +20,14 @@ import ( "context" "strings" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/app/appswitch/switch_test.go b/pkg/cli/cmd/app/appswitch/switch_test.go index 2e26fd8b1f..fc371a7473 100644 --- a/pkg/cli/cmd/app/appswitch/switch_test.go +++ b/pkg/cli/cmd/app/appswitch/switch_test.go @@ -21,12 +21,12 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/config" - "github.com/project-radius/radius/pkg/cli/framework" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/config" + "github.com/radius-project/radius/pkg/cli/framework" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/test/radcli" ) func Test_CommandValidation(t *testing.T) { diff --git a/pkg/cli/cmd/app/connections/compute.go b/pkg/cli/cmd/app/connections/compute.go index 640bdcf604..9ef8eed3f0 100644 --- a/pkg/cli/cmd/app/connections/compute.go +++ b/pkg/cli/cmd/app/connections/compute.go @@ -18,15 +18,13 @@ package connections import ( "encoding/json" - "fmt" "sort" - "strings" "github.com/go-openapi/jsonpointer" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/ucp/resources" ) // compute constructs an application graph from the given application and environment resources. @@ -197,14 +195,31 @@ func nodeFromID(id string) node { } } +// nodeFromParsedID creates a node from a resource ID. +func nodeFromParsedID(id resources.ID) node { + return node{ + ID: id.String(), + Name: id.Name(), + Type: id.Type(), + } +} + // resourceEntryFromID creates a resourceEntry from a resource ID. func resourceEntryFromID(id string) resourceEntry { return resourceEntry{node: nodeFromID(id)} } // outputResourceEntryFromID creates a outputResourceEntry from a resource ID. -func outputResourceEntryFromID(id string) outputResourceEntry { - return outputResourceEntry{node: nodeFromID(id)} +func outputResourceEntryFromID(id resources.ID) outputResourceEntry { + entry := outputResourceEntry{node: nodeFromParsedID(id)} + if len(id.ScopeSegments()) > 0 && id.IsUCPQualfied() { + entry.Provider = id.ScopeSegments()[0].Type + } else if len(id.ScopeSegments()) > 0 { + // Relative Resource ID (ARM) + entry.Provider = resourcemodel.ProviderAzure + } + + return entry } // outputResourcesFromAPIData processes the generic resource representation returned by the Radius API @@ -240,9 +255,7 @@ func outputResourcesFromAPIData(resource generated.GenericResource) []outputReso for _, or := range ors { // This is the wire format returned by the API for an output resource. type outputResourceWireFormat struct { - Identity map[string]string `json:"Identity"` - LocalID string `json:"LocalID"` - Provider string `json:"Provider"` + ID resources.ID `json:"id"` } data := outputResourceWireFormat{} @@ -253,32 +266,7 @@ func outputResourcesFromAPIData(resource generated.GenericResource) []outputReso } // Now build the entry from the API data - entry := outputResourceEntry{} - switch data.Provider { - case resourcemodel.ProviderAzure: - fallthrough - case resourcemodel.ProviderRadius: - fallthrough - case resourcemodel.ProviderAWS: - entry = outputResourceEntryFromID(data.Identity["id"]) - entry.Provider = data.Provider - - case resourcemodel.ProviderKubernetes: - resourceType := data.Identity["kind"] - group, _, found := strings.Cut(data.Identity["apiVersion"], "/") - if found && group != "" { - resourceType = fmt.Sprintf("%s/%s", group, data.Identity["kind"]) - } - - // NOTE: we don't have a resource ID for a Kubernetes resource (yet). - entry.ID = "" - entry.Name = data.Identity["name"] - entry.Type = resourceType - entry.Provider = data.Provider - - default: - entry = outputResourceEntry{node: node{Error: fmt.Sprintf("unknown provider '%s'", data.Provider)}} - } + entry := outputResourceEntryFromID(data.ID) entries = append(entries, entry) } diff --git a/pkg/cli/cmd/app/connections/compute_test.go b/pkg/cli/cmd/app/connections/compute_test.go index 31bfd9044b..24c866eaf4 100644 --- a/pkg/cli/cmd/app/connections/compute_test.go +++ b/pkg/cli/cmd/app/connections/compute_test.go @@ -19,8 +19,8 @@ package connections import ( "testing" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) @@ -77,6 +77,7 @@ func Test_compute(t *testing.T) { node: node{ Name: "demo", Type: "apps/Deployment", + ID: "/planes/kubernetes/local/namespaces/default-demo/providers/apps/Deployment/demo", }, Provider: "kubernetes", }, @@ -147,6 +148,7 @@ func Test_compute(t *testing.T) { node: node{ Name: "demo", Type: "apps/Deployment", + ID: "/planes/kubernetes/local/namespaces/default-demo/providers/apps/Deployment/demo", }, Provider: "kubernetes", }, @@ -240,11 +242,11 @@ func Test_outputResourcesFromAPIData(t *testing.T) { node: nodeFromID(azureRedisCacheResourceID), Provider: "azure", }, - // Kubernetes resources don't currently a resource ID. { node: node{ Name: "demo", Type: "apps/Deployment", + ID: "/planes/kubernetes/local/namespaces/default-demo/providers/apps/Deployment/demo", }, Provider: "kubernetes", }, @@ -258,7 +260,7 @@ func Test_outputResourcesFromAPIData(t *testing.T) { // An invalid output resource doesn't prevent other output resources from being parsed. outputResources := []any{ redisAWSOutputResource, - makeAzureOutputResource("asdf-invalid-YO"), + makeOutputResource("asdf-invalid-YO"), containerDeploymentOutputResource, } resource := generated.GenericResource{ @@ -269,18 +271,19 @@ func Test_outputResourcesFromAPIData(t *testing.T) { // Output is always sorted. expected := []outputResourceEntry{ { - node: nodeFromID(awsMemoryDBResourceID), - Provider: "aws", + node: node{ + Error: "failed to unmarshal JSON, value was not a valid resource ID: 'asdf-invalid-YO' is not a valid resource id", + }, }, { - node: nodeFromID("asdf-invalid-YO"), - Provider: "azure", + node: nodeFromID(awsMemoryDBResourceID), + Provider: "aws", }, - // Kubernetes resources don't currently a resource ID. { node: node{ Name: "demo", Type: "apps/Deployment", + ID: "/planes/kubernetes/local/namespaces/default-demo/providers/apps/Deployment/demo", }, Provider: "kubernetes", }, @@ -288,32 +291,6 @@ func Test_outputResourcesFromAPIData(t *testing.T) { actual := outputResourcesFromAPIData(resource) require.Equal(t, expected, actual) - require.Equal(t, "'asdf-invalid-YO' is not a valid resource id", actual[1].Error) - }) - - t.Run("parse invalid output resource provider", func(t *testing.T) { - outputResources := []any{ - map[string]any{ - "provider": "no idea", - }, - } - resource := generated.GenericResource{ - ID: to.Ptr(containerResourceID), - Properties: makeResourceProperties(nil, outputResources), - } - - // Output is always sorted. - expected := []outputResourceEntry{ - { - node: node{ - Error: "unknown provider 'no idea'", - }, - }, - } - - actual := outputResourcesFromAPIData(resource) - require.Equal(t, expected, actual) - require.Equal(t, "unknown provider 'no idea'", actual[0].Error) }) t.Run("no status", func(t *testing.T) { diff --git a/pkg/cli/cmd/app/connections/connections.go b/pkg/cli/cmd/app/connections/connections.go index 4f064184d8..d4a64c5e5b 100644 --- a/pkg/cli/cmd/app/connections/connections.go +++ b/pkg/cli/cmd/app/connections/connections.go @@ -8,15 +8,15 @@ package connections import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/app/connections/connections_test.go b/pkg/cli/cmd/app/connections/connections_test.go index 22946ee09d..1927ec188a 100644 --- a/pkg/cli/cmd/app/connections/connections_test.go +++ b/pkg/cli/cmd/app/connections/connections_test.go @@ -11,16 +11,16 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/app/connections/shareddata_test.go b/pkg/cli/cmd/app/connections/shareddata_test.go index c3271b2ce7..1188104a1a 100644 --- a/pkg/cli/cmd/app/connections/shareddata_test.go +++ b/pkg/cli/cmd/app/connections/shareddata_test.go @@ -16,6 +16,10 @@ limitations under the License. package connections +import ( + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" +) + // This file contains shared variables and functions used in tests. var environmentResourceID = "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/environments/test-env" @@ -30,43 +34,21 @@ func makeRedisResourceID(name string) string { return "/planes/radius/local/resourceGroups/test-group/providers/Applications.Datastores/redisCaches/" + name } -var containerDeploymentOutputResource any = makeKubernetesOutputResource("apps/v1", "Deployment", "default-demo", "demo") -var redisAWSOutputResource any = makeAWSOutputResource(awsMemoryDBResourceID) -var redisAzureOutputResource any = makeAzureOutputResource(azureRedisCacheResourceID) +var containerDeploymentOutputResource any = makeKubernetesOutputResource("apps", "Deployment", "default-demo", "demo") +var redisAWSOutputResource any = makeOutputResource(awsMemoryDBResourceID) +var redisAzureOutputResource any = makeOutputResource(azureRedisCacheResourceID) // makeKubernetesOutputResource creates a Kubernetes output resource. -func makeKubernetesOutputResource(apiVersion string, kind string, namespace string, name string) map[string]any { - return map[string]any{ - "Identity": map[string]any{ - "apiVersion": apiVersion, - "kind": kind, - "name": name, - "namespace": namespace, - }, - "LocalID": "Ignored", - "Provider": "kubernetes", - } -} - -// makeAWSOutputResource creates an AWS output resource. -func makeAWSOutputResource(id string) map[string]any { +func makeKubernetesOutputResource(group string, kind string, namespace string, name string) map[string]any { return map[string]any{ - "Identity": map[string]any{ - "id": id, - }, - "LocalID": "Ignored", - "Provider": "aws", + "id": resources_kubernetes.IDFromParts(resources_kubernetes.PlaneNameTODO, group, kind, namespace, name), } } -// makeAzureOutputResource creates an Azure output resource. -func makeAzureOutputResource(id string) map[string]any { +// makeOutputResource creates an AWS output resource. +func makeOutputResource(id string) map[string]any { return map[string]any{ - "Identity": map[string]any{ - "id": id, - }, - "LocalID": "Ignored", - "Provider": "azure", + "id": id, } } diff --git a/pkg/cli/cmd/app/delete/delete.go b/pkg/cli/cmd/app/delete/delete.go index 6356b00092..fdf0dcc214 100644 --- a/pkg/cli/cmd/app/delete/delete.go +++ b/pkg/cli/cmd/app/delete/delete.go @@ -21,14 +21,14 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/app/delete/delete_test.go b/pkg/cli/cmd/app/delete/delete_test.go index 9211e597e8..966f31f609 100644 --- a/pkg/cli/cmd/app/delete/delete_test.go +++ b/pkg/cli/cmd/app/delete/delete_test.go @@ -22,13 +22,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/app/list/list.go b/pkg/cli/cmd/app/list/list.go index 2666903601..b38a5f5f90 100644 --- a/pkg/cli/cmd/app/list/list.go +++ b/pkg/cli/cmd/app/list/list.go @@ -19,13 +19,13 @@ package list import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/app/list/list_test.go b/pkg/cli/cmd/app/list/list_test.go index 077c2f3005..6d13b4daec 100644 --- a/pkg/cli/cmd/app/list/list_test.go +++ b/pkg/cli/cmd/app/list/list_test.go @@ -21,15 +21,15 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/app/show/show.go b/pkg/cli/cmd/app/show/show.go index ff688f2003..bd618ecf2e 100644 --- a/pkg/cli/cmd/app/show/show.go +++ b/pkg/cli/cmd/app/show/show.go @@ -19,15 +19,15 @@ package list import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/app/show/show_test.go b/pkg/cli/cmd/app/show/show_test.go index d6c8c19037..bdf645ca10 100644 --- a/pkg/cli/cmd/app/show/show_test.go +++ b/pkg/cli/cmd/app/show/show_test.go @@ -21,16 +21,16 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/app/status/status.go b/pkg/cli/cmd/app/status/status.go index ec492a2020..fc481e43e0 100644 --- a/pkg/cli/cmd/app/status/status.go +++ b/pkg/cli/cmd/app/status/status.go @@ -19,16 +19,16 @@ package status import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/app/status/status_test.go b/pkg/cli/cmd/app/status/status_test.go index 7e8dbb3ff1..075e9d51c7 100644 --- a/pkg/cli/cmd/app/status/status_test.go +++ b/pkg/cli/cmd/app/status/status_test.go @@ -21,18 +21,18 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/bicep/publish/publish.go b/pkg/cli/cmd/bicep/publish/publish.go index 2ad2ff42db..f868c54905 100644 --- a/pkg/cli/cmd/bicep/publish/publish.go +++ b/pkg/cli/cmd/bicep/publish/publish.go @@ -24,11 +24,11 @@ import ( "strings" credentials "github.com/oras-project/oras-credentials-go" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" "github.com/opencontainers/go-digest" specs "github.com/opencontainers/image-spec/specs-go" diff --git a/pkg/cli/cmd/bicep/publish/publish_test.go b/pkg/cli/cmd/bicep/publish/publish_test.go index 3e3d03ce2a..3c4de88648 100644 --- a/pkg/cli/cmd/bicep/publish/publish_test.go +++ b/pkg/cli/cmd/bicep/publish/publish_test.go @@ -25,8 +25,8 @@ import ( "github.com/opencontainers/go-digest" specs "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" "oras.land/oras-go/v2" "oras.land/oras-go/v2/content/memory" diff --git a/pkg/cli/cmd/commonflags/flags.go b/pkg/cli/cmd/commonflags/flags.go index 6f0a98004d..ecc84172ac 100644 --- a/pkg/cli/cmd/commonflags/flags.go +++ b/pkg/cli/cmd/commonflags/flags.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/output" "github.com/spf13/cobra" ) @@ -80,9 +80,9 @@ func AddParameterFlag(cmd *cobra.Command) { cmd.Flags().StringArrayP("parameters", "p", []string{}, "Specify parameters for the deployment") } -// AddLinkTypeFlag adds a flag to the given command that allows the user to specify the type of the link this recipe can be consumed by. -func AddLinkTypeFlag(cmd *cobra.Command) { - cmd.Flags().String("link-type", "", "Specify the type of the link this recipe can be consumed by") +// AddResourceTypeFlag adds a flag to the given command that allows the user to specify the type of the portable resource this recipe can be consumed by. +func AddResourceTypeFlag(cmd *cobra.Command) { + cmd.Flags().String("resource-type", "", "Specify the type of the portable resource this recipe can be consumed by") } // AddAzureScopeFlags adds flags to a command to specify an Azure subscription and resource group, and marks them as diff --git a/pkg/cli/cmd/credential/common/validation.go b/pkg/cli/cmd/credential/common/validation.go index d186ccbbde..36d23ada0a 100644 --- a/pkg/cli/cmd/credential/common/validation.go +++ b/pkg/cli/cmd/credential/common/validation.go @@ -19,9 +19,9 @@ package common import ( "strings" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/clierrors" ) // Used in tests diff --git a/pkg/cli/cmd/credential/credential.go b/pkg/cli/cmd/credential/credential.go index 3084a0d061..bb58952131 100644 --- a/pkg/cli/cmd/credential/credential.go +++ b/pkg/cli/cmd/credential/credential.go @@ -17,12 +17,12 @@ limitations under the License. package credential import ( - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - credential_list "github.com/project-radius/radius/pkg/cli/cmd/credential/list" - credential_register "github.com/project-radius/radius/pkg/cli/cmd/credential/register" - credential_show "github.com/project-radius/radius/pkg/cli/cmd/credential/show" - credential_unregister "github.com/project-radius/radius/pkg/cli/cmd/credential/unregister" - "github.com/project-radius/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + credential_list "github.com/radius-project/radius/pkg/cli/cmd/credential/list" + credential_register "github.com/radius-project/radius/pkg/cli/cmd/credential/register" + credential_show "github.com/radius-project/radius/pkg/cli/cmd/credential/show" + credential_unregister "github.com/radius-project/radius/pkg/cli/cmd/credential/unregister" + "github.com/radius-project/radius/pkg/cli/framework" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/credential/list/list.go b/pkg/cli/cmd/credential/list/list.go index ca0797582a..ed1c2c351d 100644 --- a/pkg/cli/cmd/credential/list/list.go +++ b/pkg/cli/cmd/credential/list/list.go @@ -19,14 +19,14 @@ package list import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/credential/list/list_test.go b/pkg/cli/cmd/credential/list/list_test.go index 0d94224034..dd9721eb58 100644 --- a/pkg/cli/cmd/credential/list/list_test.go +++ b/pkg/cli/cmd/credential/list/list_test.go @@ -21,13 +21,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/credential/register/aws/aws.go b/pkg/cli/cmd/credential/register/aws/aws.go index a5091c94a0..d2ee2cf37d 100644 --- a/pkg/cli/cmd/credential/register/aws/aws.go +++ b/pkg/cli/cmd/credential/register/aws/aws.go @@ -19,18 +19,18 @@ package aws import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/to" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" "github.com/spf13/cobra" ) @@ -148,12 +148,12 @@ func (r *Runner) Run(ctx context.Context) error { if err != nil { return err } - credential := ucp.AWSCredentialResource{ + credential := ucp.AwsCredentialResource{ Location: to.Ptr(v1.LocationGlobal), Type: to.Ptr(cli_credential.AWSCredential), - Properties: &ucp.AWSAccessKeyCredentialProperties{ + Properties: &ucp.AwsAccessKeyCredentialProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, AccessKeyID: &r.AccessKeyID, SecretAccessKey: &r.SecretAccessKey, diff --git a/pkg/cli/cmd/credential/register/aws/aws_test.go b/pkg/cli/cmd/credential/register/aws/aws_test.go index 19da30f4d2..b9ce45a16a 100644 --- a/pkg/cli/cmd/credential/register/aws/aws_test.go +++ b/pkg/cli/cmd/credential/register/aws/aws_test.go @@ -22,15 +22,15 @@ import ( "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/to" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) @@ -100,12 +100,12 @@ func Test_Run(t *testing.T) { t.Run("Create aws provider", func(t *testing.T) { t.Run("Success", func(t *testing.T) { ctrl := gomock.NewController(t) - expectedPut := ucp.AWSCredentialResource{ + expectedPut := ucp.AwsCredentialResource{ Location: to.Ptr(v1.LocationGlobal), Type: to.Ptr(cli_credential.AWSCredential), - Properties: &ucp.AWSAccessKeyCredentialProperties{ + Properties: &ucp.AwsAccessKeyCredentialProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, AccessKeyID: to.Ptr(testAccessKeyId), SecretAccessKey: to.Ptr(testSecretAccessKey), diff --git a/pkg/cli/cmd/credential/register/azure/azure.go b/pkg/cli/cmd/credential/register/azure/azure.go index bedea63d96..986f9129c4 100644 --- a/pkg/cli/cmd/credential/register/azure/azure.go +++ b/pkg/cli/cmd/credential/register/azure/azure.go @@ -20,18 +20,18 @@ import ( "context" "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/to" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" "github.com/spf13/cobra" ) @@ -53,7 +53,7 @@ This command is intended for scripting or advanced use-cases. See 'rad init' for to configure these settings. Radius will use the provided service principal for all interactions with Azure, including Bicep deployment, -Radius environments, and Radius links. +Radius environments, and Radius portable resources. Radius will use the provided subscription and resource group as the default target scope for Bicep deployment. The provided service principal must have the Contributor or Owner role assigned for the provided resource group @@ -168,12 +168,12 @@ func (r *Runner) Run(ctx context.Context) error { ID: to.Ptr(fmt.Sprintf(common.AzureCredentialID, "default")), Properties: &ucp.AzureServicePrincipalProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, TenantID: &r.TenantID, ClientID: &r.ClientID, ClientSecret: &r.ClientSecret, - Kind: to.Ptr("ServicePrincipal"), + Kind: to.Ptr(ucp.AzureCredentialKindServicePrincipal), }, } diff --git a/pkg/cli/cmd/credential/register/azure/azure_test.go b/pkg/cli/cmd/credential/register/azure/azure_test.go index 69108bec4c..37ce67558a 100644 --- a/pkg/cli/cmd/credential/register/azure/azure_test.go +++ b/pkg/cli/cmd/credential/register/azure/azure_test.go @@ -24,17 +24,17 @@ import ( "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/to" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" ) @@ -166,12 +166,12 @@ func Test_Run(t *testing.T) { ID: to.Ptr(fmt.Sprintf(common.AzureCredentialID, "default")), Properties: &ucp.AzureServicePrincipalProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, ClientID: to.Ptr("cool-client-id"), ClientSecret: to.Ptr("cool-client-secret"), TenantID: to.Ptr("cool-tenant-id"), - Kind: to.Ptr("ServicePrincipal"), + Kind: to.Ptr(ucp.AzureCredentialKindServicePrincipal), }, } diff --git a/pkg/cli/cmd/credential/register/register.go b/pkg/cli/cmd/credential/register/register.go index 5437f6a8c6..682bbb3ce5 100644 --- a/pkg/cli/cmd/credential/register/register.go +++ b/pkg/cli/cmd/credential/register/register.go @@ -17,10 +17,10 @@ limitations under the License. package register import ( - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - credential_register_aws "github.com/project-radius/radius/pkg/cli/cmd/credential/register/aws" - credential_register_azure "github.com/project-radius/radius/pkg/cli/cmd/credential/register/azure" - "github.com/project-radius/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + credential_register_aws "github.com/radius-project/radius/pkg/cli/cmd/credential/register/aws" + credential_register_azure "github.com/radius-project/radius/pkg/cli/cmd/credential/register/azure" + "github.com/radius-project/radius/pkg/cli/framework" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/credential/show/show.go b/pkg/cli/cmd/credential/show/show.go index 8f2d03ba12..1e4e25b042 100644 --- a/pkg/cli/cmd/credential/show/show.go +++ b/pkg/cli/cmd/credential/show/show.go @@ -19,15 +19,15 @@ package show import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/credential/show/show_test.go b/pkg/cli/cmd/credential/show/show_test.go index 25391a8b09..8f8d882ff6 100644 --- a/pkg/cli/cmd/credential/show/show_test.go +++ b/pkg/cli/cmd/credential/show/show_test.go @@ -21,14 +21,14 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/credential/unregister/unregister.go b/pkg/cli/cmd/credential/unregister/unregister.go index 87dbbb8c59..40bf699a34 100644 --- a/pkg/cli/cmd/credential/unregister/unregister.go +++ b/pkg/cli/cmd/credential/unregister/unregister.go @@ -19,13 +19,13 @@ package unregister import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/cmd/credential/common" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/cmd/credential/common" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/credential/unregister/unregister_test.go b/pkg/cli/cmd/credential/unregister/unregister_test.go index 702b7f7e28..aa4ec30a23 100644 --- a/pkg/cli/cmd/credential/unregister/unregister_test.go +++ b/pkg/cli/cmd/credential/unregister/unregister_test.go @@ -21,12 +21,12 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/deploy/deploy.go b/pkg/cli/cmd/deploy/deploy.go index eed45a1d84..60e50421b9 100644 --- a/pkg/cli/cmd/deploy/deploy.go +++ b/pkg/cli/cmd/deploy/deploy.go @@ -20,19 +20,19 @@ import ( "context" "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/deploy" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/deploy" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/deploy/deploy_test.go b/pkg/cli/cmd/deploy/deploy_test.go index 28d989095a..cb4350a865 100644 --- a/pkg/cli/cmd/deploy/deploy_test.go +++ b/pkg/cli/cmd/deploy/deploy_test.go @@ -22,17 +22,17 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/config" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/deploy" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/config" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/deploy" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/env/create/create.go b/pkg/cli/cmd/env/create/create.go index 20ba44c4b4..2b6fb04641 100644 --- a/pkg/cli/cmd/env/create/create.go +++ b/pkg/cli/cmd/env/create/create.go @@ -19,22 +19,23 @@ package create import ( "context" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" "github.com/spf13/cobra" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/cmd/env/namespace" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/cmd/env/namespace" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" ) // NewCommand creates an instance of the command and runner for the `rad env create` command. @@ -131,7 +132,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { if err != nil { return err } - r.ResourceGroupName = scopeId.FindScope(resources.ResourceGroupsSegment) + r.ResourceGroupName = scopeId.FindScope(resources_radius.ScopeResourceGroups) _, err = client.ShowUCPGroup(cmd.Context(), "radius", "local", r.ResourceGroupName) if clients.Is404Error(err) { diff --git a/pkg/cli/cmd/env/create/create_test.go b/pkg/cli/cmd/env/create/create_test.go index 401cab0f0d..bb44cbc383 100644 --- a/pkg/cli/cmd/env/create/create_test.go +++ b/pkg/cli/cmd/env/create/create_test.go @@ -23,18 +23,18 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/env/namespace" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/env/namespace" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/env/delete/delete.go b/pkg/cli/cmd/env/delete/delete.go index eaa70562ba..aed9ff329b 100644 --- a/pkg/cli/cmd/env/delete/delete.go +++ b/pkg/cli/cmd/env/delete/delete.go @@ -20,13 +20,13 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/env/delete/delete_test.go b/pkg/cli/cmd/env/delete/delete_test.go index 0a6e310364..ebc79ed01a 100644 --- a/pkg/cli/cmd/env/delete/delete_test.go +++ b/pkg/cli/cmd/env/delete/delete_test.go @@ -22,13 +22,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/env/envswitch/switch.go b/pkg/cli/cmd/env/envswitch/switch.go index be552054dc..e346c4b864 100644 --- a/pkg/cli/cmd/env/envswitch/switch.go +++ b/pkg/cli/cmd/env/envswitch/switch.go @@ -22,15 +22,15 @@ import ( "github.com/spf13/cobra" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/resources" ) // NewCommand creates an instance of the command and runner for the `rad env switch` command. diff --git a/pkg/cli/cmd/env/envswitch/switch_test.go b/pkg/cli/cmd/env/envswitch/switch_test.go index d81ca1e7a0..f4b417dadf 100644 --- a/pkg/cli/cmd/env/envswitch/switch_test.go +++ b/pkg/cli/cmd/env/envswitch/switch_test.go @@ -21,11 +21,11 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/framework" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/framework" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/test/radcli" ) func Test_CommandValidation(t *testing.T) { diff --git a/pkg/cli/cmd/env/list/list.go b/pkg/cli/cmd/env/list/list.go index de5c1d4ec7..b38d0b57b3 100644 --- a/pkg/cli/cmd/env/list/list.go +++ b/pkg/cli/cmd/env/list/list.go @@ -19,13 +19,13 @@ package list import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/env/list/list_test.go b/pkg/cli/cmd/env/list/list_test.go index 838c252e1c..0317be4259 100644 --- a/pkg/cli/cmd/env/list/list_test.go +++ b/pkg/cli/cmd/env/list/list_test.go @@ -23,15 +23,15 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" ) func Test_CommandValidation(t *testing.T) { diff --git a/pkg/cli/cmd/env/namespace/mock_namespace.go b/pkg/cli/cmd/env/namespace/mock_namespace.go index 8cba58d012..f03b7878f0 100644 --- a/pkg/cli/cmd/env/namespace/mock_namespace.go +++ b/pkg/cli/cmd/env/namespace/mock_namespace.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/cmd/env/namespace (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/cmd/env/namespace (interfaces: Interface) // Package namespace is a generated GoMock package. package namespace diff --git a/pkg/cli/cmd/env/namespace/namespace.go b/pkg/cli/cmd/env/namespace/namespace.go index b3ec8cf942..ac983ef0da 100644 --- a/pkg/cli/cmd/env/namespace/namespace.go +++ b/pkg/cli/cmd/env/namespace/namespace.go @@ -19,10 +19,10 @@ package namespace import ( "context" - "github.com/project-radius/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/kubernetes" ) -//go:generate mockgen -destination=./mock_namespace.go -package=namespace -self_package github.com/project-radius/radius/pkg/cli/cmd/env/namespace github.com/project-radius/radius/pkg/cli/cmd/env/namespace Interface +//go:generate mockgen -destination=./mock_namespace.go -package=namespace -self_package github.com/radius-project/radius/pkg/cli/cmd/env/namespace github.com/radius-project/radius/pkg/cli/cmd/env/namespace Interface type Interface interface { ValidateNamespace(ctx context.Context, namespace string) error } diff --git a/pkg/cli/cmd/env/show/show.go b/pkg/cli/cmd/env/show/show.go index f341591612..af52a2687a 100644 --- a/pkg/cli/cmd/env/show/show.go +++ b/pkg/cli/cmd/env/show/show.go @@ -19,15 +19,15 @@ package show import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/env/show/show_test.go b/pkg/cli/cmd/env/show/show_test.go index caba1d9dab..06670efa2c 100644 --- a/pkg/cli/cmd/env/show/show_test.go +++ b/pkg/cli/cmd/env/show/show_test.go @@ -23,16 +23,16 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" ) func Test_CommandValidation(t *testing.T) { diff --git a/pkg/cli/cmd/env/update/update.go b/pkg/cli/cmd/env/update/update.go index 44e5219f55..4a1416776d 100644 --- a/pkg/cli/cmd/env/update/update.go +++ b/pkg/cli/cmd/env/update/update.go @@ -20,18 +20,18 @@ import ( "context" "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" "github.com/spf13/cobra" ) @@ -89,7 +89,7 @@ rad env update myenv --clear-aws commonflags.AddAzureScopeFlags(cmd) commonflags.AddAWSScopeFlags(cmd) commonflags.AddOutputFlag(cmd) - //TODO: https://github.com/project-radius/radius/issues/5247 + //TODO: https://github.com/radius-project/radius/issues/5247 commonflags.AddEnvironmentNameFlag(cmd) return cmd, runner @@ -145,7 +145,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { return err } - // TODO: Validate Azure scope components (https://github.com/project-radius/radius/issues/5155) + // TODO: Validate Azure scope components (https://github.com/radius-project/radius/issues/5155) if cmd.Flags().Changed(commonflags.AzureSubscriptionIdFlag) || cmd.Flags().Changed(commonflags.AzureResourceGroupFlag) { azureSubId, err := cli.RequireAzureSubscriptionId(cmd) if err != nil { @@ -165,7 +165,7 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { return err } - // TODO: Validate AWS scope components (https://github.com/project-radius/radius/issues/5155) + // TODO: Validate AWS scope components (https://github.com/radius-project/radius/issues/5155) // stsclient can be used to validate if cmd.Flags().Changed(commonflags.AWSRegionFlag) || cmd.Flags().Changed(commonflags.AWSAccountIdFlag) { awsRegion, err := cmd.Flags().GetString(commonflags.AWSRegionFlag) diff --git a/pkg/cli/cmd/env/update/update_test.go b/pkg/cli/cmd/env/update/update_test.go index 6604562e8a..8cff5dbf2e 100644 --- a/pkg/cli/cmd/env/update/update_test.go +++ b/pkg/cli/cmd/env/update/update_test.go @@ -24,17 +24,17 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) @@ -277,7 +277,7 @@ func Test_Update(t *testing.T) { environment := corerp.EnvironmentResource{ Name: to.Ptr("test-env"), Properties: &corerp.EnvironmentProperties{ - Recipes: map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{}, + Recipes: map[string]map[string]corerp.RecipePropertiesClassification{}, Compute: &corerp.KubernetesCompute{ Namespace: to.Ptr("default"), Kind: to.Ptr("kubernetes"), @@ -303,7 +303,7 @@ func Test_Update(t *testing.T) { testEnvProperties := &corerp.EnvironmentProperties{ Providers: testProviders, - Recipes: map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{}, + Recipes: map[string]map[string]corerp.RecipePropertiesClassification{}, Compute: &corerp.KubernetesCompute{ Namespace: to.Ptr("default"), Kind: to.Ptr("kubernetes"), diff --git a/pkg/cli/cmd/group/common/validation.go b/pkg/cli/cmd/group/common/validation.go index 65dc8abb4a..c97d727d8f 100644 --- a/pkg/cli/cmd/group/common/validation.go +++ b/pkg/cli/cmd/group/common/validation.go @@ -21,7 +21,7 @@ import ( "regexp" - "github.com/project-radius/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/clierrors" ) // ValidateResourceGroupName checks if the given resource group name is between 1 and 90 characters long, does not end with diff --git a/pkg/cli/cmd/group/create/create.go b/pkg/cli/cmd/group/create/create.go index 649df4b792..216ae87133 100644 --- a/pkg/cli/cmd/group/create/create.go +++ b/pkg/cli/cmd/group/create/create.go @@ -21,16 +21,16 @@ import ( "github.com/spf13/cobra" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/cmd/group/common" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/cmd/group/common" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) // NewCommand creates an instance of the command and runner for the `rad group create` command. diff --git a/pkg/cli/cmd/group/create/create_test.go b/pkg/cli/cmd/group/create/create_test.go index f47b0a6b25..f50fb56172 100644 --- a/pkg/cli/cmd/group/create/create_test.go +++ b/pkg/cli/cmd/group/create/create_test.go @@ -21,12 +21,12 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/group/delete/delete.go b/pkg/cli/cmd/group/delete/delete.go index 4e6cf008e7..fb55ee5b9d 100644 --- a/pkg/cli/cmd/group/delete/delete.go +++ b/pkg/cli/cmd/group/delete/delete.go @@ -20,13 +20,13 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/group/delete/delete_test.go b/pkg/cli/cmd/group/delete/delete_test.go index e336a6bff6..a0b7f2c97c 100644 --- a/pkg/cli/cmd/group/delete/delete_test.go +++ b/pkg/cli/cmd/group/delete/delete_test.go @@ -21,13 +21,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/group/group.go b/pkg/cli/cmd/group/group.go index fe6666bf9f..fb0b6bbeba 100644 --- a/pkg/cli/cmd/group/group.go +++ b/pkg/cli/cmd/group/group.go @@ -17,12 +17,12 @@ limitations under the License. package group import ( - group_create "github.com/project-radius/radius/pkg/cli/cmd/group/create" - group_delete "github.com/project-radius/radius/pkg/cli/cmd/group/delete" - group_switch "github.com/project-radius/radius/pkg/cli/cmd/group/groupswitch" - group_list "github.com/project-radius/radius/pkg/cli/cmd/group/list" - group_show "github.com/project-radius/radius/pkg/cli/cmd/group/show" - "github.com/project-radius/radius/pkg/cli/framework" + group_create "github.com/radius-project/radius/pkg/cli/cmd/group/create" + group_delete "github.com/radius-project/radius/pkg/cli/cmd/group/delete" + group_switch "github.com/radius-project/radius/pkg/cli/cmd/group/groupswitch" + group_list "github.com/radius-project/radius/pkg/cli/cmd/group/list" + group_show "github.com/radius-project/radius/pkg/cli/cmd/group/show" + "github.com/radius-project/radius/pkg/cli/framework" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/group/groupswitch/switch.go b/pkg/cli/cmd/group/groupswitch/switch.go index 1ed2319b96..0678acaa72 100644 --- a/pkg/cli/cmd/group/groupswitch/switch.go +++ b/pkg/cli/cmd/group/groupswitch/switch.go @@ -20,12 +20,12 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/group/groupswitch/switch_test.go b/pkg/cli/cmd/group/groupswitch/switch_test.go index 97ae3ef5b6..fb124d43c2 100644 --- a/pkg/cli/cmd/group/groupswitch/switch_test.go +++ b/pkg/cli/cmd/group/groupswitch/switch_test.go @@ -23,14 +23,14 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" "gopkg.in/yaml.v3" ) diff --git a/pkg/cli/cmd/group/list/list.go b/pkg/cli/cmd/group/list/list.go index aca32d47ee..6bad81515a 100644 --- a/pkg/cli/cmd/group/list/list.go +++ b/pkg/cli/cmd/group/list/list.go @@ -19,13 +19,13 @@ package list import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) @@ -119,10 +119,5 @@ func (r *Runner) Run(ctx context.Context) error { return err } - err = r.Output.WriteFormatted(r.Format, resourceGroupDetails, objectformats.GetResourceGroupTableFormat()) - - if err != nil { - return err - } - return err + return r.Output.WriteFormatted(r.Format, resourceGroupDetails, objectformats.GetResourceGroupTableFormat()) } diff --git a/pkg/cli/cmd/group/list/list_test.go b/pkg/cli/cmd/group/list/list_test.go index 4483aa43a1..fbb75f8793 100644 --- a/pkg/cli/cmd/group/list/list_test.go +++ b/pkg/cli/cmd/group/list/list_test.go @@ -21,13 +21,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/group/show/show.go b/pkg/cli/cmd/group/show/show.go index 468a8b1f98..ef915ba556 100644 --- a/pkg/cli/cmd/group/show/show.go +++ b/pkg/cli/cmd/group/show/show.go @@ -19,13 +19,13 @@ package show import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/group/show/show_test.go b/pkg/cli/cmd/group/show/show_test.go index 95593fcb2e..afed1409d4 100644 --- a/pkg/cli/cmd/group/show/show_test.go +++ b/pkg/cli/cmd/group/show/show_test.go @@ -21,16 +21,16 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/install/kubernetes/kubernetes.go b/pkg/cli/cmd/install/kubernetes/kubernetes.go index 527e2a2e49..3b65a37b96 100644 --- a/pkg/cli/cmd/install/kubernetes/kubernetes.go +++ b/pkg/cli/cmd/install/kubernetes/kubernetes.go @@ -19,11 +19,11 @@ package kubernetes import ( "context" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/version" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/install/kubernetes/kubernetes_test.go b/pkg/cli/cmd/install/kubernetes/kubernetes_test.go index 3897736e10..b7b9a01b3d 100644 --- a/pkg/cli/cmd/install/kubernetes/kubernetes_test.go +++ b/pkg/cli/cmd/install/kubernetes/kubernetes_test.go @@ -21,9 +21,9 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/radinit/application.go b/pkg/cli/cmd/radinit/application.go index 31e2e6c381..4935634a49 100644 --- a/pkg/cli/cmd/radinit/application.go +++ b/pkg/cli/cmd/radinit/application.go @@ -21,7 +21,7 @@ import ( "os" "path/filepath" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/prompt" ) const ( diff --git a/pkg/cli/cmd/radinit/application_test.go b/pkg/cli/cmd/radinit/application_test.go index 48f7e914d5..0bd73b0e5b 100644 --- a/pkg/cli/cmd/radinit/application_test.go +++ b/pkg/cli/cmd/radinit/application_test.go @@ -21,7 +21,7 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/prompt" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/radinit/aws.go b/pkg/cli/cmd/radinit/aws.go index 3b61469cc6..6283aec637 100644 --- a/pkg/cli/cmd/radinit/aws.go +++ b/pkg/cli/cmd/radinit/aws.go @@ -21,9 +21,9 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/charmbracelet/bubbles/textinput" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/prompt" ) const ( diff --git a/pkg/cli/cmd/radinit/aws_test.go b/pkg/cli/cmd/radinit/aws_test.go index 8b61230fdb..61b1fe58c3 100644 --- a/pkg/cli/cmd/radinit/aws_test.go +++ b/pkg/cli/cmd/radinit/aws_test.go @@ -24,10 +24,10 @@ import ( ec2_types "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/aws/aws-sdk-go-v2/service/sts" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/radinit/azure.go b/pkg/cli/cmd/radinit/azure.go index 26a8276242..456477a9b3 100644 --- a/pkg/cli/cmd/radinit/azure.go +++ b/pkg/cli/cmd/radinit/azure.go @@ -24,9 +24,9 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" "github.com/charmbracelet/bubbles/textinput" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/prompt" ) const ( diff --git a/pkg/cli/cmd/radinit/azure_test.go b/pkg/cli/cmd/radinit/azure_test.go index 729ac452eb..9d456e848a 100644 --- a/pkg/cli/cmd/radinit/azure_test.go +++ b/pkg/cli/cmd/radinit/azure_test.go @@ -24,10 +24,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/radinit/cloud.go b/pkg/cli/cmd/radinit/cloud.go index 16313dc73a..4e0a2e3ff4 100644 --- a/pkg/cli/cmd/radinit/cloud.go +++ b/pkg/cli/cmd/radinit/cloud.go @@ -20,9 +20,9 @@ import ( "context" "errors" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/prompt" ) const ( diff --git a/pkg/cli/cmd/radinit/cloud_test.go b/pkg/cli/cmd/radinit/cloud_test.go index f3a43480fc..7cc56a41c0 100644 --- a/pkg/cli/cmd/radinit/cloud_test.go +++ b/pkg/cli/cmd/radinit/cloud_test.go @@ -21,10 +21,10 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/radinit/cluster.go b/pkg/cli/cmd/radinit/cluster.go index 558522559a..7e3e66b1a1 100644 --- a/pkg/cli/cmd/radinit/cluster.go +++ b/pkg/cli/cmd/radinit/cluster.go @@ -20,8 +20,8 @@ import ( "context" "sort" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/version" "k8s.io/client-go/tools/clientcmd/api" ) diff --git a/pkg/cli/cmd/radinit/cluster_test.go b/pkg/cli/cmd/radinit/cluster_test.go index 5db8a04837..6363ca7a96 100644 --- a/pkg/cli/cmd/radinit/cluster_test.go +++ b/pkg/cli/cmd/radinit/cluster_test.go @@ -21,9 +21,9 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/prompt" "github.com/stretchr/testify/require" "k8s.io/client-go/tools/clientcmd/api" ) diff --git a/pkg/cli/cmd/radinit/display.go b/pkg/cli/cmd/radinit/display.go index a78e3f61ca..d3759a550b 100644 --- a/pkg/cli/cmd/radinit/display.go +++ b/pkg/cli/cmd/radinit/display.go @@ -26,7 +26,7 @@ import ( "github.com/charmbracelet/bubbles/spinner" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/prompt" ) const ( diff --git a/pkg/cli/cmd/radinit/environment.go b/pkg/cli/cmd/radinit/environment.go index f329711e3f..08ced4db85 100644 --- a/pkg/cli/cmd/radinit/environment.go +++ b/pkg/cli/cmd/radinit/environment.go @@ -21,9 +21,9 @@ import ( "sort" "strings" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" ) const ( diff --git a/pkg/cli/cmd/radinit/environment_test.go b/pkg/cli/cmd/radinit/environment_test.go index 7647279257..760aca9ba7 100644 --- a/pkg/cli/cmd/radinit/environment_test.go +++ b/pkg/cli/cmd/radinit/environment_test.go @@ -21,12 +21,12 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/radinit/init.go b/pkg/cli/cmd/radinit/init.go index 4ef1ee9cba..dccff63d8d 100644 --- a/pkg/cli/cmd/radinit/init.go +++ b/pkg/cli/cmd/radinit/init.go @@ -20,26 +20,26 @@ import ( "context" "os" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/setup" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/setup" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" "github.com/spf13/cobra" ) @@ -248,7 +248,7 @@ func (r *Runner) Run(ctx context.Context) error { return err } - var recipes map[string]map[string]corerp.EnvironmentRecipePropertiesClassification + var recipes map[string]map[string]corerp.RecipePropertiesClassification if r.Options.Recipes.DevRecipes { recipes, err = r.DevRecipeClient.GetDevRecipes(ctx) if err != nil { @@ -345,7 +345,7 @@ func (r *Runner) getAzureCredential() ucp.AzureCredentialResource { Type: to.Ptr(cli_credential.AzureCredential), Properties: &ucp.AzureServicePrincipalProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, TenantID: &r.Options.CloudProviders.Azure.ServicePrincipal.TenantID, ClientID: &r.Options.CloudProviders.Azure.ServicePrincipal.ClientID, @@ -354,13 +354,13 @@ func (r *Runner) getAzureCredential() ucp.AzureCredentialResource { } } -func (r *Runner) getAWSCredential() ucp.AWSCredentialResource { - return ucp.AWSCredentialResource{ +func (r *Runner) getAWSCredential() ucp.AwsCredentialResource { + return ucp.AwsCredentialResource{ Location: to.Ptr(v1.LocationGlobal), Type: to.Ptr(cli_credential.AWSCredential), - Properties: &ucp.AWSAccessKeyCredentialProperties{ + Properties: &ucp.AwsAccessKeyCredentialProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, AccessKeyID: &r.Options.CloudProviders.AWS.AccessKeyID, SecretAccessKey: &r.Options.CloudProviders.AWS.SecretAccessKey, diff --git a/pkg/cli/cmd/radinit/init_test.go b/pkg/cli/cmd/radinit/init_test.go index 6a0e504c0a..609c58ec71 100644 --- a/pkg/cli/cmd/radinit/init_test.go +++ b/pkg/cli/cmd/radinit/init_test.go @@ -32,24 +32,24 @@ import ( "github.com/stretchr/testify/require" "k8s.io/client-go/tools/clientcmd/api" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" - - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" + + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) func Test_CommandValidation(t *testing.T) { @@ -583,7 +583,7 @@ func Test_Run_InstallAndCreateEnvironment(t *testing.T) { full bool azureProvider *azure.Provider awsProvider *aws.Provider - recipes map[string]map[string]corerp.EnvironmentRecipePropertiesClassification + recipes map[string]map[string]corerp.RecipePropertiesClassification expectedOutput []any }{ { @@ -591,8 +591,8 @@ func Test_Run_InstallAndCreateEnvironment(t *testing.T) { full: false, azureProvider: nil, awsProvider: nil, - recipes: map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{ - "Applications.Link/redisCaches": { + recipes: map[string]map[string]corerp.RecipePropertiesClassification{ + "Applications.Datastores/redisCaches": { "default": &corerp.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("radiusdev.azurecr.io/redis:latest"), @@ -605,7 +605,7 @@ func Test_Run_InstallAndCreateEnvironment(t *testing.T) { full: false, azureProvider: nil, awsProvider: nil, - recipes: map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{}, + recipes: map[string]map[string]corerp.RecipePropertiesClassification{}, expectedOutput: []any{}, }, { @@ -634,7 +634,7 @@ func Test_Run_InstallAndCreateEnvironment(t *testing.T) { Region: "us-west-2", AccountID: "test-account-id", }, - recipes: map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{}, + recipes: map[string]map[string]corerp.RecipePropertiesClassification{}, expectedOutput: []any{}, }, { @@ -663,7 +663,7 @@ func Test_Run_InstallAndCreateEnvironment(t *testing.T) { full: false, azureProvider: nil, awsProvider: nil, - recipes: map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{}, + recipes: map[string]map[string]corerp.RecipePropertiesClassification{}, expectedOutput: []any{}, }, } @@ -712,12 +712,12 @@ func Test_Run_InstallAndCreateEnvironment(t *testing.T) { } if tc.awsProvider != nil { credentialManagementClient.EXPECT(). - PutAWS(context.Background(), ucp.AWSCredentialResource{ + PutAWS(context.Background(), ucp.AwsCredentialResource{ Location: to.Ptr(v1.LocationGlobal), Type: to.Ptr(cli_credential.AWSCredential), - Properties: &ucp.AWSAccessKeyCredentialProperties{ + Properties: &ucp.AwsAccessKeyCredentialProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, AccessKeyID: to.Ptr(tc.awsProvider.AccessKeyID), SecretAccessKey: to.Ptr(tc.awsProvider.SecretAccessKey), diff --git a/pkg/cli/cmd/radinit/mock_devrecipeclient.go b/pkg/cli/cmd/radinit/mock_devrecipeclient.go index 37e58fad91..f7ae50b1d1 100644 --- a/pkg/cli/cmd/radinit/mock_devrecipeclient.go +++ b/pkg/cli/cmd/radinit/mock_devrecipeclient.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/cmd/radinit (interfaces: DevRecipeClient) +// Source: github.com/radius-project/radius/pkg/cli/cmd/radinit (interfaces: DevRecipeClient) // Package radinit is a generated GoMock package. package radinit @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" ) // MockDevRecipeClient is a mock of DevRecipeClient interface. @@ -36,10 +36,10 @@ func (m *MockDevRecipeClient) EXPECT() *MockDevRecipeClientMockRecorder { } // GetDevRecipes mocks base method. -func (m *MockDevRecipeClient) GetDevRecipes(arg0 context.Context) (map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification, error) { +func (m *MockDevRecipeClient) GetDevRecipes(arg0 context.Context) (map[string]map[string]v20220315privatepreview.RecipePropertiesClassification, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetDevRecipes", arg0) - ret0, _ := ret[0].(map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification) + ret0, _ := ret[0].(map[string]map[string]v20220315privatepreview.RecipePropertiesClassification) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/pkg/cli/cmd/radinit/options.go b/pkg/cli/cmd/radinit/options.go index 3848d6500f..350cc8b6a0 100644 --- a/pkg/cli/cmd/radinit/options.go +++ b/pkg/cli/cmd/radinit/options.go @@ -19,10 +19,10 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/cli" - cli_aws "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + cli_aws "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/workspaces" ) // initOptions holds all of the options that will be used to initialize Radius. @@ -111,16 +111,16 @@ func (r *Runner) enterInitOptions(ctx context.Context) (*initOptions, *workspace options.Recipes.DevRecipes = !r.Full + // If the user has a current workspace we should overwrite it. + // If the user does not have a current workspace we should create a new one called default and set it as current + // If the user does not have a current workspace and has an existing one called default we should overwrite it and set it as current if ws == nil { - // Update the workspace with the information we captured about the environment. - workspace.Name = options.Environment.Name - workspace.Environment = fmt.Sprintf("/planes/radius/local/resourceGroups/%s/providers/Applications.Core/environments/%s", options.Environment.Name, options.Environment.Name) - workspace.Scope = fmt.Sprintf("/planes/radius/local/resourceGroups/%s", options.Environment.Name) - return &options, workspace, nil + workspace.Name = "default" + } else { + workspace.Name = ws.Name } + workspace.Environment = fmt.Sprintf("/planes/radius/local/resourceGroups/%s/providers/Applications.Core/environments/%s", options.Environment.Name, options.Environment.Name) + workspace.Scope = fmt.Sprintf("/planes/radius/local/resourceGroups/%s", options.Environment.Name) + return &options, workspace, nil - ws.Environment = fmt.Sprintf("/planes/radius/local/resourceGroups/%s/providers/Applications.Core/environments/%s", options.Environment.Name, options.Environment.Name) - ws.Scope = fmt.Sprintf("/planes/radius/local/resourceGroups/%s", options.Environment.Name) - - return &options, ws, nil } diff --git a/pkg/cli/cmd/radinit/options_test.go b/pkg/cli/cmd/radinit/options_test.go index 9405f56d78..8d04393860 100644 --- a/pkg/cli/cmd/radinit/options_test.go +++ b/pkg/cli/cmd/radinit/options_test.go @@ -22,12 +22,12 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/version" "github.com/spf13/viper" "github.com/stretchr/testify/require" ) @@ -96,7 +96,7 @@ func Test_enterInitOptions(t *testing.T) { require.NoError(t, err) expectedWorkspace := workspaces.Workspace{ - Name: "test-env", + Name: "default", Connection: map[string]any{ "context": "kind-kind", "kind": workspaces.KindKubernetes, @@ -157,12 +157,76 @@ workspaces: expectedWorkspace := workspaces.Workspace{ Name: "abc", Connection: map[string]any{ - "context": "cool-beans", + "context": "kind-kind", + "kind": workspaces.KindKubernetes, + }, + Environment: "/planes/radius/local/resourceGroups/test-env/providers/Applications.Core/environments/test-env", + Scope: "/planes/radius/local/resourceGroups/test-env", + } + require.Equal(t, expectedWorkspace, *workspace) + + expectedOptions := initOptions{ + Cluster: clusterOptions{ + Context: "kind-kind", + Install: true, + Namespace: "radius-system", + Version: version.Version(), + }, + Environment: environmentOptions{ + Create: true, + Name: "test-env", + Namespace: "test-namespace", + }, + } + require.Equal(t, expectedOptions, *options) + }) + + t.Run("existing-workspace-with-default-as-an-entry", func(t *testing.T) { + ctrl := gomock.NewController(t) + prompter := prompt.NewMockInterface(ctrl) + k8s := kubernetes.NewMockInterface(ctrl) + helm := helm.NewMockInterface(ctrl) + + var yaml = ` +workspaces: + default: default + items: + abc: + connection: + kind: kubernetes + context: cool-beans + scope: /a/b/c + environment: /a/b/c/providers/Applications.Core/environments/ice-cold + default: + connection: + kind: kubernetes + context: hot-beans + scope: /d/e/f + environment: /a/b/c/providers/Applications.Core/environments/hot-coffee +` + v, err := makeConfig(yaml) + runner := Runner{Prompter: prompter, KubernetesInterface: k8s, HelmInterface: helm, Full: true, ConfigHolder: &framework.ConfigHolder{Config: v}} + + require.NoError(t, err) + initGetKubeContextSuccess(k8s) + initKubeContextWithKind(prompter) + initHelmMockRadiusNotInstalled(helm) + initEnvNamePrompt(prompter, "test-env") + initNamespacePrompt(prompter, "test-namespace") + initAddCloudProviderPromptNo(prompter) + setScaffoldApplicationPromptNo(prompter) + + options, workspace, err := runner.enterInitOptions(context.Background()) + require.NoError(t, err) + + expectedWorkspace := workspaces.Workspace{ + Name: "default", + Connection: map[string]any{ + "context": "kind-kind", "kind": workspaces.KindKubernetes, }, Environment: "/planes/radius/local/resourceGroups/test-env/providers/Applications.Core/environments/test-env", Scope: "/planes/radius/local/resourceGroups/test-env", - Source: "userconfig", } require.Equal(t, expectedWorkspace, *workspace) diff --git a/pkg/cli/cmd/radinit/recipe.go b/pkg/cli/cmd/radinit/recipe.go index b63fa7917c..822be224f7 100644 --- a/pkg/cli/cmd/radinit/recipe.go +++ b/pkg/cli/cmd/radinit/recipe.go @@ -21,12 +21,11 @@ import ( "fmt" "strings" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp" - recipe_types "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/version" - + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources" + recipe_types "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/version" "oras.land/oras-go/v2/registry/remote" ) @@ -34,9 +33,9 @@ const ( DevRecipesRegistry = "radius.azurecr.io" ) -//go:generate mockgen -destination=./mock_devrecipeclient.go -package=radinit -self_package github.com/project-radius/radius/pkg/cli/cmd/radinit github.com/project-radius/radius/pkg/cli/cmd/radinit DevRecipeClient +//go:generate mockgen -destination=./mock_devrecipeclient.go -package=radinit -self_package github.com/radius-project/radius/pkg/cli/cmd/radinit github.com/radius-project/radius/pkg/cli/cmd/radinit DevRecipeClient type DevRecipeClient interface { - GetDevRecipes(ctx context.Context) (map[string]map[string]corerp.EnvironmentRecipePropertiesClassification, error) + GetDevRecipes(ctx context.Context) (map[string]map[string]corerp.RecipePropertiesClassification, error) } type devRecipeClient struct { @@ -49,7 +48,7 @@ func NewDevRecipeClient() DevRecipeClient { // GetDevRecipes is a function that queries a registry for recipes with a specific tag and returns a map of recipes. // If an error occurs, an error is returned. -func (drc *devRecipeClient) GetDevRecipes(ctx context.Context) (map[string]map[string]corerp.EnvironmentRecipePropertiesClassification, error) { +func (drc *devRecipeClient) GetDevRecipes(ctx context.Context) (map[string]map[string]corerp.RecipePropertiesClassification, error) { reg, err := remote.NewRegistry(DevRecipesRegistry) if err != nil { return nil, fmt.Errorf("failed to create client to registry %s - %s", DevRecipesRegistry, err.Error()) @@ -61,7 +60,7 @@ func (drc *devRecipeClient) GetDevRecipes(ctx context.Context) (map[string]map[s tag = "latest" } - recipes := map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{} + recipes := map[string]map[string]corerp.RecipePropertiesClassification{} // if repository has the correct path it should look like: /recipes//: // Ex: radius.azurecr.io/recipes/local-dev/rediscaches:0.20 @@ -104,8 +103,8 @@ func (drc *devRecipeClient) GetDevRecipes(ctx context.Context) (map[string]map[s } // processRepositories processes the repositories and returns the recipes. -func processRepositories(repos []string, tag string) map[string]map[string]corerp.EnvironmentRecipePropertiesClassification { - recipes := map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{} +func processRepositories(repos []string, tag string) map[string]map[string]corerp.RecipePropertiesClassification { + recipes := map[string]map[string]corerp.RecipePropertiesClassification{} // We are using the default recipe. name := "default" @@ -117,15 +116,15 @@ func processRepositories(repos []string, tag string) map[string]map[string]corer continue } - linkType := getLinkType(resourceType) - // If the link type is empty, it means we don't support the resource type. - if linkType == "" { + portableResourceType := getPortableResourceType(resourceType) + // If the PortableResource type is empty, it means we don't support the resource type. + if portableResourceType == "" { continue } repoPath := DevRecipesRegistry + "/" + repo - recipes[linkType] = map[string]corerp.EnvironmentRecipePropertiesClassification{ + recipes[portableResourceType] = map[string]corerp.RecipePropertiesClassification{ name: &corerp.BicepRecipeProperties{ TemplateKind: to.Ptr(recipe_types.TemplateKindBicep), TemplatePath: to.Ptr(repoPath + ":" + tag), @@ -152,31 +151,25 @@ func getResourceTypeFromPath(repo string) (resourceType string) { return resourceType } -// getLinkType returns the link type for the given resource type. -func getLinkType(resourceType string) string { +// getPortableResourceType returns the resource type for the given resource. +func getPortableResourceType(resourceType string) string { switch resourceType { - case "daprpubsubbrokers": - return linkrp.DaprPubSubBrokersResourceType - case "daprsecretstores": - return linkrp.DaprSecretStoresResourceType - case "daprstatestores": - return linkrp.DaprStateStoresResourceType case "mongodatabases": - return linkrp.MongoDatabasesResourceType - case "rabbitmqmessagequeues": - return linkrp.RabbitMQMessageQueuesResourceType + return portableresources.MongoDatabasesResourceType case "rediscaches": - return linkrp.RedisCachesResourceType + return portableresources.RedisCachesResourceType case "sqldatabases": - return linkrp.SqlDatabasesResourceType + return portableresources.SqlDatabasesResourceType case "rabbitmqqueues": - return linkrp.N_RabbitMQQueuesResourceType + return portableresources.RabbitMQQueuesResourceType case "pubsubbrokers": - return linkrp.N_DaprPubSubBrokersResourceType + return portableresources.DaprPubSubBrokersResourceType case "secretstores": - return linkrp.N_DaprSecretStoresResourceType + return portableresources.DaprSecretStoresResourceType case "statestores": - return linkrp.N_DaprStateStoresResourceType + return portableresources.DaprStateStoresResourceType + case "extenders": + return portableresources.ExtendersResourceType default: return "" } diff --git a/pkg/cli/cmd/radinit/recipe_test.go b/pkg/cli/cmd/radinit/recipe_test.go index 380263351a..0c65b43ea2 100644 --- a/pkg/cli/cmd/radinit/recipe_test.go +++ b/pkg/cli/cmd/radinit/recipe_test.go @@ -21,9 +21,9 @@ import ( reflect "reflect" "testing" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) @@ -73,57 +73,57 @@ func Test_getResourceTypeFromPath(t *testing.T) { } } -func Test_getLinkType(t *testing.T) { +func Test_getPortableResourceType(t *testing.T) { tests := []struct { name string resourceType string want string }{ { - "Dapr PubSub Link Type", - "daprpubsubbrokers", - "Applications.Link/daprPubSubBrokers", + "Dapr PubSub Portable Resource", + "pubsubbrokers", + "Applications.Dapr/pubSubBrokers", }, { - "Dapr Secret Store Link Type", - "daprsecretstores", - "Applications.Link/daprSecretStores", + "Dapr Secret Store Portable Resource", + "secretstores", + "Applications.Dapr/secretStores", }, { - "Dapr State Store Link Type", - "daprstatestores", - "Applications.Link/daprStateStores", + "Dapr State Store Portable Resource", + "statestores", + "Applications.Dapr/stateStores", }, { - "Rabbit MQ Link Type", - "rabbitmqmessagequeues", - "Applications.Link/rabbitMQMessageQueues", + "Rabbit MQ Portable Resource", + "rabbitmqqueues", + "Applications.Messaging/rabbitMQQueues", }, { - "Redis Cache Link Type", + "Redis Cache Portable Resource", "rediscaches", - "Applications.Link/redisCaches", + "Applications.Datastores/redisCaches", }, { - "Mongo Database Link Type", + "Mongo Database Portable Resource", "mongodatabases", - "Applications.Link/mongoDatabases", + "Applications.Datastores/mongoDatabases", }, { - "SQL Database Link Type", + "SQL Database Portable Resource", "sqldatabases", - "Applications.Link/sqlDatabases", + "Applications.Datastores/sqlDatabases", }, { - "Invalid Link Type", + "Invalid Portable Resource", "unsupported", "", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := getLinkType(tt.resourceType); got != tt.want { - t.Errorf("getLinkType() = %v, want %v", got, tt.want) + if got := getPortableResourceType(tt.resourceType); got != tt.want { + t.Errorf("getPortableResourceType() = %v, want %v", got, tt.want) } }) } @@ -134,7 +134,7 @@ func Test_processRepositories(t *testing.T) { name string repos []string tag string - want map[string]map[string]corerp.EnvironmentRecipePropertiesClassification + want map[string]map[string]corerp.RecipePropertiesClassification }{ { "Valid Repository with Redis Cache", @@ -142,8 +142,8 @@ func Test_processRepositories(t *testing.T) { "recipes/local-dev/rediscaches", }, "0.20", - map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{ - "Applications.Link/redisCaches": { + map[string]map[string]corerp.RecipePropertiesClassification{ + "Applications.Datastores/redisCaches": { "default": &corerp.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr(fmt.Sprintf("%s/recipes/local-dev/rediscaches:0.20", DevRecipesRegistry)), @@ -158,14 +158,14 @@ func Test_processRepositories(t *testing.T) { "recipes/local-dev/mongodatabases", }, "0.20", - map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{ - "Applications.Link/redisCaches": { + map[string]map[string]corerp.RecipePropertiesClassification{ + "Applications.Datastores/redisCaches": { "default": &corerp.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr(fmt.Sprintf("%s/recipes/local-dev/rediscaches:0.20", DevRecipesRegistry)), }, }, - "Applications.Link/mongoDatabases": { + "Applications.Datastores/mongoDatabases": { "default": &corerp.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr(fmt.Sprintf("%s/recipes/local-dev/mongodatabases:0.20", DevRecipesRegistry)), @@ -183,14 +183,14 @@ func Test_processRepositories(t *testing.T) { "recipes/unsupported/unsupported", }, "latest", - map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{ - "Applications.Link/redisCaches": { + map[string]map[string]corerp.RecipePropertiesClassification{ + "Applications.Datastores/redisCaches": { "default": &corerp.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr(fmt.Sprintf("%s/recipes/local-dev/rediscaches:latest", DevRecipesRegistry)), }, }, - "Applications.Link/mongoDatabases": { + "Applications.Datastores/mongoDatabases": { "default": &corerp.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr(fmt.Sprintf("%s/recipes/local-dev/mongodatabases:latest", DevRecipesRegistry)), diff --git a/pkg/cli/cmd/recipe/list/list.go b/pkg/cli/cmd/recipe/list/list.go index fa0dddfed9..fd5797c0c1 100644 --- a/pkg/cli/cmd/recipe/list/list.go +++ b/pkg/cli/cmd/recipe/list/list.go @@ -20,15 +20,15 @@ import ( "context" "sort" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - types "github.com/project-radius/radius/pkg/cli/cmd/recipe" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + types "github.com/radius-project/radius/pkg/cli/cmd/recipe" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" "github.com/spf13/cobra" ) @@ -118,14 +118,14 @@ func (r *Runner) Run(ctx context.Context) error { return err } var envRecipes []types.EnvironmentRecipe - for link, recipes := range envResource.Properties.Recipes { + for resourceType, recipes := range envResource.Properties.Recipes { for recipeName, recipeDetails := range recipes { recipe := types.EnvironmentRecipe{} switch c := recipeDetails.(type) { case *corerp.TerraformRecipeProperties: recipe = types.EnvironmentRecipe{ Name: recipeName, - LinkType: link, + ResourceType: resourceType, TemplatePath: *c.TemplatePath, TemplateKind: *c.TemplateKind, TemplateVersion: *c.TemplateVersion, @@ -133,7 +133,7 @@ func (r *Runner) Run(ctx context.Context) error { case *corerp.BicepRecipeProperties: recipe = types.EnvironmentRecipe{ Name: recipeName, - LinkType: link, + ResourceType: resourceType, TemplatePath: *c.TemplatePath, TemplateKind: *c.TemplateKind, } diff --git a/pkg/cli/cmd/recipe/list/list_test.go b/pkg/cli/cmd/recipe/list/list_test.go index e10aea5453..95da164d7c 100644 --- a/pkg/cli/cmd/recipe/list/list_test.go +++ b/pkg/cli/cmd/recipe/list/list_test.go @@ -21,19 +21,19 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - types "github.com/project-radius/radius/pkg/cli/cmd/recipe" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + types "github.com/radius-project/radius/pkg/cli/cmd/recipe" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) @@ -85,8 +85,8 @@ func Test_Run(t *testing.T) { Type: to.Ptr("applications.core/environments"), Location: to.Ptr(v1.LocationGlobal), Properties: &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -103,13 +103,13 @@ func Test_Run(t *testing.T) { recipes := []types.EnvironmentRecipe{ { Name: "cosmosDB", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, TemplateKind: recipes.TemplateKindBicep, TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1", }, { Name: "cosmosDB-terraform", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, TemplateKind: recipes.TemplateKindTerraform, TemplatePath: "Azure/cosmosdb/azurerm", TemplateVersion: "1.1.0", diff --git a/pkg/cli/cmd/recipe/register/register.go b/pkg/cli/cmd/recipe/register/register.go index 0de3084e9b..cd49b946db 100644 --- a/pkg/cli/cmd/recipe/register/register.go +++ b/pkg/cli/cmd/recipe/register/register.go @@ -19,17 +19,17 @@ package register import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/recipes" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/recipes" "github.com/spf13/cobra" ) @@ -52,13 +52,13 @@ You can specify parameters using the '--parameter' flag ('-p' for short). Parame `, Example: ` # Add a recipe to an environment -rad recipe register cosmosdb -e env_name -w workspace --template-kind bicep --template-path template_path --link-type Applications.Link/mongoDatabases +rad recipe register cosmosdb -e env_name -w workspace --template-kind bicep --template-path template_path --resource-type Applications.Datastores/mongoDatabases # Specify a parameter -rad recipe register cosmosdb -e env_name -w workspace --template-kind bicep --template-path template_path --link-type Applications.Link/mongoDatabases --parameters throughput=400 +rad recipe register cosmosdb -e env_name -w workspace --template-kind bicep --template-path template_path --resource-type Applications.Datastores/mongoDatabases --parameters throughput=400 # specify multiple parameters using a JSON parameter file -rad recipe register cosmosdb -e env_name -w workspace --template-kind bicep --template-path template_path --link-type Applications.Link/mongoDatabases --parameters @myfile.json +rad recipe register cosmosdb -e env_name -w workspace --template-kind bicep --template-path template_path --resource-type Applications.Datastores/mongoDatabases --parameters @myfile.json `, Args: cobra.ExactArgs(1), RunE: framework.RunCommand(runner), @@ -73,8 +73,8 @@ rad recipe register cosmosdb -e env_name -w workspace --template-kind bicep --te cmd.Flags().String("template-version", "", "specify the version for the terraform module.") cmd.Flags().String("template-path", "", "specify the path to the template provided by the recipe.") _ = cmd.MarkFlagRequired("template-path") - cmd.Flags().String("link-type", "", "specify the type of the link this recipe can be consumed by") - _ = cmd.MarkFlagRequired("link-type") + cmd.Flags().String("resource-type", "", "specify the type of the portable resource this recipe can be consumed by") + _ = cmd.MarkFlagRequired("resource-type") commonflags.AddParameterFlag(cmd) return cmd, runner @@ -89,7 +89,7 @@ type Runner struct { TemplateKind string TemplatePath string TemplateVersion string - LinkType string + ResourceType string RecipeName string Parameters map[string]map[string]any } @@ -106,7 +106,7 @@ func NewRunner(factory framework.Factory) *Runner { // Validate runs validation for the `rad recipe register` command. // -// Validate validates the command line args, sets the workspace, environment, template kind, template path, link type, +// Validate validates the command line args, sets the workspace, environment, template kind, template path, resource type, // recipe name, and parameters, and returns an error if any of these fail. func (r *Runner) Validate(cmd *cobra.Command, args []string) error { // Validate command line args @@ -130,11 +130,11 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { r.TemplatePath = templatePath r.TemplateVersion = templateVersion - linkType, err := cli.RequireLinkType(cmd) + resourceType, err := cli.GetResourceType(cmd) if err != nil { return err } - r.LinkType = linkType + r.ResourceType = resourceType recipeName, err := cli.RequireRecipeNameArgs(cmd, args) if err != nil { @@ -174,9 +174,9 @@ func (r *Runner) Run(ctx context.Context) error { envRecipes := envResource.Properties.Recipes if envRecipes == nil { - envRecipes = map[string]map[string]corerp.EnvironmentRecipePropertiesClassification{} + envRecipes = map[string]map[string]corerp.RecipePropertiesClassification{} } - var properties corerp.EnvironmentRecipePropertiesClassification + var properties corerp.RecipePropertiesClassification switch r.TemplateKind { case recipes.TemplateKindTerraform: properties = &corerp.TerraformRecipeProperties{ @@ -192,10 +192,10 @@ func (r *Runner) Run(ctx context.Context) error { Parameters: bicep.ConvertToMapStringInterface(r.Parameters), } } - if val, ok := envRecipes[r.LinkType]; ok { + if val, ok := envRecipes[r.ResourceType]; ok { val[r.RecipeName] = properties } else { - envRecipes[r.LinkType] = map[string]corerp.EnvironmentRecipePropertiesClassification{ + envRecipes[r.ResourceType] = map[string]corerp.RecipePropertiesClassification{ r.RecipeName: properties, } } diff --git a/pkg/cli/cmd/recipe/register/register_test.go b/pkg/cli/cmd/recipe/register/register_test.go index 65997d820a..ac66ccf7bc 100644 --- a/pkg/cli/cmd/recipe/register/register_test.go +++ b/pkg/cli/cmd/recipe/register/register_test.go @@ -25,17 +25,17 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" ) func Test_CommandValidation(t *testing.T) { @@ -47,7 +47,7 @@ func Test_Validate(t *testing.T) { testcases := []radcli.ValidateInput{ { Name: "Valid Register Command with parameters", - Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--link-type", linkrp.MongoDatabasesResourceType, "--parameters", "a=b"}, + Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--resource-type", portableresources.MongoDatabasesResourceType, "--parameters", "a=b"}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -56,7 +56,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Valid Register Command for terraform recipe", - Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindTerraform, "--template-path", "test_template", "--link-type", linkrp.MongoDatabasesResourceType, "--template-version", "1.1.0"}, + Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindTerraform, "--template-path", "test_template", "--resource-type", portableresources.MongoDatabasesResourceType, "--template-version", "1.1.0"}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -65,7 +65,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Valid Register Command with parameters passed as file", - Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--link-type", linkrp.MongoDatabasesResourceType, "--parameters", "@testdata/recipeparam.json"}, + Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--resource-type", portableresources.MongoDatabasesResourceType, "--parameters", "@testdata/recipeparam.json"}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -74,7 +74,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Register Command with fallback workspace", - Input: []string{"-e", "myenvironment", "test_recipe", "--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--link-type", linkrp.MongoDatabasesResourceType}, + Input: []string{"-e", "myenvironment", "test_recipe", "--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--resource-type", portableresources.MongoDatabasesResourceType}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -83,7 +83,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Register Command without name", - Input: []string{"--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--link-type", linkrp.MongoDatabasesResourceType}, + Input: []string{"--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template", "--resource-type", portableresources.MongoDatabasesResourceType}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -92,7 +92,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Register Command without template kind", - Input: []string{"test_recipe", "--template-path", "test_template", "--link-type", linkrp.MongoDatabasesResourceType}, + Input: []string{"test_recipe", "--template-path", "test_template", "--resource-type", portableresources.MongoDatabasesResourceType}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -101,7 +101,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Register Command without template path", - Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindBicep, "--link-type", linkrp.MongoDatabasesResourceType}, + Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindBicep, "--resource-type", portableresources.MongoDatabasesResourceType}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -109,7 +109,7 @@ func Test_Validate(t *testing.T) { }, }, { - Name: "Register Command without link-type", + Name: "Register Command without resource-type", Input: []string{"test_recipe", "--template-kind", recipes.TemplateKindBicep, "--template-path", "test_template"}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ @@ -134,8 +134,8 @@ func Test_Run(t *testing.T) { t.Run("Register recipe Success", func(t *testing.T) { ctrl := gomock.NewController(t) - testRecipes := map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + testRecipes := map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -175,7 +175,7 @@ func Test_Run(t *testing.T) { TemplateKind: recipes.TemplateKindTerraform, TemplatePath: "Azure/cosmosdb/azurerm", TemplateVersion: "1.1.0", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, RecipeName: "cosmosDB_new", } @@ -197,8 +197,8 @@ func Test_Run(t *testing.T) { t.Run("Register recipe Failure", func(t *testing.T) { ctrl := gomock.NewController(t) - testRecipes := map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + testRecipes := map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), }, @@ -244,7 +244,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, RecipeName: "cosmosDB_new", } @@ -271,7 +271,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, RecipeName: "cosmosDB_new", } @@ -284,8 +284,8 @@ func Test_Run(t *testing.T) { ctrl := gomock.NewController(t) testEnvProperties := &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -324,7 +324,7 @@ func Test_Run(t *testing.T) { Workspace: &workspaces.Workspace{Environment: "kind-kind"}, TemplateKind: recipes.TemplateKindBicep, TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/rediscaches:v1", - LinkType: linkrp.RedisCachesResourceType, + ResourceType: portableresources.RedisCachesResourceType, RecipeName: "redis", Parameters: map[string]map[string]any{}, } @@ -347,8 +347,8 @@ func Test_Run(t *testing.T) { t.Run("Register recipe with no namespace", func(t *testing.T) { ctrl := gomock.NewController(t) testEnvProperties := &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -380,7 +380,7 @@ func Test_Run(t *testing.T) { Workspace: &workspaces.Workspace{Environment: "kind-kind"}, TemplateKind: recipes.TemplateKindBicep, TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, RecipeName: "cosmosDB_no_namespace", } @@ -432,7 +432,7 @@ func Test_Run(t *testing.T) { Workspace: &workspaces.Workspace{Environment: "kind-kind"}, TemplateKind: recipes.TemplateKindBicep, TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/rediscaches:v1", - LinkType: linkrp.RedisCachesResourceType, + ResourceType: portableresources.RedisCachesResourceType, RecipeName: "redis", } diff --git a/pkg/cli/cmd/recipe/show/show.go b/pkg/cli/cmd/recipe/show/show.go index f111cacf2a..b051cd0050 100644 --- a/pkg/cli/cmd/recipe/show/show.go +++ b/pkg/cli/cmd/recipe/show/show.go @@ -21,15 +21,15 @@ import ( "fmt" "sort" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - types "github.com/project-radius/radius/pkg/cli/cmd/recipe" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + types "github.com/radius-project/radius/pkg/cli/cmd/recipe" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" "github.com/spf13/cobra" ) @@ -68,8 +68,8 @@ rad recipe show redis-dev --group dev --environment dev`, commonflags.AddWorkspaceFlag(cmd) commonflags.AddResourceGroupFlag(cmd) commonflags.AddEnvironmentNameFlag(cmd) - commonflags.AddLinkTypeFlag(cmd) - _ = cmd.MarkFlagRequired(cli.LinkTypeFlag) + commonflags.AddResourceTypeFlag(cmd) + _ = cmd.MarkFlagRequired(cli.ResourceTypeFlag) return cmd, runner } @@ -81,7 +81,7 @@ type Runner struct { Output output.Interface Workspace *workspaces.Workspace RecipeName string - LinkType string + ResourceType string Format string } @@ -98,7 +98,7 @@ func NewRunner(factory framework.Factory) *Runner { // // Validate takes in a command and a slice of strings and validates the command line arguments, setting the workspace, environment, -// recipe name, link type and output format in the Runner struct. It returns an error if any of the arguments are invalid. +// recipe name, portable resource type and output format in the Runner struct. It returns an error if any of the arguments are invalid. func (r *Runner) Validate(cmd *cobra.Command, args []string) error { // Validate command line args workspace, err := cli.RequireWorkspace(cmd, r.ConfigHolder.Config, r.ConfigHolder.DirectoryConfig) @@ -123,11 +123,11 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { } r.RecipeName = recipeName - linkType, err := cli.RequireLinkType(cmd) + resourceType, err := cli.GetResourceType(cmd) if err != nil { return err } - r.LinkType = linkType + r.ResourceType = resourceType format, err := cli.RequireOutput(cmd) if err != nil { @@ -152,14 +152,14 @@ func (r *Runner) Run(ctx context.Context) error { return err } - recipeDetails, err := client.ShowRecipe(ctx, r.Workspace.Environment, v20220315privatepreview.Recipe{Name: &r.RecipeName, LinkType: &r.LinkType}) + recipeDetails, err := client.ShowRecipe(ctx, r.Workspace.Environment, v20220315privatepreview.RecipeGetMetadata{Name: &r.RecipeName, ResourceType: &r.ResourceType}) if err != nil { return err } recipe := types.EnvironmentRecipe{ Name: r.RecipeName, - LinkType: r.LinkType, + ResourceType: r.ResourceType, TemplatePath: *recipeDetails.TemplatePath, TemplateKind: *recipeDetails.TemplateKind, } diff --git a/pkg/cli/cmd/recipe/show/show_test.go b/pkg/cli/cmd/recipe/show/show_test.go index ef72baa529..903ba99381 100644 --- a/pkg/cli/cmd/recipe/show/show_test.go +++ b/pkg/cli/cmd/recipe/show/show_test.go @@ -22,18 +22,18 @@ import ( "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - types "github.com/project-radius/radius/pkg/cli/cmd/recipe" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + types "github.com/radius-project/radius/pkg/cli/cmd/recipe" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) @@ -46,7 +46,7 @@ func Test_Validate(t *testing.T) { testcases := []radcli.ValidateInput{ { Name: "Valid Show Command", - Input: []string{"recipeName", "--link-type", "link-type"}, + Input: []string{"recipeName", "--resource-type", "resource-type"}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -55,7 +55,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Show Command with incorrect fallback workspace", - Input: []string{"-e", "my-env", "-g", "my-env", "recipeName", "--link-type", "link-type"}, + Input: []string{"-e", "my-env", "-g", "my-env", "recipeName", "--resource-type", "resource-type"}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -64,7 +64,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Show Command with too many positional args", - Input: []string{"recipeName", "arg2", "--link-type", "link-type"}, + Input: []string{"recipeName", "arg2", "--resource-type", "resource-type"}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -73,7 +73,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Show Command with fallback workspace", - Input: []string{"-e", "my-env", "-w", "test-workspace", "recipeName", "--link-type", "link-type"}, + Input: []string{"-e", "my-env", "-w", "test-workspace", "recipeName", "--resource-type", "resource-type"}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -81,7 +81,7 @@ func Test_Validate(t *testing.T) { }, }, { - Name: "Show Command without LinkType", + Name: "Show Command without ResourceType", Input: []string{"recipeName"}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ @@ -96,7 +96,7 @@ func Test_Validate(t *testing.T) { func Test_Run(t *testing.T) { t.Run("Show bicep recipe details - Success", func(t *testing.T) { ctrl := gomock.NewController(t) - envRecipe := v20220315privatepreview.RecipeMetadataProperties{ + envRecipe := v20220315privatepreview.RecipeGetMetadataResponse{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), Parameters: map[string]any{ @@ -111,7 +111,7 @@ func Test_Run(t *testing.T) { } recipe := types.EnvironmentRecipe{ Name: "cosmosDB", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, TemplateKind: recipes.TemplateKindBicep, TemplatePath: "testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1", } @@ -145,7 +145,7 @@ func Test_Run(t *testing.T) { Workspace: &workspaces.Workspace{}, Format: "table", RecipeName: "cosmosDB", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, } err := runner.Run(context.Background()) @@ -171,7 +171,7 @@ func Test_Run(t *testing.T) { t.Run("Show terraformn recipe details - Success", func(t *testing.T) { ctrl := gomock.NewController(t) - envRecipe := v20220315privatepreview.RecipeMetadataProperties{ + envRecipe := v20220315privatepreview.RecipeGetMetadataResponse{ TemplateKind: to.Ptr(recipes.TemplateKindTerraform), TemplatePath: to.Ptr("Azure/cosmosdb/azurerm"), TemplateVersion: to.Ptr("1.1.0"), @@ -187,7 +187,7 @@ func Test_Run(t *testing.T) { } recipe := types.EnvironmentRecipe{ Name: "cosmosDB", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, TemplateKind: recipes.TemplateKindTerraform, TemplatePath: "Azure/cosmosdb/azurerm", TemplateVersion: "1.1.0", @@ -222,7 +222,7 @@ func Test_Run(t *testing.T) { Workspace: &workspaces.Workspace{}, Format: "table", RecipeName: "cosmosDB", - LinkType: linkrp.MongoDatabasesResourceType, + ResourceType: portableresources.MongoDatabasesResourceType, } err := runner.Run(context.Background()) diff --git a/pkg/cli/cmd/recipe/types.go b/pkg/cli/cmd/recipe/types.go index 6c4ff26ce7..7b8104e84d 100644 --- a/pkg/cli/cmd/recipe/types.go +++ b/pkg/cli/cmd/recipe/types.go @@ -18,7 +18,7 @@ package recipe type EnvironmentRecipe struct { Name string `json:"name"` - LinkType string `json:"linkType"` + ResourceType string `json:"resourceType"` TemplateKind string `json:"templateKind"` TemplatePath string `json:"templatePath"` TemplateVersion string `json:"templateVersion"` diff --git a/pkg/cli/cmd/recipe/unregister/unregister.go b/pkg/cli/cmd/recipe/unregister/unregister.go index 327bec3c95..0d529503c0 100644 --- a/pkg/cli/cmd/recipe/unregister/unregister.go +++ b/pkg/cli/cmd/recipe/unregister/unregister.go @@ -19,15 +19,15 @@ package unregister import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) @@ -35,7 +35,7 @@ import ( // // NewCommand creates a new cobra command for unregistering a recipe from an environment, which takes in a factory and returns a cobra command -// and a runner. It also sets up flags for output, workspace, resource group, environment name and link type, with link type being a required flag. +// and a runner. It also sets up flags for output, workspace, resource group, environment name and portable resource type, with resource-type being a required flag. func NewCommand(factory framework.Factory) (*cobra.Command, framework.Runner) { runner := NewRunner(factory) @@ -52,8 +52,8 @@ func NewCommand(factory framework.Factory) (*cobra.Command, framework.Runner) { commonflags.AddWorkspaceFlag(cmd) commonflags.AddResourceGroupFlag(cmd) commonflags.AddEnvironmentNameFlag(cmd) - commonflags.AddLinkTypeFlag(cmd) - _ = cmd.MarkFlagRequired(cli.LinkTypeFlag) + commonflags.AddResourceTypeFlag(cmd) + _ = cmd.MarkFlagRequired(cli.ResourceTypeFlag) return cmd, runner } @@ -65,7 +65,7 @@ type Runner struct { Output output.Interface Workspace *workspaces.Workspace RecipeName string - LinkType string + ResourceType string } // NewRunner creates a new instance of the `rad recipe unregister` runner. @@ -80,7 +80,7 @@ func NewRunner(factory framework.Factory) *Runner { // Validate runs validation for the `rad recipe unregister` command. // -// // Runner.Validate checks the command line arguments for a workspace, environment, recipe name, and link type, and +// // Runner.Validate checks the command line arguments for a workspace, environment, recipe name, and resource type, and // returns an error if any of these are not present. func (r *Runner) Validate(cmd *cobra.Command, args []string) error { // Validate command line args @@ -102,11 +102,11 @@ func (r *Runner) Validate(cmd *cobra.Command, args []string) error { } r.RecipeName = recipeName - linkType, err := cli.RequireLinkType(cmd) + resourceType, err := cli.GetResourceType(cmd) if err != nil { return err } - r.LinkType = linkType + r.ResourceType = resourceType return nil } @@ -122,14 +122,14 @@ func (r *Runner) Run(ctx context.Context) error { return err } - envResource, recipeProperties, err := cmd.CheckIfRecipeExists(ctx, client, r.Workspace.Environment, r.RecipeName, r.LinkType) + envResource, recipeProperties, err := cmd.CheckIfRecipeExists(ctx, client, r.Workspace.Environment, r.RecipeName, r.ResourceType) if err != nil { return err } - if val, ok := recipeProperties[r.LinkType]; ok { + if val, ok := recipeProperties[r.ResourceType]; ok { delete(val, r.RecipeName) if len(val) == 0 { - delete(recipeProperties, r.LinkType) + delete(recipeProperties, r.ResourceType) } } envResource.Properties.Recipes = recipeProperties diff --git a/pkg/cli/cmd/recipe/unregister/unregister_test.go b/pkg/cli/cmd/recipe/unregister/unregister_test.go index 47613d4923..e7b9302202 100644 --- a/pkg/cli/cmd/recipe/unregister/unregister_test.go +++ b/pkg/cli/cmd/recipe/unregister/unregister_test.go @@ -25,17 +25,17 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" ) func Test_CommandValidation(t *testing.T) { @@ -47,7 +47,7 @@ func Test_Validate(t *testing.T) { testcases := []radcli.ValidateInput{ { Name: "Valid Unregister Command", - Input: []string{"test_recipe", "--link-type", "link-type"}, + Input: []string{"test_recipe", "--resource-type", "resource-type"}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -56,7 +56,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Unregister Command with fallback workspace", - Input: []string{"-e", "my-env", "test_recipe", "--link-type", "link-type"}, + Input: []string{"-e", "my-env", "test_recipe", "--resource-type", "resource-type"}, ExpectedValid: true, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -74,7 +74,7 @@ func Test_Validate(t *testing.T) { }, { Name: "Unregister Command with too many args", - Input: []string{"foo", "bar", "foo1", "--link-type", "link-type"}, + Input: []string{"foo", "bar", "foo1", "--resource-type", "resource-type"}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ ConfigFilePath: "", @@ -82,7 +82,7 @@ func Test_Validate(t *testing.T) { }, }, { - Name: "Unregister Command without link type", + Name: "Unregister Command without resource type", Input: []string{"foo"}, ExpectedValid: false, ConfigHolder: framework.ConfigHolder{ @@ -100,8 +100,8 @@ func Test_Run(t *testing.T) { ctrl := gomock.NewController(t) testEnvProperties := &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -136,7 +136,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, RecipeName: "cosmosDB", - LinkType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } expectedOutput := []any{ @@ -158,8 +158,8 @@ func Test_Run(t *testing.T) { ctrl := gomock.NewController(t) testEnvProperties := &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), }, @@ -202,7 +202,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, RecipeName: "cosmosDB", - LinkType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } err := runner.Run(context.Background()) @@ -214,8 +214,8 @@ func Test_Run(t *testing.T) { ctrl := gomock.NewController(t) testEnvProperties := &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -247,7 +247,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, RecipeName: "cosmosDB", - LinkType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } expectedOutput := []any{ @@ -274,8 +274,8 @@ func Test_Run(t *testing.T) { Type: to.Ptr("applications.core/environments"), Location: to.Ptr(v1.LocationGlobal), Properties: &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "cosmosDB": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -297,14 +297,14 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, RecipeName: "cosmosDB1", - LinkType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } err := runner.Run(context.Background()) require.Error(t, err) }) - t.Run("Unregister recipe with linkType doesn't exist in the environment", func(t *testing.T) { + t.Run("Unregister recipe with resourceType doesn't exist in the environment", func(t *testing.T) { ctrl := gomock.NewController(t) envResource := v20220315privatepreview.EnvironmentResource{ ID: to.Ptr("/planes/radius/local/resourcegroups/kind-kind/providers/applications.core/environments/kind-kind"), @@ -312,8 +312,8 @@ func Test_Run(t *testing.T) { Type: to.Ptr("applications.core/environments"), Location: to.Ptr(v1.LocationGlobal), Properties: &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "testResource": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), @@ -335,7 +335,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, RecipeName: "testResource", - LinkType: "Applications.Link/redisCaches", + ResourceType: "Applications.Datastores/redisCaches", } err := runner.Run(context.Background()) @@ -365,7 +365,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, RecipeName: "cosmosDB", - LinkType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } err := runner.Run(context.Background()) @@ -376,14 +376,14 @@ func Test_Run(t *testing.T) { ctrl := gomock.NewController(t) testEnvProperties := &v20220315privatepreview.EnvironmentProperties{ - Recipes: map[string]map[string]v20220315privatepreview.EnvironmentRecipePropertiesClassification{ - linkrp.MongoDatabasesResourceType: { + Recipes: map[string]map[string]v20220315privatepreview.RecipePropertiesClassification{ + portableresources.MongoDatabasesResourceType: { "testResource": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1"), }, }, - linkrp.RedisCachesResourceType: { + portableresources.RedisCachesResourceType: { "testResource": &v20220315privatepreview.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("testpublicrecipe.azurecr.io/bicep/modules/rediscaches:v1"), @@ -418,7 +418,7 @@ func Test_Run(t *testing.T) { Output: outputSink, Workspace: &workspaces.Workspace{Environment: "kind-kind"}, RecipeName: "testResource", - LinkType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } expectedOutput := []any{ diff --git a/pkg/cli/cmd/resource/delete/delete.go b/pkg/cli/cmd/resource/delete/delete.go index 4439cb0795..cb1035494b 100644 --- a/pkg/cli/cmd/resource/delete/delete.go +++ b/pkg/cli/cmd/resource/delete/delete.go @@ -22,13 +22,13 @@ import ( "net/http" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/resource/delete/delete_test.go b/pkg/cli/cmd/resource/delete/delete_test.go index 83005a6f84..348c043c7c 100644 --- a/pkg/cli/cmd/resource/delete/delete_test.go +++ b/pkg/cli/cmd/resource/delete/delete_test.go @@ -22,13 +22,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) @@ -158,19 +158,19 @@ func Test_Run(t *testing.T) { t.Run("Success: Prompt Confirmed", func(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - + promptMock := prompt.NewMockInterface(ctrl) promptMock.EXPECT(). GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-container", "containers")). Return(prompt.ConfirmYes, nil). Times(1) - + appManagementClient := clients.NewMockApplicationsManagementClient(ctrl) appManagementClient.EXPECT(). DeleteResource(gomock.Any(), "containers", "test-container"). Return(true, nil). Times(1) - + workspace := &workspaces.Workspace{ Connection: map[string]any{ "kind": "kubernetes", @@ -189,29 +189,29 @@ func Test_Run(t *testing.T) { Format: "table", InputPrompter: promptMock, } - + err := runner.Run(context.Background()) require.NoError(t, err) - + expected := []any{ output.LogOutput{ Format: "Resource deleted", }, } - + require.Equal(t, expected, outputSink.Writes) }) - + t.Run("Success: Prompt Cancelled", func(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() - + promptMock := prompt.NewMockInterface(ctrl) promptMock.EXPECT(). GetListInput([]string{prompt.ConfirmNo, prompt.ConfirmYes}, fmt.Sprintf(deleteConfirmation, "test-container", "containers")). Return(prompt.ConfirmNo, nil). Times(1) - + workspace := &workspaces.Workspace{ Connection: map[string]any{ "kind": "kubernetes", @@ -222,14 +222,14 @@ func Test_Run(t *testing.T) { } outputSink := &output.MockOutput{} runner := &Runner{ - InputPrompter: promptMock, - Workspace: workspace, - Format: "table", - Output: outputSink, - ResourceType: "containers", - ResourceName: "test-container", + InputPrompter: promptMock, + Workspace: workspace, + Format: "table", + Output: outputSink, + ResourceType: "containers", + ResourceName: "test-container", } - + err := runner.Run(context.Background()) require.NoError(t, err) diff --git a/pkg/cli/cmd/resource/list/list.go b/pkg/cli/cmd/resource/list/list.go index b1519bf323..ee58655818 100644 --- a/pkg/cli/cmd/resource/list/list.go +++ b/pkg/cli/cmd/resource/list/list.go @@ -19,15 +19,15 @@ package list import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/resource/list/list_test.go b/pkg/cli/cmd/resource/list/list_test.go index d4dd1aa943..9ab7634129 100644 --- a/pkg/cli/cmd/resource/list/list_test.go +++ b/pkg/cli/cmd/resource/list/list_test.go @@ -21,16 +21,16 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/resource/show/show.go b/pkg/cli/cmd/resource/show/show.go index 2dddeb6a4a..f5cb788b6d 100644 --- a/pkg/cli/cmd/resource/show/show.go +++ b/pkg/cli/cmd/resource/show/show.go @@ -19,13 +19,13 @@ package show import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/resource/show/show_test.go b/pkg/cli/cmd/resource/show/show_test.go index c6af002756..5f5d1a79cf 100644 --- a/pkg/cli/cmd/resource/show/show_test.go +++ b/pkg/cli/cmd/resource/show/show_test.go @@ -21,13 +21,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/run/run.go b/pkg/cli/cmd/run/run.go index 86ff063980..f211628cf2 100644 --- a/pkg/cli/cmd/run/run.go +++ b/pkg/cli/cmd/run/run.go @@ -23,14 +23,14 @@ import ( "os" "github.com/fatih/color" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - deploycmd "github.com/project-radius/radius/pkg/cli/cmd/deploy" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/kubernetes/logstream" - "github.com/project-radius/radius/pkg/cli/kubernetes/portforward" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + deploycmd "github.com/radius-project/radius/pkg/cli/cmd/deploy" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/kubernetes/logstream" + "github.com/radius-project/radius/pkg/cli/kubernetes/portforward" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" "github.com/spf13/cobra" "golang.org/x/sync/errgroup" ) diff --git a/pkg/cli/cmd/run/run_test.go b/pkg/cli/cmd/run/run_test.go index 6e5b068142..9e537c388f 100644 --- a/pkg/cli/cmd/run/run_test.go +++ b/pkg/cli/cmd/run/run_test.go @@ -24,21 +24,21 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clients" - deploycmd "github.com/project-radius/radius/pkg/cli/cmd/deploy" - "github.com/project-radius/radius/pkg/cli/config" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/deploy" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/kubernetes/logstream" - "github.com/project-radius/radius/pkg/cli/kubernetes/portforward" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/radcli" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clients" + deploycmd "github.com/radius-project/radius/pkg/cli/cmd/deploy" + "github.com/radius-project/radius/pkg/cli/config" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/deploy" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/kubernetes/logstream" + "github.com/radius-project/radius/pkg/cli/kubernetes/portforward" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/radcli" + "github.com/radius-project/radius/test/testcontext" ) func Test_CommandValidation(t *testing.T) { diff --git a/pkg/cli/cmd/uninstall/kubernetes/kubernetes.go b/pkg/cli/cmd/uninstall/kubernetes/kubernetes.go index f6b5ce208f..d6bbb53fe2 100644 --- a/pkg/cli/cmd/uninstall/kubernetes/kubernetes.go +++ b/pkg/cli/cmd/uninstall/kubernetes/kubernetes.go @@ -19,10 +19,10 @@ package kubernetes import ( "context" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/output" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/uninstall/kubernetes/kubernetes_test.go b/pkg/cli/cmd/uninstall/kubernetes/kubernetes_test.go index 9fbf713c26..381a12e765 100644 --- a/pkg/cli/cmd/uninstall/kubernetes/kubernetes_test.go +++ b/pkg/cli/cmd/uninstall/kubernetes/kubernetes_test.go @@ -21,9 +21,9 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/utils.go b/pkg/cli/cmd/utils.go index 23a4382ef6..52637fbdff 100644 --- a/pkg/cli/cmd/utils.go +++ b/pkg/cli/cmd/utils.go @@ -20,12 +20,12 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" ) // CreateEnvProviders forms the provider scope from the given @@ -80,7 +80,7 @@ func GetNamespace(envResource corerp.EnvironmentResource) string { // CheckIfRecipeExists checks if a given recipe exists in a given environment and returns the environment resource, recipe // properties and an error if the recipe does not exist. -func CheckIfRecipeExists(ctx context.Context, client clients.ApplicationsManagementClient, environmentName string, recipeName string, resourceType string) (corerp.EnvironmentResource, map[string]map[string]corerp.EnvironmentRecipePropertiesClassification, error) { +func CheckIfRecipeExists(ctx context.Context, client clients.ApplicationsManagementClient, environmentName string, recipeName string, resourceType string) (corerp.EnvironmentResource, map[string]map[string]corerp.RecipePropertiesClassification, error) { envResource, err := client.GetEnvDetails(ctx, environmentName) if err != nil { return corerp.EnvironmentResource{}, nil, err diff --git a/pkg/cli/cmd/utils_test.go b/pkg/cli/cmd/utils_test.go index 4e45d137e9..91626abd9c 100644 --- a/pkg/cli/cmd/utils_test.go +++ b/pkg/cli/cmd/utils_test.go @@ -20,11 +20,11 @@ import ( "errors" "testing" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/clierrors" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/clierrors" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/workspace/create/create.go b/pkg/cli/cmd/workspace/create/create.go index 065b2b0eef..2375d02982 100644 --- a/pkg/cli/cmd/workspace/create/create.go +++ b/pkg/cli/cmd/workspace/create/create.go @@ -21,16 +21,16 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clierrors" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clierrors" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/workspace/create/create_test.go b/pkg/cli/cmd/workspace/create/create_test.go index 61eedfdead..0f66e55ba0 100644 --- a/pkg/cli/cmd/workspace/create/create_test.go +++ b/pkg/cli/cmd/workspace/create/create_test.go @@ -22,13 +22,13 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - corerp "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + corerp "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" "k8s.io/client-go/tools/clientcmd/api" ) diff --git a/pkg/cli/cmd/workspace/delete/delete.go b/pkg/cli/cmd/workspace/delete/delete.go index 9df55649db..29c83b9eb3 100644 --- a/pkg/cli/cmd/workspace/delete/delete.go +++ b/pkg/cli/cmd/workspace/delete/delete.go @@ -20,12 +20,12 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/workspace/delete/delete_test.go b/pkg/cli/cmd/workspace/delete/delete_test.go index 89c2319fec..121a6111de 100644 --- a/pkg/cli/cmd/workspace/delete/delete_test.go +++ b/pkg/cli/cmd/workspace/delete/delete_test.go @@ -22,11 +22,11 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/workspace/list/list.go b/pkg/cli/cmd/workspace/list/list.go index aa84796f1e..e50bc7dc64 100644 --- a/pkg/cli/cmd/workspace/list/list.go +++ b/pkg/cli/cmd/workspace/list/list.go @@ -20,12 +20,12 @@ import ( "context" "sort" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/workspace/list/list_test.go b/pkg/cli/cmd/workspace/list/list_test.go index 4743e7cfad..3eabee8f8c 100644 --- a/pkg/cli/cmd/workspace/list/list_test.go +++ b/pkg/cli/cmd/workspace/list/list_test.go @@ -20,12 +20,12 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/spf13/viper" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/workspace/show/show.go b/pkg/cli/cmd/workspace/show/show.go index 51bb00a677..1e0d1a7316 100644 --- a/pkg/cli/cmd/workspace/show/show.go +++ b/pkg/cli/cmd/workspace/show/show.go @@ -19,12 +19,12 @@ package show import ( "context" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/workspace/show/show_test.go b/pkg/cli/cmd/workspace/show/show_test.go index e425bca8e0..03207ac9c1 100644 --- a/pkg/cli/cmd/workspace/show/show_test.go +++ b/pkg/cli/cmd/workspace/show/show_test.go @@ -20,11 +20,11 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/cmd/workspace/switch/switch.go b/pkg/cli/cmd/workspace/switch/switch.go index 60cb17160c..35a596f39d 100644 --- a/pkg/cli/cmd/workspace/switch/switch.go +++ b/pkg/cli/cmd/workspace/switch/switch.go @@ -20,11 +20,11 @@ import ( "context" "strings" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/cmd/commonflags" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/cmd/commonflags" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/cobra" ) diff --git a/pkg/cli/cmd/workspace/switch/switch_test.go b/pkg/cli/cmd/workspace/switch/switch_test.go index 4f7d35453b..92eaf31b90 100644 --- a/pkg/cli/cmd/workspace/switch/switch_test.go +++ b/pkg/cli/cmd/workspace/switch/switch_test.go @@ -21,11 +21,11 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/test/radcli" "github.com/spf13/viper" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/config.go b/pkg/cli/config.go index 6f85f83722..a865588dab 100644 --- a/pkg/cli/config.go +++ b/pkg/cli/config.go @@ -33,8 +33,8 @@ import ( "github.com/spf13/viper" "golang.org/x/text/cases" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/workspaces" ) // EnvironmentKey is the key used for the environment section diff --git a/pkg/cli/config_test.go b/pkg/cli/config_test.go index 8d4c15d148..c452a37ce1 100644 --- a/pkg/cli/config_test.go +++ b/pkg/cli/config_test.go @@ -20,7 +20,7 @@ import ( "bytes" "testing" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/viper" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/connections/factory.go b/pkg/cli/connections/factory.go index 2f6b15176f..afb24877b5 100644 --- a/pkg/cli/connections/factory.go +++ b/pkg/cli/connections/factory.go @@ -22,18 +22,19 @@ import ( "fmt" "strings" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/cli/clierrors" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/deployment" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/workspaces" - "github.com/project-radius/radius/pkg/sdk" - sdkclients "github.com/project-radius/radius/pkg/sdk/clients" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/resources" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/cli/clierrors" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/deployment" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/sdk" + sdkclients "github.com/radius-project/radius/pkg/sdk/clients" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" ) // DefaultFactory provides easy access to the default implementation of the factory. DO NOT modify this in your code. Even if it's for tests. DO NOT DO IT. @@ -95,7 +96,7 @@ func (i *impl) CreateDeploymentClient(ctx context.Context, workspace workspaces. return &deployment.ResourceDeploymentClient{ Client: dc, OperationsClient: doc, - RadiusResourceGroup: id.FindScope(resources.ResourceGroupsSegment), + RadiusResourceGroup: id.FindScope(resources_radius.ScopeResourceGroups), }, nil } @@ -207,12 +208,12 @@ func (*impl) CreateCredentialManagementClient(ctx context.Context, workspace wor clientOptions := sdk.NewClientOptions(connection) - azureCredentialClient, err := v20220901privatepreview.NewAzureCredentialClient(&aztoken.AnonymousCredential{}, clientOptions) + azureCredentialClient, err := v20220901privatepreview.NewAzureCredentialsClient(&aztoken.AnonymousCredential{}, clientOptions) if err != nil { return nil, err } - awsCredentialClient, err := v20220901privatepreview.NewAwsCredentialClient(&aztoken.AnonymousCredential{}, clientOptions) + awsCredentialClient, err := v20220901privatepreview.NewAwsCredentialsClient(&aztoken.AnonymousCredential{}, clientOptions) if err != nil { return nil, err } diff --git a/pkg/cli/connections/mock_factory.go b/pkg/cli/connections/mock_factory.go index 5b97f76b7b..7bc7cc820f 100644 --- a/pkg/cli/connections/mock_factory.go +++ b/pkg/cli/connections/mock_factory.go @@ -19,9 +19,9 @@ package connections import ( "context" - "github.com/project-radius/radius/pkg/cli/clients" - cli_credential "github.com/project-radius/radius/pkg/cli/credential" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli/clients" + cli_credential "github.com/radius-project/radius/pkg/cli/credential" + "github.com/radius-project/radius/pkg/cli/workspaces" ) var _ Factory = (*MockFactory)(nil) diff --git a/pkg/cli/credential/aws_credential_management.go b/pkg/cli/credential/aws_credential_management.go index c5e54f622d..bec1bec632 100644 --- a/pkg/cli/credential/aws_credential_management.go +++ b/pkg/cli/credential/aws_credential_management.go @@ -22,15 +22,15 @@ import ( "strings" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/project-radius/radius/pkg/cli/clierrors" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/cli/clierrors" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) -//go:generate mockgen -destination=./mock_aws_credential_management.go -package=credential -self_package github.com/project-radius/radius/pkg/cli/credential github.com/project-radius/radius/pkg/cli/credential AWSCredentialManagementClientInterface +//go:generate mockgen -destination=./mock_aws_credential_management.go -package=credential -self_package github.com/radius-project/radius/pkg/cli/credential github.com/radius-project/radius/pkg/cli/credential AWSCredentialManagementClientInterface // AWSCredentialManagementClient is used to interface with cloud provider configuration and credentials. type AWSCredentialManagementClient struct { - AWSCredentialClient ucp.AwsCredentialClient + AWSCredentialClient ucp.AwsCredentialsClient } const ( @@ -53,7 +53,7 @@ type AWSCredentialManagementClientInterface interface { // List lists the credentials registered with all ucp provider planes. List(ctx context.Context) ([]CloudProviderStatus, error) // Put registers an AWS credential with the respective ucp provider plane. - Put(ctx context.Context, credential_config ucp.AWSCredentialResource) error + Put(ctx context.Context, credential_config ucp.AwsCredentialResource) error // Delete unregisters credential from the given ucp provider plane. Delete(ctx context.Context, name string) (bool, error) } @@ -63,7 +63,7 @@ type AWSCredentialManagementClientInterface interface { // "Put" checks if the credential type is "AWSCredential" and if so, creates or updates the credential in the AWS plane, // otherwise it returns an error. -func (cpm *AWSCredentialManagementClient) Put(ctx context.Context, credential ucp.AWSCredentialResource) error { +func (cpm *AWSCredentialManagementClient) Put(ctx context.Context, credential ucp.AwsCredentialResource) error { if strings.EqualFold(*credential.Type, AWSCredential) { _, err := cpm.AWSCredentialClient.CreateOrUpdate(ctx, AWSPlaneName, defaultSecretName, credential, nil) return err @@ -84,7 +84,7 @@ func (cpm *AWSCredentialManagementClient) Get(ctx context.Context, credentialNam if err != nil { return ProviderCredentialConfiguration{}, err } - awsAccessKeyCredentials, ok := resp.AWSCredentialResource.Properties.(*ucp.AWSAccessKeyCredentialProperties) + awsAccessKeyCredentials, ok := resp.AwsCredentialResource.Properties.(*ucp.AwsAccessKeyCredentialProperties) if !ok { return ProviderCredentialConfiguration{}, clierrors.Message("Unable to find credentials for cloud provider %s.", AWSCredential) } @@ -108,15 +108,15 @@ func (cpm *AWSCredentialManagementClient) Get(ctx context.Context, credentialNam // enabled status of each credential. If an error occurs, an error is returned. func (cpm *AWSCredentialManagementClient) List(ctx context.Context) ([]CloudProviderStatus, error) { // list AWS credential - var providerList []*ucp.AWSCredentialResource + var providerList []*ucp.AwsCredentialResource - pager := cpm.AWSCredentialClient.NewListByRootScopePager(AWSPlaneName, nil) + pager := cpm.AWSCredentialClient.NewListPager(AWSPlaneName, nil) for pager.More() { nextPage, err := pager.NextPage(ctx) if err != nil { return nil, err } - credList := nextPage.AWSCredentialResourceListResult.Value + credList := nextPage.AwsCredentialResourceListResult.Value providerList = append(providerList, credList...) } diff --git a/pkg/cli/credential/azure_credential_management.go b/pkg/cli/credential/azure_credential_management.go index a387cca1c5..f17c63a559 100644 --- a/pkg/cli/credential/azure_credential_management.go +++ b/pkg/cli/credential/azure_credential_management.go @@ -22,15 +22,15 @@ import ( "strings" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/project-radius/radius/pkg/cli/clierrors" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/cli/clierrors" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) -//go:generate mockgen -destination=./mock_azure_credential_management.go -package=credential -self_package github.com/project-radius/radius/pkg/cli/credential github.com/project-radius/radius/pkg/cli/credential AzureCredentialManagementClientInterface +//go:generate mockgen -destination=./mock_azure_credential_management.go -package=credential -self_package github.com/radius-project/radius/pkg/cli/credential github.com/radius-project/radius/pkg/cli/credential AzureCredentialManagementClientInterface // AzureCredentialManagementClient is used to interface with cloud provider configuration and credentials. type AzureCredentialManagementClient struct { - AzureCredentialClient ucp.AzureCredentialClient + AzureCredentialClient ucp.AzureCredentialsClient } // AzureCredentialManagementClient is used to interface with cloud provider configuration and credentials. @@ -136,7 +136,7 @@ func (cpm *AzureCredentialManagementClient) Get(ctx context.Context, credentialN }, AzureCredentials: &AzureCredentialProperties{ ClientID: azureServicePrincipal.ClientID, - Kind: azureServicePrincipal.Kind, + Kind: (*string)(azureServicePrincipal.Kind), TenantID: azureServicePrincipal.TenantID, }, } @@ -153,7 +153,7 @@ func (cpm *AzureCredentialManagementClient) List(ctx context.Context) ([]CloudPr // list azure credential var providerList []*ucp.AzureCredentialResource - pager := cpm.AzureCredentialClient.NewListByRootScopePager(AzurePlaneName, nil) + pager := cpm.AzureCredentialClient.NewListPager(AzurePlaneName, nil) for pager.More() { nextPage, err := pager.NextPage(ctx) if err != nil { diff --git a/pkg/cli/credential/credential_management.go b/pkg/cli/credential/credential_management.go index ca92bf2c8b..5c53ab5418 100644 --- a/pkg/cli/credential/credential_management.go +++ b/pkg/cli/credential/credential_management.go @@ -20,8 +20,8 @@ import ( "context" "strings" - "github.com/project-radius/radius/pkg/cli/clients" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/cli/clients" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) const ( @@ -29,7 +29,7 @@ const ( AWSPlaneType = "aws" ) -//go:generate mockgen -destination=./mock_credentialmanagementclient.go -package=credential -self_package github.com/project-radius/radius/pkg/cli/credential github.com/project-radius/radius/pkg/cli/credential CredentialManagementClient +//go:generate mockgen -destination=./mock_credentialmanagementclient.go -package=credential -self_package github.com/radius-project/radius/pkg/cli/credential github.com/radius-project/radius/pkg/cli/credential CredentialManagementClient // CredentialManagementClient is used to interface with cloud provider configuration and credentials. type CredentialManagementClient interface { @@ -38,7 +38,7 @@ type CredentialManagementClient interface { // List lists the credentials registered with all ucp provider planes. List(ctx context.Context) ([]CloudProviderStatus, error) // PutAWS registers an AWS credential with the respective ucp provider plane. - PutAWS(ctx context.Context, credential_config ucp.AWSCredentialResource) error + PutAWS(ctx context.Context, credential_config ucp.AwsCredentialResource) error // PutAzure registers an Azure credential with the respective ucp provider plane. PutAzure(ctx context.Context, credential_config ucp.AzureCredentialResource) error // Delete unregisters credential from the given ucp provider plane. @@ -61,7 +61,7 @@ var _ CredentialManagementClient = (*UCPCredentialManagementClient)(nil) // // PutAWS function takes in a context and an AWSCredentialResource object and returns an error if the AWSClient.Put call fails. -func (cpm *UCPCredentialManagementClient) PutAWS(ctx context.Context, credential ucp.AWSCredentialResource) error { +func (cpm *UCPCredentialManagementClient) PutAWS(ctx context.Context, credential ucp.AwsCredentialResource) error { err := cpm.AWSClient.Put(ctx, credential) return err } diff --git a/pkg/cli/credential/credential_management_test.go b/pkg/cli/credential/credential_management_test.go index 78aa49593f..894094a915 100644 --- a/pkg/cli/credential/credential_management_test.go +++ b/pkg/cli/credential/credential_management_test.go @@ -24,10 +24,10 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/test/testcontext" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/test/testcontext" ) const ( @@ -62,7 +62,7 @@ func Test_AzureCredential_Put(t *testing.T) { Type: to.Ptr(AzureCredential), Properties: &ucp.AzureServicePrincipalProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, ClientID: to.Ptr(clientID), ClientSecret: to.Ptr("cool-client-secret"), @@ -105,7 +105,7 @@ func Test_AWSCredential_Put(t *testing.T) { name string planeType string planeName string - credential ucp.AWSCredentialResource + credential ucp.AwsCredentialResource err error setupMocks func(mockAzure MockAzureCredentialManagementClientInterface, mockAWS MockAWSCredentialManagementClientInterface, planeType string, planeName string) }{ @@ -113,13 +113,13 @@ func Test_AWSCredential_Put(t *testing.T) { name: "create aws credential success", planeType: AWSPlaneType, planeName: AWSPlaneName, - credential: ucp.AWSCredentialResource{ + credential: ucp.AwsCredentialResource{ Name: to.Ptr(awsProviderName), Location: to.Ptr(v1.LocationGlobal), Type: to.Ptr(AWSCredential), - Properties: &ucp.AWSAccessKeyCredentialProperties{ + Properties: &ucp.AwsAccessKeyCredentialProperties{ Storage: &ucp.CredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), }, AccessKeyID: to.Ptr("access-key-id"), SecretAccessKey: to.Ptr("secret-access-key"), diff --git a/pkg/cli/credential/mock_aws_credential_management.go b/pkg/cli/credential/mock_aws_credential_management.go index a7a8ec9658..bdb3993892 100644 --- a/pkg/cli/credential/mock_aws_credential_management.go +++ b/pkg/cli/credential/mock_aws_credential_management.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/credential (interfaces: AWSCredentialManagementClientInterface) +// Source: github.com/radius-project/radius/pkg/cli/credential (interfaces: AWSCredentialManagementClientInterface) // Package credential is a generated GoMock package. package credential @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) // MockAWSCredentialManagementClientInterface is a mock of AWSCredentialManagementClientInterface interface. @@ -81,7 +81,7 @@ func (mr *MockAWSCredentialManagementClientInterfaceMockRecorder) List(arg0 inte } // Put mocks base method. -func (m *MockAWSCredentialManagementClientInterface) Put(arg0 context.Context, arg1 v20220901privatepreview.AWSCredentialResource) error { +func (m *MockAWSCredentialManagementClientInterface) Put(arg0 context.Context, arg1 v20220901privatepreview.AwsCredentialResource) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Put", arg0, arg1) ret0, _ := ret[0].(error) diff --git a/pkg/cli/credential/mock_azure_credential_management.go b/pkg/cli/credential/mock_azure_credential_management.go index 5bc746c47e..55f15185f1 100644 --- a/pkg/cli/credential/mock_azure_credential_management.go +++ b/pkg/cli/credential/mock_azure_credential_management.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/credential (interfaces: AzureCredentialManagementClientInterface) +// Source: github.com/radius-project/radius/pkg/cli/credential (interfaces: AzureCredentialManagementClientInterface) // Package credential is a generated GoMock package. package credential @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) // MockAzureCredentialManagementClientInterface is a mock of AzureCredentialManagementClientInterface interface. diff --git a/pkg/cli/credential/mock_credentialmanagementclient.go b/pkg/cli/credential/mock_credentialmanagementclient.go index 2d7a5e61a8..cb0dd27f70 100644 --- a/pkg/cli/credential/mock_credentialmanagementclient.go +++ b/pkg/cli/credential/mock_credentialmanagementclient.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/credential (interfaces: CredentialManagementClient) +// Source: github.com/radius-project/radius/pkg/cli/credential (interfaces: CredentialManagementClient) // Package credential is a generated GoMock package. package credential @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" ) // MockCredentialManagementClient is a mock of CredentialManagementClient interface. @@ -81,7 +81,7 @@ func (mr *MockCredentialManagementClientMockRecorder) List(arg0 interface{}) *go } // PutAWS mocks base method. -func (m *MockCredentialManagementClient) PutAWS(arg0 context.Context, arg1 v20220901privatepreview.AWSCredentialResource) error { +func (m *MockCredentialManagementClient) PutAWS(arg0 context.Context, arg1 v20220901privatepreview.AwsCredentialResource) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PutAWS", arg0, arg1) ret0, _ := ret[0].(error) diff --git a/pkg/cli/deploy/deploy.go b/pkg/cli/deploy/deploy.go index 6702bf377e..83819a40fd 100644 --- a/pkg/cli/deploy/deploy.go +++ b/pkg/cli/deploy/deploy.go @@ -20,9 +20,9 @@ import ( "context" "sync" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/output" ) // DeployWithProgress runs a deployment and displays progress to the user. This is intended to be used diff --git a/pkg/cli/deploy/endpoints.go b/pkg/cli/deploy/endpoints.go index d99e2ee377..d8ec1e7330 100644 --- a/pkg/cli/deploy/endpoints.go +++ b/pkg/cli/deploy/endpoints.go @@ -19,8 +19,8 @@ package deploy import ( "context" - "github.com/project-radius/radius/pkg/cli/clients" - ucpresources "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli/clients" + ucpresources "github.com/radius-project/radius/pkg/ucp/resources" ) type PublicEndpoint struct { diff --git a/pkg/cli/deploy/mock_deploy.go b/pkg/cli/deploy/mock_deploy.go index 674af6603c..6adbe54ab2 100644 --- a/pkg/cli/deploy/mock_deploy.go +++ b/pkg/cli/deploy/mock_deploy.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/deploy (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/deploy (interfaces: Interface) // Package deploy is a generated GoMock package. package deploy @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - clients "github.com/project-radius/radius/pkg/cli/clients" + clients "github.com/radius-project/radius/pkg/cli/clients" ) // MockInterface is a mock of Interface interface. diff --git a/pkg/cli/deploy/progress.go b/pkg/cli/deploy/progress.go index 2aaa484bf2..0e2aabdf4f 100644 --- a/pkg/cli/deploy/progress.go +++ b/pkg/cli/deploy/progress.go @@ -24,8 +24,8 @@ import ( "github.com/gosuri/uilive" "github.com/mattn/go-isatty" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/output" ) // NewProgressListener creates a new ProgressListener based on whether the output is a terminal or not, returning an diff --git a/pkg/cli/deploy/types.go b/pkg/cli/deploy/types.go index 7cf755e200..e89142dc62 100644 --- a/pkg/cli/deploy/types.go +++ b/pkg/cli/deploy/types.go @@ -19,9 +19,9 @@ package deploy import ( "context" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/workspaces" ) // Interface is the interface for executing Bicep deployments in the CLI. @@ -60,7 +60,7 @@ var _ Interface = (*Impl)(nil) type Impl struct { } -//go:generate mockgen -destination=./mock_deploy.go -package=deploy -self_package github.com/project-radius/radius/pkg/cli/deploy github.com/project-radius/radius/pkg/cli/deploy Interface +//go:generate mockgen -destination=./mock_deploy.go -package=deploy -self_package github.com/radius-project/radius/pkg/cli/deploy github.com/radius-project/radius/pkg/cli/deploy Interface // DeployWithProgress runs a deployment and displays progress to the user. This is intended to be used // from the CLI and thus logs to the console. diff --git a/pkg/cli/deployment/deploy.go b/pkg/cli/deployment/deploy.go index 230f715512..b00bd0557d 100644 --- a/pkg/cli/deployment/deploy.go +++ b/pkg/cli/deployment/deploy.go @@ -27,10 +27,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/clients" - sdkclients "github.com/project-radius/radius/pkg/sdk/clients" - ucpresources "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/clients" + sdkclients "github.com/radius-project/radius/pkg/sdk/clients" + ucpresources "github.com/radius-project/radius/pkg/ucp/resources" ) const ( @@ -113,7 +113,7 @@ func (dc *ResourceDeploymentClient) startDeployment(ctx context.Context, name st }, } - resourceId = ucpresources.MakeUCPID(scopes, types...) + resourceId = ucpresources.MakeUCPID(scopes, types, nil) providerConfig := dc.GetProviderConfigs(options) poller, err := dc.Client.CreateOrUpdate(ctx, @@ -290,12 +290,14 @@ func (dc *ResourceDeploymentClient) listOperations(ctx context.Context, name str {Type: "radius", Name: "local"}, {Type: "resourcegroups", Name: dc.RadiusResourceGroup}, } - types := ucpresources.TypeSegment{ - Type: "Microsoft.Resources/deployments", - Name: name, + types := []ucpresources.TypeSegment{ + { + Type: "Microsoft.Resources/deployments", + Name: name, + }, } - resourceId = ucpresources.MakeUCPID(scopes, types) + resourceId = ucpresources.MakeUCPID(scopes, types, nil) ops, err := dc.OperationsClient.List(ctx, dc.RadiusResourceGroup, name, resourceId, sdkclients.DeploymentOperationsClientAPIVersion, nil) if err != nil { diff --git a/pkg/cli/deployment/deploy_test.go b/pkg/cli/deployment/deploy_test.go index 05278d7bb6..6b13080986 100644 --- a/pkg/cli/deployment/deploy_test.go +++ b/pkg/cli/deployment/deploy_test.go @@ -19,8 +19,8 @@ package deployment import ( "testing" - "github.com/project-radius/radius/pkg/cli/clients" - sdkclients "github.com/project-radius/radius/pkg/sdk/clients" + "github.com/radius-project/radius/pkg/cli/clients" + sdkclients "github.com/radius-project/radius/pkg/sdk/clients" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/deployment/diagnostics.go b/pkg/cli/deployment/diagnostics.go index 57e8cb8b00..24b174184b 100644 --- a/pkg/cli/deployment/diagnostics.go +++ b/pkg/cli/deployment/diagnostics.go @@ -21,10 +21,10 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - k8slabels "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + k8slabels "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/ucp/resources" "io" "net/http" diff --git a/pkg/cli/framework/config.go b/pkg/cli/framework/config.go index 77180a3453..56393d0088 100644 --- a/pkg/cli/framework/config.go +++ b/pkg/cli/framework/config.go @@ -20,9 +20,9 @@ import ( "context" "strings" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/config" - "github.com/project-radius/radius/pkg/cli/workspaces" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/config" + "github.com/radius-project/radius/pkg/cli/workspaces" "github.com/spf13/viper" ) @@ -53,7 +53,7 @@ func ConfigFromContext(ctx context.Context) *viper.Viper { return holder.Config } -//go:generate mockgen -destination=./mock_config.go -package=framework -self_package github.com/project-radius/radius/pkg/cli/framework github.com/project-radius/radius/pkg/cli/framework ConfigFileInterface +//go:generate mockgen -destination=./mock_config.go -package=framework -self_package github.com/radius-project/radius/pkg/cli/framework github.com/radius-project/radius/pkg/cli/framework ConfigFileInterface type ConfigFileInterface interface { ConfigFromContext(ctx context.Context) *viper.Viper diff --git a/pkg/cli/framework/framework.go b/pkg/cli/framework/framework.go index 305fcf761c..e9b12a6ad8 100644 --- a/pkg/cli/framework/framework.go +++ b/pkg/cli/framework/framework.go @@ -19,18 +19,18 @@ package framework import ( "context" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/cmd/env/namespace" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/deploy" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/kubernetes/logstream" - "github.com/project-radius/radius/pkg/cli/kubernetes/portforward" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/cmd/env/namespace" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/deploy" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/kubernetes/logstream" + "github.com/radius-project/radius/pkg/cli/kubernetes/portforward" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" "github.com/spf13/cobra" ) diff --git a/pkg/cli/framework/mock_config.go b/pkg/cli/framework/mock_config.go index 71a94f140b..cf5abf4c9d 100644 --- a/pkg/cli/framework/mock_config.go +++ b/pkg/cli/framework/mock_config.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/framework (interfaces: ConfigFileInterface) +// Source: github.com/radius-project/radius/pkg/cli/framework (interfaces: ConfigFileInterface) // Package framework is a generated GoMock package. package framework @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - workspaces "github.com/project-radius/radius/pkg/cli/workspaces" + workspaces "github.com/radius-project/radius/pkg/cli/workspaces" viper "github.com/spf13/viper" ) diff --git a/pkg/cli/framework/mock_framework.go b/pkg/cli/framework/mock_framework.go index cc30e05af7..7ff91b90d2 100644 --- a/pkg/cli/framework/mock_framework.go +++ b/pkg/cli/framework/mock_framework.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/framework (interfaces: Runner) +// Source: github.com/radius-project/radius/pkg/cli/framework (interfaces: Runner) // Package framework is a generated GoMock package. package framework diff --git a/pkg/cli/helm/cluster.go b/pkg/cli/helm/cluster.go index 1c6f0ee677..b02566adb9 100644 --- a/pkg/cli/helm/cluster.go +++ b/pkg/cli/helm/cluster.go @@ -26,7 +26,7 @@ import ( "helm.sh/helm/v3/pkg/storage/driver" "k8s.io/cli-runtime/pkg/genericclioptions" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/version" ) const ( @@ -189,7 +189,7 @@ type InstallState struct { Version string } -//go:generate mockgen -destination=./mock_cluster.go -package=helm -self_package github.com/project-radius/radius/pkg/cli/helm github.com/project-radius/radius/pkg/cli/helm Interface +//go:generate mockgen -destination=./mock_cluster.go -package=helm -self_package github.com/radius-project/radius/pkg/cli/helm github.com/radius-project/radius/pkg/cli/helm Interface // Interface provides an abstraction over Helm operations for installing Radius. type Interface interface { diff --git a/pkg/cli/helm/cluster_test.go b/pkg/cli/helm/cluster_test.go index 565ba35495..fe82ba5a31 100644 --- a/pkg/cli/helm/cluster_test.go +++ b/pkg/cli/helm/cluster_test.go @@ -19,7 +19,7 @@ package helm import ( "testing" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/version" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/helm/contourclient.go b/pkg/cli/helm/contourclient.go index d9b8c7a1da..f6b1f6c816 100644 --- a/pkg/cli/helm/contourclient.go +++ b/pkg/cli/helm/contourclient.go @@ -27,7 +27,7 @@ import ( "helm.sh/helm/v3/pkg/storage/driver" "k8s.io/cli-runtime/pkg/genericclioptions" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/output" ) const ( @@ -63,7 +63,7 @@ func ApplyContourHelmChart(options ContourOptions, kubeContext string) error { // https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#method-1-let-helm-do-it-for-you // TODO: Apply CRDs because Helm doesn't upgrade CRDs for you. - // https://github.com/project-radius/radius/issues/712 + // https://github.com/radius-project/radius/issues/712 // We need the CRDs to be public to do this (or consider unpacking the chart // for the CRDs) diff --git a/pkg/cli/helm/mock_cluster.go b/pkg/cli/helm/mock_cluster.go index 3d6eee30d7..1b9f5052e7 100644 --- a/pkg/cli/helm/mock_cluster.go +++ b/pkg/cli/helm/mock_cluster.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/helm (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/helm (interfaces: Interface) // Package helm is a generated GoMock package. package helm diff --git a/pkg/cli/helm/radiusclient.go b/pkg/cli/helm/radiusclient.go index 2067fca867..41a59b362e 100644 --- a/pkg/cli/helm/radiusclient.go +++ b/pkg/cli/helm/radiusclient.go @@ -22,7 +22,7 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/output" helm "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" @@ -91,7 +91,7 @@ func ApplyRadiusHelmChart(options RadiusOptions, kubeContext string) (bool, erro // https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#method-1-let-helm-do-it-for-you // TODO: Apply CRDs because Helm doesn't upgrade CRDs for you. - // https://github.com/project-radius/radius/issues/712 + // https://github.com/radius-project/radius/issues/712 // We need the CRDs to be public to do this (or consider unpacking the chart // for the CRDs) diff --git a/pkg/cli/kubernetes/kubernetes.go b/pkg/cli/kubernetes/kubernetes.go index 1d54e9d6c7..d2bc725e96 100644 --- a/pkg/cli/kubernetes/kubernetes.go +++ b/pkg/cli/kubernetes/kubernetes.go @@ -33,8 +33,8 @@ import ( "k8s.io/client-go/tools/clientcmd/api" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/kubeutil" ) var ( @@ -152,7 +152,7 @@ func GetContextFromConfigFileIfExists(configFilePath, context string) (string, e return contextName, nil } -//go:generate mockgen -destination=./mock_kubernetes.go -package=kubernetes -self_package github.com/project-radius/radius/pkg/cli/kubernetes github.com/project-radius/radius/pkg/cli/kubernetes Interface +//go:generate mockgen -destination=./mock_kubernetes.go -package=kubernetes -self_package github.com/radius-project/radius/pkg/cli/kubernetes github.com/radius-project/radius/pkg/cli/kubernetes Interface type Interface interface { GetKubeContext() (*api.Config, error) } diff --git a/pkg/cli/kubernetes/kubernetes_test.go b/pkg/cli/kubernetes/kubernetes_test.go index edd0dcae71..1d2abfdae1 100644 --- a/pkg/cli/kubernetes/kubernetes_test.go +++ b/pkg/cli/kubernetes/kubernetes_test.go @@ -22,7 +22,7 @@ import ( "os" "testing" - "github.com/project-radius/radius/test/k8sutil" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/cli/kubernetes/logstream/mock_logstream.go b/pkg/cli/kubernetes/logstream/mock_logstream.go index a79f8e5779..cd47910373 100644 --- a/pkg/cli/kubernetes/logstream/mock_logstream.go +++ b/pkg/cli/kubernetes/logstream/mock_logstream.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/kubernetes/logstream (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/kubernetes/logstream (interfaces: Interface) // Package logstream is a generated GoMock package. package logstream diff --git a/pkg/cli/kubernetes/logstream/stern.go b/pkg/cli/kubernetes/logstream/stern.go index f1dd44d8a3..49c2fd2b97 100644 --- a/pkg/cli/kubernetes/logstream/stern.go +++ b/pkg/cli/kubernetes/logstream/stern.go @@ -23,7 +23,7 @@ import ( "time" "github.com/fatih/color" - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" "github.com/stern/stern/stern" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" diff --git a/pkg/cli/kubernetes/logstream/types.go b/pkg/cli/kubernetes/logstream/types.go index c9f080d452..faa7585c1c 100644 --- a/pkg/cli/kubernetes/logstream/types.go +++ b/pkg/cli/kubernetes/logstream/types.go @@ -36,7 +36,7 @@ type Options struct { Out io.Writer } -//go:generate mockgen -destination=./mock_logstream.go -package=logstream -self_package github.com/project-radius/radius/pkg/cli/kubernetes/logstream github.com/project-radius/radius/pkg/cli/kubernetes/logstream Interface +//go:generate mockgen -destination=./mock_logstream.go -package=logstream -self_package github.com/radius-project/radius/pkg/cli/kubernetes/logstream github.com/radius-project/radius/pkg/cli/kubernetes/logstream Interface // Interface is the interface type for streaming application logs. type Interface interface { diff --git a/pkg/cli/kubernetes/mock_kubernetes.go b/pkg/cli/kubernetes/mock_kubernetes.go index cb78d814be..98aa4e7398 100644 --- a/pkg/cli/kubernetes/mock_kubernetes.go +++ b/pkg/cli/kubernetes/mock_kubernetes.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/kubernetes (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/kubernetes (interfaces: Interface) // Package kubernetes is a generated GoMock package. package kubernetes diff --git a/pkg/cli/kubernetes/portforward/application_watcher.go b/pkg/cli/kubernetes/portforward/application_watcher.go index 7734032604..5bff6da3bb 100644 --- a/pkg/cli/kubernetes/portforward/application_watcher.go +++ b/pkg/cli/kubernetes/portforward/application_watcher.go @@ -20,7 +20,7 @@ import ( "context" "reflect" - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/pkg/cli/kubernetes/portforward/application_watcher_test.go b/pkg/cli/kubernetes/portforward/application_watcher_test.go index e60621f1e8..1ff2532fef 100644 --- a/pkg/cli/kubernetes/portforward/application_watcher_test.go +++ b/pkg/cli/kubernetes/portforward/application_watcher_test.go @@ -19,7 +19,7 @@ import ( "context" "testing" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/cli/kubernetes/portforward/deployment_watcher_test.go b/pkg/cli/kubernetes/portforward/deployment_watcher_test.go index 08fcd72eac..f83232ad20 100644 --- a/pkg/cli/kubernetes/portforward/deployment_watcher_test.go +++ b/pkg/cli/kubernetes/portforward/deployment_watcher_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/cli/kubernetes/portforward/impl.go b/pkg/cli/kubernetes/portforward/impl.go index 29e330ae87..6982578415 100644 --- a/pkg/cli/kubernetes/portforward/impl.go +++ b/pkg/cli/kubernetes/portforward/impl.go @@ -19,7 +19,7 @@ package portforward import ( "context" - "github.com/project-radius/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/kubernetes" ) var _ Interface = (*Impl)(nil) diff --git a/pkg/cli/kubernetes/portforward/mock_portforward.go b/pkg/cli/kubernetes/portforward/mock_portforward.go index 518784ffda..6454ad00b6 100644 --- a/pkg/cli/kubernetes/portforward/mock_portforward.go +++ b/pkg/cli/kubernetes/portforward/mock_portforward.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/kubernetes/portforward (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/kubernetes/portforward (interfaces: Interface) // Package portforward is a generated GoMock package. package portforward diff --git a/pkg/cli/kubernetes/portforward/pod_watcher.go b/pkg/cli/kubernetes/portforward/pod_watcher.go index 71e4370e0e..1fa41d3028 100644 --- a/pkg/cli/kubernetes/portforward/pod_watcher.go +++ b/pkg/cli/kubernetes/portforward/pod_watcher.go @@ -25,7 +25,7 @@ import ( "net/http" "strings" - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" corev1 "k8s.io/api/core/v1" clientgoportforward "k8s.io/client-go/tools/portforward" "k8s.io/client-go/transport/spdy" diff --git a/pkg/cli/kubernetes/portforward/pod_watcher_test.go b/pkg/cli/kubernetes/portforward/pod_watcher_test.go index 98b3f7bf5c..58241d881e 100644 --- a/pkg/cli/kubernetes/portforward/pod_watcher_test.go +++ b/pkg/cli/kubernetes/portforward/pod_watcher_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/cli/kubernetes/portforward/types.go b/pkg/cli/kubernetes/portforward/types.go index c20dacfa0c..24c586a7b3 100644 --- a/pkg/cli/kubernetes/portforward/types.go +++ b/pkg/cli/kubernetes/portforward/types.go @@ -74,7 +74,7 @@ type StatusMessage struct { RemotePort uint16 } -//go:generate mockgen -destination=./mock_portforward.go -package=portforward -self_package github.com/project-radius/radius/pkg/cli/kubernetes/portforward github.com/project-radius/radius/pkg/cli/kubernetes/portforward Interface +//go:generate mockgen -destination=./mock_portforward.go -package=portforward -self_package github.com/radius-project/radius/pkg/cli/kubernetes/portforward github.com/radius-project/radius/pkg/cli/kubernetes/portforward Interface // Interface is the interface type for port-forwarding. type Interface interface { diff --git a/pkg/cli/kubernetes/portforward/util.go b/pkg/cli/kubernetes/portforward/util.go index cc6c12bf15..1cbb3827bd 100644 --- a/pkg/cli/kubernetes/portforward/util.go +++ b/pkg/cli/kubernetes/portforward/util.go @@ -19,7 +19,7 @@ package portforward import ( "context" - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/pkg/cli/kubernetes/portforward/util_test.go b/pkg/cli/kubernetes/portforward/util_test.go index 9d0e907efe..8b7e13223c 100644 --- a/pkg/cli/kubernetes/portforward/util_test.go +++ b/pkg/cli/kubernetes/portforward/util_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/cli/objectformats/objectformats.go b/pkg/cli/objectformats/objectformats.go index f495219613..b6224cbd6e 100644 --- a/pkg/cli/objectformats/objectformats.go +++ b/pkg/cli/objectformats/objectformats.go @@ -19,7 +19,7 @@ package objectformats import ( "strings" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/output" ) // GetApplicationStatusTableFormat() sets up the columns and headings for a table to display application names and resource counts. @@ -211,7 +211,7 @@ func GetEnvironmentRecipesTableFormat() output.FormatterOptions { }, { Heading: "TYPE", - JSONPath: "{ .LinkType }", + JSONPath: "{ .ResourceType }", }, { Heading: "TEMPLATE KIND", diff --git a/pkg/cli/objectformats/objectformats_test.go b/pkg/cli/objectformats/objectformats_test.go index 2acdafa910..c210affd98 100644 --- a/pkg/cli/objectformats/objectformats_test.go +++ b/pkg/cli/objectformats/objectformats_test.go @@ -20,9 +20,9 @@ import ( "bytes" "testing" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) diff --git a/pkg/cli/output/mock_writer.go b/pkg/cli/output/mock_writer.go index 5f8b73c278..4fc3f6c04c 100644 --- a/pkg/cli/output/mock_writer.go +++ b/pkg/cli/output/mock_writer.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/output (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/output (interfaces: Interface) // Package output is a generated GoMock package. package output diff --git a/pkg/cli/output/resources.go b/pkg/cli/output/resources.go index e70069ad93..78904a8a80 100644 --- a/pkg/cli/output/resources.go +++ b/pkg/cli/output/resources.go @@ -19,7 +19,7 @@ package output import ( "fmt" - ucpresources "github.com/project-radius/radius/pkg/ucp/resources" + ucpresources "github.com/radius-project/radius/pkg/ucp/resources" ) const ( diff --git a/pkg/cli/prompt/mock_prompter.go b/pkg/cli/prompt/mock_prompter.go index 7ec2b92092..5aebfa01ce 100644 --- a/pkg/cli/prompt/mock_prompter.go +++ b/pkg/cli/prompt/mock_prompter.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/cli/prompt (interfaces: Interface) +// Source: github.com/radius-project/radius/pkg/cli/prompt (interfaces: Interface) // Package prompt is a generated GoMock package. package prompt @@ -9,7 +9,7 @@ import ( tea "github.com/charmbracelet/bubbletea" gomock "github.com/golang/mock/gomock" - text "github.com/project-radius/radius/pkg/cli/prompt/text" + text "github.com/radius-project/radius/pkg/cli/prompt/text" ) // MockInterface is a mock of Interface interface. diff --git a/pkg/cli/prompt/prompt.go b/pkg/cli/prompt/prompt.go index ae96f58525..357c0e4e9b 100644 --- a/pkg/cli/prompt/prompt.go +++ b/pkg/cli/prompt/prompt.go @@ -22,9 +22,9 @@ import ( "github.com/charmbracelet/bubbles/list" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/project-radius/radius/pkg/cli/clierrors" - cli_list "github.com/project-radius/radius/pkg/cli/prompt/list" - "github.com/project-radius/radius/pkg/cli/prompt/text" + "github.com/radius-project/radius/pkg/cli/clierrors" + cli_list "github.com/radius-project/radius/pkg/cli/prompt/list" + "github.com/radius-project/radius/pkg/cli/prompt/text" ) const ( @@ -35,7 +35,7 @@ const ( ConfirmNo = "No" ) -//go:generate mockgen -destination=./mock_prompter.go -package=prompt -self_package github.com/project-radius/radius/pkg/cli/prompt github.com/project-radius/radius/pkg/cli/prompt Interface +//go:generate mockgen -destination=./mock_prompter.go -package=prompt -self_package github.com/radius-project/radius/pkg/cli/prompt github.com/radius-project/radius/pkg/cli/prompt Interface // Interface contains operation to prompt the user interactively. // diff --git a/pkg/cli/tools/binary_tools.go b/pkg/cli/tools/binary_tools.go index 4ed7941635..53dcf58d08 100644 --- a/pkg/cli/tools/binary_tools.go +++ b/pkg/cli/tools/binary_tools.go @@ -24,7 +24,7 @@ import ( "path" "runtime" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/version" ) // validPlatforms is a map of valid platforms to download for. The key is the combination of GOOS and GOARCH. diff --git a/pkg/cli/tools/binary_tools_test.go b/pkg/cli/tools/binary_tools_test.go index c3ed321f82..683c4cdf60 100644 --- a/pkg/cli/tools/binary_tools_test.go +++ b/pkg/cli/tools/binary_tools_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/version" ) func TestGetDownloadURI(t *testing.T) { diff --git a/pkg/cli/workspaces/connection.go b/pkg/cli/workspaces/connection.go index d32260942e..12addf527c 100644 --- a/pkg/cli/workspaces/connection.go +++ b/pkg/cli/workspaces/connection.go @@ -22,8 +22,8 @@ import ( "strings" "github.com/mitchellh/mapstructure" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/sdk" ) const KindKubernetes string = "kubernetes" diff --git a/pkg/cli/workspaces/types.go b/pkg/cli/workspaces/types.go index c4d2f62dbe..c6b7569903 100644 --- a/pkg/cli/workspaces/types.go +++ b/pkg/cli/workspaces/types.go @@ -16,7 +16,7 @@ limitations under the License. package workspaces -import "github.com/project-radius/radius/pkg/cli/config" +import "github.com/radius-project/radius/pkg/cli/config" // Workspace represents configuration for the rad CLI. // diff --git a/pkg/corerp/api/README.md b/pkg/corerp/api/README.md index 859cf9e292..f0899717bb 100644 --- a/pkg/corerp/api/README.md +++ b/pkg/corerp/api/README.md @@ -34,14 +34,7 @@ These settings apply only when `--tag=core-2022-03-15-privatepreview` is specifi ```yaml $(tag) == 'core-2022-03-15-privatepreview' input-file: - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/environments.json - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/applications.json - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/httpRoutes.json - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/gateways.json - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/containers.json - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/volumes.json - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/secretstores.json - - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/extenders.json + - ../../../swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/openapi.json modelerfour: treat-type-object-as-anything: false diff --git a/pkg/corerp/api/v20220315privatepreview/application_conversion.go b/pkg/corerp/api/v20220315privatepreview/application_conversion.go index 3ac9b36283..704b255de0 100644 --- a/pkg/corerp/api/v20220315privatepreview/application_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/application_conversion.go @@ -17,10 +17,10 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned Application resource to version-agnostic datamodel. @@ -83,7 +83,7 @@ func (dst *ApplicationResource) ConvertFrom(src v1.DataModelInterface) error { }, } - var extensions []ApplicationExtensionClassification + var extensions []ExtensionClassification if app.Properties.Extensions != nil { for _, e := range app.Properties.Extensions { extensions = append(extensions, fromAppExtensionClassificationDataModel(e)) @@ -95,17 +95,17 @@ func (dst *ApplicationResource) ConvertFrom(src v1.DataModelInterface) error { } // fromAppExtensionClassificationDataModel: Converts from base datamodel to versioned datamodel -func fromAppExtensionClassificationDataModel(e datamodel.Extension) ApplicationExtensionClassification { +func fromAppExtensionClassificationDataModel(e datamodel.Extension) ExtensionClassification { switch e.Kind { case datamodel.KubernetesMetadata: var ann, lbl = fromExtensionClassificationFields(e) - return &ApplicationKubernetesMetadataExtension{ + return &KubernetesMetadataExtension{ Kind: to.Ptr(string(e.Kind)), Annotations: *to.StringMapPtr(ann), Labels: *to.StringMapPtr(lbl), } case datamodel.KubernetesNamespaceExtension: - return &ApplicationKubernetesNamespaceExtension{ + return &KubernetesNamespaceExtension{ Kind: to.Ptr(string(e.Kind)), Namespace: to.Ptr(e.KubernetesNamespace.Namespace), } @@ -115,9 +115,9 @@ func fromAppExtensionClassificationDataModel(e datamodel.Extension) ApplicationE } // toAppExtensionDataModel: Converts from versioned datamodel to base datamodel -func toAppExtensionDataModel(e ApplicationExtensionClassification) *datamodel.Extension { +func toAppExtensionDataModel(e ExtensionClassification) *datamodel.Extension { switch c := e.(type) { - case *ApplicationKubernetesMetadataExtension: + case *KubernetesMetadataExtension: return &datamodel.Extension{ Kind: datamodel.KubernetesMetadata, KubernetesMetadata: &datamodel.KubeMetadataExtension{ @@ -125,7 +125,7 @@ func toAppExtensionDataModel(e ApplicationExtensionClassification) *datamodel.Ex Labels: to.StringMap(c.Labels), }, } - case *ApplicationKubernetesNamespaceExtension: + case *KubernetesNamespaceExtension: if c.Namespace == nil || *c.Namespace == "" { return nil } diff --git a/pkg/corerp/api/v20220315privatepreview/application_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/application_conversion_test.go index 7b0294082c..5c1f0073fe 100644 --- a/pkg/corerp/api/v20220315privatepreview/application_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/application_conversion_test.go @@ -20,9 +20,10 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -129,7 +130,7 @@ func TestApplicationConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/container_conversion.go b/pkg/corerp/api/v20220315privatepreview/container_conversion.go index 84dcda801b..c1c7fcf993 100644 --- a/pkg/corerp/api/v20220315privatepreview/container_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/container_conversion.go @@ -17,10 +17,12 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + "encoding/json" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned Container resource to version-agnostic datamodel. @@ -70,7 +72,7 @@ func (src *ContainerResource) ConvertTo() (v1.DataModelInterface, error) { for key, val := range src.Properties.Container.Ports { port := datamodel.ContainerPort{ ContainerPort: to.Int32(val.ContainerPort), - Protocol: toProtocolDataModel(val.Protocol), + Protocol: toPortProtocolDataModel(val.Protocol), Provides: to.String(val.Provides), } @@ -120,17 +122,19 @@ func (src *ContainerResource) ConvertTo() (v1.DataModelInterface, error) { }, Connections: connections, Container: datamodel.Container{ - Image: to.String(src.Properties.Container.Image), - Env: to.StringMap(src.Properties.Container.Env), - LivenessProbe: livenessProbe, - Ports: ports, - ReadinessProbe: readinessProbe, - Volumes: volumes, - Command: stringSlice(src.Properties.Container.Command), - Args: stringSlice(src.Properties.Container.Args), - WorkingDir: to.String(src.Properties.Container.WorkingDir), + Image: to.String(src.Properties.Container.Image), + ImagePullPolicy: toImagePullPolicyDataModel(src.Properties.Container.ImagePullPolicy), + Env: to.StringMap(src.Properties.Container.Env), + LivenessProbe: livenessProbe, + Ports: ports, + ReadinessProbe: readinessProbe, + Volumes: volumes, + Command: stringSlice(src.Properties.Container.Command), + Args: stringSlice(src.Properties.Container.Args), + WorkingDir: to.String(src.Properties.Container.WorkingDir), }, Extensions: extensions, + Runtimes: toRuntimeProperties(src.Properties.Runtimes), }, } @@ -155,7 +159,7 @@ func (dst *ContainerResource) ConvertFrom(src v1.DataModelInterface) error { connections := make(map[string]*ConnectionProperties) for key, val := range c.Properties.Connections { roles := []*string{} - var kind *Kind + var kind *IAMKind for _, r := range val.IAM.Roles { roles = append(roles, to.Ptr(r)) @@ -188,11 +192,11 @@ func (dst *ContainerResource) ConvertFrom(src v1.DataModelInterface) error { readinessProbe = fromHealthProbePropertiesDataModel(c.Properties.Container.ReadinessProbe) } - ports := make(map[string]*ContainerPort) + ports := make(map[string]*ContainerPortProperties) for key, val := range c.Properties.Container.Ports { - ports[key] = &ContainerPort{ + ports[key] = &ContainerPortProperties{ ContainerPort: to.Ptr(val.ContainerPort), - Protocol: fromProtocolDataModel(val.Protocol), + Protocol: fromPortProtocolDataModel(val.Protocol), Provides: to.Ptr(val.Provides), } @@ -213,7 +217,7 @@ func (dst *ContainerResource) ConvertFrom(src v1.DataModelInterface) error { } } - var extensions []ContainerExtensionClassification + var extensions []ExtensionClassification if c.Properties.Extensions != nil { for _, e := range c.Properties.Extensions { extensions = append(extensions, fromExtensionClassificationDataModel(e)) @@ -237,29 +241,61 @@ func (dst *ContainerResource) ConvertFrom(src v1.DataModelInterface) error { dst.Tags = *to.StringMapPtr(c.Tags) dst.Properties = &ContainerProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(c.Properties.Status.OutputResources), + OutputResources: toOutputResources(c.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(c.InternalMetadata.AsyncProvisioningState), Application: to.Ptr(c.Properties.Application), Connections: connections, Container: &Container{ - Image: to.Ptr(c.Properties.Container.Image), - Env: *to.StringMapPtr(c.Properties.Container.Env), - LivenessProbe: livenessProbe, - Ports: ports, - ReadinessProbe: readinessProbe, - Volumes: volumes, - Command: to.SliceOfPtrs(c.Properties.Container.Command...), - Args: to.SliceOfPtrs(c.Properties.Container.Args...), - WorkingDir: to.Ptr(c.Properties.Container.WorkingDir), + Image: to.Ptr(c.Properties.Container.Image), + ImagePullPolicy: fromImagePullPolicyDataModel(c.Properties.Container.ImagePullPolicy), + Env: *to.StringMapPtr(c.Properties.Container.Env), + LivenessProbe: livenessProbe, + Ports: ports, + ReadinessProbe: readinessProbe, + Volumes: volumes, + Command: to.SliceOfPtrs(c.Properties.Container.Command...), + Args: to.SliceOfPtrs(c.Properties.Container.Args...), + WorkingDir: to.Ptr(c.Properties.Container.WorkingDir), }, Extensions: extensions, Identity: identity, + Runtimes: fromRuntimeProperties(c.Properties.Runtimes), } return nil } +func toImagePullPolicyDataModel(pullPolicy *ImagePullPolicy) string { + if pullPolicy == nil { + return "" + } + + switch *pullPolicy { + case ImagePullPolicyAlways: + return "Always" + case ImagePullPolicyIfNotPresent: + return "IfNotPresent" + case ImagePullPolicyNever: + return "Never" + default: + return "" + } +} + +func fromImagePullPolicyDataModel(pullPolicy string) *ImagePullPolicy { + switch pullPolicy { + case "Always": + return to.Ptr(ImagePullPolicyAlways) + case "IfNotPresent": + return to.Ptr(ImagePullPolicyIfNotPresent) + case "Never": + return to.Ptr(ImagePullPolicyNever) + default: + return nil + } +} + func toHealthProbePropertiesDataModel(h HealthProbePropertiesClassification) datamodel.HealthProbeProperties { switch c := h.(type) { case *ExecHealthProbeProperties: @@ -329,57 +365,73 @@ func fromHealthProbePropertiesDataModel(h datamodel.HealthProbeProperties) Healt return nil } -func toKindDataModel(kind *Kind) datamodel.IAMKind { +func toKindDataModel(kind *IAMKind) datamodel.IAMKind { switch *kind { - case KindAzure: + case IAMKindAzure: return datamodel.KindAzure default: return datamodel.KindAzure } } -func fromKindDataModel(kind datamodel.IAMKind) *Kind { - var k Kind +func fromKindDataModel(kind datamodel.IAMKind) *IAMKind { + var k IAMKind switch kind { case datamodel.KindAzure: - k = KindAzure + k = IAMKindAzure default: - k = KindAzure + k = IAMKindAzure } return &k } -func toProtocolDataModel(protocol *Protocol) datamodel.Protocol { +func toPortProtocolDataModel(protocol *PortProtocol) datamodel.Protocol { + if protocol == nil { + return datamodel.ProtocolTCP + } + switch *protocol { + case PortProtocolTCP: + return datamodel.ProtocolTCP + case PortProtocolUDP: + return datamodel.ProtocolUDP + default: + return datamodel.ProtocolTCP + } +} + +func toDaprProtocolDataModel(protocol *DaprSidecarExtensionProtocol) datamodel.Protocol { if protocol == nil { return datamodel.ProtocolHTTP } switch *protocol { - case ProtocolHTTP: + case DaprSidecarExtensionProtocolHTTP: return datamodel.ProtocolHTTP - case ProtocolGrpc: + case DaprSidecarExtensionProtocolGrpc: return datamodel.ProtocolGrpc - case ProtocolTCP: - return datamodel.ProtocolTCP - case ProtocolUDP: - return datamodel.ProtocolUDP default: return datamodel.ProtocolHTTP } } - -func fromProtocolDataModel(protocol datamodel.Protocol) *Protocol { - var p Protocol +func fromPortProtocolDataModel(protocol datamodel.Protocol) *PortProtocol { + var p PortProtocol switch protocol { - case datamodel.ProtocolHTTP: - p = ProtocolHTTP - case datamodel.ProtocolGrpc: - p = ProtocolGrpc case datamodel.ProtocolTCP: - p = ProtocolTCP + p = PortProtocolTCP case datamodel.ProtocolUDP: - p = ProtocolUDP + p = PortProtocolUDP + default: + p = PortProtocolTCP + } + return &p +} + +func fromProtocolDataModel(protocol datamodel.Protocol) *DaprSidecarExtensionProtocol { + var p DaprSidecarExtensionProtocol + switch protocol { + case datamodel.ProtocolGrpc: + p = DaprSidecarExtensionProtocolGrpc default: - p = ProtocolHTTP + p = DaprSidecarExtensionProtocolHTTP } return &p } @@ -452,6 +504,50 @@ func fromManagedStoreDataModel(managedStore datamodel.ManagedStore) *ManagedStor return &m } +func toRuntimeProperties(runtime *RuntimesProperties) *datamodel.RuntimeProperties { + if runtime == nil { + return nil + } + + r := &datamodel.RuntimeProperties{} + if runtime.Kubernetes != nil { + r.Kubernetes = &datamodel.KubernetesRuntime{ + Base: to.String(runtime.Kubernetes.Base), + } + if runtime.Kubernetes.Pod != nil { + // Serializes PodSpec patch object to JSON-encoded. Internally, Radius does JSON strategic merge patch + // with this JSON-encoded PodSpec patch object. Thus, datamodel holds JSON-encoded PodSpec patch object + // as a string. + serialiedPodPatch, err := json.Marshal(runtime.Kubernetes.Pod) + if err != nil { + return nil + } + r.Kubernetes.Pod = string(serialiedPodPatch) + } + } + return r +} + +func fromRuntimeProperties(runtime *datamodel.RuntimeProperties) *RuntimesProperties { + if runtime == nil { + return nil + } + r := &RuntimesProperties{} + if runtime.Kubernetes != nil { + r.Kubernetes = &KubernetesRuntimeProperties{ + Base: to.Ptr(runtime.Kubernetes.Base), + } + if runtime.Kubernetes.Pod != "" { + podPatch := map[string]any{} + if err := json.Unmarshal([]byte(runtime.Kubernetes.Pod), &podPatch); err != nil { + return nil + } + r.Kubernetes.Pod = podPatch + } + } + return r +} + func toPermissionDataModel(rbac *VolumePermission) datamodel.VolumePermission { if rbac == nil { return datamodel.VolumePermissionRead @@ -481,7 +577,7 @@ func fromPermissionDataModel(rbac datamodel.VolumePermission) *VolumePermission } // toExtensionDataModel: Converts from versioned datamodel to base datamodel -func toExtensionDataModel(e ContainerExtensionClassification) datamodel.Extension { +func toExtensionDataModel(e ExtensionClassification) datamodel.Extension { switch c := e.(type) { case *ManualScalingExtension: return datamodel.Extension{ @@ -497,10 +593,10 @@ func toExtensionDataModel(e ContainerExtensionClassification) datamodel.Extensio AppID: to.String(c.AppID), AppPort: to.Int32(c.AppPort), Config: to.String(c.Config), - Protocol: toProtocolDataModel(c.Protocol), + Protocol: toDaprProtocolDataModel(c.Protocol), }, } - case *ContainerKubernetesMetadataExtension: + case *KubernetesMetadataExtension: return datamodel.Extension{ Kind: datamodel.KubernetesMetadata, KubernetesMetadata: &datamodel.KubeMetadataExtension{ @@ -514,7 +610,7 @@ func toExtensionDataModel(e ContainerExtensionClassification) datamodel.Extensio } // fromExtensionClassificationDataModel: Converts from base datamodel to versioned datamodel -func fromExtensionClassificationDataModel(e datamodel.Extension) ContainerExtensionClassification { +func fromExtensionClassificationDataModel(e datamodel.Extension) ExtensionClassification { switch e.Kind { case datamodel.ManualScaling: return &ManualScalingExtension{ @@ -531,7 +627,7 @@ func fromExtensionClassificationDataModel(e datamodel.Extension) ContainerExtens } case datamodel.KubernetesMetadata: var ann, lbl = fromExtensionClassificationFields(e) - return &ContainerKubernetesMetadataExtension{ + return &KubernetesMetadataExtension{ Kind: to.Ptr(string(e.Kind)), Annotations: *to.StringMapPtr(ann), Labels: *to.StringMapPtr(lbl), diff --git a/pkg/corerp/api/v20220315privatepreview/container_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/container_conversion_test.go index 73e38c04d3..207f0e5399 100644 --- a/pkg/corerp/api/v20220315privatepreview/container_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/container_conversion_test.go @@ -20,11 +20,12 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -40,6 +41,11 @@ func TestContainerConvertVersionedToDataModel(t *testing.T) { err: nil, emptyExt: false, }, + { + filename: "containerresource-runtimes.json", + err: nil, + emptyExt: false, + }, { filename: "containerresourceemptyext.json", err: nil, @@ -66,7 +72,6 @@ func TestContainerConvertVersionedToDataModel(t *testing.T) { if tt.err != nil { require.ErrorIs(t, err, tt.err) } else { - // assert require.NoError(t, err) ct := dm.(*datamodel.ContainerResource) @@ -97,13 +102,19 @@ func TestContainerConvertVersionedToDataModel(t *testing.T) { } else { require.Equal(t, getTestContainerExtensions(t), ct.Properties.Extensions) } + + if r.Properties.Runtimes != nil { + require.NotNil(t, ct.Properties.Runtimes.Kubernetes) + require.NotEmpty(t, ct.Properties.Runtimes.Kubernetes.Base) + require.Equal(t, *r.Properties.Runtimes.Kubernetes.Base, ct.Properties.Runtimes.Kubernetes.Base) + require.Equal(t, "{\"containers\":[{\"name\":\"sidecar\"}],\"hostNetwork\":true}", ct.Properties.Runtimes.Kubernetes.Pod) + } } }) } } func TestContainerConvertDataModelToVersioned(t *testing.T) { - conversionTests := []struct { filename string err error @@ -114,6 +125,11 @@ func TestContainerConvertDataModelToVersioned(t *testing.T) { err: nil, emptyExt: false, }, + { + filename: "containerresourcedatamodel-runtime.json", + err: nil, + emptyExt: false, + }, { filename: "containerresourcedatamodelemptyext.json", err: nil, @@ -147,13 +163,26 @@ func TestContainerConvertDataModelToVersioned(t *testing.T) { require.Equal(t, "azure", string(val.IAM.Kind)) require.Equal(t, "read", val.IAM.Roles[0]) require.Equal(t, "radius.azurecr.io/webapptutorial-todoapp", r.Properties.Container.Image) - require.Equal(t, "Deployment", versioned.Properties.Status.OutputResources[0]["LocalID"]) - require.Equal(t, "aks", versioned.Properties.Status.OutputResources[0]["Provider"]) + require.Equal(t, resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), versioned.Properties.Status) require.Equal(t, "kubernetesMetadata", *versioned.Properties.Extensions[2].GetExtension().Kind) require.Equal(t, 3, len(versioned.Properties.Extensions)) require.Equal(t, to.SliceOfPtrs([]string{"/bin/sh"}...), versioned.Properties.Container.Command) require.Equal(t, to.SliceOfPtrs([]string{"-c", "while true; do echo hello; sleep 10;done"}...), versioned.Properties.Container.Args) require.Equal(t, to.Ptr("/app"), versioned.Properties.Container.WorkingDir) + + if r.Properties.Runtimes != nil { + require.NotNil(t, versioned.Properties.Runtimes) + require.NotEmpty(t, *versioned.Properties.Runtimes.Kubernetes.Base) + require.Equal(t, r.Properties.Runtimes.Kubernetes.Base, *versioned.Properties.Runtimes.Kubernetes.Base) + require.Equal(t, map[string]any{ + "containers": []any{ + map[string]any{ + "name": "sidecar", + }, + }, + "hostNetwork": true, + }, versioned.Properties.Runtimes.Kubernetes.Pod) + } } }) } @@ -200,7 +229,7 @@ func TestContainerConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/environment_conversion.go b/pkg/corerp/api/v20220315privatepreview/environment_conversion.go index 0c196d0457..51101bb4a9 100644 --- a/pkg/corerp/api/v20220315privatepreview/environment_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/environment_conversion.go @@ -20,12 +20,13 @@ import ( "fmt" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - types "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/portableresources" + types "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) const ( @@ -64,13 +65,13 @@ func (src *EnvironmentResource) ConvertTo() (v1.DataModelInterface, error) { if src.Properties.Recipes != nil { envRecipes := make(map[string]map[string]datamodel.EnvironmentRecipeProperties) for resourceType, recipes := range src.Properties.Recipes { - if !isValidLinkType(resourceType) { - return &datamodel.Environment{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid link type: %q", resourceType)) + if !portableresources.IsValidPortableResourceType(resourceType) { + return &datamodel.Environment{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid resource type: %q", resourceType)) } envRecipes[resourceType] = map[string]datamodel.EnvironmentRecipeProperties{} for recipeName, recipeDetails := range recipes { if recipeDetails != nil { - if recipeDetails.GetEnvironmentRecipeProperties().TemplateKind == nil || !isValidTemplateKind(*recipeDetails.GetEnvironmentRecipeProperties().TemplateKind) { + if recipeDetails.GetRecipeProperties().TemplateKind == nil || !isValidTemplateKind(*recipeDetails.GetRecipeProperties().TemplateKind) { formats := []string{} for _, format := range types.SupportedTemplateKind { formats = append(formats, fmt.Sprintf("%q", format)) @@ -135,9 +136,9 @@ func (dst *EnvironmentResource) ConvertFrom(src v1.DataModelInterface) error { } if env.Properties.Recipes != nil { - recipes := make(map[string]map[string]EnvironmentRecipePropertiesClassification) + recipes := make(map[string]map[string]RecipePropertiesClassification) for resourceType, recipe := range env.Properties.Recipes { - recipes[resourceType] = map[string]EnvironmentRecipePropertiesClassification{} + recipes[resourceType] = map[string]RecipePropertiesClassification{} for recipeName, recipeDetails := range recipe { recipes[resourceType][recipeName] = fromRecipePropertiesClassificationDatamodel(recipeDetails) } @@ -159,7 +160,7 @@ func (dst *EnvironmentResource) ConvertFrom(src v1.DataModelInterface) error { } } - var extensions []EnvironmentExtensionClassification + var extensions []ExtensionClassification if env.Properties.Extensions != nil { for _, e := range env.Properties.Extensions { extensions = append(extensions, fromEnvExtensionClassificationDataModel(e)) @@ -255,11 +256,11 @@ func fromEnvironmentComputeKind(kind rpv1.EnvironmentComputeKind) *string { } // fromExtensionClassificationEnvDataModel: Converts from base datamodel to versioned datamodel -func fromEnvExtensionClassificationDataModel(e datamodel.Extension) EnvironmentExtensionClassification { +func fromEnvExtensionClassificationDataModel(e datamodel.Extension) ExtensionClassification { switch e.Kind { case datamodel.KubernetesMetadata: var ann, lbl = fromExtensionClassificationFields(e) - return &EnvironmentKubernetesMetadataExtension{ + return &KubernetesMetadataExtension{ Kind: to.Ptr(string(e.Kind)), Annotations: *to.StringMapPtr(ann), Labels: *to.StringMapPtr(lbl), @@ -270,9 +271,9 @@ func fromEnvExtensionClassificationDataModel(e datamodel.Extension) EnvironmentE } // toEnvExtensionDataModel: Converts from versioned datamodel to base datamodel -func toEnvExtensionDataModel(e EnvironmentExtensionClassification) datamodel.Extension { +func toEnvExtensionDataModel(e ExtensionClassification) datamodel.Extension { switch c := e.(type) { - case *EnvironmentKubernetesMetadataExtension: + case *KubernetesMetadataExtension: return datamodel.Extension{ Kind: datamodel.KubernetesMetadata, KubernetesMetadata: &datamodel.KubeMetadataExtension{ @@ -285,7 +286,7 @@ func toEnvExtensionDataModel(e EnvironmentExtensionClassification) datamodel.Ext return datamodel.Extension{} } -func toEnvironmentRecipeProperties(e EnvironmentRecipePropertiesClassification) (datamodel.EnvironmentRecipeProperties, error) { +func toEnvironmentRecipeProperties(e RecipePropertiesClassification) (datamodel.EnvironmentRecipeProperties, error) { switch c := e.(type) { case *TerraformRecipeProperties: if c.TemplatePath != nil { @@ -310,7 +311,7 @@ func toEnvironmentRecipeProperties(e EnvironmentRecipePropertiesClassification) return datamodel.EnvironmentRecipeProperties{}, nil } -func fromRecipePropertiesClassificationDatamodel(e datamodel.EnvironmentRecipeProperties) EnvironmentRecipePropertiesClassification { +func fromRecipePropertiesClassificationDatamodel(e datamodel.EnvironmentRecipeProperties) RecipePropertiesClassification { switch e.TemplateKind { case types.TemplateKindTerraform: return &TerraformRecipeProperties{ diff --git a/pkg/corerp/api/v20220315privatepreview/environment_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/environment_conversion_test.go index d49bc506d2..42545b43f9 100644 --- a/pkg/corerp/api/v20220315privatepreview/environment_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/environment_conversion_test.go @@ -21,13 +21,14 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -73,7 +74,7 @@ func TestConvertVersionedToDataModel(t *testing.T) { }, }, Recipes: map[string]map[string]datamodel.EnvironmentRecipeProperties{ - linkrp.MongoDatabasesResourceType: { + portableresources.MongoDatabasesResourceType: { "cosmos-recipe": datamodel.EnvironmentRecipeProperties{ TemplateKind: recipes.TemplateKindBicep, TemplatePath: "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", @@ -117,7 +118,7 @@ func TestConvertVersionedToDataModel(t *testing.T) { }, }, Recipes: map[string]map[string]datamodel.EnvironmentRecipeProperties{ - linkrp.MongoDatabasesResourceType: { + portableresources.MongoDatabasesResourceType: { "cosmos-recipe": datamodel.EnvironmentRecipeProperties{ TemplateKind: recipes.TemplateKindBicep, TemplatePath: "br:sampleregistry.azureacr.io/radius/recipes/mongodatabases", @@ -135,13 +136,13 @@ func TestConvertVersionedToDataModel(t *testing.T) { TemplatePath: "http://example.com/myrecipe.zip", }, }, - linkrp.RedisCachesResourceType: { + portableresources.RedisCachesResourceType: { "redis-recipe": datamodel.EnvironmentRecipeProperties{ TemplateKind: recipes.TemplateKindBicep, TemplatePath: "br:sampleregistry.azureacr.io/radius/recipes/rediscaches", }, }, - linkrp.DaprStateStoresResourceType: { + portableresources.DaprStateStoresResourceType: { "statestore-recipe": datamodel.EnvironmentRecipeProperties{ TemplateKind: recipes.TemplateKindTerraform, TemplatePath: "Azure/storage/azurerm", @@ -184,7 +185,7 @@ func TestConvertVersionedToDataModel(t *testing.T) { }, }, Recipes: map[string]map[string]datamodel.EnvironmentRecipeProperties{ - linkrp.MongoDatabasesResourceType: { + portableresources.MongoDatabasesResourceType: { "cosmos-recipe": datamodel.EnvironmentRecipeProperties{ TemplateKind: recipes.TemplateKindBicep, TemplatePath: "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", @@ -226,7 +227,7 @@ func TestConvertVersionedToDataModel(t *testing.T) { }, }, Recipes: map[string]map[string]datamodel.EnvironmentRecipeProperties{ - linkrp.MongoDatabasesResourceType: { + portableresources.MongoDatabasesResourceType: { "cosmos-recipe": datamodel.EnvironmentRecipeProperties{ TemplateKind: recipes.TemplateKindBicep, TemplatePath: "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", @@ -247,8 +248,8 @@ func TestConvertVersionedToDataModel(t *testing.T) { err: &v1.ErrModelConversion{PropertyName: "$.properties.compute.namespace", ValidValue: "63 characters or less"}, }, { - filename: "environmentresource-invalid-linktype.json", - err: &v1.ErrClientRP{Code: v1.CodeInvalid, Message: "invalid link type: \"Applications.Link/pubsub\""}, + filename: "environmentresource-invalid-resourcetype.json", + err: &v1.ErrClientRP{Code: v1.CodeInvalid, Message: "invalid resource type: \"Applications.Dapr/pubsub\""}, }, { filename: "environmentresource-invalid-templatekind.json", @@ -326,17 +327,17 @@ func TestConvertDataModelToVersioned(t *testing.T) { require.Equal(t, "kubernetes", string(*versioned.Properties.Compute.GetEnvironmentCompute().Kind)) require.Equal(t, "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", string(*versioned.Properties.Compute.GetEnvironmentCompute().ResourceID)) require.Equal(t, 1, len(versioned.Properties.Recipes)) - require.Equal(t, "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", string(*versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["cosmos-recipe"].GetEnvironmentRecipeProperties().TemplatePath)) - require.Equal(t, recipes.TemplateKindBicep, string(*versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["cosmos-recipe"].GetEnvironmentRecipeProperties().TemplateKind)) - require.Equal(t, map[string]any{"throughput": float64(400)}, versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["cosmos-recipe"].GetEnvironmentRecipeProperties().Parameters) + require.Equal(t, "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", string(*versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["cosmos-recipe"].GetRecipeProperties().TemplatePath)) + require.Equal(t, recipes.TemplateKindBicep, string(*versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["cosmos-recipe"].GetRecipeProperties().TemplateKind)) + require.Equal(t, map[string]any{"throughput": float64(400)}, versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["cosmos-recipe"].GetRecipeProperties().Parameters) require.Equal(t, "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", string(*versioned.Properties.Providers.Azure.Scope)) require.Equal(t, "/planes/aws/aws/accounts/140313373712/regions/us-west-2", string(*versioned.Properties.Providers.Aws.Scope)) require.Equal(t, "kubernetesMetadata", *versioned.Properties.Extensions[0].GetExtension().Kind) require.Equal(t, 1, len(versioned.Properties.Extensions)) - recipeDetails := versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["terraform-recipe"] + recipeDetails := versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["terraform-recipe"] if tt.filename == "environmentresourcedatamodel.json" { - require.Equal(t, "Azure/cosmosdb/azurerm", string(*versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["terraform-recipe"].GetEnvironmentRecipeProperties().TemplatePath)) - require.Equal(t, recipes.TemplateKindTerraform, string(*versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["terraform-recipe"].GetEnvironmentRecipeProperties().TemplateKind)) + require.Equal(t, "Azure/cosmosdb/azurerm", string(*versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["terraform-recipe"].GetRecipeProperties().TemplatePath)) + require.Equal(t, recipes.TemplateKindTerraform, string(*versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["terraform-recipe"].GetRecipeProperties().TemplateKind)) switch c := recipeDetails.(type) { case *TerraformRecipeProperties: @@ -395,8 +396,8 @@ func TestConvertDataModelWithIdentityToVersioned(t *testing.T) { require.Equal(t, "kubernetes", string(*versioned.Properties.Compute.GetEnvironmentCompute().Kind)) require.Equal(t, "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", string(*versioned.Properties.Compute.GetEnvironmentCompute().ResourceID)) require.Equal(t, 1, len(versioned.Properties.Recipes)) - require.Equal(t, "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", string(*versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["cosmos-recipe"].GetEnvironmentRecipeProperties().TemplatePath)) - require.Equal(t, recipes.TemplateKindBicep, string(*versioned.Properties.Recipes[linkrp.MongoDatabasesResourceType]["cosmos-recipe"].GetEnvironmentRecipeProperties().TemplateKind)) + require.Equal(t, "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", string(*versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["cosmos-recipe"].GetRecipeProperties().TemplatePath)) + require.Equal(t, recipes.TemplateKindBicep, string(*versioned.Properties.Recipes[portableresources.MongoDatabasesResourceType]["cosmos-recipe"].GetRecipeProperties().TemplateKind)) require.Equal(t, "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", string(*versioned.Properties.Providers.Azure.Scope)) require.Equal(t, &IdentitySettings{ @@ -409,36 +410,12 @@ func TestConvertDataModelWithIdentityToVersioned(t *testing.T) { require.Equal(t, "https://oidcurl/guid", string(*versioned.Properties.Compute.GetEnvironmentCompute().Identity.OidcIssuer)) } -type fakeResource struct{} - -func (f *fakeResource) ResourceTypeName() string { - return "FakeResource" -} - -func (f *fakeResource) GetSystemData() *v1.SystemData { - return nil -} - -func (f *fakeResource) GetBaseResource() *v1.BaseResource { - return nil -} - -func (f *fakeResource) ProvisioningState() v1.ProvisioningState { - return v1.ProvisioningStateAccepted -} - -func (f *fakeResource) SetProvisioningState(state v1.ProvisioningState) { -} - -func (f *fakeResource) UpdateMetadata(ctx *v1.ARMRequestContext, oldResource *v1.BaseResource) { -} - func TestConvertFromValidation(t *testing.T) { validationTests := []struct { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion.go b/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion.go index af53255a50..e2dd4c990f 100644 --- a/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion.go @@ -19,19 +19,19 @@ package v20220315privatepreview import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - types "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + types "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo returns an error as it does not support converting Environment Recipe Properties to a version-agnostic object. -func (src *RecipeMetadataProperties) ConvertTo() (v1.DataModelInterface, error) { +func (src *RecipeGetMetadataResponse) ConvertTo() (v1.DataModelInterface, error) { return nil, fmt.Errorf("converting Environment Recipe Properties to a version-agnostic object is not supported") } // ConvertFrom converts from version-agnostic datamodel to the versioned Environment recipe properties resource. -func (dst *RecipeMetadataProperties) ConvertFrom(src v1.DataModelInterface) error { +func (dst *RecipeGetMetadataResponse) ConvertFrom(src v1.DataModelInterface) error { recipe, ok := src.(*datamodel.EnvironmentRecipeProperties) if !ok { return v1.ErrInvalidModelConversion @@ -46,9 +46,9 @@ func (dst *RecipeMetadataProperties) ConvertFrom(src v1.DataModelInterface) erro } // ConvertTo converts from the versioned Environment Recipe Properties resource to version-agnostic datamodel. -func (src *Recipe) ConvertTo() (v1.DataModelInterface, error) { +func (src *RecipeGetMetadata) ConvertTo() (v1.DataModelInterface, error) { return &datamodel.Recipe{ - Name: to.String(src.Name), - LinkType: to.String(src.LinkType), + Name: to.String(src.Name), + ResourceType: to.String(src.ResourceType), }, nil } diff --git a/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion_test.go index bc303544c2..6f9fa96f6d 100644 --- a/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/environmentrecipeproperties_conversion_test.go @@ -20,17 +20,17 @@ import ( "encoding/json" "testing" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - types "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + types "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) func TestEnvironmentRecipePropertiesConvertVersionedToDataModel(t *testing.T) { t.Run("Convert to Data Model", func(t *testing.T) { - r := &RecipeMetadataProperties{} + r := &RecipeGetMetadataResponse{} // act _, err := r.ConvertTo() @@ -49,7 +49,7 @@ func TestEnvironmentRecipePropertiesConvertDataModelToVersioned(t *testing.T) { require.NoError(t, err) // act - versioned := &RecipeMetadataProperties{} + versioned := &RecipeGetMetadataResponse{} err = versioned.ConvertFrom(r) // assert require.NoError(t, err) @@ -72,7 +72,7 @@ func TestEnvironmentRecipePropertiesConvertDataModelToVersioned_EmptyTemplateKin require.NoError(t, err) // act - versioned := &RecipeMetadataProperties{} + versioned := &RecipeGetMetadataResponse{} err = versioned.ConvertFrom(r) // assert require.NoError(t, err) @@ -89,11 +89,11 @@ func TestRecipeConvertVersionedToDataModel(t *testing.T) { t.Run("Convert to Data Model", func(t *testing.T) { filename := "reciperesource.json" expected := &datamodel.Recipe{ - LinkType: linkrp.MongoDatabasesResourceType, - Name: "mongo-azure", + ResourceType: portableresources.MongoDatabasesResourceType, + Name: "mongo-azure", } rawPayload := testutil.ReadFixture(filename) - r := &Recipe{} + r := &RecipeGetMetadata{} err := json.Unmarshal(rawPayload, r) require.NoError(t, err) // act diff --git a/pkg/corerp/api/v20220315privatepreview/extender_conversion.go b/pkg/corerp/api/v20220315privatepreview/extender_conversion.go index f6430242a3..f5153f9b91 100644 --- a/pkg/corerp/api/v20220315privatepreview/extender_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/extender_conversion.go @@ -19,12 +19,11 @@ package v20220315privatepreview import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_apiver "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned Extender resource to version-agnostic datamodel and returns it, or an error if the @@ -78,7 +77,7 @@ func (dst *ExtenderResource) ConvertFrom(src v1.DataModelInterface) error { dst.Tags = *to.StringMapPtr(extender.Tags) dst.Properties = &ExtenderProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(extender.Properties.Status.OutputResources), + OutputResources: toOutputResources(extender.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(extender.InternalMetadata.AsyncProvisioningState), Environment: to.Ptr(extender.Properties.Environment), @@ -91,24 +90,24 @@ func (dst *ExtenderResource) ConvertFrom(src v1.DataModelInterface) error { return nil } -func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (linkrp.ResourceProvisioning, error) { +func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (portableresources.ResourceProvisioning, error) { if provisioning == nil { - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil } switch *provisioning { case ResourceProvisioningManual: - return linkrp.ResourceProvisioningManual, nil + return portableresources.ResourceProvisioningManual, nil case ResourceProvisioningRecipe: - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil default: return "", &v1.ErrModelConversion{PropertyName: "$.properties.resourceProvisioning", ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues())} } } -func fromResourceProvisioningDataModel(provisioning linkrp.ResourceProvisioning) *ResourceProvisioning { +func fromResourceProvisioningDataModel(provisioning portableresources.ResourceProvisioning) *ResourceProvisioning { var converted ResourceProvisioning switch provisioning { - case linkrp.ResourceProvisioningManual: + case portableresources.ResourceProvisioningManual: converted = ResourceProvisioningManual default: converted = ResourceProvisioningRecipe @@ -117,22 +116,22 @@ func fromResourceProvisioningDataModel(provisioning linkrp.ResourceProvisioning) return &converted } -func fromRecipeDataModel(r linkrp.LinkRecipe) *ResourceRecipe { - return &ResourceRecipe{ +func fromRecipeDataModel(r portableresources.ResourceRecipe) *Recipe { + return &Recipe{ Name: to.Ptr(r.Name), Parameters: r.Parameters, } } -func toRecipeDataModel(r *ResourceRecipe) linkrp.LinkRecipe { +func toRecipeDataModel(r *Recipe) portableresources.ResourceRecipe { if r == nil { - return linkrp.LinkRecipe{ - Name: linkrp_apiver.DefaultRecipeName, + return portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, } } - recipe := linkrp.LinkRecipe{} + recipe := portableresources.ResourceRecipe{} if r.Name == nil { - recipe.Name = linkrp_apiver.DefaultRecipeName + recipe.Name = portableresources.DefaultRecipeName } else { recipe.Name = to.String(r.Name) } diff --git a/pkg/corerp/api/v20220315privatepreview/extender_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/extender_conversion_test.go index 290bd7783a..e308f266fe 100644 --- a/pkg/corerp/api/v20220315privatepreview/extender_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/extender_conversion_test.go @@ -20,12 +20,13 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_apiver "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -59,9 +60,9 @@ func TestExtender_ConvertVersionedToDataModel(t *testing.T) { Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", }, AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Secrets: map[string]any{"accountSid": "sid", "authToken": "token"}, - ResourceRecipe: linkrp.LinkRecipe{Name: "default"}, + ResourceRecipe: portableresources.ResourceRecipe{Name: "default"}, }, }, }, @@ -89,8 +90,8 @@ func TestExtender_ConvertVersionedToDataModel(t *testing.T) { Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", }, AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - ResourceRecipe: linkrp.LinkRecipe{Name: "default"}, + ResourceProvisioning: portableresources.ResourceProvisioningManual, + ResourceRecipe: portableresources.ResourceRecipe{Name: "default"}, }, }, }, @@ -117,8 +118,8 @@ func TestExtender_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - ResourceRecipe: linkrp.LinkRecipe{Name: "test-recipe"}, + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, + ResourceRecipe: portableresources.ResourceRecipe{Name: "test-recipe"}, }, }, }, @@ -126,10 +127,9 @@ func TestExtender_ConvertVersionedToDataModel(t *testing.T) { for _, payload := range testset { // arrange - rawPayload, err := linkrp_apiver.LoadTestData("./testdata/" + payload.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(payload.file) versionedResource := &ExtenderResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) // act @@ -159,17 +159,9 @@ func TestExtender_ConvertDataModelToVersioned(t *testing.T) { Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), ResourceProvisioning: to.Ptr(ResourceProvisioningManual), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &ResourceRecipe{Name: to.Ptr(""), Parameters: nil}, + Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "ExtenderProvider", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), @@ -189,7 +181,7 @@ func TestExtender_ConvertDataModelToVersioned(t *testing.T) { Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), ResourceProvisioning: to.Ptr(ResourceProvisioningManual), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &ResourceRecipe{Name: to.Ptr(""), Parameters: nil}, + Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, Status: &ResourceStatus{}, }, @@ -211,16 +203,8 @@ func TestExtender_ConvertDataModelToVersioned(t *testing.T) { Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &ResourceRecipe{Name: to.Ptr("test-recipe"), Parameters: nil}, - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "ExtenderProvider", - }, - }, - }, + Recipe: &Recipe{Name: to.Ptr("test-recipe"), Parameters: nil}, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), @@ -234,10 +218,9 @@ func TestExtender_ConvertDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := linkrp_apiver.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) resource := &datamodel.Extender{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &ExtenderResource{} @@ -257,7 +240,7 @@ func TestExtender_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/gateway_conversion.go b/pkg/corerp/api/v20220315privatepreview/gateway_conversion.go index 3d29041144..237c3f6300 100644 --- a/pkg/corerp/api/v20220315privatepreview/gateway_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/gateway_conversion.go @@ -17,10 +17,10 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned Gateway resource to version-agnostic datamodel. @@ -97,9 +97,9 @@ func (dst *GatewayResource) ConvertFrom(src v1.DataModelInterface) error { return v1.ErrInvalidModelConversion } - var tls *GatewayPropertiesTLS + var tls *GatewayTLS if g.Properties.TLS != nil { - tls = &GatewayPropertiesTLS{ + tls = &GatewayTLS{ CertificateFrom: to.Ptr(g.Properties.TLS.CertificateFrom), MinimumProtocolVersion: fromTLSMinVersionDataModel(g.Properties.TLS.MinimumProtocolVersion), SSLPassthrough: to.Ptr(g.Properties.TLS.SSLPassthrough), @@ -118,9 +118,9 @@ func (dst *GatewayResource) ConvertFrom(src v1.DataModelInterface) error { } } - var hostname *GatewayPropertiesHostname + var hostname *GatewayHostname if g.Properties.Hostname != nil { - hostname = &GatewayPropertiesHostname{ + hostname = &GatewayHostname{ FullyQualifiedHostname: to.Ptr(g.Properties.Hostname.FullyQualifiedHostname), Prefix: to.Ptr(g.Properties.Hostname.Prefix), } @@ -134,7 +134,7 @@ func (dst *GatewayResource) ConvertFrom(src v1.DataModelInterface) error { dst.Tags = *to.StringMapPtr(g.Tags) dst.Properties = &GatewayProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(g.Properties.Status.OutputResources), + OutputResources: toOutputResources(g.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(g.InternalMetadata.AsyncProvisioningState), Application: to.Ptr(g.Properties.Application), @@ -153,9 +153,9 @@ func toTLSMinVersionDataModel(tlsMinVersion *TLSMinVersion) datamodel.MinimumTLS } switch *tlsMinVersion { - case TLSMinVersionOne2: + case TLSMinVersionTls12: return datamodel.TLSMinVersion12 - case TLSMinVersionOne3: + case TLSMinVersionTls13: return datamodel.TLSMinVersion13 default: return datamodel.DefaultTLSMinVersion @@ -166,11 +166,11 @@ func fromTLSMinVersionDataModel(tlsMinVersion datamodel.MinimumTLSProtocolVersio var t TLSMinVersion switch tlsMinVersion { case datamodel.TLSMinVersion12: - t = TLSMinVersionOne2 + t = TLSMinVersionTls12 case datamodel.TLSMinVersion13: - t = TLSMinVersionOne3 + t = TLSMinVersionTls13 default: - t = TLSMinVersionOne2 + t = TLSMinVersionTls12 } return &t diff --git a/pkg/corerp/api/v20220315privatepreview/gateway_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/gateway_conversion_test.go index 0512e53451..521df4a370 100644 --- a/pkg/corerp/api/v20220315privatepreview/gateway_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/gateway_conversion_test.go @@ -20,10 +20,11 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -77,8 +78,7 @@ func TestGatewayConvertDataModelToVersioned(t *testing.T) { require.Equal(t, "myreplaceprefix", *versioned.Properties.Routes[0].ReplacePrefix) require.Equal(t, "mypath", *versioned.Properties.Routes[0].Path) require.Equal(t, "http://myprefix.myapp.mydomain.com", *versioned.Properties.URL) - require.Equal(t, "Deployment", versioned.Properties.Status.OutputResources[0]["LocalID"]) - require.Equal(t, "kubernetes", versioned.Properties.Status.OutputResources[0]["Provider"]) + require.Equal(t, resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), versioned.Properties.Status) } func TestGatewaySSLPassthroughConvertVersionedToDataModel(t *testing.T) { @@ -132,8 +132,7 @@ func TestGatewaySSLPassthroughConvertDataModelToVersioned(t *testing.T) { require.Equal(t, "mypath", *versioned.Properties.Routes[0].Path) require.Equal(t, "myreplaceprefix", *versioned.Properties.Routes[0].ReplacePrefix) require.Equal(t, "http://myprefix.myapp.mydomain.com", *versioned.Properties.URL) - require.Equal(t, "Deployment", versioned.Properties.Status.OutputResources[0]["LocalID"]) - require.Equal(t, "kubernetes", versioned.Properties.Status.OutputResources[0]["Provider"]) + require.Equal(t, resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), versioned.Properties.Status) require.Equal(t, true, *versioned.Properties.TLS.SSLPassthrough) } @@ -189,10 +188,9 @@ func TestGatewayTLSTerminationConvertDataModelToVersioned(t *testing.T) { require.Equal(t, "mypath", *versioned.Properties.Routes[0].Path) require.Equal(t, "myreplaceprefix", *versioned.Properties.Routes[0].ReplacePrefix) require.Equal(t, "http://myprefix.myapp.mydomain.com", *versioned.Properties.URL) - require.Equal(t, "Deployment", versioned.Properties.Status.OutputResources[0]["LocalID"]) - require.Equal(t, "kubernetes", versioned.Properties.Status.OutputResources[0]["Provider"]) + require.Equal(t, resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), versioned.Properties.Status) require.Equal(t, "secretname", *versioned.Properties.TLS.CertificateFrom) - require.Equal(t, TLSMinVersionOne3, *versioned.Properties.TLS.MinimumProtocolVersion) + require.Equal(t, TLSMinVersionTls13, *versioned.Properties.TLS.MinimumProtocolVersion) } func TestGatewayTLSTerminationConvertVersionedToDataModel_NoMinProtocolVersion(t *testing.T) { @@ -247,10 +245,9 @@ func TestGatewayTLSTerminationConvertDataModelToVersioned_NoMinProtocolVersion(t require.Equal(t, "mypath", *versioned.Properties.Routes[0].Path) require.Equal(t, "myreplaceprefix", *versioned.Properties.Routes[0].ReplacePrefix) require.Equal(t, "http://myprefix.myapp.mydomain.com", *versioned.Properties.URL) - require.Equal(t, "Deployment", versioned.Properties.Status.OutputResources[0]["LocalID"]) - require.Equal(t, "kubernetes", versioned.Properties.Status.OutputResources[0]["Provider"]) + require.Equal(t, resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), versioned.Properties.Status) require.Equal(t, "secretname", *versioned.Properties.TLS.CertificateFrom) - require.Equal(t, TLSMinVersionOne2, *versioned.Properties.TLS.MinimumProtocolVersion) + require.Equal(t, TLSMinVersionTls12, *versioned.Properties.TLS.MinimumProtocolVersion) } func TestGatewayConvertFromValidation(t *testing.T) { @@ -258,7 +255,7 @@ func TestGatewayConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/httproute_conversion.go b/pkg/corerp/api/v20220315privatepreview/httproute_conversion.go index 258b8fe7ac..cd3c935f6d 100644 --- a/pkg/corerp/api/v20220315privatepreview/httproute_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/httproute_conversion.go @@ -17,10 +17,10 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned HTTPRoute resource to version-agnostic datamodel. @@ -68,7 +68,7 @@ func (dst *HTTPRouteResource) ConvertFrom(src v1.DataModelInterface) error { dst.Tags = *to.StringMapPtr(route.Tags) dst.Properties = &HTTPRouteProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(route.Properties.Status.OutputResources), + OutputResources: toOutputResources(route.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(route.InternalMetadata.AsyncProvisioningState), Application: to.Ptr(route.Properties.Application), diff --git a/pkg/corerp/api/v20220315privatepreview/httproute_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/httproute_conversion_test.go index 24162324e0..bd75d6ea9b 100644 --- a/pkg/corerp/api/v20220315privatepreview/httproute_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/httproute_conversion_test.go @@ -20,10 +20,11 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -74,8 +75,7 @@ func TestHTTPRouteConvertDataModelToVersioned(t *testing.T) { require.Equal(t, int32(8080), r.Properties.Port) require.Equal(t, "http", r.Properties.Scheme) require.Equal(t, "http://testapplications.com/httproute/", r.Properties.URL) - require.Equal(t, "Deployment", versioned.Properties.Status.OutputResources[0]["LocalID"]) - require.Equal(t, "kubernetes", versioned.Properties.Status.OutputResources[0]["Provider"]) + require.Equal(t, resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), versioned.Properties.Status) } func TestHTTPRouteConvertFromValidation(t *testing.T) { @@ -83,7 +83,7 @@ func TestHTTPRouteConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/secretstore_conversion.go b/pkg/corerp/api/v20220315privatepreview/secretstore_conversion.go index 21750be56b..a150a115a0 100644 --- a/pkg/corerp/api/v20220315privatepreview/secretstore_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/secretstore_conversion.go @@ -17,10 +17,10 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned SecretStoreResource resource to version-agnostic datamodel. @@ -66,7 +66,7 @@ func (dst *SecretStoreResource) ConvertFrom(src v1.DataModelInterface) error { dst.Tags = *to.StringMapPtr(ss.Tags) dst.Properties = &SecretStoreProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(ss.Properties.Status.OutputResources), + OutputResources: toOutputResources(ss.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(ss.InternalMetadata.AsyncProvisioningState), Application: to.Ptr(ss.Properties.Application), diff --git a/pkg/corerp/api/v20220315privatepreview/secretstore_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/secretstore_conversion_test.go index 61617e04d8..27f5dd0bab 100644 --- a/pkg/corerp/api/v20220315privatepreview/secretstore_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/secretstore_conversion_test.go @@ -20,12 +20,12 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -107,8 +107,7 @@ func TestSecretStoreConvertDataModelToVersioned(t *testing.T) { require.Equal(t, "Applications.Core/secretStores", r.Type) require.Equal(t, "dev", r.Tags["env"]) require.Equal(t, "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", r.Properties.Application) - identity := versioned.Properties.Status.OutputResources[0]["Identity"].(resourcemodel.KubernetesIdentity) - require.Equal(t, "Secret", identity.Kind) + require.Equal(t, resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), versioned.Properties.Status) require.Equal(t, "certificate", string(*versioned.Properties.Type)) require.Nil(t, versioned.Properties.Data["tls.crt"].Encoding) require.Equal(t, "", to.String(versioned.Properties.Data["tls.crt"].Value)) @@ -150,7 +149,7 @@ func TestSecretStoreConvertFromValidation(t *testing.T) { src v1.ResourceDataModel err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresource-runtimes.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresource-runtimes.json new file mode 100644 index 0000000000..f297aa46b0 --- /dev/null +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresource-runtimes.json @@ -0,0 +1,89 @@ +{ + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "provisioningState": "Succeeded", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "source": "inventory_route_id", + "disableDefaultEnvVars": true, + "iam": { + "kind": "azure", + "roles": [ + "read" + ] + } + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "livenessProbe": { + "kind": "tcp", + "failureThreshold": 5, + "initialDelaySeconds": 5, + "periodSeconds": 5, + "timeoutSeconds": 5, + "containerPort": 8080 + }, + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcuri/id", + "resource": "resourceid" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 + }, + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" + }, + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ], + "runtimes": { + "kubernetes": { + "base": "apiVersion: v1\nkind: Service\nmetadata:\n name: my-service\nspec:\n selector:\n app.kubernetes.io/name: MyApp\n ports:\n - protocol: TCP\n port: 80\n targetPort: 9376", + "pod": { + "containers": [ + { + "name": "sidecar" + } + ], + "hostNetwork": true + } + } + } + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresource.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresource.json index 308d92c379..c53d5aa869 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/containerresource.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresource.json @@ -6,11 +6,7 @@ "status": { "outputResources": [ { - "LocalID": "Deployment", - "ResourceType": { - "Type": "containers", - "Provider": "aks" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodel-runtime.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodel-runtime.json new file mode 100644 index 0000000000..0364a72c9f --- /dev/null +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodel-runtime.json @@ -0,0 +1,101 @@ +{ + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "provisioningState": "Succeeded", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "source": "inventory_route_id", + "iam": { + "kind": "azure", + "roles": [ + "read" + ] + } + } + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcuri/id", + "resource": "resourceid" + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "livenessProbe": { + "kind": "tcp", + "tcp": { + "healthProbeBase": { + "failureThreshold": 5, + "initialDelaySeconds": 5, + "periodSeconds": 5 + }, + "containerPort": 8080 + } + }, + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "extensions": [ + { + "kind": "manualScaling", + "manualScaling": { + "replicas": 2 + } + }, + { + "kind": "daprSidecar", + "daprSidecar": { + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" + } + }, + { + "kind": "kubernetesMetadata", + "kubernetesmetadata": { + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + } + ], + "runtimes": { + "kubernetes": { + "base": "apiVersion: v1\nkind: Service\nmetadata:\n name: my-service\nspec:\n selector:\n app.kubernetes.io/name: MyApp\n ports:\n - protocol: TCP\n port: 80\n targetPort: 9376", + "pod": "{\"containers\":[{\"name\":\"sidecar\"}],\"hostNetwork\":true}" + } + } + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodel.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodel.json index 996f62bade..57bb303c92 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodel.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodel.json @@ -18,11 +18,7 @@ "status": { "outputResources": [ { - "LocalID": "Deployment", - "ResourceType": { - "Type": "containers", - "Provider": "aks" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodelemptyext.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodelemptyext.json index 0b272ae4ea..285068e132 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodelemptyext.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcedatamodelemptyext.json @@ -1,89 +1,85 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "provisioningState": "Succeeded", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "source": "inventory_route_id", + "iam": { + "kind": "azure", + "roles": [ + "read" + ] + } + } }, - "provisioningState": "Succeeded", - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "containers", - "Provider": "aks" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "source": "inventory_route_id", - "iam": { - "kind": "azure", - "roles": [ - "read" - ] - } + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcuri/id", + "resource": "resourceid" + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "livenessProbe": { + "kind": "tcp", + "tcp": { + "healthProbeBase": { + "failureThreshold": 5, + "initialDelaySeconds": 5, + "periodSeconds": 5 + }, + "containerPort": 8080 } }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcuri/id", - "resource": "resourceid" - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "livenessProbe": { - "kind": "tcp", - "tcp": { - "healthProbeBase": { - "failureThreshold": 5, - "initialDelaySeconds": 5, - "periodSeconds": 5 - }, - "containerPort": 8080 - } - }, - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "extensions": [ + { + "kind": "manualScaling", + "manualScaling": { + "replicas": 2 + } }, - "extensions": [ - { - "kind": "manualScaling", - "manualScaling": { - "replicas": 2 - } - }, - { - "kind": "daprSidecar", - "daprSidecar": { - "appId": "app-id", - "appPort": 80, - "config": "config", - "protocol": "http" - } - }, - { - "kind": "kubernetesMetadata" + { + "kind": "daprSidecar", + "daprSidecar": { + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" } - ] - } - } \ No newline at end of file + }, + { + "kind": "kubernetesMetadata" + } + ] + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext.json index 05c38645bb..2a2f48e5c3 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext.json @@ -1,74 +1,70 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "containers", - "Provider": "aks" - } - } - ] - }, - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "source": "inventory_route_id", - "disableDefaultEnvVars": true, - "iam": { - "kind": "azure", - "roles": [ - "read" - ] - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "provisioningState": "Succeeded", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "source": "inventory_route_id", + "disableDefaultEnvVars": true, + "iam": { + "kind": "azure", + "roles": [ + "read" + ] + } + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "livenessProbe": { + "kind": "tcp", + "failureThreshold": 5, + "initialDelaySeconds": 5, + "periodSeconds": 5, + "timeoutSeconds": 5, + "containerPort": 8080 }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "livenessProbe": { - "kind": "tcp", - "failureThreshold": 5, - "initialDelaySeconds": 5, - "periodSeconds": 5, - "timeoutSeconds": 5, - "containerPort": 8080 - }, - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcuri/id", + "resource": "resourceid" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcuri/id", - "resource": "resourceid" + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" }, - "extensions": [ - { - "kind": "manualScaling", - "replicas": 2 - }, - { - "kind": "daprSidecar", - "appId": "app-id", - "appPort": 80, - "config": "config", - "protocol": "http" - }, - { - "kind": "kubernetesMetadata", - "annotations": {}, - "labels": {} - } - ] - } - } \ No newline at end of file + { + "kind": "kubernetesMetadata", + "annotations": {}, + "labels": {} + } + ] + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext2.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext2.json index a5c0117707..a177501577 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext2.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourceemptyext2.json @@ -1,72 +1,68 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "containers", - "Provider": "aks" - } - } - ] - }, - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "source": "inventory_route_id", - "disableDefaultEnvVars": true, - "iam": { - "kind": "azure", - "roles": [ - "read" - ] - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "provisioningState": "Succeeded", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "source": "inventory_route_id", + "disableDefaultEnvVars": true, + "iam": { + "kind": "azure", + "roles": [ + "read" + ] + } + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "livenessProbe": { + "kind": "tcp", + "failureThreshold": 5, + "initialDelaySeconds": 5, + "periodSeconds": 5, + "timeoutSeconds": 5, + "containerPort": 8080 }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "livenessProbe": { - "kind": "tcp", - "failureThreshold": 5, - "initialDelaySeconds": 5, - "periodSeconds": 5, - "timeoutSeconds": 5, - "containerPort": 8080 - }, - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcuri/id", + "resource": "resourceid" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcuri/id", - "resource": "resourceid" + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" }, - "extensions": [ - { - "kind": "manualScaling", - "replicas": 2 - }, - { - "kind": "daprSidecar", - "appId": "app-id", - "appPort": 80, - "config": "config", - "protocol": "http" - }, - { - "kind": "kubernetesMetadata" - } - ] - } - } \ No newline at end of file + { + "kind": "kubernetesMetadata" + } + ] + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcenegativetest.json b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcenegativetest.json index 7f594a9147..532694b031 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcenegativetest.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/containerresourcenegativetest.json @@ -6,11 +6,7 @@ "status": { "outputResources": [ { - "LocalID": "Deployment", - "ResourceType": { - "Type": "containers", - "Provider": "aks" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-linktype.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-linktype.json deleted file mode 100644 index e00cb9da1f..0000000000 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-linktype.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "name": "env0", - "type": "Applications.Core/environments", - "properties": { - "compute": { - "kind": "kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default" - }, - "providers": { - "azure": { - "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" - }, - "aws": { - "scope": "/planes/aws/aws/accounts/140313373712/regions/us-west-2" - } - }, - "recipes": { - "Applications.Link/pubsub":{ - "cosmos-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/pubsub" - } - } - } - } - } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-resourcetype.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-resourcetype.json new file mode 100644 index 0000000000..217e39f54f --- /dev/null +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-resourcetype.json @@ -0,0 +1,28 @@ +{ + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "compute": { + "kind": "kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default" + }, + "providers": { + "azure": { + "scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + }, + "aws": { + "scope": "/planes/aws/aws/accounts/140313373712/regions/us-west-2" + } + }, + "recipes": { + "Applications.Dapr/pubsub":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/pubsub" + } + } + } + } + } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-templatekind.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-templatekind.json index 6a4d4f9a52..d59b36a83a 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-templatekind.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-invalid-templatekind.json @@ -14,7 +14,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "helm", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/mongo" diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-missing-templatekind.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-missing-templatekind.json index b4729202b2..6288126867 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-missing-templatekind.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-missing-templatekind.json @@ -14,7 +14,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/mongo" } diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-terraformrecipe-localpath.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-terraformrecipe-localpath.json index 095ec7bf86..145cf4a3c5 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-terraformrecipe-localpath.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-terraformrecipe-localpath.json @@ -14,7 +14,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "terraform", "templatePath": "../not-allowed/" diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-with-workload-identity.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-with-workload-identity.json index 76dedf0711..45ddb6e7c3 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-with-workload-identity.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource-with-workload-identity.json @@ -19,7 +19,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource.json index e0f691271d..f8673b1d36 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresource.json @@ -17,7 +17,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/mongodatabases", @@ -35,13 +35,13 @@ "templatePath": "http://example.com/myrecipe.zip" } }, - "Applications.Link/redisCaches":{ + "Applications.Datastores/redisCaches":{ "redis-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/rediscaches" } }, - "Applications.Link/daprStateStores":{ + "Applications.Dapr/stateStores":{ "statestore-recipe": { "templateKind": "terraform", "templatePath": "Azure/storage/azurerm", diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel-with-workload-identity.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel-with-workload-identity.json index 94fa8c1d91..71dd115a5a 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel-with-workload-identity.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel-with-workload-identity.json @@ -32,7 +32,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel.json index c7ba9c3197..b361ca6d9e 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodel.json @@ -30,7 +30,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptyext.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptyext.json index 3cfeef0c81..e32d7dc027 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptyext.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptyext.json @@ -30,7 +30,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptytemplatekind.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptytemplatekind.json index 4e50f8ac6e..bfab0d1d29 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptytemplatekind.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourcedatamodelemptytemplatekind.json @@ -27,7 +27,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" } diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext.json index d26670c5d5..4a0a4dbdda 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext.json @@ -14,7 +14,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext2.json b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext2.json index 4bdc949084..d9f13ccdf8 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext2.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/environmentresourceemptyext2.json @@ -14,7 +14,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "cosmos-recipe": { "templateKind": "bicep", "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/extender_manual.json b/pkg/corerp/api/v20220315privatepreview/testdata/extender_manual.json index 7ffc98b6e7..d3ebe2bd3c 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/extender_manual.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/extender_manual.json @@ -1,24 +1,22 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken": "token" - }, - "resourceProvisioning": "manual" - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken": "token" + }, + "resourceProvisioning": "manual" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/extender_recipe.json b/pkg/corerp/api/v20220315privatepreview/testdata/extender_recipe.json index 0e15799e71..d90eb5898d 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/extender_recipe.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/extender_recipe.json @@ -1,21 +1,19 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "test-recipe" - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "recipe": { + "name": "test-recipe" } + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_manual.json b/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_manual.json index 42c4ac0300..f557f855c1 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_manual.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_manual.json @@ -1,37 +1,35 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "additionalProperties": { + "fromNumber": "222-222-2222" }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "additionalProperties":{ - "fromNumber": "222-222-2222" - }, - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } -} + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_recipe.json b/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_recipe.json index efc983aba4..dd931d5e5e 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_recipe.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/extenderdatamodel_recipe.json @@ -1,32 +1,30 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "test-recipe" - } + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "recipe": { + "name": "test-recipe" } -} + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/extenderresponseresourcedatamodel.json b/pkg/corerp/api/v20220315privatepreview/testdata/extenderresponseresourcedatamodel.json index e9e10ddb4b..8ac29c54b0 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/extenderresponseresourcedatamodel.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/extenderresponseresourcedatamodel.json @@ -1,33 +1,31 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "additionalProperties": { + "fromNumber": "222-222-2222" }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "additionalProperties":{ - "fromNumber": "222-222-2222" - }, - "resourceProvisioning": "manual" - } -} + "resourceProvisioning": "manual" + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-sslpassthrough.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-sslpassthrough.json index 5ea604fba3..8af0e3ac85 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-sslpassthrough.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-sslpassthrough.json @@ -1,34 +1,30 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls": { - "sslPassthrough": true - }, - "url": "http://myprefix.myapp.mydomain.com" - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" + }, + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "sslPassthrough": true + }, + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination-nominprotocolversion.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination-nominprotocolversion.json index d02b2dbc45..86032cb2b3 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination-nominprotocolversion.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination-nominprotocolversion.json @@ -1,34 +1,30 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls": { - "certificateFrom": "secretname" - }, - "url": "http://myprefix.myapp.mydomain.com" - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" + }, + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "certificateFrom": "secretname" + }, + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination.json index 21d404e567..cf14076331 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource-with-tlstermination.json @@ -1,35 +1,31 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls": { - "certificateFrom": "secretname", - "minimumProtocolVersion": "1.3" - }, - "url": "http://myprefix.myapp.mydomain.com" - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" + }, + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "certificateFrom": "secretname", + "minimumProtocolVersion": "1.3" + }, + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource.json index 5ca8254efe..a0df3dfb35 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresource.json @@ -1,31 +1,27 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "url": "http://myprefix.myapp.mydomain.com" - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" + }, + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-sslpassthrough.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-sslpassthrough.json index a3877e7afc..92249ee132 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-sslpassthrough.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-sslpassthrough.json @@ -1,45 +1,41 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" }, - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls": { - "sslPassthrough": true - }, - "url": "http://myprefix.myapp.mydomain.com" - } + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "sslPassthrough": true + }, + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination-nominprotocolversion.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination-nominprotocolversion.json index cc611a6ad2..93f1a34d0b 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination-nominprotocolversion.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination-nominprotocolversion.json @@ -1,45 +1,41 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" }, - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls": { - "certificateFrom": "secretname" - }, - "url": "http://myprefix.myapp.mydomain.com" - } + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "certificateFrom": "secretname" + }, + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination.json index f7c8b5d431..b0d1aedfc3 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel-with-tlstermination.json @@ -1,46 +1,42 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" }, - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls": { - "certificateFrom": "secretname", - "minimumProtocolVersion": "1.3" - }, - "url": "http://myprefix.myapp.mydomain.com" - } + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "certificateFrom": "secretname", + "minimumProtocolVersion": "1.3" + }, + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel.json b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel.json index 38853ca0ba..255a6366f6 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/gatewayresourcedatamodel.json @@ -1,42 +1,38 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" }, - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix": "myprefix" - }, - "routes": [ - { - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "url": "http://myprefix.myapp.mydomain.com" - } + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "url": "http://myprefix.myapp.mydomain.com" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresource.json b/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresource.json index a52810c5e7..039861adc5 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresource.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresource.json @@ -1,21 +1,19 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/httpRoutes/route0", - "name": "route0", - "type": "Applications.Core/httpRoutes", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "HttpRoute", - "Provider": "kubernetes" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": "localhost", - "port":8080, - "scheme": "http", - "url": "http://testapplications.com/httproute/" - } -} + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": "localhost", + "port": 8080, + "scheme": "http", + "url": "http://testapplications.com/httproute/" + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresourcedatamodel.json b/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresourcedatamodel.json index 802c1433ea..b2b3eb364c 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresourcedatamodel.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/httprouteresourcedatamodel.json @@ -1,32 +1,30 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/httpRoutes/route0", - "name": "route0", - "type": "Applications.Core/httpRoutes", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "HttpRoute", - "Provider": "kubernetes" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": "localhost", - "port":8080, - "scheme": "http", - "url": "http://testapplications.com/httproute/" - } -} + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": "localhost", + "port": 8080, + "scheme": "http", + "url": "http://testapplications.com/httproute/" + } +} \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/reciperesource.json b/pkg/corerp/api/v20220315privatepreview/testdata/reciperesource.json index c55f66c896..ee608ee6db 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/reciperesource.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/reciperesource.json @@ -1,4 +1,4 @@ { - "linkType":"Applications.Link/mongoDatabases", + "resourceType":"Applications.Datastores/mongoDatabases", "name":"mongo-azure" } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel-resource.json b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel-resource.json index 02bd47d720..d0dc865d13 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel-resource.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel-resource.json @@ -1,54 +1,43 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", - "name": "secret0", - "type": "Applications.Core/secretStores", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/tls_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/tls_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "status": { - "outputResources": [ - { - "identity": { - "resourceType": { - "type": "Secret", - "provider": "kubernetes" - }, - "data": { - "kind": "Secret", - "apiVersion": "v1", - "namespace": "app0-default", - "name": "secret0" - } - } - } - ] + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "properties": { + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/tls_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/tls_key", + "version": "1" } + } }, - "tags": { - "env": "dev" + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] } + }, + "tags": { + "env": "dev" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel.json b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel.json index 24e97b5c4d..549ea8ab32 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-datamodel.json @@ -1,49 +1,38 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", - "name": "secret0", - "type": "Applications.Core/secretStores", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "properties": { + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "value": "-----BEGIN CERT---- ..." + }, + "tls.key": { + "encoding": "base64", + "value": "-----BEGIN KEY---- ..." + } }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "value": "-----BEGIN CERT---- ..." - }, - "tls.key": { - "encoding": "base64", - "value": "-----BEGIN KEY---- ..." - } - }, - "resource": "default/letsencrypt-prod", - "status": { - "outputResources": [ - { - "identity": { - "resourceType": { - "type": "Secret", - "provider": "kubernetes" - }, - "data": { - "kind": "Secret", - "apiVersion": "v1", - "namespace": "default", - "name": "letsencrypt-prod" - } - } - } - ] + "resource": "default/letsencrypt-prod", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } - }, - "tags": { - "env": "dev" + ] } + }, + "tags": { + "env": "dev" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned-resource.json b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned-resource.json index 7d57e90096..c1a99b3eb5 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned-resource.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned-resource.json @@ -1,46 +1,35 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", - "name": "secret0", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/tls_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/tls_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "status": { - "outputResources": [ - { - "identity": { - "resourceType": { - "type": "Secret", - "provider": "kubernetes" - }, - "data": { - "kind": "Secret", - "apiVersion": "v1", - "namespace": "app0-default", - "name": "secret0" - } - } - } - ] + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/tls_cert", + "version": "1" } + }, + "tls.key": { + "valueFrom": { + "name": "secret/tls_key", + "version": "1" + } + } }, - "tags": { - "env": "dev" + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] } + }, + "tags": { + "env": "dev" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned.json b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned.json index 44ffdcea9a..563a4c203f 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/secretstore-versioned.json @@ -1,40 +1,29 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", - "name": "secret0", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "encoding": "base64", - "value": "-----BEGIN CERT---- ..." - }, - "tls.key": { - "value": "-----BEGIN KEY---- ..." - } - }, - "status": { - "outputResources": [ - { - "identity": { - "resourceType": { - "type": "Secret", - "provider": "kubernetes" - }, - "data": { - "kind": "Secret", - "apiVersion": "v1", - "namespace": "default", - "name": "letsencrypt-prod" - } - } - } - ] - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "encoding": "base64", + "value": "-----BEGIN CERT---- ..." + }, + "tls.key": { + "value": "-----BEGIN KEY---- ..." + } }, - "tags": { - "env": "dev" + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] } + }, + "tags": { + "env": "dev" + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv-datamodel.json b/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv-datamodel.json index b6cb739a8f..5c68dbf9c3 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv-datamodel.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv-datamodel.json @@ -1,70 +1,68 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/volumes/azkeyvault0", - "name": "azkeyvault0", - "type": "Applications.Core/volumes", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/volumes/azkeyvault0", + "name": "azkeyvault0", + "type": "Applications.Core/volumes", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "provisioningState": "Succeeded", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "provisioningState": "Succeeded", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Volume", - "Provider": "kubernetes" - } - }] + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "azureKeyVault": { + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "alias": "aliassecret-1", + "version": "1", + "encoding": "utf-8" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "alias": "aliaskey1-1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "alias": "aliascert1-1", + "certType": "certificate", + "encoding": "utf-8" }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "azureKeyVault": { - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "alias": "aliassecret-1", - "version": "1", - "encoding": "utf-8" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "alias": "aliaskey1-1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "alias": "aliascert1-1", - "certType": "certificate", - "encoding": "utf-8" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" } + } } + } } \ No newline at end of file diff --git a/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv.json b/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv.json index 3dddfefefa..e8e09a8651 100644 --- a/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv.json +++ b/pkg/corerp/api/v20220315privatepreview/testdata/volume-az-kv.json @@ -16,10 +16,11 @@ }, "properties": { "status": { - "outputResources": [{ - "LocalID": "Deployment", - "Provider": "kubernetes" - }] + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, "provisioningState": "Succeeded", "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", diff --git a/pkg/corerp/api/v20220315privatepreview/util.go b/pkg/corerp/api/v20220315privatepreview/util.go index 04924090d6..c38ea491ed 100644 --- a/pkg/corerp/api/v20220315privatepreview/util.go +++ b/pkg/corerp/api/v20220315privatepreview/util.go @@ -19,11 +19,10 @@ package v20220315privatepreview import ( "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" "golang.org/x/exp/slices" ) @@ -122,29 +121,26 @@ func stringSlice(s []*string) []string { return r } -func isValidLinkType(link string) bool { - linkTypes := []string{ - linkrp.DaprPubSubBrokersResourceType, - linkrp.DaprSecretStoresResourceType, - linkrp.DaprStateStoresResourceType, - linkrp.ExtendersResourceType, - linkrp.MongoDatabasesResourceType, - linkrp.RabbitMQMessageQueuesResourceType, - linkrp.RedisCachesResourceType, - linkrp.SqlDatabasesResourceType, - // Resources After Split of LinkRP Namespace - linkrp.N_RabbitMQQueuesResourceType, - linkrp.N_DaprPubSubBrokersResourceType, - linkrp.N_DaprSecretStoresResourceType, - linkrp.N_DaprStateStoresResourceType, - linkrp.N_MongoDatabasesResourceType, - linkrp.N_RedisCachesResourceType, - linkrp.N_SqlDatabasesResourceType, - linkrp.N_ExtendersResourceType, - } - return slices.Contains(linkTypes, link) -} - func isValidTemplateKind(templateKind string) bool { return slices.Contains(recipes.SupportedTemplateKind, templateKind) } + +func toOutputResources(outputResources []rpv1.OutputResource) []*OutputResource { + var outResources []*OutputResource + for _, or := range outputResources { + r := &OutputResource{ + ID: to.Ptr(or.ID.String()), + } + + // We will not serialize the following fields if they are empty or nil. + if or.LocalID != "" { + r.LocalID = to.Ptr(or.LocalID) + } + if or.RadiusManaged != nil { + r.RadiusManaged = or.RadiusManaged + } + + outResources = append(outResources, r) + } + return outResources +} diff --git a/pkg/corerp/api/v20220315privatepreview/util_test.go b/pkg/corerp/api/v20220315privatepreview/util_test.go index 1a487956b9..5518c45f12 100644 --- a/pkg/corerp/api/v20220315privatepreview/util_test.go +++ b/pkg/corerp/api/v20220315privatepreview/util_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/require" ) @@ -124,13 +124,3 @@ func TestFromSystemDataModel(t *testing.T) { require.Equal(t, tt.LastModifiedAt, string(c)) } } - -func TestValidLinkType(t *testing.T) { - isValid := isValidLinkType("Applications.Link/mongoDatabases") - require.Equal(t, true, isValid) -} - -func TestInvalidLinkType(t *testing.T) { - isValid := isValidLinkType("Applications.Link/pubSubBroker") - require.Equal(t, false, isValid) -} diff --git a/pkg/corerp/api/v20220315privatepreview/volume_conversion.go b/pkg/corerp/api/v20220315privatepreview/volume_conversion.go index 876c013a19..d7b13011b9 100644 --- a/pkg/corerp/api/v20220315privatepreview/volume_conversion.go +++ b/pkg/corerp/api/v20220315privatepreview/volume_conversion.go @@ -17,10 +17,10 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned HTTPRoute resource to version-agnostic datamodel. @@ -95,7 +95,7 @@ func (dst *VolumeResource) ConvertFrom(src v1.DataModelInterface) error { azProp := resource.Properties.AzureKeyVault p := &AzureKeyVaultVolumeProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(resource.Properties.Status.OutputResources), + OutputResources: toOutputResources(resource.Properties.Status.OutputResources), }, Kind: to.Ptr(resource.Properties.Kind), Application: to.Ptr(resource.Properties.Application), @@ -167,8 +167,8 @@ func toSecretDataModel(s *SecretObjectProperties) *datamodel.SecretObjectPropert } } -func fromEncoding(encode *datamodel.SecretEncoding) *Encoding { - enc := EncodingUTF8 +func fromEncoding(encode *datamodel.SecretEncoding) *VolumeSecretEncodings { + enc := VolumeSecretEncodingsUTF8 if encode == nil { return &enc @@ -176,18 +176,18 @@ func fromEncoding(encode *datamodel.SecretEncoding) *Encoding { switch *encode { case datamodel.SecretObjectPropertiesEncodingBase64: - enc = EncodingBase64 + enc = VolumeSecretEncodingsBase64 case datamodel.SecretObjectPropertiesEncodingHex: - enc = EncodingHex + enc = VolumeSecretEncodingsHex case datamodel.SecretObjectPropertiesEncodingUTF8: - enc = EncodingUTF8 + enc = VolumeSecretEncodingsUTF8 default: - enc = EncodingUTF8 + enc = VolumeSecretEncodingsUTF8 } return &enc } -func toEncoding(e *Encoding) *datamodel.SecretEncoding { +func toEncoding(e *VolumeSecretEncodings) *datamodel.SecretEncoding { enc := datamodel.SecretObjectPropertiesEncodingUTF8 if e == nil { @@ -195,11 +195,11 @@ func toEncoding(e *Encoding) *datamodel.SecretEncoding { } switch *e { - case EncodingBase64: + case VolumeSecretEncodingsBase64: enc = datamodel.SecretObjectPropertiesEncodingBase64 - case EncodingHex: + case VolumeSecretEncodingsHex: enc = datamodel.SecretObjectPropertiesEncodingHex - case EncodingUTF8: + case VolumeSecretEncodingsUTF8: enc = datamodel.SecretObjectPropertiesEncodingUTF8 default: enc = datamodel.SecretObjectPropertiesEncodingUTF8 @@ -217,9 +217,9 @@ func toCertDataModel(c *CertificateObjectProperties) *datamodel.CertificateObjec if c.Format != nil { switch *c.Format { - case FormatPem: + case CertificateFormatsPem: prop.Format = to.Ptr(datamodel.CertificateFormatPEM) - case FormatPfx: + case CertificateFormatsPfx: prop.Format = to.Ptr(datamodel.CertificateFormatPFX) default: prop.Format = to.Ptr(datamodel.CertificateFormatPEM) @@ -228,11 +228,11 @@ func toCertDataModel(c *CertificateObjectProperties) *datamodel.CertificateObjec if c.CertType != nil { switch *c.CertType { - case CertTypeCertificate: + case CertificateTypesCertificate: prop.CertType = to.Ptr(datamodel.CertificateTypeCertificate) - case CertTypePrivatekey: + case CertificateTypesPrivatekey: prop.CertType = to.Ptr(datamodel.CertificateTypePrivateKey) - case CertTypePublickey: + case CertificateTypesPublickey: prop.CertType = to.Ptr(datamodel.CertificateTypePublicKey) } } @@ -251,22 +251,22 @@ func fromCertDataModel(dm *datamodel.CertificateObjectProperties) *CertificateOb if dm.Format != nil { switch *dm.Format { case datamodel.CertificateFormatPEM: - prop.Format = to.Ptr(FormatPem) + prop.Format = to.Ptr(CertificateFormatsPem) case datamodel.CertificateFormatPFX: - prop.Format = to.Ptr(FormatPfx) + prop.Format = to.Ptr(CertificateFormatsPfx) default: - prop.Format = to.Ptr(FormatPem) + prop.Format = to.Ptr(CertificateFormatsPem) } } if dm.CertType != nil { switch *dm.CertType { case datamodel.CertificateTypeCertificate: - prop.CertType = to.Ptr(CertTypeCertificate) + prop.CertType = to.Ptr(CertificateTypesCertificate) case datamodel.CertificateTypePrivateKey: - prop.CertType = to.Ptr(CertTypePrivatekey) + prop.CertType = to.Ptr(CertificateTypesPrivatekey) case datamodel.CertificateTypePublicKey: - prop.CertType = to.Ptr(CertTypePublickey) + prop.CertType = to.Ptr(CertificateTypesPublickey) } } diff --git a/pkg/corerp/api/v20220315privatepreview/volume_conversion_test.go b/pkg/corerp/api/v20220315privatepreview/volume_conversion_test.go index 459a610b7a..f0b6222781 100644 --- a/pkg/corerp/api/v20220315privatepreview/volume_conversion_test.go +++ b/pkg/corerp/api/v20220315privatepreview/volume_conversion_test.go @@ -20,10 +20,11 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -62,7 +63,6 @@ func TestVolumeConvertDataModelToVersioned(t *testing.T) { expected := &VolumeResource{} err = json.Unmarshal(testutil.ReadFixture("volume-az-kv.json"), expected) require.NoError(t, err) - expected.Properties.GetVolumeProperties().Status.OutputResources[0]["Identity"] = nil // act versioned := &VolumeResource{} @@ -82,7 +82,7 @@ func TestVolumeConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_applications_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_applications_client.go index c06ce943cb..df7731ffad 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_applications_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_applications_client.go @@ -27,7 +27,9 @@ type ApplicationsClient struct { } // NewApplicationsClient creates a new instance of ApplicationsClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewApplicationsClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApplicationsClient, error) { @@ -42,17 +44,17 @@ func NewApplicationsClient(rootScope string, credential azcore.TokenCredential, return client, nil } -// CreateOrUpdate - Create or update an Application. +// CreateOrUpdate - Create a ApplicationResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - applicationName - The name of the application. -// - applicationResource - application details +// - applicationName - The application name +// - resource - Resource create parameters. // - options - ApplicationsClientCreateOrUpdateOptions contains the optional parameters for the ApplicationsClient.CreateOrUpdate // method. -func (client *ApplicationsClient) CreateOrUpdate(ctx context.Context, applicationName string, applicationResource ApplicationResource, options *ApplicationsClientCreateOrUpdateOptions) (ApplicationsClientCreateOrUpdateResponse, error) { +func (client *ApplicationsClient) CreateOrUpdate(ctx context.Context, applicationName string, resource ApplicationResource, options *ApplicationsClientCreateOrUpdateOptions) (ApplicationsClientCreateOrUpdateResponse, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, applicationName, applicationResource, options) + req, err := client.createOrUpdateCreateRequest(ctx, applicationName, resource, options) if err != nil { return ApplicationsClientCreateOrUpdateResponse{}, err } @@ -69,7 +71,7 @@ func (client *ApplicationsClient) CreateOrUpdate(ctx context.Context, applicatio } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ApplicationsClient) createOrUpdateCreateRequest(ctx context.Context, applicationName string, applicationResource ApplicationResource, options *ApplicationsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ApplicationsClient) createOrUpdateCreateRequest(ctx context.Context, applicationName string, resource ApplicationResource, options *ApplicationsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/applications/{applicationName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if applicationName == "" { @@ -84,7 +86,7 @@ func (client *ApplicationsClient) createOrUpdateCreateRequest(ctx context.Contex reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, applicationResource); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -99,11 +101,11 @@ func (client *ApplicationsClient) createOrUpdateHandleResponse(resp *http.Respon return result, nil } -// Delete - Delete an Application. +// Delete - Delete a ApplicationResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - applicationName - The name of the application. +// - applicationName - The application name // - options - ApplicationsClientDeleteOptions contains the optional parameters for the ApplicationsClient.Delete method. func (client *ApplicationsClient) Delete(ctx context.Context, applicationName string, options *ApplicationsClientDeleteOptions) (ApplicationsClientDeleteResponse, error) { var err error @@ -115,7 +117,7 @@ func (client *ApplicationsClient) Delete(ctx context.Context, applicationName st if err != nil { return ApplicationsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return ApplicationsClientDeleteResponse{}, err } @@ -141,11 +143,11 @@ func (client *ApplicationsClient) deleteCreateRequest(ctx context.Context, appli return req, nil } -// Get - Gets the properties of an Application. +// Get - Get a ApplicationResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - applicationName - The name of the application. +// - applicationName - The application name // - options - ApplicationsClientGetOptions contains the optional parameters for the ApplicationsClient.Get method. func (client *ApplicationsClient) Get(ctx context.Context, applicationName string, options *ApplicationsClientGetOptions) (ApplicationsClientGetResponse, error) { var err error @@ -193,7 +195,7 @@ func (client *ApplicationsClient) getHandleResponse(resp *http.Response) (Applic return result, nil } -// NewListByScopePager - List all applications in the given scope. +// NewListByScopePager - List ApplicationResource resources by Scope // // Generated from API version 2022-03-15-privatepreview // - options - ApplicationsClientListByScopeOptions contains the optional parameters for the ApplicationsClient.NewListByScopePager @@ -244,22 +246,22 @@ func (client *ApplicationsClient) listByScopeCreateRequest(ctx context.Context, // listByScopeHandleResponse handles the ListByScope response. func (client *ApplicationsClient) listByScopeHandleResponse(resp *http.Response) (ApplicationsClientListByScopeResponse, error) { result := ApplicationsClientListByScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationResourceListResult); err != nil { return ApplicationsClientListByScopeResponse{}, err } return result, nil } -// Update - Update the properties of an existing Application. +// Update - Update a ApplicationResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - applicationName - The name of the application. -// - applicationResource - application details +// - applicationName - The application name +// - properties - The resource properties to be updated. // - options - ApplicationsClientUpdateOptions contains the optional parameters for the ApplicationsClient.Update method. -func (client *ApplicationsClient) Update(ctx context.Context, applicationName string, applicationResource ApplicationResource, options *ApplicationsClientUpdateOptions) (ApplicationsClientUpdateResponse, error) { +func (client *ApplicationsClient) Update(ctx context.Context, applicationName string, properties ApplicationResourceUpdate, options *ApplicationsClientUpdateOptions) (ApplicationsClientUpdateResponse, error) { var err error - req, err := client.updateCreateRequest(ctx, applicationName, applicationResource, options) + req, err := client.updateCreateRequest(ctx, applicationName, properties, options) if err != nil { return ApplicationsClientUpdateResponse{}, err } @@ -267,7 +269,7 @@ func (client *ApplicationsClient) Update(ctx context.Context, applicationName st if err != nil { return ApplicationsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return ApplicationsClientUpdateResponse{}, err } @@ -276,7 +278,7 @@ func (client *ApplicationsClient) Update(ctx context.Context, applicationName st } // updateCreateRequest creates the Update request. -func (client *ApplicationsClient) updateCreateRequest(ctx context.Context, applicationName string, applicationResource ApplicationResource, options *ApplicationsClientUpdateOptions) (*policy.Request, error) { +func (client *ApplicationsClient) updateCreateRequest(ctx context.Context, applicationName string, properties ApplicationResourceUpdate, options *ApplicationsClientUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/applications/{applicationName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if applicationName == "" { @@ -291,7 +293,7 @@ func (client *ApplicationsClient) updateCreateRequest(ctx context.Context, appli reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, applicationResource); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_client_factory.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_client_factory.go index e5b97e5df2..c47bbe49a7 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_client_factory.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_client_factory.go @@ -22,7 +22,9 @@ type ClientFactory struct { // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { @@ -66,6 +68,11 @@ func (c *ClientFactory) NewHTTPRoutesClient() *HTTPRoutesClient { return subClient } +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewSecretStoresClient() *SecretStoresClient { subClient, _ := NewSecretStoresClient(c.rootScope, c.credential, c.options) return subClient diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_constants.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_constants.go index fa36ac05ca..de80b30323 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_constants.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_constants.go @@ -12,21 +12,56 @@ const ( moduleVersion = "v0.0.1" ) -// CertType - Certificate object type to be downloaded - the certificate itself, private key or public key of the certificate -type CertType string +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string const ( - CertTypeCertificate CertType = "certificate" - CertTypePrivatekey CertType = "privatekey" - CertTypePublickey CertType = "publickey" + ActionTypeInternal ActionType = "Internal" ) -// PossibleCertTypeValues returns the possible values for the CertType const type. -func PossibleCertTypeValues() []CertType { - return []CertType{ - CertTypeCertificate, - CertTypePrivatekey, - CertTypePublickey, +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CertificateFormats - Represents certificate formats +type CertificateFormats string + +const ( + // CertificateFormatsPem - PEM Certificate format + CertificateFormatsPem CertificateFormats = "pem" + // CertificateFormatsPfx - PFX Certificate format + CertificateFormatsPfx CertificateFormats = "pfx" +) + +// PossibleCertificateFormatsValues returns the possible values for the CertificateFormats const type. +func PossibleCertificateFormatsValues() []CertificateFormats { + return []CertificateFormats{ + CertificateFormatsPem, + CertificateFormatsPfx, + } +} + +// CertificateTypes - Represents certificate types +type CertificateTypes string + +const ( + // CertificateTypesCertificate - Certificate type + CertificateTypesCertificate CertificateTypes = "certificate" + // CertificateTypesPrivatekey - Private Key type + CertificateTypesPrivatekey CertificateTypes = "privatekey" + // CertificateTypesPublickey - Public Key type + CertificateTypesPublickey CertificateTypes = "publickey" +) + +// PossibleCertificateTypesValues returns the possible values for the CertificateTypes const type. +func PossibleCertificateTypesValues() []CertificateTypes { + return []CertificateTypes{ + CertificateTypesCertificate, + CertificateTypesPrivatekey, + CertificateTypesPublickey, } } @@ -50,45 +85,46 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } -// Encoding - Encoding format. Default utf-8 -type Encoding string +// DaprSidecarExtensionProtocol - The Dapr sidecar extension protocol +type DaprSidecarExtensionProtocol string const ( - EncodingBase64 Encoding = "base64" - EncodingHex Encoding = "hex" - EncodingUTF8 Encoding = "utf-8" + // DaprSidecarExtensionProtocolGrpc - gRPC protocol + DaprSidecarExtensionProtocolGrpc DaprSidecarExtensionProtocol = "grpc" + // DaprSidecarExtensionProtocolHTTP - HTTP protocol + DaprSidecarExtensionProtocolHTTP DaprSidecarExtensionProtocol = "http" ) -// PossibleEncodingValues returns the possible values for the Encoding const type. -func PossibleEncodingValues() []Encoding { - return []Encoding{ - EncodingBase64, - EncodingHex, - EncodingUTF8, +// PossibleDaprSidecarExtensionProtocolValues returns the possible values for the DaprSidecarExtensionProtocol const type. +func PossibleDaprSidecarExtensionProtocolValues() []DaprSidecarExtensionProtocol { + return []DaprSidecarExtensionProtocol{ + DaprSidecarExtensionProtocolGrpc, + DaprSidecarExtensionProtocolHTTP, } } -// Format - Certificate format. Default pem -type Format string +// IAMKind - The kind of IAM provider to configure +type IAMKind string const ( - FormatPem Format = "pem" - FormatPfx Format = "pfx" + // IAMKindAzure - Azure Active Directory + IAMKindAzure IAMKind = "azure" ) -// PossibleFormatValues returns the possible values for the Format const type. -func PossibleFormatValues() []Format { - return []Format{ - FormatPem, - FormatPfx, +// PossibleIAMKindValues returns the possible values for the IAMKind const type. +func PossibleIAMKindValues() []IAMKind { + return []IAMKind{ + IAMKindAzure, } } -// IdentitySettingKind - Configuration for supported external identity providers +// IdentitySettingKind - IdentitySettingKind is the kind of supported external identity setting type IdentitySettingKind string const ( + // IdentitySettingKindAzureComWorkload - azure ad workload identity IdentitySettingKindAzureComWorkload IdentitySettingKind = "azure.com.workload" + // IdentitySettingKindUndefined - undefined identity IdentitySettingKindUndefined IdentitySettingKind = "undefined" ) @@ -100,25 +136,34 @@ func PossibleIdentitySettingKindValues() []IdentitySettingKind { } } -// Kind - The kind of IAM provider to configure -type Kind string +// ImagePullPolicy - The image pull policy for the container +type ImagePullPolicy string const ( - KindAzure Kind = "azure" + // ImagePullPolicyAlways - Always + ImagePullPolicyAlways ImagePullPolicy = "Always" + // ImagePullPolicyIfNotPresent - IfNotPresent + ImagePullPolicyIfNotPresent ImagePullPolicy = "IfNotPresent" + // ImagePullPolicyNever - Never + ImagePullPolicyNever ImagePullPolicy = "Never" ) -// PossibleKindValues returns the possible values for the Kind const type. -func PossibleKindValues() []Kind { - return []Kind{ - KindAzure, +// PossibleImagePullPolicyValues returns the possible values for the ImagePullPolicy const type. +func PossibleImagePullPolicyValues() []ImagePullPolicy { + return []ImagePullPolicy{ + ImagePullPolicyAlways, + ImagePullPolicyIfNotPresent, + ImagePullPolicyNever, } } -// ManagedStore - Backing store for the ephemeral volume +// ManagedStore - The managed store for the ephemeral volume type ManagedStore string const ( + // ManagedStoreDisk - Disk store ManagedStoreDisk ManagedStore = "disk" + // ManagedStoreMemory - Memory store ManagedStoreMemory ManagedStore = "memory" ) @@ -130,36 +175,60 @@ func PossibleManagedStoreValues() []ManagedStore { } } -// Protocol - Protocol in use by the port -type Protocol string +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string const ( - ProtocolGrpc Protocol = "grpc" - ProtocolHTTP Protocol = "http" - ProtocolTCP Protocol = "TCP" - ProtocolUDP Protocol = "UDP" + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" ) -// PossibleProtocolValues returns the possible values for the Protocol const type. -func PossibleProtocolValues() []Protocol { - return []Protocol{ - ProtocolGrpc, - ProtocolHTTP, - ProtocolTCP, - ProtocolUDP, +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, } } -// ProvisioningState - Provisioning state of the resource at the time the operation was called. +// PortProtocol - The protocol in use by the port +type PortProtocol string + +const ( + // PortProtocolTCP - TCP protocol + PortProtocolTCP PortProtocol = "TCP" + // PortProtocolUDP - UDP protocol + PortProtocolUDP PortProtocol = "UDP" +) + +// PossiblePortProtocolValues returns the possible values for the PortProtocol const type. +func PossiblePortProtocolValues() []PortProtocol { + return []PortProtocol{ + PortProtocolTCP, + PortProtocolUDP, + } +} + +// ProvisioningState - Provisioning state of the portable resource at the time the operation was called type ProvisioningState string const ( + // ProvisioningStateAccepted - The resource create request has been accepted ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - The resource is being deleted ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is being provisioned ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is updating ProvisioningStateUpdating ProvisioningState = "Updating" ) @@ -182,7 +251,9 @@ func PossibleProvisioningStateValues() []ProvisioningState { type ResourceProvisioning string const ( + // ResourceProvisioningManual - The resource lifecycle will be managed by the user ResourceProvisioningManual ResourceProvisioning = "manual" + // ResourceProvisioningRecipe - The resource lifecycle will be managed by Radius ResourceProvisioningRecipe ResourceProvisioning = "recipe" ) @@ -194,11 +265,13 @@ func PossibleResourceProvisioningValues() []ResourceProvisioning { } } -// SecretStoreDataType - The type of secret store data +// SecretStoreDataType - The type of SecretStore data type SecretStoreDataType string const ( + // SecretStoreDataTypeCertificate - Certificate secret data type SecretStoreDataTypeCertificate SecretStoreDataType = "certificate" + // SecretStoreDataTypeGeneric - Generic secret data type SecretStoreDataTypeGeneric SecretStoreDataType = "generic" ) @@ -210,11 +283,13 @@ func PossibleSecretStoreDataTypeValues() []SecretStoreDataType { } } -// SecretValueEncoding - The encoding of value +// SecretValueEncoding - The type of SecretValue Encoding type SecretValueEncoding string const ( + // SecretValueEncodingBase64 - The base64-encoded secret value SecretValueEncodingBase64 SecretValueEncoding = "base64" + // SecretValueEncodingRaw - The raw secret value SecretValueEncodingRaw SecretValueEncoding = "raw" ) @@ -226,27 +301,46 @@ func PossibleSecretValueEncodingValues() []SecretValueEncoding { } } -// TLSMinVersion - TLS minimum protocol version (defaults to 1.2). +// TLSMinVersion - Tls Minimum versions for Gateway resource. type TLSMinVersion string const ( - TLSMinVersionOne2 TLSMinVersion = "1.2" - TLSMinVersionOne3 TLSMinVersion = "1.3" + // TLSMinVersionTls12 - TLS Version 1.2 + TLSMinVersionTls12 TLSMinVersion = "1.2" + // TLSMinVersionTls13 - TLS Version 1.3 + TLSMinVersionTls13 TLSMinVersion = "1.3" ) // PossibleTLSMinVersionValues returns the possible values for the TLSMinVersion const type. func PossibleTLSMinVersionValues() []TLSMinVersion { return []TLSMinVersion{ - TLSMinVersionOne2, - TLSMinVersionOne3, + TLSMinVersionTls12, + TLSMinVersionTls13, } } -// VolumePermission - Container read/write access to the volume +// Versions - Supported API versions for the Applications.Core resource provider. +type Versions string + +const ( + // VersionsV20220315Privatepreview - 2022-03-15-privatepreview + VersionsV20220315Privatepreview Versions = "2022-03-15-privatepreview" +) + +// PossibleVersionsValues returns the possible values for the Versions const type. +func PossibleVersionsValues() []Versions { + return []Versions{ + VersionsV20220315Privatepreview, + } +} + +// VolumePermission - The persistent volume permission type VolumePermission string const ( + // VolumePermissionRead - Read only VolumePermissionRead VolumePermission = "read" + // VolumePermissionWrite - Read and write VolumePermissionWrite VolumePermission = "write" ) @@ -258,3 +352,24 @@ func PossibleVolumePermissionValues() []VolumePermission { } } +// VolumeSecretEncodings - Represents secret encodings +type VolumeSecretEncodings string + +const ( + // VolumeSecretEncodingsBase64 - Base64 encoding + VolumeSecretEncodingsBase64 VolumeSecretEncodings = "base64" + // VolumeSecretEncodingsHex - Hex encoding + VolumeSecretEncodingsHex VolumeSecretEncodings = "hex" + // VolumeSecretEncodingsUTF8 - UTF-8 encoding + VolumeSecretEncodingsUTF8 VolumeSecretEncodings = "utf-8" +) + +// PossibleVolumeSecretEncodingsValues returns the possible values for the VolumeSecretEncodings const type. +func PossibleVolumeSecretEncodingsValues() []VolumeSecretEncodings { + return []VolumeSecretEncodings{ + VolumeSecretEncodingsBase64, + VolumeSecretEncodingsHex, + VolumeSecretEncodingsUTF8, + } +} + diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_containers_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_containers_client.go index b2139fc21a..48d784f8a9 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_containers_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_containers_client.go @@ -27,7 +27,9 @@ type ContainersClient struct { } // NewContainersClient creates a new instance of ContainersClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewContainersClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContainersClient, error) { @@ -42,34 +44,52 @@ func NewContainersClient(rootScope string, credential azcore.TokenCredential, op return client, nil } -// CreateOrUpdate - Create or update a Container. +// BeginCreateOrUpdate - Create a ContainerResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - containerName - The name of the conatiner. -// - containerResource - containers details -// - options - ContainersClientCreateOrUpdateOptions contains the optional parameters for the ContainersClient.CreateOrUpdate +// - containerName - Container name +// - resource - Resource create parameters. +// - options - ContainersClientBeginCreateOrUpdateOptions contains the optional parameters for the ContainersClient.BeginCreateOrUpdate // method. -func (client *ContainersClient) CreateOrUpdate(ctx context.Context, containerName string, containerResource ContainerResource, options *ContainersClientCreateOrUpdateOptions) (ContainersClientCreateOrUpdateResponse, error) { +func (client *ContainersClient) BeginCreateOrUpdate(ctx context.Context, containerName string, resource ContainerResource, options *ContainersClientBeginCreateOrUpdateOptions) (*runtime.Poller[ContainersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, containerName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ContainersClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ContainersClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a ContainerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *ContainersClient) createOrUpdate(ctx context.Context, containerName string, resource ContainerResource, options *ContainersClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, containerName, containerResource, options) + req, err := client.createOrUpdateCreateRequest(ctx, containerName, resource, options) if err != nil { - return ContainersClientCreateOrUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ContainersClientCreateOrUpdateResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return ContainersClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ContainersClient) createOrUpdateCreateRequest(ctx context.Context, containerName string, containerResource ContainerResource, options *ContainersClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ContainersClient) createOrUpdateCreateRequest(ctx context.Context, containerName string, resource ContainerResource, options *ContainersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/containers/{containerName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if containerName == "" { @@ -84,46 +104,56 @@ func (client *ContainersClient) createOrUpdateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, containerResource); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ContainersClient) createOrUpdateHandleResponse(resp *http.Response) (ContainersClientCreateOrUpdateResponse, error) { - result := ContainersClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ContainerResource); err != nil { - return ContainersClientCreateOrUpdateResponse{}, err +// BeginDelete - Delete a ContainerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - containerName - Container name +// - options - ContainersClientBeginDeleteOptions contains the optional parameters for the ContainersClient.BeginDelete method. +func (client *ContainersClient) BeginDelete(ctx context.Context, containerName string, options *ContainersClientBeginDeleteOptions) (*runtime.Poller[ContainersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, containerName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ContainersClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ContainersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Delete a Container. +// Delete - Delete a ContainerResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - containerName - The name of the conatiner. -// - options - ContainersClientDeleteOptions contains the optional parameters for the ContainersClient.Delete method. -func (client *ContainersClient) Delete(ctx context.Context, containerName string, options *ContainersClientDeleteOptions) (ContainersClientDeleteResponse, error) { +func (client *ContainersClient) deleteOperation(ctx context.Context, containerName string, options *ContainersClientBeginDeleteOptions) (*http.Response, error) { var err error req, err := client.deleteCreateRequest(ctx, containerName, options) if err != nil { - return ContainersClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ContainersClientDeleteResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return ContainersClientDeleteResponse{}, err + return nil, err } - return ContainersClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *ContainersClient) deleteCreateRequest(ctx context.Context, containerName string, options *ContainersClientDeleteOptions) (*policy.Request, error) { +func (client *ContainersClient) deleteCreateRequest(ctx context.Context, containerName string, options *ContainersClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/containers/{containerName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if containerName == "" { @@ -141,11 +171,11 @@ func (client *ContainersClient) deleteCreateRequest(ctx context.Context, contain return req, nil } -// Get - Gets the properties of an Container. +// Get - Get a ContainerResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - containerName - The name of the conatiner. +// - containerName - Container name // - options - ContainersClientGetOptions contains the optional parameters for the ContainersClient.Get method. func (client *ContainersClient) Get(ctx context.Context, containerName string, options *ContainersClientGetOptions) (ContainersClientGetResponse, error) { var err error @@ -193,7 +223,7 @@ func (client *ContainersClient) getHandleResponse(resp *http.Response) (Containe return result, nil } -// NewListByScopePager - List all containers in the given scope. +// NewListByScopePager - List ContainerResource resources by Scope // // Generated from API version 2022-03-15-privatepreview // - options - ContainersClientListByScopeOptions contains the optional parameters for the ContainersClient.NewListByScopePager @@ -244,39 +274,57 @@ func (client *ContainersClient) listByScopeCreateRequest(ctx context.Context, op // listByScopeHandleResponse handles the ListByScope response. func (client *ContainersClient) listByScopeHandleResponse(resp *http.Response) (ContainersClientListByScopeResponse, error) { result := ContainersClientListByScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ContainerResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerResourceListResult); err != nil { return ContainersClientListByScopeResponse{}, err } return result, nil } -// Update - Update the properties of an existing Container. +// BeginUpdate - Update a ContainerResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - containerName - The name of the conatiner. -// - containersResource - Container details -// - options - ContainersClientUpdateOptions contains the optional parameters for the ContainersClient.Update method. -func (client *ContainersClient) Update(ctx context.Context, containerName string, containersResource ContainerResource, options *ContainersClientUpdateOptions) (ContainersClientUpdateResponse, error) { +// - containerName - Container name +// - properties - The resource properties to be updated. +// - options - ContainersClientBeginUpdateOptions contains the optional parameters for the ContainersClient.BeginUpdate method. +func (client *ContainersClient) BeginUpdate(ctx context.Context, containerName string, properties ContainerResourceUpdate, options *ContainersClientBeginUpdateOptions) (*runtime.Poller[ContainersClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, containerName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ContainersClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ContainersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a ContainerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *ContainersClient) update(ctx context.Context, containerName string, properties ContainerResourceUpdate, options *ContainersClientBeginUpdateOptions) (*http.Response, error) { var err error - req, err := client.updateCreateRequest(ctx, containerName, containersResource, options) + req, err := client.updateCreateRequest(ctx, containerName, properties, options) if err != nil { - return ContainersClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ContainersClientUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return ContainersClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *ContainersClient) updateCreateRequest(ctx context.Context, containerName string, containersResource ContainerResource, options *ContainersClientUpdateOptions) (*policy.Request, error) { +func (client *ContainersClient) updateCreateRequest(ctx context.Context, containerName string, properties ContainerResourceUpdate, options *ContainersClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/containers/{containerName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if containerName == "" { @@ -291,18 +339,9 @@ func (client *ContainersClient) updateCreateRequest(ctx context.Context, contain reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, containersResource); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil } -// updateHandleResponse handles the Update response. -func (client *ContainersClient) updateHandleResponse(resp *http.Response) (ContainersClientUpdateResponse, error) { - result := ContainersClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ContainerResource); err != nil { - return ContainersClientUpdateResponse{}, err - } - return result, nil -} - diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_environments_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_environments_client.go index 78fae339a9..e04f55a18c 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_environments_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_environments_client.go @@ -27,7 +27,9 @@ type EnvironmentsClient struct { } // NewEnvironmentsClient creates a new instance of EnvironmentsClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewEnvironmentsClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EnvironmentsClient, error) { @@ -42,17 +44,17 @@ func NewEnvironmentsClient(rootScope string, credential azcore.TokenCredential, return client, nil } -// CreateOrUpdate - Create or update an Environment. +// CreateOrUpdate - Create a EnvironmentResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - environmentName - The name of the environment -// - environmentResource - environment details +// - environmentName - environment name +// - resource - Resource create parameters. // - options - EnvironmentsClientCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.CreateOrUpdate // method. -func (client *EnvironmentsClient) CreateOrUpdate(ctx context.Context, environmentName string, environmentResource EnvironmentResource, options *EnvironmentsClientCreateOrUpdateOptions) (EnvironmentsClientCreateOrUpdateResponse, error) { +func (client *EnvironmentsClient) CreateOrUpdate(ctx context.Context, environmentName string, resource EnvironmentResource, options *EnvironmentsClientCreateOrUpdateOptions) (EnvironmentsClientCreateOrUpdateResponse, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, environmentName, environmentResource, options) + req, err := client.createOrUpdateCreateRequest(ctx, environmentName, resource, options) if err != nil { return EnvironmentsClientCreateOrUpdateResponse{}, err } @@ -69,7 +71,7 @@ func (client *EnvironmentsClient) CreateOrUpdate(ctx context.Context, environmen } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Context, environmentName string, environmentResource EnvironmentResource, options *EnvironmentsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Context, environmentName string, resource EnvironmentResource, options *EnvironmentsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/environments/{environmentName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if environmentName == "" { @@ -84,7 +86,7 @@ func (client *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Contex reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, environmentResource); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -99,11 +101,11 @@ func (client *EnvironmentsClient) createOrUpdateHandleResponse(resp *http.Respon return result, nil } -// Delete - Delete an Environment. +// Delete - Delete a EnvironmentResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - environmentName - The name of the environment +// - environmentName - environment name // - options - EnvironmentsClientDeleteOptions contains the optional parameters for the EnvironmentsClient.Delete method. func (client *EnvironmentsClient) Delete(ctx context.Context, environmentName string, options *EnvironmentsClientDeleteOptions) (EnvironmentsClientDeleteResponse, error) { var err error @@ -115,7 +117,7 @@ func (client *EnvironmentsClient) Delete(ctx context.Context, environmentName st if err != nil { return EnvironmentsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) return EnvironmentsClientDeleteResponse{}, err } @@ -141,11 +143,11 @@ func (client *EnvironmentsClient) deleteCreateRequest(ctx context.Context, envir return req, nil } -// Get - Gets the properties of an Environment. +// Get - Get a EnvironmentResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - environmentName - The name of the environment +// - environmentName - environment name // - options - EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. func (client *EnvironmentsClient) Get(ctx context.Context, environmentName string, options *EnvironmentsClientGetOptions) (EnvironmentsClientGetResponse, error) { var err error @@ -193,35 +195,35 @@ func (client *EnvironmentsClient) getHandleResponse(resp *http.Response) (Enviro return result, nil } -// GetRecipeMetadata - Gets recipe metadata including parameters and any constraints on the parameters. +// GetMetadata - Gets recipe metadata including parameters and any constraints on the parameters. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - environmentName - The name of the environment -// - recipeParameter - Recipe parameters. -// - options - EnvironmentsClientGetRecipeMetadataOptions contains the optional parameters for the EnvironmentsClient.GetRecipeMetadata +// - environmentName - environment name +// - body - The content of the action request +// - options - EnvironmentsClientGetMetadataOptions contains the optional parameters for the EnvironmentsClient.GetMetadata // method. -func (client *EnvironmentsClient) GetRecipeMetadata(ctx context.Context, environmentName string, recipeParameter Recipe, options *EnvironmentsClientGetRecipeMetadataOptions) (EnvironmentsClientGetRecipeMetadataResponse, error) { +func (client *EnvironmentsClient) GetMetadata(ctx context.Context, environmentName string, body RecipeGetMetadata, options *EnvironmentsClientGetMetadataOptions) (EnvironmentsClientGetMetadataResponse, error) { var err error - req, err := client.getRecipeMetadataCreateRequest(ctx, environmentName, recipeParameter, options) + req, err := client.getMetadataCreateRequest(ctx, environmentName, body, options) if err != nil { - return EnvironmentsClientGetRecipeMetadataResponse{}, err + return EnvironmentsClientGetMetadataResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return EnvironmentsClientGetRecipeMetadataResponse{}, err + return EnvironmentsClientGetMetadataResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return EnvironmentsClientGetRecipeMetadataResponse{}, err + return EnvironmentsClientGetMetadataResponse{}, err } - resp, err := client.getRecipeMetadataHandleResponse(httpResp) + resp, err := client.getMetadataHandleResponse(httpResp) return resp, err } -// getRecipeMetadataCreateRequest creates the GetRecipeMetadata request. -func (client *EnvironmentsClient) getRecipeMetadataCreateRequest(ctx context.Context, environmentName string, recipeParameter Recipe, options *EnvironmentsClientGetRecipeMetadataOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Core/environments/{environmentName}/getmetadata" +// getMetadataCreateRequest creates the GetMetadata request. +func (client *EnvironmentsClient) getMetadataCreateRequest(ctx context.Context, environmentName string, body RecipeGetMetadata, options *EnvironmentsClientGetMetadataOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Core/environments/{environmentName}/getMetadata" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if environmentName == "" { return nil, errors.New("parameter environmentName cannot be empty") @@ -235,22 +237,22 @@ func (client *EnvironmentsClient) getRecipeMetadataCreateRequest(ctx context.Con reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, recipeParameter); err != nil { + if err := runtime.MarshalAsJSON(req, body); err != nil { return nil, err } return req, nil } -// getRecipeMetadataHandleResponse handles the GetRecipeMetadata response. -func (client *EnvironmentsClient) getRecipeMetadataHandleResponse(resp *http.Response) (EnvironmentsClientGetRecipeMetadataResponse, error) { - result := EnvironmentsClientGetRecipeMetadataResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RecipeMetadataProperties); err != nil { - return EnvironmentsClientGetRecipeMetadataResponse{}, err +// getMetadataHandleResponse handles the GetMetadata response. +func (client *EnvironmentsClient) getMetadataHandleResponse(resp *http.Response) (EnvironmentsClientGetMetadataResponse, error) { + result := EnvironmentsClientGetMetadataResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecipeGetMetadataResponse); err != nil { + return EnvironmentsClientGetMetadataResponse{}, err } return result, nil } -// NewListByScopePager - List all environments in a scope. +// NewListByScopePager - List EnvironmentResource resources by Scope // // Generated from API version 2022-03-15-privatepreview // - options - EnvironmentsClientListByScopeOptions contains the optional parameters for the EnvironmentsClient.NewListByScopePager @@ -301,22 +303,22 @@ func (client *EnvironmentsClient) listByScopeCreateRequest(ctx context.Context, // listByScopeHandleResponse handles the ListByScope response. func (client *EnvironmentsClient) listByScopeHandleResponse(resp *http.Response) (EnvironmentsClientListByScopeResponse, error) { result := EnvironmentsClientListByScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.EnvironmentResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.EnvironmentResourceListResult); err != nil { return EnvironmentsClientListByScopeResponse{}, err } return result, nil } -// Update - Update the properties of an existing Environment. +// Update - Update a EnvironmentResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - environmentName - The name of the environment -// - environmentResource - environment details +// - environmentName - environment name +// - properties - The resource properties to be updated. // - options - EnvironmentsClientUpdateOptions contains the optional parameters for the EnvironmentsClient.Update method. -func (client *EnvironmentsClient) Update(ctx context.Context, environmentName string, environmentResource EnvironmentResource, options *EnvironmentsClientUpdateOptions) (EnvironmentsClientUpdateResponse, error) { +func (client *EnvironmentsClient) Update(ctx context.Context, environmentName string, properties EnvironmentResourceUpdate, options *EnvironmentsClientUpdateOptions) (EnvironmentsClientUpdateResponse, error) { var err error - req, err := client.updateCreateRequest(ctx, environmentName, environmentResource, options) + req, err := client.updateCreateRequest(ctx, environmentName, properties, options) if err != nil { return EnvironmentsClientUpdateResponse{}, err } @@ -324,7 +326,7 @@ func (client *EnvironmentsClient) Update(ctx context.Context, environmentName st if err != nil { return EnvironmentsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return EnvironmentsClientUpdateResponse{}, err } @@ -333,7 +335,7 @@ func (client *EnvironmentsClient) Update(ctx context.Context, environmentName st } // updateCreateRequest creates the Update request. -func (client *EnvironmentsClient) updateCreateRequest(ctx context.Context, environmentName string, environmentResource EnvironmentResource, options *EnvironmentsClientUpdateOptions) (*policy.Request, error) { +func (client *EnvironmentsClient) updateCreateRequest(ctx context.Context, environmentName string, properties EnvironmentResourceUpdate, options *EnvironmentsClientUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/environments/{environmentName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if environmentName == "" { @@ -348,7 +350,7 @@ func (client *EnvironmentsClient) updateCreateRequest(ctx context.Context, envir reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, environmentResource); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_extenders_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_extenders_client.go index 208b89749e..35d2424f58 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_extenders_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_extenders_client.go @@ -27,7 +27,9 @@ type ExtendersClient struct { } // NewExtendersClient creates a new instance of ExtendersClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExtendersClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExtendersClient, error) { @@ -42,34 +44,52 @@ func NewExtendersClient(rootScope string, credential azcore.TokenCredential, opt return client, nil } -// CreateOrUpdate - Creates or updates a Extender portable resource. +// BeginCreateOrUpdate - Create a ExtenderResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - extenderName - The name of the Extender portable resource. -// - extenderParameters - Extender create parameters. -// - options - ExtendersClientCreateOrUpdateOptions contains the optional parameters for the ExtendersClient.CreateOrUpdate +// - extenderName - The name of the ExtenderResource portable resource +// - resource - Resource create parameters. +// - options - ExtendersClientBeginCreateOrUpdateOptions contains the optional parameters for the ExtendersClient.BeginCreateOrUpdate // method. -func (client *ExtendersClient) CreateOrUpdate(ctx context.Context, extenderName string, extenderParameters ExtenderResource, options *ExtendersClientCreateOrUpdateOptions) (ExtendersClientCreateOrUpdateResponse, error) { +func (client *ExtendersClient) BeginCreateOrUpdate(ctx context.Context, extenderName string, resource ExtenderResource, options *ExtendersClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExtendersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, extenderName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExtendersClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ExtendersClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a ExtenderResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *ExtendersClient) createOrUpdate(ctx context.Context, extenderName string, resource ExtenderResource, options *ExtendersClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, extenderName, extenderParameters, options) + req, err := client.createOrUpdateCreateRequest(ctx, extenderName, resource, options) if err != nil { - return ExtendersClientCreateOrUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ExtendersClientCreateOrUpdateResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return ExtendersClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ExtendersClient) createOrUpdateCreateRequest(ctx context.Context, extenderName string, extenderParameters ExtenderResource, options *ExtendersClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ExtendersClient) createOrUpdateCreateRequest(ctx context.Context, extenderName string, resource ExtenderResource, options *ExtendersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/extenders/{extenderName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if extenderName == "" { @@ -84,46 +104,56 @@ func (client *ExtendersClient) createOrUpdateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, extenderParameters); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ExtendersClient) createOrUpdateHandleResponse(resp *http.Response) (ExtendersClientCreateOrUpdateResponse, error) { - result := ExtendersClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExtenderResource); err != nil { - return ExtendersClientCreateOrUpdateResponse{}, err +// BeginDelete - Delete a ExtenderResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - extenderName - The name of the ExtenderResource portable resource +// - options - ExtendersClientBeginDeleteOptions contains the optional parameters for the ExtendersClient.BeginDelete method. +func (client *ExtendersClient) BeginDelete(ctx context.Context, extenderName string, options *ExtendersClientBeginDeleteOptions) (*runtime.Poller[ExtendersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, extenderName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExtendersClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ExtendersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Deletes an existing Extender portable resource. +// Delete - Delete a ExtenderResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - extenderName - The name of the Extender portable resource. -// - options - ExtendersClientDeleteOptions contains the optional parameters for the ExtendersClient.Delete method. -func (client *ExtendersClient) Delete(ctx context.Context, extenderName string, options *ExtendersClientDeleteOptions) (ExtendersClientDeleteResponse, error) { +func (client *ExtendersClient) deleteOperation(ctx context.Context, extenderName string, options *ExtendersClientBeginDeleteOptions) (*http.Response, error) { var err error req, err := client.deleteCreateRequest(ctx, extenderName, options) if err != nil { - return ExtendersClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ExtendersClientDeleteResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return ExtendersClientDeleteResponse{}, err + return nil, err } - return ExtendersClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *ExtendersClient) deleteCreateRequest(ctx context.Context, extenderName string, options *ExtendersClientDeleteOptions) (*policy.Request, error) { +func (client *ExtendersClient) deleteCreateRequest(ctx context.Context, extenderName string, options *ExtendersClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/extenders/{extenderName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if extenderName == "" { @@ -141,11 +171,11 @@ func (client *ExtendersClient) deleteCreateRequest(ctx context.Context, extender return req, nil } -// Get - Retrieves information about a Extender portable resource. +// Get - Get a ExtenderResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - extenderName - The name of the Extender portable resource. +// - extenderName - The name of the ExtenderResource portable resource // - options - ExtendersClientGetOptions contains the optional parameters for the ExtendersClient.Get method. func (client *ExtendersClient) Get(ctx context.Context, extenderName string, options *ExtendersClientGetOptions) (ExtendersClientGetResponse, error) { var err error @@ -193,41 +223,41 @@ func (client *ExtendersClient) getHandleResponse(resp *http.Response) (Extenders return result, nil } -// NewListByRootScopePager - Lists information about all Extender portable resources in the given root scope. +// NewListByScopePager - List ExtenderResource resources by Scope // // Generated from API version 2022-03-15-privatepreview -// - options - ExtendersClientListByRootScopeOptions contains the optional parameters for the ExtendersClient.NewListByRootScopePager +// - options - ExtendersClientListByScopeOptions contains the optional parameters for the ExtendersClient.NewListByScopePager // method. -func (client *ExtendersClient) NewListByRootScopePager(options *ExtendersClientListByRootScopeOptions) (*runtime.Pager[ExtendersClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[ExtendersClientListByRootScopeResponse]{ - More: func(page ExtendersClientListByRootScopeResponse) bool { +func (client *ExtendersClient) NewListByScopePager(options *ExtendersClientListByScopeOptions) (*runtime.Pager[ExtendersClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[ExtendersClientListByScopeResponse]{ + More: func(page ExtendersClientListByScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *ExtendersClientListByRootScopeResponse) (ExtendersClientListByRootScopeResponse, error) { + Fetcher: func(ctx context.Context, page *ExtendersClientListByScopeResponse) (ExtendersClientListByScopeResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) + req, err = client.listByScopeCreateRequest(ctx, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return ExtendersClientListByRootScopeResponse{}, err + return ExtendersClientListByScopeResponse{}, err } resp, err := client.internal.Pipeline().Do(req) if err != nil { - return ExtendersClientListByRootScopeResponse{}, err + return ExtendersClientListByScopeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExtendersClientListByRootScopeResponse{}, runtime.NewResponseError(resp) + return ExtendersClientListByScopeResponse{}, runtime.NewResponseError(resp) } - return client.listByRootScopeHandleResponse(resp) + return client.listByScopeHandleResponse(resp) }, }) } -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *ExtendersClient) listByRootScopeCreateRequest(ctx context.Context, options *ExtendersClientListByRootScopeOptions) (*policy.Request, error) { +// listByScopeCreateRequest creates the ListByScope request. +func (client *ExtendersClient) listByScopeCreateRequest(ctx context.Context, options *ExtendersClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/extenders" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -241,24 +271,25 @@ func (client *ExtendersClient) listByRootScopeCreateRequest(ctx context.Context, return req, nil } -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *ExtendersClient) listByRootScopeHandleResponse(resp *http.Response) (ExtendersClientListByRootScopeResponse, error) { - result := ExtendersClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExtenderList); err != nil { - return ExtendersClientListByRootScopeResponse{}, err +// listByScopeHandleResponse handles the ListByScope response. +func (client *ExtendersClient) listByScopeHandleResponse(resp *http.Response) (ExtendersClientListByScopeResponse, error) { + result := ExtendersClientListByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtenderResourceListResult); err != nil { + return ExtendersClientListByScopeResponse{}, err } return result, nil } -// ListSecrets - Lists secrets values for the specified Extender portable resource. +// ListSecrets - Lists secrets values for the specified Extender resource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - extenderName - The name of the Extender portable resource. +// - extenderName - The name of the ExtenderResource portable resource +// - body - The content of the action request // - options - ExtendersClientListSecretsOptions contains the optional parameters for the ExtendersClient.ListSecrets method. -func (client *ExtendersClient) ListSecrets(ctx context.Context, extenderName string, options *ExtendersClientListSecretsOptions) (ExtendersClientListSecretsResponse, error) { +func (client *ExtendersClient) ListSecrets(ctx context.Context, extenderName string, body map[string]any, options *ExtendersClientListSecretsOptions) (ExtendersClientListSecretsResponse, error) { var err error - req, err := client.listSecretsCreateRequest(ctx, extenderName, options) + req, err := client.listSecretsCreateRequest(ctx, extenderName, body, options) if err != nil { return ExtendersClientListSecretsResponse{}, err } @@ -275,7 +306,7 @@ func (client *ExtendersClient) ListSecrets(ctx context.Context, extenderName str } // listSecretsCreateRequest creates the ListSecrets request. -func (client *ExtendersClient) listSecretsCreateRequest(ctx context.Context, extenderName string, options *ExtendersClientListSecretsOptions) (*policy.Request, error) { +func (client *ExtendersClient) listSecretsCreateRequest(ctx context.Context, extenderName string, body map[string]any, options *ExtendersClientListSecretsOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/extenders/{extenderName}/listSecrets" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if extenderName == "" { @@ -290,15 +321,83 @@ func (client *ExtendersClient) listSecretsCreateRequest(ctx context.Context, ext reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err +} return req, nil } // listSecretsHandleResponse handles the ListSecrets response. func (client *ExtendersClient) listSecretsHandleResponse(resp *http.Response) (ExtendersClientListSecretsResponse, error) { result := ExtendersClientListSecretsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.Object); err != nil { return ExtendersClientListSecretsResponse{}, err } return result, nil } +// BeginUpdate - Update a ExtenderResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - extenderName - The name of the ExtenderResource portable resource +// - properties - The resource properties to be updated. +// - options - ExtendersClientBeginUpdateOptions contains the optional parameters for the ExtendersClient.BeginUpdate method. +func (client *ExtendersClient) BeginUpdate(ctx context.Context, extenderName string, properties ExtenderResourceUpdate, options *ExtendersClientBeginUpdateOptions) (*runtime.Poller[ExtendersClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, extenderName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExtendersClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ExtendersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a ExtenderResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *ExtendersClient) update(ctx context.Context, extenderName string, properties ExtenderResourceUpdate, options *ExtendersClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, extenderName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ExtendersClient) updateCreateRequest(ctx context.Context, extenderName string, properties ExtenderResourceUpdate, options *ExtendersClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Core/extenders/{extenderName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if extenderName == "" { + return nil, errors.New("parameter extenderName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extenderName}", url.PathEscape(extenderName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_gateways_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_gateways_client.go index 16c62a59ff..07f36a6364 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_gateways_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_gateways_client.go @@ -27,7 +27,9 @@ type GatewaysClient struct { } // NewGatewaysClient creates a new instance of GatewaysClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewGatewaysClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GatewaysClient, error) { @@ -42,33 +44,51 @@ func NewGatewaysClient(rootScope string, credential azcore.TokenCredential, opti return client, nil } -// CreateOrUpdate - Create or update a Gateway. +// BeginCreate - Create a GatewayResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - gatewayName - The name of the Gateway. -// - gatewayResource - Gateway details -// - options - GatewaysClientCreateOrUpdateOptions contains the optional parameters for the GatewaysClient.CreateOrUpdate method. -func (client *GatewaysClient) CreateOrUpdate(ctx context.Context, gatewayName string, gatewayResource GatewayResource, options *GatewaysClientCreateOrUpdateOptions) (GatewaysClientCreateOrUpdateResponse, error) { +// - gatewayName - Gateway name +// - resource - Resource create parameters. +// - options - GatewaysClientBeginCreateOptions contains the optional parameters for the GatewaysClient.BeginCreate method. +func (client *GatewaysClient) BeginCreate(ctx context.Context, gatewayName string, resource GatewayResource, options *GatewaysClientBeginCreateOptions) (*runtime.Poller[GatewaysClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, gatewayName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GatewaysClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GatewaysClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Create a GatewayResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *GatewaysClient) create(ctx context.Context, gatewayName string, resource GatewayResource, options *GatewaysClientBeginCreateOptions) (*http.Response, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, gatewayName, gatewayResource, options) + req, err := client.createCreateRequest(ctx, gatewayName, resource, options) if err != nil { - return GatewaysClientCreateOrUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return GatewaysClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return GatewaysClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err + return httpResp, nil } -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *GatewaysClient) createOrUpdateCreateRequest(ctx context.Context, gatewayName string, gatewayResource GatewayResource, options *GatewaysClientCreateOrUpdateOptions) (*policy.Request, error) { +// createCreateRequest creates the Create request. +func (client *GatewaysClient) createCreateRequest(ctx context.Context, gatewayName string, resource GatewayResource, options *GatewaysClientBeginCreateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/gateways/{gatewayName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if gatewayName == "" { @@ -83,46 +103,122 @@ func (client *GatewaysClient) createOrUpdateCreateRequest(ctx context.Context, g reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, gatewayResource); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *GatewaysClient) createOrUpdateHandleResponse(resp *http.Response) (GatewaysClientCreateOrUpdateResponse, error) { - result := GatewaysClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.GatewayResource); err != nil { - return GatewaysClientCreateOrUpdateResponse{}, err +// BeginCreateOrUpdate - Update a GatewayResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - gatewayName - Gateway name +// - properties - The resource properties to be updated. +// - options - GatewaysClientBeginCreateOrUpdateOptions contains the optional parameters for the GatewaysClient.BeginCreateOrUpdate +// method. +func (client *GatewaysClient) BeginCreateOrUpdate(ctx context.Context, gatewayName string, properties GatewayResourceUpdate, options *GatewaysClientBeginCreateOrUpdateOptions) (*runtime.Poller[GatewaysClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, gatewayName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GatewaysClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GatewaysClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Delete a Gateway. +// CreateOrUpdate - Update a GatewayResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *GatewaysClient) createOrUpdate(ctx context.Context, gatewayName string, properties GatewayResourceUpdate, options *GatewaysClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, gatewayName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GatewaysClient) createOrUpdateCreateRequest(ctx context.Context, gatewayName string, properties GatewayResourceUpdate, options *GatewaysClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Core/gateways/{gatewayName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if gatewayName == "" { + return nil, errors.New("parameter gatewayName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + +// BeginDelete - Delete a GatewayResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - gatewayName - The name of the Gateway. -// - options - GatewaysClientDeleteOptions contains the optional parameters for the GatewaysClient.Delete method. -func (client *GatewaysClient) Delete(ctx context.Context, gatewayName string, options *GatewaysClientDeleteOptions) (GatewaysClientDeleteResponse, error) { +// - gatewayName - Gateway name +// - options - GatewaysClientBeginDeleteOptions contains the optional parameters for the GatewaysClient.BeginDelete method. +func (client *GatewaysClient) BeginDelete(ctx context.Context, gatewayName string, options *GatewaysClientBeginDeleteOptions) (*runtime.Poller[GatewaysClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, gatewayName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GatewaysClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GatewaysClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a GatewayResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *GatewaysClient) deleteOperation(ctx context.Context, gatewayName string, options *GatewaysClientBeginDeleteOptions) (*http.Response, error) { var err error req, err := client.deleteCreateRequest(ctx, gatewayName, options) if err != nil { - return GatewaysClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return GatewaysClientDeleteResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return GatewaysClientDeleteResponse{}, err + return nil, err } - return GatewaysClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *GatewaysClient) deleteCreateRequest(ctx context.Context, gatewayName string, options *GatewaysClientDeleteOptions) (*policy.Request, error) { +func (client *GatewaysClient) deleteCreateRequest(ctx context.Context, gatewayName string, options *GatewaysClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/gateways/{gatewayName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if gatewayName == "" { @@ -140,11 +236,11 @@ func (client *GatewaysClient) deleteCreateRequest(ctx context.Context, gatewayNa return req, nil } -// Get - Gets the properties of a Gateway. +// Get - Get a GatewayResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - gatewayName - The name of the Gateway. +// - gatewayName - Gateway name // - options - GatewaysClientGetOptions contains the optional parameters for the GatewaysClient.Get method. func (client *GatewaysClient) Get(ctx context.Context, gatewayName string, options *GatewaysClientGetOptions) (GatewaysClientGetResponse, error) { var err error @@ -192,7 +288,7 @@ func (client *GatewaysClient) getHandleResponse(resp *http.Response) (GatewaysCl return result, nil } -// NewListByScopePager - List all Gateways in the given scope. +// NewListByScopePager - List GatewayResource resources by Scope // // Generated from API version 2022-03-15-privatepreview // - options - GatewaysClientListByScopeOptions contains the optional parameters for the GatewaysClient.NewListByScopePager @@ -243,65 +339,9 @@ func (client *GatewaysClient) listByScopeCreateRequest(ctx context.Context, opti // listByScopeHandleResponse handles the ListByScope response. func (client *GatewaysClient) listByScopeHandleResponse(resp *http.Response) (GatewaysClientListByScopeResponse, error) { result := GatewaysClientListByScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.GatewayResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.GatewayResourceListResult); err != nil { return GatewaysClientListByScopeResponse{}, err } return result, nil } -// Update - Update the properties of an existing Gateway. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-03-15-privatepreview -// - gatewayName - The name of the Gateway. -// - gatewayResource - Gateway details -// - options - GatewaysClientUpdateOptions contains the optional parameters for the GatewaysClient.Update method. -func (client *GatewaysClient) Update(ctx context.Context, gatewayName string, gatewayResource GatewayResource, options *GatewaysClientUpdateOptions) (GatewaysClientUpdateResponse, error) { - var err error - req, err := client.updateCreateRequest(ctx, gatewayName, gatewayResource, options) - if err != nil { - return GatewaysClientUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return GatewaysClientUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return GatewaysClientUpdateResponse{}, err - } - resp, err := client.updateHandleResponse(httpResp) - return resp, err -} - -// updateCreateRequest creates the Update request. -func (client *GatewaysClient) updateCreateRequest(ctx context.Context, gatewayName string, gatewayResource GatewayResource, options *GatewaysClientUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Core/gateways/{gatewayName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if gatewayName == "" { - return nil, errors.New("parameter gatewayName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{gatewayName}", url.PathEscape(gatewayName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, gatewayResource); err != nil { - return nil, err -} - return req, nil -} - -// updateHandleResponse handles the Update response. -func (client *GatewaysClient) updateHandleResponse(resp *http.Response) (GatewaysClientUpdateResponse, error) { - result := GatewaysClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.GatewayResource); err != nil { - return GatewaysClientUpdateResponse{}, err - } - return result, nil -} - diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_httproutes_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_httproutes_client.go index 900ad9daf9..490655e8d3 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_httproutes_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_httproutes_client.go @@ -27,7 +27,9 @@ type HTTPRoutesClient struct { } // NewHTTPRoutesClient creates a new instance of HTTPRoutesClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewHTTPRoutesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HTTPRoutesClient, error) { @@ -42,34 +44,52 @@ func NewHTTPRoutesClient(rootScope string, credential azcore.TokenCredential, op return client, nil } -// CreateOrUpdate - Create or update an HTTP Route. +// BeginCreateOrUpdate - Create a HttpRouteResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - httpRouteName - The name of the HTTP Route. -// - httpRouteResource - HTTP Route details -// - options - HTTPRoutesClientCreateOrUpdateOptions contains the optional parameters for the HTTPRoutesClient.CreateOrUpdate +// - httpRouteName - HTTPRoute name +// - resource - Resource create parameters. +// - options - HTTPRoutesClientBeginCreateOrUpdateOptions contains the optional parameters for the HTTPRoutesClient.BeginCreateOrUpdate // method. -func (client *HTTPRoutesClient) CreateOrUpdate(ctx context.Context, httpRouteName string, httpRouteResource HTTPRouteResource, options *HTTPRoutesClientCreateOrUpdateOptions) (HTTPRoutesClientCreateOrUpdateResponse, error) { +func (client *HTTPRoutesClient) BeginCreateOrUpdate(ctx context.Context, httpRouteName string, resource HTTPRouteResource, options *HTTPRoutesClientBeginCreateOrUpdateOptions) (*runtime.Poller[HTTPRoutesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, httpRouteName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[HTTPRoutesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[HTTPRoutesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a HttpRouteResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *HTTPRoutesClient) createOrUpdate(ctx context.Context, httpRouteName string, resource HTTPRouteResource, options *HTTPRoutesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, httpRouteName, httpRouteResource, options) + req, err := client.createOrUpdateCreateRequest(ctx, httpRouteName, resource, options) if err != nil { - return HTTPRoutesClientCreateOrUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return HTTPRoutesClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return HTTPRoutesClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *HTTPRoutesClient) createOrUpdateCreateRequest(ctx context.Context, httpRouteName string, httpRouteResource HTTPRouteResource, options *HTTPRoutesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *HTTPRoutesClient) createOrUpdateCreateRequest(ctx context.Context, httpRouteName string, resource HTTPRouteResource, options *HTTPRoutesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/httpRoutes/{httpRouteName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if httpRouteName == "" { @@ -84,46 +104,56 @@ func (client *HTTPRoutesClient) createOrUpdateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, httpRouteResource); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *HTTPRoutesClient) createOrUpdateHandleResponse(resp *http.Response) (HTTPRoutesClientCreateOrUpdateResponse, error) { - result := HTTPRoutesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.HTTPRouteResource); err != nil { - return HTTPRoutesClientCreateOrUpdateResponse{}, err +// BeginDelete - Delete a HttpRouteResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - httpRouteName - HTTPRoute name +// - options - HTTPRoutesClientBeginDeleteOptions contains the optional parameters for the HTTPRoutesClient.BeginDelete method. +func (client *HTTPRoutesClient) BeginDelete(ctx context.Context, httpRouteName string, options *HTTPRoutesClientBeginDeleteOptions) (*runtime.Poller[HTTPRoutesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, httpRouteName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[HTTPRoutesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[HTTPRoutesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Delete an HTTP Route. +// Delete - Delete a HttpRouteResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - httpRouteName - The name of the HTTP Route. -// - options - HTTPRoutesClientDeleteOptions contains the optional parameters for the HTTPRoutesClient.Delete method. -func (client *HTTPRoutesClient) Delete(ctx context.Context, httpRouteName string, options *HTTPRoutesClientDeleteOptions) (HTTPRoutesClientDeleteResponse, error) { +func (client *HTTPRoutesClient) deleteOperation(ctx context.Context, httpRouteName string, options *HTTPRoutesClientBeginDeleteOptions) (*http.Response, error) { var err error req, err := client.deleteCreateRequest(ctx, httpRouteName, options) if err != nil { - return HTTPRoutesClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return HTTPRoutesClientDeleteResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return HTTPRoutesClientDeleteResponse{}, err + return nil, err } - return HTTPRoutesClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *HTTPRoutesClient) deleteCreateRequest(ctx context.Context, httpRouteName string, options *HTTPRoutesClientDeleteOptions) (*policy.Request, error) { +func (client *HTTPRoutesClient) deleteCreateRequest(ctx context.Context, httpRouteName string, options *HTTPRoutesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/httpRoutes/{httpRouteName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if httpRouteName == "" { @@ -141,11 +171,11 @@ func (client *HTTPRoutesClient) deleteCreateRequest(ctx context.Context, httpRou return req, nil } -// Get - Gets the properties of an HTTP Route. +// Get - Get a HttpRouteResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - httpRouteName - The name of the HTTP Route. +// - httpRouteName - HTTPRoute name // - options - HTTPRoutesClientGetOptions contains the optional parameters for the HTTPRoutesClient.Get method. func (client *HTTPRoutesClient) Get(ctx context.Context, httpRouteName string, options *HTTPRoutesClientGetOptions) (HTTPRoutesClientGetResponse, error) { var err error @@ -193,7 +223,7 @@ func (client *HTTPRoutesClient) getHandleResponse(resp *http.Response) (HTTPRout return result, nil } -// NewListByScopePager - List all HTTP Routes in the given scope. +// NewListByScopePager - List HttpRouteResource resources by Scope // // Generated from API version 2022-03-15-privatepreview // - options - HTTPRoutesClientListByScopeOptions contains the optional parameters for the HTTPRoutesClient.NewListByScopePager @@ -244,39 +274,57 @@ func (client *HTTPRoutesClient) listByScopeCreateRequest(ctx context.Context, op // listByScopeHandleResponse handles the ListByScope response. func (client *HTTPRoutesClient) listByScopeHandleResponse(resp *http.Response) (HTTPRoutesClientListByScopeResponse, error) { result := HTTPRoutesClientListByScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.HTTPRouteResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.HTTPRouteResourceListResult); err != nil { return HTTPRoutesClientListByScopeResponse{}, err } return result, nil } -// Update - Update the properties of an existing HTTP Route. +// BeginUpdate - Update a HttpRouteResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - httpRouteName - HTTPRoute name +// - properties - The resource properties to be updated. +// - options - HTTPRoutesClientBeginUpdateOptions contains the optional parameters for the HTTPRoutesClient.BeginUpdate method. +func (client *HTTPRoutesClient) BeginUpdate(ctx context.Context, httpRouteName string, properties HTTPRouteResourceUpdate, options *HTTPRoutesClientBeginUpdateOptions) (*runtime.Poller[HTTPRoutesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, httpRouteName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[HTTPRoutesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[HTTPRoutesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a HttpRouteResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - httpRouteName - The name of the HTTP Route. -// - httpRouteResource - HTTP Route details -// - options - HTTPRoutesClientUpdateOptions contains the optional parameters for the HTTPRoutesClient.Update method. -func (client *HTTPRoutesClient) Update(ctx context.Context, httpRouteName string, httpRouteResource HTTPRouteResource, options *HTTPRoutesClientUpdateOptions) (HTTPRoutesClientUpdateResponse, error) { +func (client *HTTPRoutesClient) update(ctx context.Context, httpRouteName string, properties HTTPRouteResourceUpdate, options *HTTPRoutesClientBeginUpdateOptions) (*http.Response, error) { var err error - req, err := client.updateCreateRequest(ctx, httpRouteName, httpRouteResource, options) + req, err := client.updateCreateRequest(ctx, httpRouteName, properties, options) if err != nil { - return HTTPRoutesClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return HTTPRoutesClientUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return HTTPRoutesClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *HTTPRoutesClient) updateCreateRequest(ctx context.Context, httpRouteName string, httpRouteResource HTTPRouteResource, options *HTTPRoutesClientUpdateOptions) (*policy.Request, error) { +func (client *HTTPRoutesClient) updateCreateRequest(ctx context.Context, httpRouteName string, properties HTTPRouteResourceUpdate, options *HTTPRoutesClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/httpRoutes/{httpRouteName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if httpRouteName == "" { @@ -291,18 +339,9 @@ func (client *HTTPRoutesClient) updateCreateRequest(ctx context.Context, httpRou reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, httpRouteResource); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil } -// updateHandleResponse handles the Update response. -func (client *HTTPRoutesClient) updateHandleResponse(resp *http.Response) (HTTPRoutesClientUpdateResponse, error) { - result := HTTPRoutesClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.HTTPRouteResource); err != nil { - return HTTPRoutesClientUpdateResponse{}, err - } - return result, nil -} - diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_interfaces.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_interfaces.go index b8b508f9e8..ebed5bd3ac 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_interfaces.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_interfaces.go @@ -7,26 +7,6 @@ package v20220315privatepreview -// ApplicationExtensionClassification provides polymorphic access to related types. -// Call the interface's GetApplicationExtension() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *ApplicationExtension, *ApplicationKubernetesMetadataExtension, *ApplicationKubernetesNamespaceExtension -type ApplicationExtensionClassification interface { - ExtensionClassification - // GetApplicationExtension returns the ApplicationExtension content of the underlying type. - GetApplicationExtension() *ApplicationExtension -} - -// ContainerExtensionClassification provides polymorphic access to related types. -// Call the interface's GetContainerExtension() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *ContainerExtension, *ContainerKubernetesMetadataExtension, *DaprSidecarExtension, *ManualScalingExtension -type ContainerExtensionClassification interface { - ExtensionClassification - // GetContainerExtension returns the ContainerExtension content of the underlying type. - GetContainerExtension() *ContainerExtension -} - // EnvironmentComputeClassification provides polymorphic access to related types. // Call the interface's GetEnvironmentCompute() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: @@ -36,30 +16,19 @@ type EnvironmentComputeClassification interface { GetEnvironmentCompute() *EnvironmentCompute } -// EnvironmentExtensionClassification provides polymorphic access to related types. -// Call the interface's GetEnvironmentExtension() method to access the common type. +// EnvironmentComputeUpdateClassification provides polymorphic access to related types. +// Call the interface's GetEnvironmentComputeUpdate() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *EnvironmentExtension, *EnvironmentKubernetesMetadataExtension -type EnvironmentExtensionClassification interface { - ExtensionClassification - // GetEnvironmentExtension returns the EnvironmentExtension content of the underlying type. - GetEnvironmentExtension() *EnvironmentExtension -} - -// EnvironmentRecipePropertiesClassification provides polymorphic access to related types. -// Call the interface's GetEnvironmentRecipeProperties() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *BicepRecipeProperties, *EnvironmentRecipeProperties, *TerraformRecipeProperties -type EnvironmentRecipePropertiesClassification interface { - // GetEnvironmentRecipeProperties returns the EnvironmentRecipeProperties content of the underlying type. - GetEnvironmentRecipeProperties() *EnvironmentRecipeProperties +// - *EnvironmentComputeUpdate, *KubernetesComputeUpdate +type EnvironmentComputeUpdateClassification interface { + // GetEnvironmentComputeUpdate returns the EnvironmentComputeUpdate content of the underlying type. + GetEnvironmentComputeUpdate() *EnvironmentComputeUpdate } // ExtensionClassification provides polymorphic access to related types. // Call the interface's GetExtension() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: -// - *ApplicationExtension, *ApplicationKubernetesNamespaceExtension, *ContainerExtension, *ContainerKubernetesMetadataExtension, -// - *DaprSidecarExtension, *EnvironmentExtension, *Extension, *ManualScalingExtension +// - *DaprSidecarExtension, *Extension, *KubernetesMetadataExtension, *KubernetesNamespaceExtension, *ManualScalingExtension type ExtensionClassification interface { // GetExtension returns the Extension content of the underlying type. GetExtension() *Extension @@ -74,6 +43,24 @@ type HealthProbePropertiesClassification interface { GetHealthProbeProperties() *HealthProbeProperties } +// RecipePropertiesClassification provides polymorphic access to related types. +// Call the interface's GetRecipeProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BicepRecipeProperties, *RecipeProperties, *TerraformRecipeProperties +type RecipePropertiesClassification interface { + // GetRecipeProperties returns the RecipeProperties content of the underlying type. + GetRecipeProperties() *RecipeProperties +} + +// RecipePropertiesUpdateClassification provides polymorphic access to related types. +// Call the interface's GetRecipePropertiesUpdate() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BicepRecipePropertiesUpdate, *RecipePropertiesUpdate, *TerraformRecipePropertiesUpdate +type RecipePropertiesUpdateClassification interface { + // GetRecipePropertiesUpdate returns the RecipePropertiesUpdate content of the underlying type. + GetRecipePropertiesUpdate() *RecipePropertiesUpdate +} + // VolumeClassification provides polymorphic access to related types. // Call the interface's GetVolume() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_models.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_models.go index 09aa7bf296..707d39a845 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_models.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_models.go @@ -9,92 +9,27 @@ package v20220315privatepreview import "time" -type ApplicationExtension struct { - // REQUIRED; Specifies the extensions of a resource. - Kind *string -} - -// GetApplicationExtension implements the ApplicationExtensionClassification interface for type ApplicationExtension. -func (a *ApplicationExtension) GetApplicationExtension() *ApplicationExtension { return a } - -// GetExtension implements the ExtensionClassification interface for type ApplicationExtension. -func (a *ApplicationExtension) GetExtension() *Extension { - return &Extension{ - Kind: a.Kind, - } -} - -// ApplicationKubernetesMetadataExtension - Specifies the metadata that should be applied to Kubernetes resources created -// by all Containers in this Application. -type ApplicationKubernetesMetadataExtension struct { - // REQUIRED; Specifies the extensions of a resource. - Kind *string - - // Annotations to be applied to the Kubernetes resources output by the resource - Annotations map[string]*string - - // Labels to be applied to the Kubernetes resources output by the resource - Labels map[string]*string -} - -// GetApplicationExtension implements the ApplicationExtensionClassification interface for type ApplicationKubernetesMetadataExtension. -func (a *ApplicationKubernetesMetadataExtension) GetApplicationExtension() *ApplicationExtension { - return &ApplicationExtension{ - Kind: a.Kind, - } -} - -// GetExtension implements the ExtensionClassification interface for type ApplicationKubernetesMetadataExtension. -func (a *ApplicationKubernetesMetadataExtension) GetExtension() *Extension { - return &Extension{ - Kind: a.Kind, - } -} - -// ApplicationKubernetesNamespaceExtension - Specifies application-scoped namespace. -type ApplicationKubernetesNamespaceExtension struct { - // REQUIRED; Specifies the extensions of a resource. - Kind *string - - // REQUIRED; The Kubernetes namespace to use for this application. - Namespace *string -} - -// GetApplicationExtension implements the ApplicationExtensionClassification interface for type ApplicationKubernetesNamespaceExtension. -func (a *ApplicationKubernetesNamespaceExtension) GetApplicationExtension() *ApplicationExtension { - return &ApplicationExtension{ - Kind: a.Kind, - } -} - -// GetExtension implements the ExtensionClassification interface for type ApplicationKubernetesNamespaceExtension. -func (a *ApplicationKubernetesNamespaceExtension) GetExtension() *Extension { - return &Extension{ - Kind: a.Kind, - } -} - // ApplicationProperties - Application properties type ApplicationProperties struct { - // REQUIRED; The resource id of the environment linked to application. + // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to Environment *string - // Extensions spec of the resource - Extensions []ApplicationExtensionClassification + // The application extension. + Extensions []ExtensionClassification - // READ-ONLY; Provisioning state of the application at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of the resource + // READ-ONLY; Status of a resource. Status *ResourceStatus } -// ApplicationResource - Radius Application. +// ApplicationResource - Radius Application resource type ApplicationResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Application properties + // The resource-specific properties for this resource. Properties *ApplicationProperties // Resource tags. @@ -106,27 +41,52 @@ type ApplicationResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// ApplicationResourceList - The list of applications. -type ApplicationResourceList struct { - // The link used to get the next page of applications list. +// ApplicationResourceListResult - The response of a ApplicationResource list operation. +type ApplicationResourceListResult struct { + // REQUIRED; The ApplicationResource items on this page + Value []*ApplicationResource + + // The link to the next page of items NextLink *string +} - // The list of applications. - Value []*ApplicationResource +// ApplicationResourceUpdate - The type used for update operations of the ApplicationResource. +type ApplicationResourceUpdate struct { + // The updatable properties of the ApplicationResource. + Properties *ApplicationResourceUpdateProperties + + // Resource tags. + Tags map[string]*string } +// ApplicationResourceUpdateProperties - The updatable properties of the ApplicationResource. +type ApplicationResourceUpdateProperties struct { + // The compute resource used by application environment. + Compute EnvironmentComputeUpdateClassification + + // The environment extension. + Extensions []ExtensionClassification + + // Cloud providers configuration for the environment. + Providers *ProvidersUpdate + + // Specifies Recipes linked to the Environment. + Recipes map[string]map[string]RecipePropertiesUpdateClassification +} + +// AzureKeyVaultVolumeProperties - Represents Azure Key Vault Volume properties type AzureKeyVaultVolumeProperties struct { - // REQUIRED; Specifies the resource id of the application + // REQUIRED; Fully qualified resource ID for the application that the portable resource is consumed by Application *string - // REQUIRED; The volume kind + // REQUIRED; Discriminator property for VolumeProperties. Kind *string // REQUIRED; The ID of the keyvault to use for this volume resource @@ -135,7 +95,7 @@ type AzureKeyVaultVolumeProperties struct { // The KeyVault certificates that this volume exposes Certificates map[string]*CertificateObjectProperties - // The resource id of the environment linked to the resource + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) Environment *string // The KeyVault keys that this volume exposes @@ -144,10 +104,10 @@ type AzureKeyVaultVolumeProperties struct { // The KeyVault secrets that this volume exposes Secrets map[string]*SecretObjectProperties - // READ-ONLY; Provisioning state of the Volume at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of the resource + // READ-ONLY; Status of a resource. Status *ResourceStatus } @@ -162,21 +122,9 @@ func (a *AzureKeyVaultVolumeProperties) GetVolumeProperties() *VolumeProperties } } -// BasicResourceProperties - Basic properties of a Radius resource. -type BasicResourceProperties struct { - // REQUIRED; Specifies the resource id of the application - Application *string - - // The resource id of the environment linked to the resource - Environment *string - - // READ-ONLY; Status of the resource - Status *ResourceStatus -} - -// BicepRecipeProperties - Properties of a Recipe linked to an Environment. +// BicepRecipeProperties - Represents Bicep recipe properties. type BicepRecipeProperties struct { - // REQUIRED; Format of the template provided by the recipe. Allowed values: bicep, terraform. + // REQUIRED; Discriminator property for RecipeProperties. TemplateKind *string // REQUIRED; Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. @@ -186,45 +134,82 @@ type BicepRecipeProperties struct { Parameters map[string]any } -// GetEnvironmentRecipeProperties implements the EnvironmentRecipePropertiesClassification interface for type BicepRecipeProperties. -func (b *BicepRecipeProperties) GetEnvironmentRecipeProperties() *EnvironmentRecipeProperties { - return &EnvironmentRecipeProperties{ +// GetRecipeProperties implements the RecipePropertiesClassification interface for type BicepRecipeProperties. +func (b *BicepRecipeProperties) GetRecipeProperties() *RecipeProperties { + return &RecipeProperties{ Parameters: b.Parameters, TemplateKind: b.TemplateKind, TemplatePath: b.TemplatePath, } } +// BicepRecipePropertiesUpdate - Represents Bicep recipe properties. +type BicepRecipePropertiesUpdate struct { + // REQUIRED; Discriminator property for RecipeProperties. + TemplateKind *string + + // Key/value parameters to pass to the recipe template at deployment + Parameters map[string]any + + // Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. + TemplatePath *string +} + +// GetRecipePropertiesUpdate implements the RecipePropertiesUpdateClassification interface for type BicepRecipePropertiesUpdate. +func (b *BicepRecipePropertiesUpdate) GetRecipePropertiesUpdate() *RecipePropertiesUpdate { + return &RecipePropertiesUpdate{ + Parameters: b.Parameters, + TemplateKind: b.TemplateKind, + TemplatePath: b.TemplatePath, + } +} + +// CertificateObjectProperties - Represents certificate object properties type CertificateObjectProperties struct { // REQUIRED; The name of the certificate Name *string - // File name when written to disk. + // File name when written to disk Alias *string // Certificate object type to be downloaded - the certificate itself, private key or public key of the certificate - CertType *CertType + CertType *CertificateTypes // Encoding format. Default utf-8 - Encoding *Encoding + Encoding *VolumeSecretEncodings // Certificate format. Default pem - Format *Format + Format *CertificateFormats // Certificate version Version *string } +// ConnectionProperties - Connection Properties type ConnectionProperties struct { // REQUIRED; The source of the connection Source *string + + // default environment variable override DisableDefaultEnvVars *bool - // The properties of IAM + // iam properties Iam *IamProperties } -// Container - Definition of a container. +// ConnectionPropertiesUpdate - Connection Properties +type ConnectionPropertiesUpdate struct { + // default environment variable override + DisableDefaultEnvVars *bool + + // iam properties + Iam *IamPropertiesUpdate + + // The source of the connection + Source *string +} + +// Container - Definition of a container type Container struct { // REQUIRED; The registry and image to download and run in your container Image *string @@ -235,119 +220,102 @@ type Container struct { // Entrypoint array. Overrides the container image's ENTRYPOINT Command []*string - // Dictionary of + // environment Env map[string]*string - // Properties for readiness/liveness probe + // The pull policy for the container image + ImagePullPolicy *ImagePullPolicy + + // liveness probe properties LivenessProbe HealthProbePropertiesClassification - // Dictionary of - Ports map[string]*ContainerPort + // container ports + Ports map[string]*ContainerPortProperties - // Properties for readiness/liveness probe + // readiness probe properties ReadinessProbe HealthProbePropertiesClassification - // Dictionary of + // container volumes Volumes map[string]VolumeClassification // Working directory for the container WorkingDir *string } -type ContainerExtension struct { - // REQUIRED; Specifies the extensions of a resource. - Kind *string -} - -// GetContainerExtension implements the ContainerExtensionClassification interface for type ContainerExtension. -func (c *ContainerExtension) GetContainerExtension() *ContainerExtension { return c } - -// GetExtension implements the ExtensionClassification interface for type ContainerExtension. -func (c *ContainerExtension) GetExtension() *Extension { - return &Extension{ - Kind: c.Kind, - } -} - -// ContainerKubernetesMetadataExtension - Specifies the metadata that should be applied to Kubernetes resources created for -// the Container resource -type ContainerKubernetesMetadataExtension struct { - // REQUIRED; Specifies the extensions of a resource. - Kind *string +// ContainerPortProperties - Specifies a listening port for the container +type ContainerPortProperties struct { + // REQUIRED; The listening port number + ContainerPort *int32 - // Annotations to be applied to the Kubernetes resources output by the resource - Annotations map[string]*string + // Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired + Port *int32 - // Labels to be applied to the Kubernetes resources output by the resource - Labels map[string]*string -} + // Protocol in use by the port + Protocol *PortProtocol -// GetContainerExtension implements the ContainerExtensionClassification interface for type ContainerKubernetesMetadataExtension. -func (c *ContainerKubernetesMetadataExtension) GetContainerExtension() *ContainerExtension { - return &ContainerExtension{ - Kind: c.Kind, - } -} + // Specifies a route provided by this port + Provides *string -// GetExtension implements the ExtensionClassification interface for type ContainerKubernetesMetadataExtension. -func (c *ContainerKubernetesMetadataExtension) GetExtension() *Extension { - return &Extension{ - Kind: c.Kind, - } + // Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults +// to 'http' or 'https' depending on the port value + Scheme *string } -// ContainerPort - Specifies a listening port for the container -type ContainerPort struct { - // REQUIRED; The listening port number +// ContainerPortPropertiesUpdate - Specifies a listening port for the container +type ContainerPortPropertiesUpdate struct { + // The listening port number ContainerPort *int32 - // Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired. + // Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired Port *int32 // Protocol in use by the port - Protocol *Protocol + Protocol *PortProtocol // Specifies a route provided by this port Provides *string // Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults -// to 'http' or 'https' depending on the port value. +// to 'http' or 'https' depending on the port value Scheme *string } // ContainerProperties - Container properties type ContainerProperties struct { - // REQUIRED; Specifies the resource id of the application + // REQUIRED; Fully qualified resource ID for the application that the portable resource is consumed by Application *string // REQUIRED; Definition of a container. Container *Container - // Dictionary of + // Specifies a connection to another resource. Connections map[string]*ConnectionProperties - // The resource id of the environment linked to the resource + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) Environment *string // Extensions spec of the resource - Extensions []ContainerExtensionClassification + Extensions []ExtensionClassification // Configuration for supported external identity providers Identity *IdentitySettings - // READ-ONLY; Gets the status of the container at the time the operation was called. + // Specifies Runtime-specific functionality + Runtimes *RuntimesProperties + + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of the resource + // READ-ONLY; Status of a resource. Status *ResourceStatus } -// ContainerResource - Container +// ContainerResource - Concrete tracked resource types can be created by aliasing this type using a specific property type. type ContainerResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Container properties + // The resource-specific properties for this resource. Properties *ContainerProperties // Resource tags. @@ -359,20 +327,86 @@ type ContainerResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// ContainerResourceList - The list of containers. -type ContainerResourceList struct { - // The link used to get the next page of containers list. +// ContainerResourceListResult - The response of a ContainerResource list operation. +type ContainerResourceListResult struct { + // REQUIRED; The ContainerResource items on this page + Value []*ContainerResource + + // The link to the next page of items NextLink *string +} - // The list of containers. - Value []*ContainerResource +// ContainerResourceUpdate - The type used for update operations of the ContainerResource. +type ContainerResourceUpdate struct { + // The updatable properties of the ContainerResource. + Properties *ContainerResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// ContainerResourceUpdateProperties - The updatable properties of the ContainerResource. +type ContainerResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by + Application *string + + // Specifies a connection to another resource. + Connections map[string]*ConnectionPropertiesUpdate + + // Definition of a container. + Container *ContainerUpdate + + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) + Environment *string + + // Extensions spec of the resource + Extensions []ExtensionClassification + + // Configuration for supported external identity providers + Identity *IdentitySettingsUpdate + + // Specifies Runtime-specific functionality + Runtimes *RuntimesProperties +} + +// ContainerUpdate - Definition of a container +type ContainerUpdate struct { + // Arguments to the entrypoint. Overrides the container image's CMD + Args []*string + + // Entrypoint array. Overrides the container image's ENTRYPOINT + Command []*string + + // environment + Env map[string]*string + + // The registry and image to download and run in your container + Image *string + + // The pull policy for the container image + ImagePullPolicy *ImagePullPolicy + + // liveness probe properties + LivenessProbe HealthProbePropertiesClassification + + // container ports + Ports map[string]*ContainerPortPropertiesUpdate + + // readiness probe properties + ReadinessProbe HealthProbePropertiesClassification + + // container volumes + Volumes map[string]VolumeClassification + + // Working directory for the container + WorkingDir *string } // DaprSidecarExtension - Specifies the resource should have a Dapr sidecar injected @@ -380,7 +414,7 @@ type DaprSidecarExtension struct { // REQUIRED; The Dapr appId. Specifies the identifier used by Dapr for service invocation. AppID *string - // REQUIRED; Specifies the extensions of a resource. + // REQUIRED; Discriminator property for Extension. Kind *string // The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. @@ -390,14 +424,7 @@ type DaprSidecarExtension struct { Config *string // Specifies the Dapr app-protocol to use for the resource. - Protocol *Protocol -} - -// GetContainerExtension implements the ContainerExtensionClassification interface for type DaprSidecarExtension. -func (d *DaprSidecarExtension) GetContainerExtension() *ContainerExtension { - return &ContainerExtension{ - Kind: d.Kind, - } + Protocol *DaprSidecarExtensionProtocol } // GetExtension implements the ExtensionClassification interface for type DaprSidecarExtension. @@ -407,9 +434,9 @@ func (d *DaprSidecarExtension) GetExtension() *Extension { } } -// EnvironmentCompute - Compute resource used by application environment resource. +// EnvironmentCompute - Represents backing compute resource type EnvironmentCompute struct { - // REQUIRED; Type of compute resource. + // REQUIRED; Discriminator property for EnvironmentCompute. Kind *string // Configuration for supported external identity providers @@ -422,87 +449,45 @@ type EnvironmentCompute struct { // GetEnvironmentCompute implements the EnvironmentComputeClassification interface for type EnvironmentCompute. func (e *EnvironmentCompute) GetEnvironmentCompute() *EnvironmentCompute { return e } -type EnvironmentExtension struct { - // REQUIRED; Specifies the extensions of a resource. - Kind *string -} - -// GetEnvironmentExtension implements the EnvironmentExtensionClassification interface for type EnvironmentExtension. -func (e *EnvironmentExtension) GetEnvironmentExtension() *EnvironmentExtension { return e } - -// GetExtension implements the ExtensionClassification interface for type EnvironmentExtension. -func (e *EnvironmentExtension) GetExtension() *Extension { - return &Extension{ - Kind: e.Kind, - } -} - -// EnvironmentKubernetesMetadataExtension - Specifies the metadata that should be applied to Kubernetes resources created -// by all Containers in this Environment. -type EnvironmentKubernetesMetadataExtension struct { - // REQUIRED; Specifies the extensions of a resource. +// EnvironmentComputeUpdate - Represents backing compute resource +type EnvironmentComputeUpdate struct { + // REQUIRED; Discriminator property for EnvironmentCompute. Kind *string - // Annotations to be applied to the Kubernetes resources output by the resource - Annotations map[string]*string + // Configuration for supported external identity providers + Identity *IdentitySettingsUpdate - // Labels to be applied to the Kubernetes resources output by the resource - Labels map[string]*string + // The resource id of the compute resource for application environment. + ResourceID *string } -// GetEnvironmentExtension implements the EnvironmentExtensionClassification interface for type EnvironmentKubernetesMetadataExtension. -func (e *EnvironmentKubernetesMetadataExtension) GetEnvironmentExtension() *EnvironmentExtension { - return &EnvironmentExtension{ - Kind: e.Kind, - } -} +// GetEnvironmentComputeUpdate implements the EnvironmentComputeUpdateClassification interface for type EnvironmentComputeUpdate. +func (e *EnvironmentComputeUpdate) GetEnvironmentComputeUpdate() *EnvironmentComputeUpdate { return e } -// GetExtension implements the ExtensionClassification interface for type EnvironmentKubernetesMetadataExtension. -func (e *EnvironmentKubernetesMetadataExtension) GetExtension() *Extension { - return &Extension{ - Kind: e.Kind, - } -} - -// EnvironmentProperties - Application environment properties +// EnvironmentProperties - Environment properties type EnvironmentProperties struct { - // REQUIRED; Compute resource used by application environment resource. + // REQUIRED; The compute resource used by application environment. Compute EnvironmentComputeClassification - // Extensions spec of the resource - Extensions []EnvironmentExtensionClassification + // The environment extension. + Extensions []ExtensionClassification // Cloud providers configuration for the environment. Providers *Providers // Specifies Recipes linked to the Environment. - Recipes map[string]map[string]EnvironmentRecipePropertiesClassification + Recipes map[string]map[string]RecipePropertiesClassification - // READ-ONLY; Provisioning state of the environment at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState } -// EnvironmentRecipeProperties - Properties of a Recipe linked to an Environment. -type EnvironmentRecipeProperties struct { - // REQUIRED; Format of the template provided by the recipe. Allowed values: bicep, terraform. - TemplateKind *string - - // REQUIRED; Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. - TemplatePath *string - - // Key/value parameters to pass to the recipe template at deployment - Parameters map[string]any -} - -// GetEnvironmentRecipeProperties implements the EnvironmentRecipePropertiesClassification interface for type EnvironmentRecipeProperties. -func (e *EnvironmentRecipeProperties) GetEnvironmentRecipeProperties() *EnvironmentRecipeProperties { return e } - -// EnvironmentResource - Application environment. +// EnvironmentResource - The environment resource type EnvironmentResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Application environment properties + // The resource-specific properties for this resource. Properties *EnvironmentProperties // Resource tags. @@ -514,25 +499,49 @@ type EnvironmentResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// EnvironmentResourceList - The list of environments. -type EnvironmentResourceList struct { - // The link used to get the next page of environments list. +// EnvironmentResourceListResult - The response of a EnvironmentResource list operation. +type EnvironmentResourceListResult struct { + // REQUIRED; The EnvironmentResource items on this page + Value []*EnvironmentResource + + // The link to the next page of items NextLink *string +} - // The list of environments. - Value []*EnvironmentResource +// EnvironmentResourceUpdate - The type used for update operations of the EnvironmentResource. +type EnvironmentResourceUpdate struct { + // The updatable properties of the EnvironmentResource. + Properties *EnvironmentResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// EnvironmentResourceUpdateProperties - The updatable properties of the EnvironmentResource. +type EnvironmentResourceUpdateProperties struct { + // The compute resource used by application environment. + Compute EnvironmentComputeUpdateClassification + + // The environment extension. + Extensions []ExtensionClassification + + // Cloud providers configuration for the environment. + Providers *ProvidersUpdate + + // Specifies Recipes linked to the Environment. + Recipes map[string]map[string]RecipePropertiesUpdateClassification } // EphemeralVolume - Specifies an ephemeral volume for a container type EphemeralVolume struct { - // REQUIRED; The Volume kind + // REQUIRED; Discriminator property for Volume. Kind *string // REQUIRED; Backing store for the ephemeral volume @@ -589,7 +598,7 @@ type ExecHealthProbeProperties struct { // REQUIRED; Command to execute to probe readiness/liveness Command *string - // REQUIRED; The HealthProbeProperties kind + // REQUIRED; Discriminator property for HealthProbeProperties. Kind *string // Threshold number of times the probe fails after which a failure would be reported @@ -616,48 +625,39 @@ func (e *ExecHealthProbeProperties) GetHealthProbeProperties() *HealthProbePrope } } -// ExtenderList - Object that includes an array of Extender and a possible portable resource for next set. -type ExtenderList struct { - // The link used to fetch the next page of Extender list. - NextLink *string - - // List of Extender portable resources. - Value []*ExtenderResource -} - -// ExtenderProperties - Extender portable resource properties. +// ExtenderProperties - ExtenderResource portable resource properties type ExtenderProperties struct { - // REQUIRED; The resource id of the environment linked to the resource + // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to Environment *string // OPTIONAL; Contains additional key/value pairs not defined in the schema. AdditionalProperties map[string]any - // Specifies the resource id of the application + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) Application *string - // The recipe used to automatically deploy underlying infrastructure for the Extender portable resource. - Recipe *ResourceRecipe + // The recipe used to automatically deploy underlying infrastructure for the extender portable resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. ResourceProvisioning *ResourceProvisioning - // The secret values for the given Extender portable resource. + // The secrets for referenced resource Secrets map[string]any - // READ-ONLY; Provisioning state of the Extender portable resource at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of a Portable resource. + // READ-ONLY; Status of a resource. Status *ResourceStatus } -// ExtenderResource - Extender portable resource. +// ExtenderResource portable resource type ExtenderResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Extender portable resource properties. + // The resource-specific properties for this resource. Properties *ExtenderProperties // Resource tags. @@ -669,82 +669,105 @@ type ExtenderResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// Extension of a resource. +// ExtenderResourceListResult - The response of a ExtenderResource list operation. +type ExtenderResourceListResult struct { + // REQUIRED; The ExtenderResource items on this page + Value []*ExtenderResource + + // The link to the next page of items + NextLink *string +} + +// ExtenderResourceUpdate - The type used for update operations of the ExtenderResource. +type ExtenderResourceUpdate struct { + // The updatable properties of the ExtenderResource. + Properties *ExtenderResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// ExtenderResourceUpdateProperties - The updatable properties of the ExtenderResource. +type ExtenderResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string + + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string + + // The recipe used to automatically deploy underlying infrastructure for the extender portable resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning + + // The secrets for referenced resource + Secrets map[string]any +} + +// Extension of a environment/application resource. type Extension struct { - // REQUIRED; Specifies the extensions of a resource. + // REQUIRED; Discriminator property for Extension. Kind *string } // GetExtension implements the ExtensionClassification interface for type Extension. func (e *Extension) GetExtension() *Extension { return e } +// GatewayHostname - Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io. +type GatewayHostname struct { + // Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both +// are defined. + FullyQualifiedHostname *string + + // Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' +// and will be overridden if both are defined. + Prefix *string +} + // GatewayProperties - Gateway properties type GatewayProperties struct { - // REQUIRED; Specifies the resource id of the application + // REQUIRED; Fully qualified resource ID for the application that the portable resource is consumed by Application *string // REQUIRED; Routes attached to this Gateway Routes []*GatewayRoute - // The resource id of the environment linked to the resource + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) Environment *string // Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io. - Hostname *GatewayPropertiesHostname + Hostname *GatewayHostname // Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet). Internal *bool // TLS configuration for the Gateway. - TLS *GatewayPropertiesTLS + TLS *GatewayTLS - // READ-ONLY; Provisioning state of the Gateway at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of the resource + // READ-ONLY; Status of a resource. Status *ResourceStatus - // READ-ONLY; URL of the gateway resource. Readonly. - URL *string -} - -// GatewayPropertiesHostname - Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: -// mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io. -type GatewayPropertiesHostname struct { - // Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both -// are defined. - FullyQualifiedHostname *string - - // Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' -// and will be overridden if both are defined. - Prefix *string -} - -// GatewayPropertiesTLS - TLS configuration for the Gateway. -type GatewayPropertiesTLS struct { - // Declares which Kubernetes TLS secret will be used. - CertificateFrom *string - - // TLS minimum protocol version (defaults to 1.2). - MinimumProtocolVersion *TLSMinVersion - - // If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption. - SSLPassthrough *bool + // READ-ONLY; URL of the gateway resource. Readonly + URL *string } -// GatewayResource - Gateway Resource that specifies how traffic is exposed to the application. +// GatewayResource - Concrete tracked resource types can be created by aliasing this type using a specific property type. type GatewayResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; Gateway properties + // The resource-specific properties for this resource. Properties *GatewayProperties // Resource tags. @@ -756,22 +779,53 @@ type GatewayResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// GatewayResourceList - The list of Gateways. -type GatewayResourceList struct { - // The link used to get the next page of Gateways list. +// GatewayResourceListResult - The response of a GatewayResource list operation. +type GatewayResourceListResult struct { + // REQUIRED; The GatewayResource items on this page + Value []*GatewayResource + + // The link to the next page of items NextLink *string +} - // The list of Gateways. - Value []*GatewayResource +// GatewayResourceUpdate - The type used for update operations of the GatewayResource. +type GatewayResourceUpdate struct { + // The updatable properties of the GatewayResource. + Properties *GatewayResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// GatewayResourceUpdateProperties - The updatable properties of the GatewayResource. +type GatewayResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by + Application *string + + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) + Environment *string + + // Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io. + Hostname *GatewayHostname + + // Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet). + Internal *bool + + // Routes attached to this Gateway + Routes []*GatewayRoute + + // TLS configuration for the Gateway. + TLS *GatewayTLS } +// GatewayRoute - Route attached to Gateway type GatewayRoute struct { // The HttpRoute to route to. Ex - myserviceroute.id. Destination *string @@ -784,12 +838,24 @@ type GatewayRoute struct { ReplacePrefix *string } +// GatewayTLS - TLS configuration definition for Gateway resource. +type GatewayTLS struct { + // The resource id for the secret containing the TLS certificate and key for the gateway. + CertificateFrom *string + + // TLS minimum protocol version (defaults to 1.2). + MinimumProtocolVersion *TLSMinVersion + + // If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption. + SSLPassthrough *bool +} + // HTTPGetHealthProbeProperties - Specifies the properties for readiness/liveness probe using HTTP Get type HTTPGetHealthProbeProperties struct { // REQUIRED; The listening port number ContainerPort *int32 - // REQUIRED; The HealthProbeProperties kind + // REQUIRED; Discriminator property for HealthProbeProperties. Kind *string // REQUIRED; The route to make the HTTP request on @@ -822,12 +888,12 @@ func (h *HTTPGetHealthProbeProperties) GetHealthProbeProperties() *HealthProbePr } } -// HTTPRouteProperties - HTTP Route properties +// HTTPRouteProperties - HTTPRoute properties type HTTPRouteProperties struct { - // REQUIRED; Specifies the resource id of the application + // REQUIRED; Fully qualified resource ID for the application that the portable resource is consumed by Application *string - // The resource id of the environment linked to the resource + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) Environment *string // The internal hostname accepting traffic for the HTTP Route. Readonly. @@ -836,25 +902,25 @@ type HTTPRouteProperties struct { // The port number for the HTTP Route. Defaults to 80. Readonly. Port *int32 - // The scheme used for traffic. Readonly. - Scheme *string - - // A stable URL that that can be used to route traffic to a resource. Readonly. - URL *string - - // READ-ONLY; Provisioning state of the HTTP Route at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of the resource + // READ-ONLY; The scheme used for traffic. Readonly. + Scheme *string + + // READ-ONLY; Status of a resource. Status *ResourceStatus + + // READ-ONLY; A stable URL that that can be used to route traffic to a resource. Readonly. + URL *string } -// HTTPRouteResource - Radius HTTP Route Resource. +// HTTPRouteResource - Radius HTTPRoute Resource. type HTTPRouteResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; HTTP Route properties + // The resource-specific properties for this resource. Properties *HTTPRouteProperties // Resource tags. @@ -866,25 +932,49 @@ type HTTPRouteResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// HTTPRouteResourceList - The list of HTTP Routes. -type HTTPRouteResourceList struct { - // The link used to get the next page of HTTP Routes list. +// HTTPRouteResourceListResult - The response of a HttpRouteResource list operation. +type HTTPRouteResourceListResult struct { + // REQUIRED; The HttpRouteResource items on this page + Value []*HTTPRouteResource + + // The link to the next page of items NextLink *string +} - // The list of HTTP Route. - Value []*HTTPRouteResource +// HTTPRouteResourceUpdate - The type used for update operations of the HttpRouteResource. +type HTTPRouteResourceUpdate struct { + // The updatable properties of the HttpRouteResource. + Properties *HTTPRouteResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// HTTPRouteResourceUpdateProperties - The updatable properties of the HttpRouteResource. +type HTTPRouteResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by + Application *string + + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) + Environment *string + + // The internal hostname accepting traffic for the HTTP Route. Readonly. + Hostname *string + + // The port number for the HTTP Route. Defaults to 80. Readonly. + Port *int32 } // HealthProbeProperties - Properties for readiness/liveness probe type HealthProbeProperties struct { - // REQUIRED; The HealthProbeProperties kind + // REQUIRED; Discriminator property for HealthProbeProperties. Kind *string // Threshold number of times the probe fails after which a failure would be reported @@ -903,17 +993,39 @@ type HealthProbeProperties struct { // GetHealthProbeProperties implements the HealthProbePropertiesClassification interface for type HealthProbeProperties. func (h *HealthProbeProperties) GetHealthProbeProperties() *HealthProbeProperties { return h } -// IamProperties - The properties of IAM +// IamProperties - IAM properties type IamProperties struct { // REQUIRED; The kind of IAM provider to configure - Kind *Kind + Kind *IAMKind + + // RBAC permissions to be assigned on the source resource + Roles []*string +} + +// IamPropertiesUpdate - IAM properties +type IamPropertiesUpdate struct { + // The kind of IAM provider to configure + Kind *IAMKind // RBAC permissions to be assigned on the source resource Roles []*string } +// IdentitySettings is the external identity setting. type IdentitySettings struct { - // REQUIRED; Configuration for supported external identity providers + // REQUIRED; kind of identity setting + Kind *IdentitySettingKind + + // The URI for your compute platform's OIDC issuer + OidcIssuer *string + + // The resource ID of the provisioned identity + Resource *string +} + +// IdentitySettingsUpdate - IdentitySettings is the external identity setting. +type IdentitySettingsUpdate struct { + // kind of identity setting Kind *IdentitySettingKind // The URI for your compute platform's OIDC issuer @@ -923,20 +1035,21 @@ type IdentitySettings struct { Resource *string } +// KeyObjectProperties - Represents key object properties type KeyObjectProperties struct { // REQUIRED; The name of the key Name *string - // File name when written to disk. + // File name when written to disk Alias *string // Key version Version *string } -// KubernetesCompute - Specifies the properties for Kubernetes compute environment +// KubernetesCompute - The Kubernetes compute configuration type KubernetesCompute struct { - // REQUIRED; Type of compute resource. + // REQUIRED; Discriminator property for EnvironmentCompute. Kind *string // REQUIRED; The namespace to use for the environment. @@ -958,22 +1071,84 @@ func (k *KubernetesCompute) GetEnvironmentCompute() *EnvironmentCompute { } } -// ManualScalingExtension - ManualScaling Extension -type ManualScalingExtension struct { - // REQUIRED; Specifies the extensions of a resource. +// KubernetesComputeUpdate - The Kubernetes compute configuration +type KubernetesComputeUpdate struct { + // REQUIRED; Discriminator property for EnvironmentCompute. Kind *string - // Replica count. - Replicas *int32 + // Configuration for supported external identity providers + Identity *IdentitySettingsUpdate + + // The namespace to use for the environment. + Namespace *string + + // The resource id of the compute resource for application environment. + ResourceID *string } -// GetContainerExtension implements the ContainerExtensionClassification interface for type ManualScalingExtension. -func (m *ManualScalingExtension) GetContainerExtension() *ContainerExtension { - return &ContainerExtension{ - Kind: m.Kind, +// GetEnvironmentComputeUpdate implements the EnvironmentComputeUpdateClassification interface for type KubernetesComputeUpdate. +func (k *KubernetesComputeUpdate) GetEnvironmentComputeUpdate() *EnvironmentComputeUpdate { + return &EnvironmentComputeUpdate{ + Identity: k.Identity, + Kind: k.Kind, + ResourceID: k.ResourceID, + } +} + +// KubernetesMetadataExtension - Kubernetes metadata extension of a environment/application resource. +type KubernetesMetadataExtension struct { + // REQUIRED; Discriminator property for Extension. + Kind *string + + // Annotations to be applied to the Kubernetes resources output by the resource + Annotations map[string]*string + + // Labels to be applied to the Kubernetes resources output by the resource + Labels map[string]*string +} + +// GetExtension implements the ExtensionClassification interface for type KubernetesMetadataExtension. +func (k *KubernetesMetadataExtension) GetExtension() *Extension { + return &Extension{ + Kind: k.Kind, + } +} + +// KubernetesNamespaceExtension - Kubernetes namespace extension of a environment/application resource. +type KubernetesNamespaceExtension struct { + // REQUIRED; Discriminator property for Extension. + Kind *string + + // REQUIRED; The namespace of the application environment. + Namespace *string +} + +// GetExtension implements the ExtensionClassification interface for type KubernetesNamespaceExtension. +func (k *KubernetesNamespaceExtension) GetExtension() *Extension { + return &Extension{ + Kind: k.Kind, } } +// KubernetesRuntimeProperties - The runtime configuration properties for Kubernetes +type KubernetesRuntimeProperties struct { + // The serialized YAML manifest which represents the base Kubernetes resources to deploy, such as Deployment, Service, ServiceAccount, +// Secrets, and ConfigMaps. + Base *string + + // A strategic merge patch that will be applied to the PodSpec object when this container is being deployed. + Pod map[string]any +} + +// ManualScalingExtension - ManualScaling Extension +type ManualScalingExtension struct { + // REQUIRED; Discriminator property for Extension. + Kind *string + + // REQUIRED; Replica count. + Replicas *int32 +} + // GetExtension implements the ExtensionClassification interface for type ManualScalingExtension. func (m *ManualScalingExtension) GetExtension() *Extension { return &Extension{ @@ -981,9 +1156,72 @@ func (m *ManualScalingExtension) GetExtension() *Extension { } } +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane +// operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", +// "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual +// Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft +// Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job +// Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// OutputResource - Properties of an output resource. +type OutputResource struct { + // The UCP resource ID of the underlying resource. + ID *string + + // The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency +// relationship. LocalIDs do not have any particular format or meaning beyond +// being compared to determine dependency relationships. + LocalID *string + + // Determines whether Radius manages the lifecycle of the underlying resource. + RadiusManaged *bool +} + // PersistentVolume - Specifies a persistent volume for a container type PersistentVolume struct { - // REQUIRED; The Volume kind + // REQUIRED; Discriminator property for Volume. Kind *string // REQUIRED; The source of the volume @@ -1004,64 +1242,121 @@ func (p *PersistentVolume) GetVolume() *Volume { } } -// PortableResourceBasicProperties - Basic properties of a Portable resource. -type PortableResourceBasicProperties struct { - // REQUIRED; The resource id of the environment linked to the resource - Environment *string - - // Specifies the resource id of the application - Application *string - - // READ-ONLY; Status of a Portable resource. - Status *ResourceStatus -} - -// Providers - Cloud providers configuration +// Providers - The Cloud providers configuration type Providers struct { - // AWS cloud provider configuration + // The AWS cloud provider configuration Aws *ProvidersAws - // Azure cloud provider configuration + // The Azure cloud provider configuration Azure *ProvidersAzure } -// ProvidersAws - AWS cloud provider configuration +// ProvidersAws - The AWS cloud provider definition type ProvidersAws struct { + // REQUIRED; Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2' + Scope *string +} + +// ProvidersAwsUpdate - The AWS cloud provider definition +type ProvidersAwsUpdate struct { // Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2' Scope *string } -// ProvidersAzure - Azure cloud provider configuration +// ProvidersAzure - The Azure cloud provider definition type ProvidersAzure struct { + // REQUIRED; Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup' + Scope *string +} + +// ProvidersAzureUpdate - The Azure cloud provider definition +type ProvidersAzureUpdate struct { // Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup' Scope *string } -// Recipe properties. +// ProvidersUpdate - The Cloud providers configuration +type ProvidersUpdate struct { + // The AWS cloud provider configuration + Aws *ProvidersAwsUpdate + + // The Azure cloud provider configuration + Azure *ProvidersAzureUpdate +} + +// Recipe - The recipe used to automatically deploy underlying infrastructure for a portable resource type Recipe struct { - // Type of the link this recipe can be consumed by. For example: 'Applications.Link/mongoDatabases' - LinkType *string + // REQUIRED; The name of the recipe within the environment to use + Name *string + + // Key/value parameters to pass into the recipe at deployment + Parameters map[string]any +} - // Name of the recipe registered to the environment. +// RecipeGetMetadata - Represents the request body of the getmetadata action. +type RecipeGetMetadata struct { + // REQUIRED; The name of the recipe registered to the environment Name *string + + // REQUIRED; Type of the resource this recipe can be consumed by. For example: 'Applications.Datastores/mongoDatabases' + ResourceType *string } -// RecipeMetadataProperties - Properties of a Recipe linked to an Environment. -type RecipeMetadataProperties struct { - // Key/value parameters to pass to the recipe template at deployment +// RecipeGetMetadataResponse - The properties of a Recipe linked to an Environment. +type RecipeGetMetadataResponse struct { + // REQUIRED; The key/value parameters to pass to the recipe template at deployment. Parameters map[string]any - // Format of the template provided by the recipe. Allowed values: bicep, terraform. + // REQUIRED; The format of the template provided by the recipe. Allowed values: bicep, terraform. TemplateKind *string - // Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. + // REQUIRED; The path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. TemplatePath *string - // Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted + // The version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted // for other module sources. TemplateVersion *string } +// RecipeProperties - Format of the template provided by the recipe. Allowed values: bicep, terraform. +type RecipeProperties struct { + // REQUIRED; Discriminator property for RecipeProperties. + TemplateKind *string + + // REQUIRED; Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. + TemplatePath *string + + // Key/value parameters to pass to the recipe template at deployment + Parameters map[string]any +} + +// GetRecipeProperties implements the RecipePropertiesClassification interface for type RecipeProperties. +func (r *RecipeProperties) GetRecipeProperties() *RecipeProperties { return r } + +// RecipePropertiesUpdate - Format of the template provided by the recipe. Allowed values: bicep, terraform. +type RecipePropertiesUpdate struct { + // REQUIRED; Discriminator property for RecipeProperties. + TemplateKind *string + + // Key/value parameters to pass to the recipe template at deployment + Parameters map[string]any + + // Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. + TemplatePath *string +} + +// GetRecipePropertiesUpdate implements the RecipePropertiesUpdateClassification interface for type RecipePropertiesUpdate. +func (r *RecipePropertiesUpdate) GetRecipePropertiesUpdate() *RecipePropertiesUpdate { return r } + +// RecipeUpdate - The recipe used to automatically deploy underlying infrastructure for a portable resource +type RecipeUpdate struct { + // The name of the recipe within the environment to use + Name *string + + // Key/value parameters to pass into the recipe at deployment + Parameters map[string]any +} + // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} @@ -1070,57 +1365,61 @@ type Resource struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// ResourceRecipe - The recipe used to automatically deploy underlying infrastructure for a portable resource. -type ResourceRecipe struct { - // REQUIRED; The name of the recipe within the environment to use. - Name *string - - // Key/value parameters to pass into the recipe at deployment. - Parameters map[string]any -} - // ResourceStatus - Status of a resource. type ResourceStatus struct { - // Compute resource used by application environment resource. + // The compute resource associated with the resource. Compute EnvironmentComputeClassification - OutputResources []map[string]any + + // Properties of an output resource + OutputResources []*OutputResource +} + +// RuntimesProperties - The properties for runtime configuration +type RuntimesProperties struct { + // The runtime configuration properties for Kubernetes + Kubernetes *KubernetesRuntimeProperties } +// SecretObjectProperties - Represents secret object properties type SecretObjectProperties struct { // REQUIRED; The name of the secret Name *string - // File name when written to disk. + // File name when written to disk Alias *string // Encoding format. Default utf-8 - Encoding *Encoding + Encoding *VolumeSecretEncodings - // Secret version + // secret version Version *string } // SecretStoreListSecretsResult - The list of secrets type SecretStoreListSecretsResult struct { - // An object to represent key-value type secrets + // REQUIRED; An object to represent key-value type secrets Data map[string]*SecretValueProperties - // The type of secret store data + // REQUIRED; The type of secret store data Type *SecretStoreDataType } +// SecretStoreProperties - The properties of SecretStore type SecretStoreProperties struct { - // REQUIRED; Specifies the resource id of the application + // REQUIRED; Fully qualified resource ID for the application that the portable resource is consumed by Application *string // REQUIRED; An object to represent key-value type secrets Data map[string]*SecretValueProperties - // The resource id of the environment linked to the resource + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) Environment *string // The resource id of external secret store. @@ -1129,19 +1428,19 @@ type SecretStoreProperties struct { // The type of secret store data Type *SecretStoreDataType - // READ-ONLY; Provisioning state of the SecretStore at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of the resource + // READ-ONLY; Status of a resource. Status *ResourceStatus } -// SecretStoreResource - Radius SecretStore Resource. +// SecretStoreResource - Concrete tracked resource types can be created by aliasing this type using a specific property type. type SecretStoreResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED; The resource-specific properties for this resource. + // The resource-specific properties for this resource. Properties *SecretStoreProperties // Resource tags. @@ -1153,22 +1452,50 @@ type SecretStoreResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// SecretStoreResourceList - The list of SecretStores. -type SecretStoreResourceList struct { - // The link used to get the next page of SecretStores list. +// SecretStoreResourceListResult - The response of a SecretStoreResource list operation. +type SecretStoreResourceListResult struct { + // REQUIRED; The SecretStoreResource items on this page + Value []*SecretStoreResource + + // The link to the next page of items NextLink *string +} - // The list of SecretStore. - Value []*SecretStoreResource +// SecretStoreResourceUpdate - The type used for update operations of the SecretStoreResource. +type SecretStoreResourceUpdate struct { + // The updatable properties of the SecretStoreResource. + Properties *SecretStoreResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// SecretStoreResourceUpdateProperties - The updatable properties of the SecretStoreResource. +type SecretStoreResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by + Application *string + + // An object to represent key-value type secrets + Data map[string]*SecretValueProperties + + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) + Environment *string + + // The resource id of external secret store. + Resource *string + + // The type of secret store data + Type *SecretStoreDataType } +// SecretValueProperties - The properties of SecretValue type SecretValueProperties struct { // The encoding of value Encoding *SecretValueEncoding @@ -1206,7 +1533,7 @@ type TCPHealthProbeProperties struct { // REQUIRED; The listening port number ContainerPort *int32 - // REQUIRED; The HealthProbeProperties kind + // REQUIRED; Discriminator property for HealthProbeProperties. Kind *string // Threshold number of times the probe fails after which a failure would be reported @@ -1233,9 +1560,9 @@ func (t *TCPHealthProbeProperties) GetHealthProbeProperties() *HealthProbeProper } } -// TerraformRecipeProperties - Properties of a Recipe linked to an Environment. +// TerraformRecipeProperties - Represents Terraform recipe properties. type TerraformRecipeProperties struct { - // REQUIRED; Format of the template provided by the recipe. Allowed values: bicep, terraform. + // REQUIRED; Discriminator property for RecipeProperties. TemplateKind *string // REQUIRED; Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. @@ -1249,9 +1576,34 @@ type TerraformRecipeProperties struct { TemplateVersion *string } -// GetEnvironmentRecipeProperties implements the EnvironmentRecipePropertiesClassification interface for type TerraformRecipeProperties. -func (t *TerraformRecipeProperties) GetEnvironmentRecipeProperties() *EnvironmentRecipeProperties { - return &EnvironmentRecipeProperties{ +// GetRecipeProperties implements the RecipePropertiesClassification interface for type TerraformRecipeProperties. +func (t *TerraformRecipeProperties) GetRecipeProperties() *RecipeProperties { + return &RecipeProperties{ + Parameters: t.Parameters, + TemplateKind: t.TemplateKind, + TemplatePath: t.TemplatePath, + } +} + +// TerraformRecipePropertiesUpdate - Represents Terraform recipe properties. +type TerraformRecipePropertiesUpdate struct { + // REQUIRED; Discriminator property for RecipeProperties. + TemplateKind *string + + // Key/value parameters to pass to the recipe template at deployment + Parameters map[string]any + + // Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported. + TemplatePath *string + + // Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted +// for other module sources. + TemplateVersion *string +} + +// GetRecipePropertiesUpdate implements the RecipePropertiesUpdateClassification interface for type TerraformRecipePropertiesUpdate. +func (t *TerraformRecipePropertiesUpdate) GetRecipePropertiesUpdate() *RecipePropertiesUpdate { + return &RecipePropertiesUpdate{ Parameters: t.Parameters, TemplateKind: t.TemplateKind, TemplatePath: t.TemplatePath, @@ -1273,10 +1625,14 @@ type TrackedResource struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } +// ValueFromProperties - The Secret value source properties type ValueFromProperties struct { // REQUIRED; The name of the referenced secret. Name *string @@ -1287,7 +1643,7 @@ type ValueFromProperties struct { // Volume - Specifies a volume for a container type Volume struct { - // REQUIRED; The Volume kind + // REQUIRED; Discriminator property for Volume. Kind *string // The path where the volume is mounted @@ -1297,32 +1653,33 @@ type Volume struct { // GetVolume implements the VolumeClassification interface for type Volume. func (v *Volume) GetVolume() *Volume { return v } +// VolumeProperties - Volume properties type VolumeProperties struct { - // REQUIRED; Specifies the resource id of the application + // REQUIRED; Fully qualified resource ID for the application that the portable resource is consumed by Application *string - // REQUIRED; The volume kind + // REQUIRED; Discriminator property for VolumeProperties. Kind *string - // The resource id of the environment linked to the resource + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) Environment *string - // READ-ONLY; Provisioning state of the Volume at the time the operation was called. + // READ-ONLY; The status of the asynchronous operation. ProvisioningState *ProvisioningState - // READ-ONLY; Status of the resource + // READ-ONLY; Status of a resource. Status *ResourceStatus } // GetVolumeProperties implements the VolumePropertiesClassification interface for type VolumeProperties. func (v *VolumeProperties) GetVolumeProperties() *VolumeProperties { return v } -// VolumeResource - Radius Volume Resource. +// VolumeResource - Radius Volume resource. type VolumeResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // REQUIRED + // The resource-specific properties for this resource. Properties VolumePropertiesClassification // Resource tags. @@ -1334,19 +1691,37 @@ type VolumeResource struct { // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } -// VolumeResourceList - The list of Volumes. -type VolumeResourceList struct { - // The link used to get the next page of Volumes list. +// VolumeResourceListResult - The response of a VolumeResource list operation. +type VolumeResourceListResult struct { + // REQUIRED; The VolumeResource items on this page + Value []*VolumeResource + + // The link to the next page of items NextLink *string +} - // The list of Volume. - Value []*VolumeResource +// VolumeResourceUpdate - The type used for update operations of the VolumeResource. +type VolumeResourceUpdate struct { + // The updatable properties of the VolumeResource. + Properties *VolumeResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// VolumeResourceUpdateProperties - The updatable properties of the VolumeResource. +type VolumeResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by + Application *string + + // Fully qualified resource ID for the environment that the portable resource is linked to (if applicable) + Environment *string } diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_models_serde.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_models_serde.go index 945e5e0880..f56e2e9934 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_models_serde.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_models_serde.go @@ -14,99 +14,6 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type ApplicationExtension. -func (a ApplicationExtension) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - objectMap["kind"] = "ApplicationExtension" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationExtension. -func (a *ApplicationExtension) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "kind": - err = unpopulate(val, "Kind", &a.Kind) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationKubernetesMetadataExtension. -func (a ApplicationKubernetesMetadataExtension) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "annotations", a.Annotations) - objectMap["kind"] = "kubernetesMetadata" - populate(objectMap, "labels", a.Labels) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationKubernetesMetadataExtension. -func (a *ApplicationKubernetesMetadataExtension) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "annotations": - err = unpopulate(val, "Annotations", &a.Annotations) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &a.Kind) - delete(rawMsg, key) - case "labels": - err = unpopulate(val, "Labels", &a.Labels) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ApplicationKubernetesNamespaceExtension. -func (a ApplicationKubernetesNamespaceExtension) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - objectMap["kind"] = "kubernetesNamespace" - populate(objectMap, "namespace", a.Namespace) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationKubernetesNamespaceExtension. -func (a *ApplicationKubernetesNamespaceExtension) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "kind": - err = unpopulate(val, "Kind", &a.Kind) - delete(rawMsg, key) - case "namespace": - err = unpopulate(val, "Namespace", &a.Namespace) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ApplicationProperties. func (a ApplicationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -130,7 +37,7 @@ func (a *ApplicationProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Environment", &a.Environment) delete(rawMsg, key) case "extensions": - a.Extensions, err = unmarshalApplicationExtensionClassificationArray(val) + a.Extensions, err = unmarshalExtensionClassificationArray(val) delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) @@ -197,16 +104,16 @@ func (a *ApplicationResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ApplicationResourceList. -func (a ApplicationResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ApplicationResourceListResult. +func (a ApplicationResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceList. -func (a *ApplicationResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceListResult. +func (a *ApplicationResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -228,6 +135,87 @@ func (a *ApplicationResourceList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ApplicationResourceUpdate. +func (a ApplicationResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceUpdate. +func (a *ApplicationResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApplicationResourceUpdateProperties. +func (a ApplicationResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "compute", a.Compute) + populate(objectMap, "extensions", a.Extensions) + populate(objectMap, "providers", a.Providers) + populate(objectMap, "recipes", a.Recipes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceUpdateProperties. +func (a *ApplicationResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "compute": + a.Compute, err = unmarshalEnvironmentComputeUpdateClassification(val) + delete(rawMsg, key) + case "extensions": + a.Extensions, err = unmarshalExtensionClassificationArray(val) + delete(rawMsg, key) + case "providers": + err = unpopulate(val, "Providers", &a.Providers) + delete(rawMsg, key) + case "recipes": + var recipesRaw map[string]json.RawMessage + if err = json.Unmarshal(val, &recipesRaw); err != nil { + return err + } + recipes := map[string]map[string]RecipePropertiesUpdateClassification{} + for k1, v1 := range recipesRaw { + recipes[k1], err = unmarshalRecipePropertiesUpdateClassificationMap(v1) + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + a.Recipes = recipes + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type AzureKeyVaultVolumeProperties. func (a AzureKeyVaultVolumeProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -287,17 +275,17 @@ func (a *AzureKeyVaultVolumeProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type BasicResourceProperties. -func (b BasicResourceProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type BicepRecipeProperties. +func (b BicepRecipeProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "application", b.Application) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) + populate(objectMap, "parameters", b.Parameters) + objectMap["templateKind"] = "bicep" + populate(objectMap, "templatePath", b.TemplatePath) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicResourceProperties. -func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type BicepRecipeProperties. +func (b *BicepRecipeProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) @@ -305,14 +293,14 @@ func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) + case "parameters": + err = unpopulate(val, "Parameters", &b.Parameters) delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) + case "templateKind": + err = unpopulate(val, "TemplateKind", &b.TemplateKind) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) + case "templatePath": + err = unpopulate(val, "TemplatePath", &b.TemplatePath) delete(rawMsg, key) } if err != nil { @@ -322,8 +310,8 @@ func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type BicepRecipeProperties. -func (b BicepRecipeProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type BicepRecipePropertiesUpdate. +func (b BicepRecipePropertiesUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "parameters", b.Parameters) objectMap["templateKind"] = "bicep" @@ -331,8 +319,8 @@ func (b BicepRecipeProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type BicepRecipeProperties. -func (b *BicepRecipeProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type BicepRecipePropertiesUpdate. +func (b *BicepRecipePropertiesUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) @@ -439,6 +427,41 @@ func (c *ConnectionProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ConnectionPropertiesUpdate. +func (c ConnectionPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "disableDefaultEnvVars", c.DisableDefaultEnvVars) + populate(objectMap, "iam", c.Iam) + populate(objectMap, "source", c.Source) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectionPropertiesUpdate. +func (c *ConnectionPropertiesUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "disableDefaultEnvVars": + err = unpopulate(val, "DisableDefaultEnvVars", &c.DisableDefaultEnvVars) + delete(rawMsg, key) + case "iam": + err = unpopulate(val, "Iam", &c.Iam) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &c.Source) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Container. func (c Container) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -446,6 +469,7 @@ func (c Container) MarshalJSON() ([]byte, error) { populate(objectMap, "command", c.Command) populate(objectMap, "env", c.Env) populate(objectMap, "image", c.Image) + populate(objectMap, "imagePullPolicy", c.ImagePullPolicy) populate(objectMap, "livenessProbe", c.LivenessProbe) populate(objectMap, "ports", c.Ports) populate(objectMap, "readinessProbe", c.ReadinessProbe) @@ -475,6 +499,9 @@ func (c *Container) UnmarshalJSON(data []byte) error { case "image": err = unpopulate(val, "Image", &c.Image) delete(rawMsg, key) + case "imagePullPolicy": + err = unpopulate(val, "ImagePullPolicy", &c.ImagePullPolicy) + delete(rawMsg, key) case "livenessProbe": c.LivenessProbe, err = unmarshalHealthProbePropertiesClassification(val) delete(rawMsg, key) @@ -498,15 +525,19 @@ func (c *Container) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ContainerExtension. -func (c ContainerExtension) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ContainerPortProperties. +func (c ContainerPortProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["kind"] = "ContainerExtension" + populate(objectMap, "containerPort", c.ContainerPort) + populate(objectMap, "port", c.Port) + populate(objectMap, "protocol", c.Protocol) + populate(objectMap, "provides", c.Provides) + populate(objectMap, "scheme", c.Scheme) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerExtension. -func (c *ContainerExtension) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerPortProperties. +func (c *ContainerPortProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -514,43 +545,20 @@ func (c *ContainerExtension) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "kind": - err = unpopulate(val, "Kind", &c.Kind) + case "containerPort": + err = unpopulate(val, "ContainerPort", &c.ContainerPort) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ContainerKubernetesMetadataExtension. -func (c ContainerKubernetesMetadataExtension) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "annotations", c.Annotations) - objectMap["kind"] = "kubernetesMetadata" - populate(objectMap, "labels", c.Labels) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerKubernetesMetadataExtension. -func (c *ContainerKubernetesMetadataExtension) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "annotations": - err = unpopulate(val, "Annotations", &c.Annotations) + case "port": + err = unpopulate(val, "Port", &c.Port) delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &c.Kind) + case "protocol": + err = unpopulate(val, "Protocol", &c.Protocol) delete(rawMsg, key) - case "labels": - err = unpopulate(val, "Labels", &c.Labels) + case "provides": + err = unpopulate(val, "Provides", &c.Provides) + delete(rawMsg, key) + case "scheme": + err = unpopulate(val, "Scheme", &c.Scheme) delete(rawMsg, key) } if err != nil { @@ -560,8 +568,8 @@ func (c *ContainerKubernetesMetadataExtension) UnmarshalJSON(data []byte) error return nil } -// MarshalJSON implements the json.Marshaller interface for type ContainerPort. -func (c ContainerPort) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ContainerPortPropertiesUpdate. +func (c ContainerPortPropertiesUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "containerPort", c.ContainerPort) populate(objectMap, "port", c.Port) @@ -571,8 +579,8 @@ func (c ContainerPort) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerPort. -func (c *ContainerPort) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerPortPropertiesUpdate. +func (c *ContainerPortPropertiesUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -613,6 +621,7 @@ func (c ContainerProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "extensions", c.Extensions) populate(objectMap, "identity", c.Identity) populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "runtimes", c.Runtimes) populate(objectMap, "status", c.Status) return json.Marshal(objectMap) } @@ -639,7 +648,7 @@ func (c *ContainerProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Environment", &c.Environment) delete(rawMsg, key) case "extensions": - c.Extensions, err = unmarshalContainerExtensionClassificationArray(val) + c.Extensions, err = unmarshalExtensionClassificationArray(val) delete(rawMsg, key) case "identity": err = unpopulate(val, "Identity", &c.Identity) @@ -647,6 +656,9 @@ func (c *ContainerProperties) UnmarshalJSON(data []byte) error { case "provisioningState": err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) delete(rawMsg, key) + case "runtimes": + err = unpopulate(val, "Runtimes", &c.Runtimes) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &c.Status) delete(rawMsg, key) @@ -709,16 +721,16 @@ func (c *ContainerResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ContainerResourceList. -func (c ContainerResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ContainerResourceListResult. +func (c ContainerResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerResourceList. -func (c *ContainerResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerResourceListResult. +func (c *ContainerResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -740,93 +752,205 @@ func (c *ContainerResourceList) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DaprSidecarExtension. -func (d DaprSidecarExtension) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ContainerResourceUpdate. +func (c ContainerResourceUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "appId", d.AppID) - populate(objectMap, "appPort", d.AppPort) - populate(objectMap, "config", d.Config) - objectMap["kind"] = "daprSidecar" - populate(objectMap, "protocol", d.Protocol) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprSidecarExtension. -func (d *DaprSidecarExtension) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerResourceUpdate. +func (c *ContainerResourceUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "appId": - err = unpopulate(val, "AppID", &d.AppID) - delete(rawMsg, key) - case "appPort": - err = unpopulate(val, "AppPort", &d.AppPort) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) delete(rawMsg, key) - case "config": - err = unpopulate(val, "Config", &d.Config) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &d.Kind) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerResourceUpdateProperties. +func (c ContainerResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", c.Application) + populate(objectMap, "connections", c.Connections) + populate(objectMap, "container", c.Container) + populate(objectMap, "environment", c.Environment) + populate(objectMap, "extensions", c.Extensions) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "runtimes", c.Runtimes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerResourceUpdateProperties. +func (c *ContainerResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &c.Application) delete(rawMsg, key) - case "protocol": - err = unpopulate(val, "Protocol", &d.Protocol) + case "connections": + err = unpopulate(val, "Connections", &c.Connections) + delete(rawMsg, key) + case "container": + err = unpopulate(val, "Container", &c.Container) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &c.Environment) + delete(rawMsg, key) + case "extensions": + c.Extensions, err = unmarshalExtensionClassificationArray(val) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &c.Identity) + delete(rawMsg, key) + case "runtimes": + err = unpopulate(val, "Runtimes", &c.Runtimes) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnvironmentCompute. -func (e EnvironmentCompute) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ContainerUpdate. +func (c ContainerUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "identity", e.Identity) - objectMap["kind"] = e.Kind - populate(objectMap, "resourceId", e.ResourceID) + populate(objectMap, "args", c.Args) + populate(objectMap, "command", c.Command) + populate(objectMap, "env", c.Env) + populate(objectMap, "image", c.Image) + populate(objectMap, "imagePullPolicy", c.ImagePullPolicy) + populate(objectMap, "livenessProbe", c.LivenessProbe) + populate(objectMap, "ports", c.Ports) + populate(objectMap, "readinessProbe", c.ReadinessProbe) + populate(objectMap, "volumes", c.Volumes) + populate(objectMap, "workingDir", c.WorkingDir) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentCompute. -func (e *EnvironmentCompute) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerUpdate. +func (c *ContainerUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "identity": - err = unpopulate(val, "Identity", &e.Identity) + case "args": + err = unpopulate(val, "Args", &c.Args) + delete(rawMsg, key) + case "command": + err = unpopulate(val, "Command", &c.Command) + delete(rawMsg, key) + case "env": + err = unpopulate(val, "Env", &c.Env) + delete(rawMsg, key) + case "image": + err = unpopulate(val, "Image", &c.Image) + delete(rawMsg, key) + case "imagePullPolicy": + err = unpopulate(val, "ImagePullPolicy", &c.ImagePullPolicy) + delete(rawMsg, key) + case "livenessProbe": + c.LivenessProbe, err = unmarshalHealthProbePropertiesClassification(val) + delete(rawMsg, key) + case "ports": + err = unpopulate(val, "Ports", &c.Ports) + delete(rawMsg, key) + case "readinessProbe": + c.ReadinessProbe, err = unmarshalHealthProbePropertiesClassification(val) + delete(rawMsg, key) + case "volumes": + c.Volumes, err = unmarshalVolumeClassificationMap(val) + delete(rawMsg, key) + case "workingDir": + err = unpopulate(val, "WorkingDir", &c.WorkingDir) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DaprSidecarExtension. +func (d DaprSidecarExtension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appId", d.AppID) + populate(objectMap, "appPort", d.AppPort) + populate(objectMap, "config", d.Config) + objectMap["kind"] = "daprSidecar" + populate(objectMap, "protocol", d.Protocol) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DaprSidecarExtension. +func (d *DaprSidecarExtension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appId": + err = unpopulate(val, "AppID", &d.AppID) + delete(rawMsg, key) + case "appPort": + err = unpopulate(val, "AppPort", &d.AppPort) + delete(rawMsg, key) + case "config": + err = unpopulate(val, "Config", &d.Config) delete(rawMsg, key) case "kind": - err = unpopulate(val, "Kind", &e.Kind) + err = unpopulate(val, "Kind", &d.Kind) delete(rawMsg, key) - case "resourceId": - err = unpopulate(val, "ResourceID", &e.ResourceID) + case "protocol": + err = unpopulate(val, "Protocol", &d.Protocol) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type EnvironmentExtension. -func (e EnvironmentExtension) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnvironmentCompute. +func (e EnvironmentCompute) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - objectMap["kind"] = "EnvironmentExtension" + populate(objectMap, "identity", e.Identity) + objectMap["kind"] = e.Kind + populate(objectMap, "resourceId", e.ResourceID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentExtension. -func (e *EnvironmentExtension) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentCompute. +func (e *EnvironmentCompute) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -834,9 +958,15 @@ func (e *EnvironmentExtension) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) case "kind": err = unpopulate(val, "Kind", &e.Kind) delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &e.ResourceID) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -845,17 +975,17 @@ func (e *EnvironmentExtension) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type EnvironmentKubernetesMetadataExtension. -func (e EnvironmentKubernetesMetadataExtension) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnvironmentComputeUpdate. +func (e EnvironmentComputeUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "annotations", e.Annotations) - objectMap["kind"] = "kubernetesMetadata" - populate(objectMap, "labels", e.Labels) + populate(objectMap, "identity", e.Identity) + objectMap["kind"] = e.Kind + populate(objectMap, "resourceId", e.ResourceID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentKubernetesMetadataExtension. -func (e *EnvironmentKubernetesMetadataExtension) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentComputeUpdate. +func (e *EnvironmentComputeUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -863,14 +993,14 @@ func (e *EnvironmentKubernetesMetadataExtension) UnmarshalJSON(data []byte) erro for key, val := range rawMsg { var err error switch key { - case "annotations": - err = unpopulate(val, "Annotations", &e.Annotations) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) delete(rawMsg, key) case "kind": err = unpopulate(val, "Kind", &e.Kind) delete(rawMsg, key) - case "labels": - err = unpopulate(val, "Labels", &e.Labels) + case "resourceId": + err = unpopulate(val, "ResourceID", &e.ResourceID) delete(rawMsg, key) } if err != nil { @@ -904,7 +1034,7 @@ func (e *EnvironmentProperties) UnmarshalJSON(data []byte) error { e.Compute, err = unmarshalEnvironmentComputeClassification(val) delete(rawMsg, key) case "extensions": - e.Extensions, err = unmarshalEnvironmentExtensionClassificationArray(val) + e.Extensions, err = unmarshalExtensionClassificationArray(val) delete(rawMsg, key) case "providers": err = unpopulate(val, "Providers", &e.Providers) @@ -917,9 +1047,9 @@ func (e *EnvironmentProperties) UnmarshalJSON(data []byte) error { if err = json.Unmarshal(val, &recipesRaw); err != nil { return err } - recipes := map[string]map[string]EnvironmentRecipePropertiesClassification{} + recipes := map[string]map[string]RecipePropertiesClassification{} for k1, v1 := range recipesRaw { - recipes[k1], err = unmarshalEnvironmentRecipePropertiesClassificationMap(v1) + recipes[k1], err = unmarshalRecipePropertiesClassificationMap(v1) if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) } @@ -934,41 +1064,6 @@ func (e *EnvironmentProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type EnvironmentRecipeProperties. -func (e EnvironmentRecipeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "parameters", e.Parameters) - objectMap["templateKind"] = e.TemplateKind - populate(objectMap, "templatePath", e.TemplatePath) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentRecipeProperties. -func (e *EnvironmentRecipeProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "parameters": - err = unpopulate(val, "Parameters", &e.Parameters) - delete(rawMsg, key) - case "templateKind": - err = unpopulate(val, "TemplateKind", &e.TemplateKind) - delete(rawMsg, key) - case "templatePath": - err = unpopulate(val, "TemplatePath", &e.TemplatePath) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type EnvironmentResource. func (e EnvironmentResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1020,16 +1115,16 @@ func (e *EnvironmentResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type EnvironmentResourceList. -func (e EnvironmentResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type EnvironmentResourceListResult. +func (e EnvironmentResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", e.NextLink) populate(objectMap, "value", e.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentResourceList. -func (e *EnvironmentResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentResourceListResult. +func (e *EnvironmentResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1051,6 +1146,87 @@ func (e *EnvironmentResourceList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type EnvironmentResourceUpdate. +func (e EnvironmentResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentResourceUpdate. +func (e *EnvironmentResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EnvironmentResourceUpdateProperties. +func (e EnvironmentResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "compute", e.Compute) + populate(objectMap, "extensions", e.Extensions) + populate(objectMap, "providers", e.Providers) + populate(objectMap, "recipes", e.Recipes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentResourceUpdateProperties. +func (e *EnvironmentResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "compute": + e.Compute, err = unmarshalEnvironmentComputeUpdateClassification(val) + delete(rawMsg, key) + case "extensions": + e.Extensions, err = unmarshalExtensionClassificationArray(val) + delete(rawMsg, key) + case "providers": + err = unpopulate(val, "Providers", &e.Providers) + delete(rawMsg, key) + case "recipes": + var recipesRaw map[string]json.RawMessage + if err = json.Unmarshal(val, &recipesRaw); err != nil { + return err + } + recipes := map[string]map[string]RecipePropertiesUpdateClassification{} + for k1, v1 := range recipesRaw { + recipes[k1], err = unmarshalRecipePropertiesUpdateClassificationMap(v1) + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + e.Recipes = recipes + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type EphemeralVolume. func (e EphemeralVolume) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1234,39 +1410,8 @@ func (e *ExecHealthProbeProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ExtenderList. -func (e ExtenderList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExtenderList. -func (e *ExtenderList) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &e.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &e.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExtenderProperties. -func (e ExtenderProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtenderProperties. +func (e ExtenderProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "application", e.Application) populate(objectMap, "environment", e.Environment) @@ -1382,6 +1527,111 @@ func (e *ExtenderResource) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ExtenderResourceListResult. +func (e ExtenderResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtenderResourceListResult. +func (e *ExtenderResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtenderResourceUpdate. +func (e ExtenderResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtenderResourceUpdate. +func (e *ExtenderResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtenderResourceUpdateProperties. +func (e ExtenderResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", e.Application) + populate(objectMap, "environment", e.Environment) + populate(objectMap, "recipe", e.Recipe) + populate(objectMap, "resourceProvisioning", e.ResourceProvisioning) + populate(objectMap, "secrets", e.Secrets) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtenderResourceUpdateProperties. +func (e *ExtenderResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &e.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &e.Environment) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &e.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &e.ResourceProvisioning) + delete(rawMsg, key) + case "secrets": + err = unpopulate(val, "Secrets", &e.Secrets) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Extension. func (e Extension) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1409,6 +1659,37 @@ func (e *Extension) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type GatewayHostname. +func (g GatewayHostname) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "fullyQualifiedHostname", g.FullyQualifiedHostname) + populate(objectMap, "prefix", g.Prefix) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayHostname. +func (g *GatewayHostname) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "fullyQualifiedHostname": + err = unpopulate(val, "FullyQualifiedHostname", &g.FullyQualifiedHostname) + delete(rawMsg, key) + case "prefix": + err = unpopulate(val, "Prefix", &g.Prefix) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GatewayProperties. func (g GatewayProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1468,16 +1749,21 @@ func (g *GatewayProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayPropertiesHostname. -func (g GatewayPropertiesHostname) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayResource. +func (g GatewayResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "fullyQualifiedHostname", g.FullyQualifiedHostname) - populate(objectMap, "prefix", g.Prefix) + populate(objectMap, "id", g.ID) + populate(objectMap, "location", g.Location) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayPropertiesHostname. -func (g *GatewayPropertiesHostname) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResource. +func (g *GatewayResource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -1485,11 +1771,26 @@ func (g *GatewayPropertiesHostname) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "fullyQualifiedHostname": - err = unpopulate(val, "FullyQualifiedHostname", &g.FullyQualifiedHostname) + case "id": + err = unpopulate(val, "ID", &g.ID) delete(rawMsg, key) - case "prefix": - err = unpopulate(val, "Prefix", &g.Prefix) + case "location": + err = unpopulate(val, "Location", &g.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) } if err != nil { @@ -1499,17 +1800,16 @@ func (g *GatewayPropertiesHostname) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayPropertiesTLS. -func (g GatewayPropertiesTLS) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayResourceListResult. +func (g GatewayResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "certificateFrom", g.CertificateFrom) - populate(objectMap, "minimumProtocolVersion", g.MinimumProtocolVersion) - populate(objectMap, "sslPassthrough", g.SSLPassthrough) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayPropertiesTLS. -func (g *GatewayPropertiesTLS) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResourceListResult. +func (g *GatewayResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -1517,14 +1817,11 @@ func (g *GatewayPropertiesTLS) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "certificateFrom": - err = unpopulate(val, "CertificateFrom", &g.CertificateFrom) - delete(rawMsg, key) - case "minimumProtocolVersion": - err = unpopulate(val, "MinimumProtocolVersion", &g.MinimumProtocolVersion) + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) delete(rawMsg, key) - case "sslPassthrough": - err = unpopulate(val, "SSLPassthrough", &g.SSLPassthrough) + case "value": + err = unpopulate(val, "Value", &g.Value) delete(rawMsg, key) } if err != nil { @@ -1534,21 +1831,16 @@ func (g *GatewayPropertiesTLS) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayResource. -func (g GatewayResource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayResourceUpdate. +func (g GatewayResourceUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", g.ID) - populate(objectMap, "location", g.Location) - populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) - populate(objectMap, "systemData", g.SystemData) populate(objectMap, "tags", g.Tags) - populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResource. -func (g *GatewayResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResourceUpdate. +func (g *GatewayResourceUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -1556,27 +1848,12 @@ func (g *GatewayResource) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &g.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &g.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &g.Name) - delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &g.Properties) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &g.SystemData) - delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &g.Tags) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &g.Type) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -1585,16 +1862,20 @@ func (g *GatewayResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type GatewayResourceList. -func (g GatewayResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayResourceUpdateProperties. +func (g GatewayResourceUpdateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", g.NextLink) - populate(objectMap, "value", g.Value) + populate(objectMap, "application", g.Application) + populate(objectMap, "environment", g.Environment) + populate(objectMap, "hostname", g.Hostname) + populate(objectMap, "internal", g.Internal) + populate(objectMap, "routes", g.Routes) + populate(objectMap, "tls", g.TLS) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResourceList. -func (g *GatewayResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayResourceUpdateProperties. +func (g *GatewayResourceUpdateProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", g, err) @@ -1602,11 +1883,23 @@ func (g *GatewayResourceList) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &g.NextLink) + case "application": + err = unpopulate(val, "Application", &g.Application) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &g.Value) + case "environment": + err = unpopulate(val, "Environment", &g.Environment) + delete(rawMsg, key) + case "hostname": + err = unpopulate(val, "Hostname", &g.Hostname) + delete(rawMsg, key) + case "internal": + err = unpopulate(val, "Internal", &g.Internal) + delete(rawMsg, key) + case "routes": + err = unpopulate(val, "Routes", &g.Routes) + delete(rawMsg, key) + case "tls": + err = unpopulate(val, "TLS", &g.TLS) delete(rawMsg, key) } if err != nil { @@ -1651,10 +1944,45 @@ func (g *GatewayRoute) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type HTTPGetHealthProbeProperties. -func (h HTTPGetHealthProbeProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type GatewayTLS. +func (g GatewayTLS) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "containerPort", h.ContainerPort) + populate(objectMap, "certificateFrom", g.CertificateFrom) + populate(objectMap, "minimumProtocolVersion", g.MinimumProtocolVersion) + populate(objectMap, "sslPassthrough", g.SSLPassthrough) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayTLS. +func (g *GatewayTLS) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "certificateFrom": + err = unpopulate(val, "CertificateFrom", &g.CertificateFrom) + delete(rawMsg, key) + case "minimumProtocolVersion": + err = unpopulate(val, "MinimumProtocolVersion", &g.MinimumProtocolVersion) + delete(rawMsg, key) + case "sslPassthrough": + err = unpopulate(val, "SSLPassthrough", &g.SSLPassthrough) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPGetHealthProbeProperties. +func (h HTTPGetHealthProbeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "containerPort", h.ContainerPort) populate(objectMap, "failureThreshold", h.FailureThreshold) populate(objectMap, "headers", h.Headers) populate(objectMap, "initialDelaySeconds", h.InitialDelaySeconds) @@ -1812,16 +2140,16 @@ func (h *HTTPRouteResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type HTTPRouteResourceList. -func (h HTTPRouteResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type HTTPRouteResourceListResult. +func (h HTTPRouteResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", h.NextLink) populate(objectMap, "value", h.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPRouteResourceList. -func (h *HTTPRouteResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPRouteResourceListResult. +func (h *HTTPRouteResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", h, err) @@ -1843,6 +2171,76 @@ func (h *HTTPRouteResourceList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type HTTPRouteResourceUpdate. +func (h HTTPRouteResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", h.Properties) + populate(objectMap, "tags", h.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPRouteResourceUpdate. +func (h *HTTPRouteResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &h.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &h.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPRouteResourceUpdateProperties. +func (h HTTPRouteResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", h.Application) + populate(objectMap, "environment", h.Environment) + populate(objectMap, "hostname", h.Hostname) + populate(objectMap, "port", h.Port) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPRouteResourceUpdateProperties. +func (h *HTTPRouteResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &h.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &h.Environment) + delete(rawMsg, key) + case "hostname": + err = unpopulate(val, "Hostname", &h.Hostname) + delete(rawMsg, key) + case "port": + err = unpopulate(val, "Port", &h.Port) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type HealthProbeProperties. func (h HealthProbeProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1917,6 +2315,37 @@ func (i *IamProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type IamPropertiesUpdate. +func (i IamPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "roles", i.Roles) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IamPropertiesUpdate. +func (i *IamPropertiesUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "roles": + err = unpopulate(val, "Roles", &i.Roles) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type IdentitySettings. func (i IdentitySettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1952,6 +2381,41 @@ func (i *IdentitySettings) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type IdentitySettingsUpdate. +func (i IdentitySettingsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "oidcIssuer", i.OidcIssuer) + populate(objectMap, "resource", i.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentitySettingsUpdate. +func (i *IdentitySettingsUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "oidcIssuer": + err = unpopulate(val, "OidcIssuer", &i.OidcIssuer) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &i.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type KeyObjectProperties. func (k KeyObjectProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2026,6 +2490,142 @@ func (k *KubernetesCompute) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type KubernetesComputeUpdate. +func (k KubernetesComputeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", k.Identity) + objectMap["kind"] = "kubernetes" + populate(objectMap, "namespace", k.Namespace) + populate(objectMap, "resourceId", k.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesComputeUpdate. +func (k *KubernetesComputeUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &k.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &k.Kind) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &k.Namespace) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &k.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesMetadataExtension. +func (k KubernetesMetadataExtension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "annotations", k.Annotations) + objectMap["kind"] = "kubernetesMetadata" + populate(objectMap, "labels", k.Labels) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesMetadataExtension. +func (k *KubernetesMetadataExtension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "annotations": + err = unpopulate(val, "Annotations", &k.Annotations) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &k.Kind) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &k.Labels) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesNamespaceExtension. +func (k KubernetesNamespaceExtension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = "kubernetesNamespace" + populate(objectMap, "namespace", k.Namespace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesNamespaceExtension. +func (k *KubernetesNamespaceExtension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &k.Kind) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &k.Namespace) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesRuntimeProperties. +func (k KubernetesRuntimeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "base", k.Base) + populate(objectMap, "pod", k.Pod) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesRuntimeProperties. +func (k *KubernetesRuntimeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "base": + err = unpopulate(val, "Base", &k.Base) + delete(rawMsg, key) + case "pod": + err = unpopulate(val, "Pod", &k.Pod) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ManualScalingExtension. func (m ManualScalingExtension) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2057,6 +2657,154 @@ func (m *ManualScalingExtension) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OutputResource. +func (o OutputResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "localId", o.LocalID) + populate(objectMap, "radiusManaged", o.RadiusManaged) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OutputResource. +func (o *OutputResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "localId": + err = unpopulate(val, "LocalID", &o.LocalID) + delete(rawMsg, key) + case "radiusManaged": + err = unpopulate(val, "RadiusManaged", &o.RadiusManaged) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type PersistentVolume. func (p PersistentVolume) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2096,17 +2844,16 @@ func (p *PersistentVolume) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type PortableResourceBasicProperties. -func (p PortableResourceBasicProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Providers. +func (p Providers) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "application", p.Application) - populate(objectMap, "environment", p.Environment) - populate(objectMap, "status", p.Status) + populate(objectMap, "aws", p.Aws) + populate(objectMap, "azure", p.Azure) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type PortableResourceBasicProperties. -func (p *PortableResourceBasicProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Providers. +func (p *Providers) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -2114,14 +2861,38 @@ func (p *PortableResourceBasicProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "application": - err = unpopulate(val, "Application", &p.Application) + case "aws": + err = unpopulate(val, "Aws", &p.Aws) delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &p.Environment) + case "azure": + err = unpopulate(val, "Azure", &p.Azure) delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &p.Status) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvidersAws. +func (p ProvidersAws) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scope", p.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvidersAws. +func (p *ProvidersAws) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "scope": + err = unpopulate(val, "Scope", &p.Scope) delete(rawMsg, key) } if err != nil { @@ -2131,16 +2902,97 @@ func (p *PortableResourceBasicProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Providers. -func (p Providers) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ProvidersAwsUpdate. +func (p ProvidersAwsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scope", p.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvidersAwsUpdate. +func (p *ProvidersAwsUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "scope": + err = unpopulate(val, "Scope", &p.Scope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvidersAzure. +func (p ProvidersAzure) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scope", p.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvidersAzure. +func (p *ProvidersAzure) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "scope": + err = unpopulate(val, "Scope", &p.Scope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvidersAzureUpdate. +func (p ProvidersAzureUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scope", p.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvidersAzureUpdate. +func (p *ProvidersAzureUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "scope": + err = unpopulate(val, "Scope", &p.Scope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvidersUpdate. +func (p ProvidersUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "aws", p.Aws) populate(objectMap, "azure", p.Azure) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Providers. -func (p *Providers) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvidersUpdate. +func (p *ProvidersUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -2162,70 +3014,118 @@ func (p *Providers) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ProvidersAws. -func (p ProvidersAws) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Recipe. +func (r Recipe) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "scope", p.Scope) + populate(objectMap, "name", r.Name) + populate(objectMap, "parameters", r.Parameters) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProvidersAws. -func (p *ProvidersAws) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Recipe. +func (r *Recipe) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "scope": - err = unpopulate(val, "Scope", &p.Scope) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecipeGetMetadata. +func (r RecipeGetMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "resourceType", r.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeGetMetadata. +func (r *RecipeGetMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ProvidersAzure. -func (p ProvidersAzure) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RecipeGetMetadataResponse. +func (r RecipeGetMetadataResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "scope", p.Scope) + populate(objectMap, "parameters", r.Parameters) + populate(objectMap, "templateKind", r.TemplateKind) + populate(objectMap, "templatePath", r.TemplatePath) + populate(objectMap, "templateVersion", r.TemplateVersion) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ProvidersAzure. -func (p *ProvidersAzure) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeGetMetadataResponse. +func (r *RecipeGetMetadataResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { - case "scope": - err = unpopulate(val, "Scope", &p.Scope) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) + delete(rawMsg, key) + case "templateKind": + err = unpopulate(val, "TemplateKind", &r.TemplateKind) + delete(rawMsg, key) + case "templatePath": + err = unpopulate(val, "TemplatePath", &r.TemplatePath) + delete(rawMsg, key) + case "templateVersion": + err = unpopulate(val, "TemplateVersion", &r.TemplateVersion) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", p, err) + return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Recipe. -func (r Recipe) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RecipeProperties. +func (r RecipeProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "linkType", r.LinkType) - populate(objectMap, "name", r.Name) + populate(objectMap, "parameters", r.Parameters) + objectMap["templateKind"] = r.TemplateKind + populate(objectMap, "templatePath", r.TemplatePath) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Recipe. -func (r *Recipe) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeProperties. +func (r *RecipeProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -2233,11 +3133,14 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "linkType": - err = unpopulate(val, "LinkType", &r.LinkType) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) + case "templateKind": + err = unpopulate(val, "TemplateKind", &r.TemplateKind) + delete(rawMsg, key) + case "templatePath": + err = unpopulate(val, "TemplatePath", &r.TemplatePath) delete(rawMsg, key) } if err != nil { @@ -2247,18 +3150,17 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type RecipeMetadataProperties. -func (r RecipeMetadataProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RecipePropertiesUpdate. +func (r RecipePropertiesUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "parameters", r.Parameters) - populate(objectMap, "templateKind", r.TemplateKind) + objectMap["templateKind"] = r.TemplateKind populate(objectMap, "templatePath", r.TemplatePath) - populate(objectMap, "templateVersion", r.TemplateVersion) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeMetadataProperties. -func (r *RecipeMetadataProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipePropertiesUpdate. +func (r *RecipePropertiesUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -2275,9 +3177,6 @@ func (r *RecipeMetadataProperties) UnmarshalJSON(data []byte) error { case "templatePath": err = unpopulate(val, "TemplatePath", &r.TemplatePath) delete(rawMsg, key) - case "templateVersion": - err = unpopulate(val, "TemplateVersion", &r.TemplateVersion) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -2286,17 +3185,16 @@ func (r *RecipeMetadataProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type RecipeUpdate. +func (r RecipeUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) + populate(objectMap, "parameters", r.Parameters) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeUpdate. +func (r *RecipeUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -2304,14 +3202,11 @@ func (r *Resource) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) delete(rawMsg, key) } if err != nil { @@ -2321,16 +3216,18 @@ func (r *Resource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceRecipe. -func (r ResourceRecipe) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) - populate(objectMap, "parameters", r.Parameters) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceRecipe. -func (r *ResourceRecipe) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -2338,11 +3235,17 @@ func (r *ResourceRecipe) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &r.Parameters) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) delete(rawMsg, key) } if err != nil { @@ -2383,6 +3286,33 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type RuntimesProperties. +func (r RuntimesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kubernetes", r.Kubernetes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RuntimesProperties. +func (r *RuntimesProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kubernetes": + err = unpopulate(val, "Kubernetes", &r.Kubernetes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SecretObjectProperties. func (s SecretObjectProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2555,16 +3485,16 @@ func (s *SecretStoreResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type SecretStoreResourceList. -func (s SecretStoreResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SecretStoreResourceListResult. +func (s SecretStoreResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type SecretStoreResourceList. -func (s *SecretStoreResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretStoreResourceListResult. +func (s *SecretStoreResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -2586,6 +3516,80 @@ func (s *SecretStoreResourceList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SecretStoreResourceUpdate. +func (s SecretStoreResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretStoreResourceUpdate. +func (s *SecretStoreResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecretStoreResourceUpdateProperties. +func (s SecretStoreResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", s.Application) + populate(objectMap, "data", s.Data) + populate(objectMap, "environment", s.Environment) + populate(objectMap, "resource", s.Resource) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretStoreResourceUpdateProperties. +func (s *SecretStoreResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &s.Application) + delete(rawMsg, key) + case "data": + err = unpopulate(val, "Data", &s.Data) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &s.Environment) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &s.Resource) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SecretValueProperties. func (s SecretValueProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2754,12 +3758,52 @@ func (t *TerraformRecipeProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TerraformRecipePropertiesUpdate. +func (t TerraformRecipePropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "parameters", t.Parameters) + objectMap["templateKind"] = "terraform" + populate(objectMap, "templatePath", t.TemplatePath) + populate(objectMap, "templateVersion", t.TemplateVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TerraformRecipePropertiesUpdate. +func (t *TerraformRecipePropertiesUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "parameters": + err = unpopulate(val, "Parameters", &t.Parameters) + delete(rawMsg, key) + case "templateKind": + err = unpopulate(val, "TemplateKind", &t.TemplateKind) + delete(rawMsg, key) + case "templatePath": + err = unpopulate(val, "TemplatePath", &t.TemplatePath) + delete(rawMsg, key) + case "templateVersion": + err = unpopulate(val, "TemplateVersion", &t.TemplateVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) populate(objectMap, "tags", t.Tags) populate(objectMap, "type", t.Type) return json.Marshal(objectMap) @@ -2783,6 +3827,9 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &t.Name) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &t.Tags) delete(rawMsg, key) @@ -2953,16 +4000,16 @@ func (v *VolumeResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type VolumeResourceList. -func (v VolumeResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type VolumeResourceListResult. +func (v VolumeResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeResourceList. -func (v *VolumeResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeResourceListResult. +func (v *VolumeResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) @@ -2984,6 +4031,68 @@ func (v *VolumeResourceList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type VolumeResourceUpdate. +func (v VolumeResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeResourceUpdate. +func (v *VolumeResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &v.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeResourceUpdateProperties. +func (v VolumeResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", v.Application) + populate(objectMap, "environment", v.Environment) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeResourceUpdateProperties. +func (v *VolumeResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &v.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &v.Environment) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + func populate(m map[string]any, k string, v any) { if v == nil { return diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_operations_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_operations_client.go similarity index 75% rename from pkg/linkrp/api/v20220315privatepreview/zz_generated_operations_client.go rename to pkg/corerp/api/v20220315privatepreview/zz_generated_operations_client.go index 015d4b59bd..45332310ab 100644 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_operations_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_operations_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -12,8 +11,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,35 +19,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, -pl: pl, + internal: cl, } return client, nil } // NewListPager - List the operations for the provider +// // Generated from API version 2022-03-15-privatepreview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) (*runtime.Pager[OperationsClientListResponse]) { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -67,7 +56,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -81,8 +70,8 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Applications.Link/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + urlPath := "/providers/Applications.Core/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_options.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_options.go index ec32fcc126..fe4b6ee5df 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_options.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_options.go @@ -32,14 +32,23 @@ type ApplicationsClientUpdateOptions struct { // placeholder for future optional parameters } -// ContainersClientCreateOrUpdateOptions contains the optional parameters for the ContainersClient.CreateOrUpdate method. -type ContainersClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters +// ContainersClientBeginCreateOrUpdateOptions contains the optional parameters for the ContainersClient.BeginCreateOrUpdate +// method. +type ContainersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// ContainersClientDeleteOptions contains the optional parameters for the ContainersClient.Delete method. -type ContainersClientDeleteOptions struct { - // placeholder for future optional parameters +// ContainersClientBeginDeleteOptions contains the optional parameters for the ContainersClient.BeginDelete method. +type ContainersClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ContainersClientBeginUpdateOptions contains the optional parameters for the ContainersClient.BeginUpdate method. +type ContainersClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // ContainersClientGetOptions contains the optional parameters for the ContainersClient.Get method. @@ -52,11 +61,6 @@ type ContainersClientListByScopeOptions struct { // placeholder for future optional parameters } -// ContainersClientUpdateOptions contains the optional parameters for the ContainersClient.Update method. -type ContainersClientUpdateOptions struct { - // placeholder for future optional parameters -} - // EnvironmentsClientCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.CreateOrUpdate method. type EnvironmentsClientCreateOrUpdateOptions struct { // placeholder for future optional parameters @@ -67,14 +71,13 @@ type EnvironmentsClientDeleteOptions struct { // placeholder for future optional parameters } -// EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. -type EnvironmentsClientGetOptions struct { +// EnvironmentsClientGetMetadataOptions contains the optional parameters for the EnvironmentsClient.GetMetadata method. +type EnvironmentsClientGetMetadataOptions struct { // placeholder for future optional parameters } -// EnvironmentsClientGetRecipeMetadataOptions contains the optional parameters for the EnvironmentsClient.GetRecipeMetadata -// method. -type EnvironmentsClientGetRecipeMetadataOptions struct { +// EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. +type EnvironmentsClientGetOptions struct { // placeholder for future optional parameters } @@ -88,14 +91,23 @@ type EnvironmentsClientUpdateOptions struct { // placeholder for future optional parameters } -// ExtendersClientCreateOrUpdateOptions contains the optional parameters for the ExtendersClient.CreateOrUpdate method. -type ExtendersClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters +// ExtendersClientBeginCreateOrUpdateOptions contains the optional parameters for the ExtendersClient.BeginCreateOrUpdate +// method. +type ExtendersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// ExtendersClientDeleteOptions contains the optional parameters for the ExtendersClient.Delete method. -type ExtendersClientDeleteOptions struct { - // placeholder for future optional parameters +// ExtendersClientBeginDeleteOptions contains the optional parameters for the ExtendersClient.BeginDelete method. +type ExtendersClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ExtendersClientBeginUpdateOptions contains the optional parameters for the ExtendersClient.BeginUpdate method. +type ExtendersClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // ExtendersClientGetOptions contains the optional parameters for the ExtendersClient.Get method. @@ -103,9 +115,8 @@ type ExtendersClientGetOptions struct { // placeholder for future optional parameters } -// ExtendersClientListByRootScopeOptions contains the optional parameters for the ExtendersClient.NewListByRootScopePager -// method. -type ExtendersClientListByRootScopeOptions struct { +// ExtendersClientListByScopeOptions contains the optional parameters for the ExtendersClient.NewListByScopePager method. +type ExtendersClientListByScopeOptions struct { // placeholder for future optional parameters } @@ -114,14 +125,22 @@ type ExtendersClientListSecretsOptions struct { // placeholder for future optional parameters } -// GatewaysClientCreateOrUpdateOptions contains the optional parameters for the GatewaysClient.CreateOrUpdate method. -type GatewaysClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters +// GatewaysClientBeginCreateOptions contains the optional parameters for the GatewaysClient.BeginCreate method. +type GatewaysClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// GatewaysClientDeleteOptions contains the optional parameters for the GatewaysClient.Delete method. -type GatewaysClientDeleteOptions struct { - // placeholder for future optional parameters +// GatewaysClientBeginCreateOrUpdateOptions contains the optional parameters for the GatewaysClient.BeginCreateOrUpdate method. +type GatewaysClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GatewaysClientBeginDeleteOptions contains the optional parameters for the GatewaysClient.BeginDelete method. +type GatewaysClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // GatewaysClientGetOptions contains the optional parameters for the GatewaysClient.Get method. @@ -134,19 +153,23 @@ type GatewaysClientListByScopeOptions struct { // placeholder for future optional parameters } -// GatewaysClientUpdateOptions contains the optional parameters for the GatewaysClient.Update method. -type GatewaysClientUpdateOptions struct { - // placeholder for future optional parameters +// HTTPRoutesClientBeginCreateOrUpdateOptions contains the optional parameters for the HTTPRoutesClient.BeginCreateOrUpdate +// method. +type HTTPRoutesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// HTTPRoutesClientCreateOrUpdateOptions contains the optional parameters for the HTTPRoutesClient.CreateOrUpdate method. -type HTTPRoutesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters +// HTTPRoutesClientBeginDeleteOptions contains the optional parameters for the HTTPRoutesClient.BeginDelete method. +type HTTPRoutesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// HTTPRoutesClientDeleteOptions contains the optional parameters for the HTTPRoutesClient.Delete method. -type HTTPRoutesClientDeleteOptions struct { - // placeholder for future optional parameters +// HTTPRoutesClientBeginUpdateOptions contains the optional parameters for the HTTPRoutesClient.BeginUpdate method. +type HTTPRoutesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // HTTPRoutesClientGetOptions contains the optional parameters for the HTTPRoutesClient.Get method. @@ -159,19 +182,28 @@ type HTTPRoutesClientListByScopeOptions struct { // placeholder for future optional parameters } -// HTTPRoutesClientUpdateOptions contains the optional parameters for the HTTPRoutesClient.Update method. -type HTTPRoutesClientUpdateOptions struct { +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { // placeholder for future optional parameters } -// SecretStoresClientCreateOrUpdateOptions contains the optional parameters for the SecretStoresClient.CreateOrUpdate method. -type SecretStoresClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters +// SecretStoresClientBeginCreateOrUpdateOptions contains the optional parameters for the SecretStoresClient.BeginCreateOrUpdate +// method. +type SecretStoresClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// SecretStoresClientDeleteOptions contains the optional parameters for the SecretStoresClient.Delete method. -type SecretStoresClientDeleteOptions struct { - // placeholder for future optional parameters +// SecretStoresClientBeginDeleteOptions contains the optional parameters for the SecretStoresClient.BeginDelete method. +type SecretStoresClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SecretStoresClientBeginUpdateOptions contains the optional parameters for the SecretStoresClient.BeginUpdate method. +type SecretStoresClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // SecretStoresClientGetOptions contains the optional parameters for the SecretStoresClient.Get method. @@ -179,8 +211,8 @@ type SecretStoresClientGetOptions struct { // placeholder for future optional parameters } -// SecretStoresClientListOptions contains the optional parameters for the SecretStoresClient.NewListPager method. -type SecretStoresClientListOptions struct { +// SecretStoresClientListByScopeOptions contains the optional parameters for the SecretStoresClient.NewListByScopePager method. +type SecretStoresClientListByScopeOptions struct { // placeholder for future optional parameters } @@ -189,19 +221,22 @@ type SecretStoresClientListSecretsOptions struct { // placeholder for future optional parameters } -// SecretStoresClientUpdateOptions contains the optional parameters for the SecretStoresClient.Update method. -type SecretStoresClientUpdateOptions struct { - // placeholder for future optional parameters +// VolumesClientBeginCreateOrUpdateOptions contains the optional parameters for the VolumesClient.BeginCreateOrUpdate method. +type VolumesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// VolumesClientCreateOrUpdateOptions contains the optional parameters for the VolumesClient.CreateOrUpdate method. -type VolumesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters +// VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +type VolumesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } -// VolumesClientDeleteOptions contains the optional parameters for the VolumesClient.Delete method. -type VolumesClientDeleteOptions struct { - // placeholder for future optional parameters +// VolumesClientBeginUpdateOptions contains the optional parameters for the VolumesClient.BeginUpdate method. +type VolumesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. @@ -214,8 +249,3 @@ type VolumesClientListByScopeOptions struct { // placeholder for future optional parameters } -// VolumesClientUpdateOptions contains the optional parameters for the VolumesClient.Update method. -type VolumesClientUpdateOptions struct { - // placeholder for future optional parameters -} - diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go index 65aeef0538..748d969c67 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go @@ -9,7 +9,7 @@ package v20220315privatepreview import "encoding/json" -func unmarshalApplicationExtensionClassification(rawMsg json.RawMessage) (ApplicationExtensionClassification, error) { +func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (EnvironmentComputeClassification, error) { if rawMsg == nil { return nil, nil } @@ -17,14 +17,12 @@ func unmarshalApplicationExtensionClassification(rawMsg json.RawMessage) (Applic if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } - var b ApplicationExtensionClassification + var b EnvironmentComputeClassification switch m["kind"] { - case "kubernetesMetadata": - b = &ApplicationKubernetesMetadataExtension{} - case "kubernetesNamespace": - b = &ApplicationKubernetesNamespaceExtension{} + case "kubernetes": + b = &KubernetesCompute{} default: - b = &ApplicationExtension{} + b = &EnvironmentCompute{} } if err := json.Unmarshal(rawMsg, b); err != nil { return nil, err @@ -32,26 +30,28 @@ func unmarshalApplicationExtensionClassification(rawMsg json.RawMessage) (Applic return b, nil } -func unmarshalApplicationExtensionClassificationArray(rawMsg json.RawMessage) ([]ApplicationExtensionClassification, error) { +func unmarshalEnvironmentComputeUpdateClassification(rawMsg json.RawMessage) (EnvironmentComputeUpdateClassification, error) { if rawMsg == nil { return nil, nil } - var rawMessages []json.RawMessage - if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } - fArray := make([]ApplicationExtensionClassification, len(rawMessages)) - for index, rawMessage := range rawMessages { - f, err := unmarshalApplicationExtensionClassification(rawMessage) - if err != nil { - return nil, err - } - fArray[index] = f + var b EnvironmentComputeUpdateClassification + switch m["kind"] { + case "kubernetes": + b = &KubernetesComputeUpdate{} + default: + b = &EnvironmentComputeUpdate{} } - return fArray, nil + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } -func unmarshalContainerExtensionClassification(rawMsg json.RawMessage) (ContainerExtensionClassification, error) { +func unmarshalExtensionClassification(rawMsg json.RawMessage) (ExtensionClassification, error) { if rawMsg == nil { return nil, nil } @@ -59,16 +59,18 @@ func unmarshalContainerExtensionClassification(rawMsg json.RawMessage) (Containe if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } - var b ContainerExtensionClassification + var b ExtensionClassification switch m["kind"] { case "daprSidecar": b = &DaprSidecarExtension{} case "kubernetesMetadata": - b = &ContainerKubernetesMetadataExtension{} + b = &KubernetesMetadataExtension{} + case "kubernetesNamespace": + b = &KubernetesNamespaceExtension{} case "manualScaling": b = &ManualScalingExtension{} default: - b = &ContainerExtension{} + b = &Extension{} } if err := json.Unmarshal(rawMsg, b); err != nil { return nil, err @@ -76,7 +78,7 @@ func unmarshalContainerExtensionClassification(rawMsg json.RawMessage) (Containe return b, nil } -func unmarshalContainerExtensionClassificationArray(rawMsg json.RawMessage) ([]ContainerExtensionClassification, error) { +func unmarshalExtensionClassificationArray(rawMsg json.RawMessage) ([]ExtensionClassification, error) { if rawMsg == nil { return nil, nil } @@ -84,9 +86,9 @@ func unmarshalContainerExtensionClassificationArray(rawMsg json.RawMessage) ([]C if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { return nil, err } - fArray := make([]ContainerExtensionClassification, len(rawMessages)) + fArray := make([]ExtensionClassification, len(rawMessages)) for index, rawMessage := range rawMessages { - f, err := unmarshalContainerExtensionClassification(rawMessage) + f, err := unmarshalExtensionClassification(rawMessage) if err != nil { return nil, err } @@ -95,7 +97,7 @@ func unmarshalContainerExtensionClassificationArray(rawMsg json.RawMessage) ([]C return fArray, nil } -func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (EnvironmentComputeClassification, error) { +func unmarshalHealthProbePropertiesClassification(rawMsg json.RawMessage) (HealthProbePropertiesClassification, error) { if rawMsg == nil { return nil, nil } @@ -103,12 +105,16 @@ func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (Environm if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } - var b EnvironmentComputeClassification + var b HealthProbePropertiesClassification switch m["kind"] { - case "kubernetes": - b = &KubernetesCompute{} + case "exec": + b = &ExecHealthProbeProperties{} + case "httpGet": + b = &HTTPGetHealthProbeProperties{} + case "tcp": + b = &TCPHealthProbeProperties{} default: - b = &EnvironmentCompute{} + b = &HealthProbeProperties{} } if err := json.Unmarshal(rawMsg, b); err != nil { return nil, err @@ -116,7 +122,7 @@ func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (Environm return b, nil } -func unmarshalEnvironmentExtensionClassification(rawMsg json.RawMessage) (EnvironmentExtensionClassification, error) { +func unmarshalRecipePropertiesClassification(rawMsg json.RawMessage) (RecipePropertiesClassification, error) { if rawMsg == nil { return nil, nil } @@ -124,12 +130,14 @@ func unmarshalEnvironmentExtensionClassification(rawMsg json.RawMessage) (Enviro if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } - var b EnvironmentExtensionClassification - switch m["kind"] { - case "kubernetesMetadata": - b = &EnvironmentKubernetesMetadataExtension{} + var b RecipePropertiesClassification + switch m["templateKind"] { + case "bicep": + b = &BicepRecipeProperties{} + case "terraform": + b = &TerraformRecipeProperties{} default: - b = &EnvironmentExtension{} + b = &RecipeProperties{} } if err := json.Unmarshal(rawMsg, b); err != nil { return nil, err @@ -137,26 +145,26 @@ func unmarshalEnvironmentExtensionClassification(rawMsg json.RawMessage) (Enviro return b, nil } -func unmarshalEnvironmentExtensionClassificationArray(rawMsg json.RawMessage) ([]EnvironmentExtensionClassification, error) { +func unmarshalRecipePropertiesClassificationMap(rawMsg json.RawMessage) (map[string]RecipePropertiesClassification, error) { if rawMsg == nil { return nil, nil } - var rawMessages []json.RawMessage + var rawMessages map[string]json.RawMessage if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { return nil, err } - fArray := make([]EnvironmentExtensionClassification, len(rawMessages)) - for index, rawMessage := range rawMessages { - f, err := unmarshalEnvironmentExtensionClassification(rawMessage) + fMap := make(map[string]RecipePropertiesClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalRecipePropertiesClassification(rawMessage) if err != nil { return nil, err } - fArray[index] = f + fMap[key] = f } - return fArray, nil + return fMap, nil } -func unmarshalEnvironmentRecipePropertiesClassification(rawMsg json.RawMessage) (EnvironmentRecipePropertiesClassification, error) { +func unmarshalRecipePropertiesUpdateClassification(rawMsg json.RawMessage) (RecipePropertiesUpdateClassification, error) { if rawMsg == nil { return nil, nil } @@ -164,14 +172,14 @@ func unmarshalEnvironmentRecipePropertiesClassification(rawMsg json.RawMessage) if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } - var b EnvironmentRecipePropertiesClassification + var b RecipePropertiesUpdateClassification switch m["templateKind"] { case "bicep": - b = &BicepRecipeProperties{} + b = &BicepRecipePropertiesUpdate{} case "terraform": - b = &TerraformRecipeProperties{} + b = &TerraformRecipePropertiesUpdate{} default: - b = &EnvironmentRecipeProperties{} + b = &RecipePropertiesUpdate{} } if err := json.Unmarshal(rawMsg, b); err != nil { return nil, err @@ -179,7 +187,7 @@ func unmarshalEnvironmentRecipePropertiesClassification(rawMsg json.RawMessage) return b, nil } -func unmarshalEnvironmentRecipePropertiesClassificationMap(rawMsg json.RawMessage) (map[string]EnvironmentRecipePropertiesClassification, error) { +func unmarshalRecipePropertiesUpdateClassificationMap(rawMsg json.RawMessage) (map[string]RecipePropertiesUpdateClassification, error) { if rawMsg == nil { return nil, nil } @@ -187,9 +195,9 @@ func unmarshalEnvironmentRecipePropertiesClassificationMap(rawMsg json.RawMessag if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { return nil, err } - fMap := make(map[string]EnvironmentRecipePropertiesClassification, len(rawMessages)) + fMap := make(map[string]RecipePropertiesUpdateClassification, len(rawMessages)) for key, rawMessage := range rawMessages { - f, err := unmarshalEnvironmentRecipePropertiesClassification(rawMessage) + f, err := unmarshalRecipePropertiesUpdateClassification(rawMessage) if err != nil { return nil, err } @@ -198,31 +206,6 @@ func unmarshalEnvironmentRecipePropertiesClassificationMap(rawMsg json.RawMessag return fMap, nil } -func unmarshalHealthProbePropertiesClassification(rawMsg json.RawMessage) (HealthProbePropertiesClassification, error) { - if rawMsg == nil { - return nil, nil - } - var m map[string]any - if err := json.Unmarshal(rawMsg, &m); err != nil { - return nil, err - } - var b HealthProbePropertiesClassification - switch m["kind"] { - case "exec": - b = &ExecHealthProbeProperties{} - case "httpGet": - b = &HTTPGetHealthProbeProperties{} - case "tcp": - b = &TCPHealthProbeProperties{} - default: - b = &HealthProbeProperties{} - } - if err := json.Unmarshal(rawMsg, b); err != nil { - return nil, err - } - return b, nil -} - func unmarshalVolumeClassification(rawMsg json.RawMessage) (VolumeClassification, error) { if rawMsg == nil { return nil, nil diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_response_types.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_response_types.go index 366f1e4285..ed14cb1dc7 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_response_types.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_response_types.go @@ -9,7 +9,7 @@ package v20220315privatepreview // ApplicationsClientCreateOrUpdateResponse contains the response from method ApplicationsClient.CreateOrUpdate. type ApplicationsClientCreateOrUpdateResponse struct { - // Radius Application. + // Radius Application resource ApplicationResource } @@ -20,54 +20,54 @@ type ApplicationsClientDeleteResponse struct { // ApplicationsClientGetResponse contains the response from method ApplicationsClient.Get. type ApplicationsClientGetResponse struct { - // Radius Application. + // Radius Application resource ApplicationResource } // ApplicationsClientListByScopeResponse contains the response from method ApplicationsClient.NewListByScopePager. type ApplicationsClientListByScopeResponse struct { - // The list of applications. - ApplicationResourceList + // The response of a ApplicationResource list operation. + ApplicationResourceListResult } // ApplicationsClientUpdateResponse contains the response from method ApplicationsClient.Update. type ApplicationsClientUpdateResponse struct { - // Radius Application. + // Radius Application resource ApplicationResource } -// ContainersClientCreateOrUpdateResponse contains the response from method ContainersClient.CreateOrUpdate. +// ContainersClientCreateOrUpdateResponse contains the response from method ContainersClient.BeginCreateOrUpdate. type ContainersClientCreateOrUpdateResponse struct { - // Container + // Concrete tracked resource types can be created by aliasing this type using a specific property type. ContainerResource } -// ContainersClientDeleteResponse contains the response from method ContainersClient.Delete. +// ContainersClientDeleteResponse contains the response from method ContainersClient.BeginDelete. type ContainersClientDeleteResponse struct { // placeholder for future response values } // ContainersClientGetResponse contains the response from method ContainersClient.Get. type ContainersClientGetResponse struct { - // Container + // Concrete tracked resource types can be created by aliasing this type using a specific property type. ContainerResource } // ContainersClientListByScopeResponse contains the response from method ContainersClient.NewListByScopePager. type ContainersClientListByScopeResponse struct { - // The list of containers. - ContainerResourceList + // The response of a ContainerResource list operation. + ContainerResourceListResult } -// ContainersClientUpdateResponse contains the response from method ContainersClient.Update. +// ContainersClientUpdateResponse contains the response from method ContainersClient.BeginUpdate. type ContainersClientUpdateResponse struct { - // Container + // Concrete tracked resource types can be created by aliasing this type using a specific property type. ContainerResource } // EnvironmentsClientCreateOrUpdateResponse contains the response from method EnvironmentsClient.CreateOrUpdate. type EnvironmentsClientCreateOrUpdateResponse struct { - // Application environment. + // The environment resource EnvironmentResource } @@ -76,138 +76,150 @@ type EnvironmentsClientDeleteResponse struct { // placeholder for future response values } -// EnvironmentsClientGetRecipeMetadataResponse contains the response from method EnvironmentsClient.GetRecipeMetadata. -type EnvironmentsClientGetRecipeMetadataResponse struct { - // Properties of a Recipe linked to an Environment. - RecipeMetadataProperties +// EnvironmentsClientGetMetadataResponse contains the response from method EnvironmentsClient.GetMetadata. +type EnvironmentsClientGetMetadataResponse struct { + // The properties of a Recipe linked to an Environment. + RecipeGetMetadataResponse } // EnvironmentsClientGetResponse contains the response from method EnvironmentsClient.Get. type EnvironmentsClientGetResponse struct { - // Application environment. + // The environment resource EnvironmentResource } // EnvironmentsClientListByScopeResponse contains the response from method EnvironmentsClient.NewListByScopePager. type EnvironmentsClientListByScopeResponse struct { - // The list of environments. - EnvironmentResourceList + // The response of a EnvironmentResource list operation. + EnvironmentResourceListResult } // EnvironmentsClientUpdateResponse contains the response from method EnvironmentsClient.Update. type EnvironmentsClientUpdateResponse struct { - // Application environment. + // The environment resource EnvironmentResource } -// ExtendersClientCreateOrUpdateResponse contains the response from method ExtendersClient.CreateOrUpdate. +// ExtendersClientCreateOrUpdateResponse contains the response from method ExtendersClient.BeginCreateOrUpdate. type ExtendersClientCreateOrUpdateResponse struct { - // Extender portable resource. + // ExtenderResource portable resource ExtenderResource } -// ExtendersClientDeleteResponse contains the response from method ExtendersClient.Delete. +// ExtendersClientDeleteResponse contains the response from method ExtendersClient.BeginDelete. type ExtendersClientDeleteResponse struct { // placeholder for future response values } // ExtendersClientGetResponse contains the response from method ExtendersClient.Get. type ExtendersClientGetResponse struct { - // Extender portable resource. + // ExtenderResource portable resource ExtenderResource } -// ExtendersClientListByRootScopeResponse contains the response from method ExtendersClient.NewListByRootScopePager. -type ExtendersClientListByRootScopeResponse struct { - // Object that includes an array of Extender and a possible portable resource for next set. - ExtenderList +// ExtendersClientListByScopeResponse contains the response from method ExtendersClient.NewListByScopePager. +type ExtendersClientListByScopeResponse struct { + // The response of a ExtenderResource list operation. + ExtenderResourceListResult } // ExtendersClientListSecretsResponse contains the response from method ExtendersClient.ListSecrets. type ExtendersClientListSecretsResponse struct { - // The secret values for the given Extender portable resource. - Value map[string]any + // Any object + Object map[string]any } -// GatewaysClientCreateOrUpdateResponse contains the response from method GatewaysClient.CreateOrUpdate. +// ExtendersClientUpdateResponse contains the response from method ExtendersClient.BeginUpdate. +type ExtendersClientUpdateResponse struct { + // ExtenderResource portable resource + ExtenderResource +} + +// GatewaysClientCreateOrUpdateResponse contains the response from method GatewaysClient.BeginCreateOrUpdate. type GatewaysClientCreateOrUpdateResponse struct { - // Gateway Resource that specifies how traffic is exposed to the application. + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + GatewayResource +} + +// GatewaysClientCreateResponse contains the response from method GatewaysClient.BeginCreate. +type GatewaysClientCreateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. GatewayResource } -// GatewaysClientDeleteResponse contains the response from method GatewaysClient.Delete. +// GatewaysClientDeleteResponse contains the response from method GatewaysClient.BeginDelete. type GatewaysClientDeleteResponse struct { // placeholder for future response values } // GatewaysClientGetResponse contains the response from method GatewaysClient.Get. type GatewaysClientGetResponse struct { - // Gateway Resource that specifies how traffic is exposed to the application. + // Concrete tracked resource types can be created by aliasing this type using a specific property type. GatewayResource } // GatewaysClientListByScopeResponse contains the response from method GatewaysClient.NewListByScopePager. type GatewaysClientListByScopeResponse struct { - // The list of Gateways. - GatewayResourceList + // The response of a GatewayResource list operation. + GatewayResourceListResult } -// GatewaysClientUpdateResponse contains the response from method GatewaysClient.Update. -type GatewaysClientUpdateResponse struct { - // Gateway Resource that specifies how traffic is exposed to the application. - GatewayResource -} - -// HTTPRoutesClientCreateOrUpdateResponse contains the response from method HTTPRoutesClient.CreateOrUpdate. +// HTTPRoutesClientCreateOrUpdateResponse contains the response from method HTTPRoutesClient.BeginCreateOrUpdate. type HTTPRoutesClientCreateOrUpdateResponse struct { - // Radius HTTP Route Resource. + // Radius HTTPRoute Resource. HTTPRouteResource } -// HTTPRoutesClientDeleteResponse contains the response from method HTTPRoutesClient.Delete. +// HTTPRoutesClientDeleteResponse contains the response from method HTTPRoutesClient.BeginDelete. type HTTPRoutesClientDeleteResponse struct { // placeholder for future response values } // HTTPRoutesClientGetResponse contains the response from method HTTPRoutesClient.Get. type HTTPRoutesClientGetResponse struct { - // Radius HTTP Route Resource. + // Radius HTTPRoute Resource. HTTPRouteResource } // HTTPRoutesClientListByScopeResponse contains the response from method HTTPRoutesClient.NewListByScopePager. type HTTPRoutesClientListByScopeResponse struct { - // The list of HTTP Routes. - HTTPRouteResourceList + // The response of a HttpRouteResource list operation. + HTTPRouteResourceListResult } -// HTTPRoutesClientUpdateResponse contains the response from method HTTPRoutesClient.Update. +// HTTPRoutesClientUpdateResponse contains the response from method HTTPRoutesClient.BeginUpdate. type HTTPRoutesClientUpdateResponse struct { - // Radius HTTP Route Resource. + // Radius HTTPRoute Resource. HTTPRouteResource } -// SecretStoresClientCreateOrUpdateResponse contains the response from method SecretStoresClient.CreateOrUpdate. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// SecretStoresClientCreateOrUpdateResponse contains the response from method SecretStoresClient.BeginCreateOrUpdate. type SecretStoresClientCreateOrUpdateResponse struct { - // Radius SecretStore Resource. + // Concrete tracked resource types can be created by aliasing this type using a specific property type. SecretStoreResource } -// SecretStoresClientDeleteResponse contains the response from method SecretStoresClient.Delete. +// SecretStoresClientDeleteResponse contains the response from method SecretStoresClient.BeginDelete. type SecretStoresClientDeleteResponse struct { // placeholder for future response values } // SecretStoresClientGetResponse contains the response from method SecretStoresClient.Get. type SecretStoresClientGetResponse struct { - // Radius SecretStore Resource. + // Concrete tracked resource types can be created by aliasing this type using a specific property type. SecretStoreResource } -// SecretStoresClientListResponse contains the response from method SecretStoresClient.NewListPager. -type SecretStoresClientListResponse struct { - // The list of SecretStores. - SecretStoreResourceList +// SecretStoresClientListByScopeResponse contains the response from method SecretStoresClient.NewListByScopePager. +type SecretStoresClientListByScopeResponse struct { + // The response of a SecretStoreResource list operation. + SecretStoreResourceListResult } // SecretStoresClientListSecretsResponse contains the response from method SecretStoresClient.ListSecrets. @@ -216,38 +228,38 @@ type SecretStoresClientListSecretsResponse struct { SecretStoreListSecretsResult } -// SecretStoresClientUpdateResponse contains the response from method SecretStoresClient.Update. +// SecretStoresClientUpdateResponse contains the response from method SecretStoresClient.BeginUpdate. type SecretStoresClientUpdateResponse struct { - // Radius SecretStore Resource. + // Concrete tracked resource types can be created by aliasing this type using a specific property type. SecretStoreResource } -// VolumesClientCreateOrUpdateResponse contains the response from method VolumesClient.CreateOrUpdate. +// VolumesClientCreateOrUpdateResponse contains the response from method VolumesClient.BeginCreateOrUpdate. type VolumesClientCreateOrUpdateResponse struct { - // Radius Volume Resource. + // Radius Volume resource. VolumeResource } -// VolumesClientDeleteResponse contains the response from method VolumesClient.Delete. +// VolumesClientDeleteResponse contains the response from method VolumesClient.BeginDelete. type VolumesClientDeleteResponse struct { // placeholder for future response values } // VolumesClientGetResponse contains the response from method VolumesClient.Get. type VolumesClientGetResponse struct { - // Radius Volume Resource. + // Radius Volume resource. VolumeResource } // VolumesClientListByScopeResponse contains the response from method VolumesClient.NewListByScopePager. type VolumesClientListByScopeResponse struct { - // The list of Volumes. - VolumeResourceList + // The response of a VolumeResource list operation. + VolumeResourceListResult } -// VolumesClientUpdateResponse contains the response from method VolumesClient.Update. +// VolumesClientUpdateResponse contains the response from method VolumesClient.BeginUpdate. type VolumesClientUpdateResponse struct { - // Radius Volume Resource. + // Radius Volume resource. VolumeResource } diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_secretstores_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_secretstores_client.go index f26ec8333b..6131dcbcdc 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_secretstores_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_secretstores_client.go @@ -27,7 +27,9 @@ type SecretStoresClient struct { } // NewSecretStoresClient creates a new instance of SecretStoresClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSecretStoresClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecretStoresClient, error) { @@ -42,34 +44,52 @@ func NewSecretStoresClient(rootScope string, credential azcore.TokenCredential, return client, nil } -// CreateOrUpdate - Create or update a secret store. +// BeginCreateOrUpdate - Create a SecretStoreResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - secretStoreName - The name of the secret store. -// - secretStoreResource - SecretStore details -// - options - SecretStoresClientCreateOrUpdateOptions contains the optional parameters for the SecretStoresClient.CreateOrUpdate +// - secretStoreName - SecretStore name +// - resource - Resource create parameters. +// - options - SecretStoresClientBeginCreateOrUpdateOptions contains the optional parameters for the SecretStoresClient.BeginCreateOrUpdate // method. -func (client *SecretStoresClient) CreateOrUpdate(ctx context.Context, secretStoreName string, secretStoreResource SecretStoreResource, options *SecretStoresClientCreateOrUpdateOptions) (SecretStoresClientCreateOrUpdateResponse, error) { +func (client *SecretStoresClient) BeginCreateOrUpdate(ctx context.Context, secretStoreName string, resource SecretStoreResource, options *SecretStoresClientBeginCreateOrUpdateOptions) (*runtime.Poller[SecretStoresClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, secretStoreName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecretStoresClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SecretStoresClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a SecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *SecretStoresClient) createOrUpdate(ctx context.Context, secretStoreName string, resource SecretStoreResource, options *SecretStoresClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, secretStoreName, secretStoreResource, options) + req, err := client.createOrUpdateCreateRequest(ctx, secretStoreName, resource, options) if err != nil { - return SecretStoresClientCreateOrUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SecretStoresClientCreateOrUpdateResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return SecretStoresClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *SecretStoresClient) createOrUpdateCreateRequest(ctx context.Context, secretStoreName string, secretStoreResource SecretStoreResource, options *SecretStoresClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *SecretStoresClient) createOrUpdateCreateRequest(ctx context.Context, secretStoreName string, resource SecretStoreResource, options *SecretStoresClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if secretStoreName == "" { @@ -84,46 +104,57 @@ func (client *SecretStoresClient) createOrUpdateCreateRequest(ctx context.Contex reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, secretStoreResource); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *SecretStoresClient) createOrUpdateHandleResponse(resp *http.Response) (SecretStoresClientCreateOrUpdateResponse, error) { - result := SecretStoresClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SecretStoreResource); err != nil { - return SecretStoresClientCreateOrUpdateResponse{}, err +// BeginDelete - Delete a SecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - secretStoreName - SecretStore name +// - options - SecretStoresClientBeginDeleteOptions contains the optional parameters for the SecretStoresClient.BeginDelete +// method. +func (client *SecretStoresClient) BeginDelete(ctx context.Context, secretStoreName string, options *SecretStoresClientBeginDeleteOptions) (*runtime.Poller[SecretStoresClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, secretStoreName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecretStoresClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SecretStoresClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Delete a secret store. +// Delete - Delete a SecretStoreResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - secretStoreName - The name of the secret store. -// - options - SecretStoresClientDeleteOptions contains the optional parameters for the SecretStoresClient.Delete method. -func (client *SecretStoresClient) Delete(ctx context.Context, secretStoreName string, options *SecretStoresClientDeleteOptions) (SecretStoresClientDeleteResponse, error) { +func (client *SecretStoresClient) deleteOperation(ctx context.Context, secretStoreName string, options *SecretStoresClientBeginDeleteOptions) (*http.Response, error) { var err error req, err := client.deleteCreateRequest(ctx, secretStoreName, options) if err != nil { - return SecretStoresClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SecretStoresClientDeleteResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return SecretStoresClientDeleteResponse{}, err + return nil, err } - return SecretStoresClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *SecretStoresClient) deleteCreateRequest(ctx context.Context, secretStoreName string, options *SecretStoresClientDeleteOptions) (*policy.Request, error) { +func (client *SecretStoresClient) deleteCreateRequest(ctx context.Context, secretStoreName string, options *SecretStoresClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if secretStoreName == "" { @@ -141,11 +172,11 @@ func (client *SecretStoresClient) deleteCreateRequest(ctx context.Context, secre return req, nil } -// Get - Gets the properties of a secret store. +// Get - Get a SecretStoreResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - secretStoreName - The name of the secret store. +// - secretStoreName - SecretStore name // - options - SecretStoresClientGetOptions contains the optional parameters for the SecretStoresClient.Get method. func (client *SecretStoresClient) Get(ctx context.Context, secretStoreName string, options *SecretStoresClientGetOptions) (SecretStoresClientGetResponse, error) { var err error @@ -193,40 +224,41 @@ func (client *SecretStoresClient) getHandleResponse(resp *http.Response) (Secret return result, nil } -// NewListPager - List all secret stores in the given scope. +// NewListByScopePager - List SecretStoreResource resources by Scope // // Generated from API version 2022-03-15-privatepreview -// - options - SecretStoresClientListOptions contains the optional parameters for the SecretStoresClient.NewListPager method. -func (client *SecretStoresClient) NewListPager(options *SecretStoresClientListOptions) (*runtime.Pager[SecretStoresClientListResponse]) { - return runtime.NewPager(runtime.PagingHandler[SecretStoresClientListResponse]{ - More: func(page SecretStoresClientListResponse) bool { +// - options - SecretStoresClientListByScopeOptions contains the optional parameters for the SecretStoresClient.NewListByScopePager +// method. +func (client *SecretStoresClient) NewListByScopePager(options *SecretStoresClientListByScopeOptions) (*runtime.Pager[SecretStoresClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[SecretStoresClientListByScopeResponse]{ + More: func(page SecretStoresClientListByScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *SecretStoresClientListResponse) (SecretStoresClientListResponse, error) { + Fetcher: func(ctx context.Context, page *SecretStoresClientListByScopeResponse) (SecretStoresClientListByScopeResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listCreateRequest(ctx, options) + req, err = client.listByScopeCreateRequest(ctx, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return SecretStoresClientListResponse{}, err + return SecretStoresClientListByScopeResponse{}, err } resp, err := client.internal.Pipeline().Do(req) if err != nil { - return SecretStoresClientListResponse{}, err + return SecretStoresClientListByScopeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return SecretStoresClientListResponse{}, runtime.NewResponseError(resp) + return SecretStoresClientListByScopeResponse{}, runtime.NewResponseError(resp) } - return client.listHandleResponse(resp) + return client.listByScopeHandleResponse(resp) }, }) } -// listCreateRequest creates the List request. -func (client *SecretStoresClient) listCreateRequest(ctx context.Context, options *SecretStoresClientListOptions) (*policy.Request, error) { +// listByScopeCreateRequest creates the ListByScope request. +func (client *SecretStoresClient) listByScopeCreateRequest(ctx context.Context, options *SecretStoresClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/secretStores" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -240,11 +272,11 @@ func (client *SecretStoresClient) listCreateRequest(ctx context.Context, options return req, nil } -// listHandleResponse handles the List response. -func (client *SecretStoresClient) listHandleResponse(resp *http.Response) (SecretStoresClientListResponse, error) { - result := SecretStoresClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SecretStoreResourceList); err != nil { - return SecretStoresClientListResponse{}, err +// listByScopeHandleResponse handles the ListByScope response. +func (client *SecretStoresClient) listByScopeHandleResponse(resp *http.Response) (SecretStoresClientListByScopeResponse, error) { + result := SecretStoresClientListByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SecretStoreResourceListResult); err != nil { + return SecretStoresClientListByScopeResponse{}, err } return result, nil } @@ -253,12 +285,13 @@ func (client *SecretStoresClient) listHandleResponse(resp *http.Response) (Secre // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - secretStoreName - The name of the secret store. +// - secretStoreName - SecretStore name +// - body - The content of the action request // - options - SecretStoresClientListSecretsOptions contains the optional parameters for the SecretStoresClient.ListSecrets // method. -func (client *SecretStoresClient) ListSecrets(ctx context.Context, secretStoreName string, options *SecretStoresClientListSecretsOptions) (SecretStoresClientListSecretsResponse, error) { +func (client *SecretStoresClient) ListSecrets(ctx context.Context, secretStoreName string, body map[string]any, options *SecretStoresClientListSecretsOptions) (SecretStoresClientListSecretsResponse, error) { var err error - req, err := client.listSecretsCreateRequest(ctx, secretStoreName, options) + req, err := client.listSecretsCreateRequest(ctx, secretStoreName, body, options) if err != nil { return SecretStoresClientListSecretsResponse{}, err } @@ -275,7 +308,7 @@ func (client *SecretStoresClient) ListSecrets(ctx context.Context, secretStoreNa } // listSecretsCreateRequest creates the ListSecrets request. -func (client *SecretStoresClient) listSecretsCreateRequest(ctx context.Context, secretStoreName string, options *SecretStoresClientListSecretsOptions) (*policy.Request, error) { +func (client *SecretStoresClient) listSecretsCreateRequest(ctx context.Context, secretStoreName string, body map[string]any, options *SecretStoresClientListSecretsOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}/listSecrets" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if secretStoreName == "" { @@ -290,6 +323,9 @@ func (client *SecretStoresClient) listSecretsCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err +} return req, nil } @@ -302,33 +338,52 @@ func (client *SecretStoresClient) listSecretsHandleResponse(resp *http.Response) return result, nil } -// Update - Update the properties of an existing secret store. +// BeginUpdate - Update a SecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - secretStoreName - SecretStore name +// - properties - The resource properties to be updated. +// - options - SecretStoresClientBeginUpdateOptions contains the optional parameters for the SecretStoresClient.BeginUpdate +// method. +func (client *SecretStoresClient) BeginUpdate(ctx context.Context, secretStoreName string, properties SecretStoreResourceUpdate, options *SecretStoresClientBeginUpdateOptions) (*runtime.Poller[SecretStoresClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, secretStoreName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecretStoresClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SecretStoresClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a SecretStoreResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - secretStoreName - The name of the secret store. -// - secretStoreResource - SecretStore details -// - options - SecretStoresClientUpdateOptions contains the optional parameters for the SecretStoresClient.Update method. -func (client *SecretStoresClient) Update(ctx context.Context, secretStoreName string, secretStoreResource SecretStoreResource, options *SecretStoresClientUpdateOptions) (SecretStoresClientUpdateResponse, error) { +func (client *SecretStoresClient) update(ctx context.Context, secretStoreName string, properties SecretStoreResourceUpdate, options *SecretStoresClientBeginUpdateOptions) (*http.Response, error) { var err error - req, err := client.updateCreateRequest(ctx, secretStoreName, secretStoreResource, options) + req, err := client.updateCreateRequest(ctx, secretStoreName, properties, options) if err != nil { - return SecretStoresClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SecretStoresClientUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return SecretStoresClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *SecretStoresClient) updateCreateRequest(ctx context.Context, secretStoreName string, secretStoreResource SecretStoreResource, options *SecretStoresClientUpdateOptions) (*policy.Request, error) { +func (client *SecretStoresClient) updateCreateRequest(ctx context.Context, secretStoreName string, properties SecretStoreResourceUpdate, options *SecretStoresClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if secretStoreName == "" { @@ -343,18 +398,9 @@ func (client *SecretStoresClient) updateCreateRequest(ctx context.Context, secre reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, secretStoreResource); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil } -// updateHandleResponse handles the Update response. -func (client *SecretStoresClient) updateHandleResponse(resp *http.Response) (SecretStoresClientUpdateResponse, error) { - result := SecretStoresClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SecretStoreResource); err != nil { - return SecretStoresClientUpdateResponse{}, err - } - return result, nil -} - diff --git a/pkg/corerp/api/v20220315privatepreview/zz_generated_volumes_client.go b/pkg/corerp/api/v20220315privatepreview/zz_generated_volumes_client.go index 9d8a497c58..77c0c7ba68 100644 --- a/pkg/corerp/api/v20220315privatepreview/zz_generated_volumes_client.go +++ b/pkg/corerp/api/v20220315privatepreview/zz_generated_volumes_client.go @@ -27,7 +27,9 @@ type VolumesClient struct { } // NewVolumesClient creates a new instance of VolumesClient with the specified values. -// - rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID} +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVolumesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VolumesClient, error) { @@ -42,33 +44,52 @@ func NewVolumesClient(rootScope string, credential azcore.TokenCredential, optio return client, nil } -// CreateOrUpdate - Create or update an Volume. +// BeginCreateOrUpdate - Create a VolumeResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - volumeName - The name of the Volume. -// - volumeResource - Volume details -// - options - VolumesClientCreateOrUpdateOptions contains the optional parameters for the VolumesClient.CreateOrUpdate method. -func (client *VolumesClient) CreateOrUpdate(ctx context.Context, volumeName string, volumeResource VolumeResource, options *VolumesClientCreateOrUpdateOptions) (VolumesClientCreateOrUpdateResponse, error) { +// - volumeName - Volume name +// - resource - Resource create parameters. +// - options - VolumesClientBeginCreateOrUpdateOptions contains the optional parameters for the VolumesClient.BeginCreateOrUpdate +// method. +func (client *VolumesClient) BeginCreateOrUpdate(ctx context.Context, volumeName string, resource VolumeResource, options *VolumesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VolumesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, volumeName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a VolumeResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *VolumesClient) createOrUpdate(ctx context.Context, volumeName string, resource VolumeResource, options *VolumesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error - req, err := client.createOrUpdateCreateRequest(ctx, volumeName, volumeResource, options) + req, err := client.createOrUpdateCreateRequest(ctx, volumeName, resource, options) if err != nil { - return VolumesClientCreateOrUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return VolumesClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return VolumesClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VolumesClient) createOrUpdateCreateRequest(ctx context.Context, volumeName string, volumeResource VolumeResource, options *VolumesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *VolumesClient) createOrUpdateCreateRequest(ctx context.Context, volumeName string, resource VolumeResource, options *VolumesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/volumes/{volumeName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if volumeName == "" { @@ -83,46 +104,56 @@ func (client *VolumesClient) createOrUpdateCreateRequest(ctx context.Context, vo reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, volumeResource); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *VolumesClient) createOrUpdateHandleResponse(resp *http.Response) (VolumesClientCreateOrUpdateResponse, error) { - result := VolumesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VolumeResource); err != nil { - return VolumesClientCreateOrUpdateResponse{}, err +// BeginDelete - Delete a VolumeResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - volumeName - Volume name +// - options - VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +func (client *VolumesClient) BeginDelete(ctx context.Context, volumeName string, options *VolumesClientBeginDeleteOptions) (*runtime.Poller[VolumesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, volumeName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Delete an Volume. +// Delete - Delete a VolumeResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - volumeName - The name of the Volume. -// - options - VolumesClientDeleteOptions contains the optional parameters for the VolumesClient.Delete method. -func (client *VolumesClient) Delete(ctx context.Context, volumeName string, options *VolumesClientDeleteOptions) (VolumesClientDeleteResponse, error) { +func (client *VolumesClient) deleteOperation(ctx context.Context, volumeName string, options *VolumesClientBeginDeleteOptions) (*http.Response, error) { var err error req, err := client.deleteCreateRequest(ctx, volumeName, options) if err != nil { - return VolumesClientDeleteResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return VolumesClientDeleteResponse{}, err + return nil, err } if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { err = runtime.NewResponseError(httpResp) - return VolumesClientDeleteResponse{}, err + return nil, err } - return VolumesClientDeleteResponse{}, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *VolumesClient) deleteCreateRequest(ctx context.Context, volumeName string, options *VolumesClientDeleteOptions) (*policy.Request, error) { +func (client *VolumesClient) deleteCreateRequest(ctx context.Context, volumeName string, options *VolumesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/volumes/{volumeName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if volumeName == "" { @@ -140,11 +171,11 @@ func (client *VolumesClient) deleteCreateRequest(ctx context.Context, volumeName return req, nil } -// Get - Gets the properties of an Volume. +// Get - Get a VolumeResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - volumeName - The name of the Volume. +// - volumeName - Volume name // - options - VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. func (client *VolumesClient) Get(ctx context.Context, volumeName string, options *VolumesClientGetOptions) (VolumesClientGetResponse, error) { var err error @@ -192,7 +223,7 @@ func (client *VolumesClient) getHandleResponse(resp *http.Response) (VolumesClie return result, nil } -// NewListByScopePager - List all volumes in the given scope. +// NewListByScopePager - List VolumeResource resources by Scope // // Generated from API version 2022-03-15-privatepreview // - options - VolumesClientListByScopeOptions contains the optional parameters for the VolumesClient.NewListByScopePager method. @@ -242,39 +273,57 @@ func (client *VolumesClient) listByScopeCreateRequest(ctx context.Context, optio // listByScopeHandleResponse handles the ListByScope response. func (client *VolumesClient) listByScopeHandleResponse(resp *http.Response) (VolumesClientListByScopeResponse, error) { result := VolumesClientListByScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VolumeResourceList); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeResourceListResult); err != nil { return VolumesClientListByScopeResponse{}, err } return result, nil } -// Update - Update the properties of an existing Volume. +// BeginUpdate - Update a VolumeResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - volumeName - Volume name +// - properties - The resource properties to be updated. +// - options - VolumesClientBeginUpdateOptions contains the optional parameters for the VolumesClient.BeginUpdate method. +func (client *VolumesClient) BeginUpdate(ctx context.Context, volumeName string, properties VolumeResourceUpdate, options *VolumesClientBeginUpdateOptions) (*runtime.Poller[VolumesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, volumeName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VolumesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a VolumeResource // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2022-03-15-privatepreview -// - volumeName - The name of the Volume. -// - volumeResource - Volume details -// - options - VolumesClientUpdateOptions contains the optional parameters for the VolumesClient.Update method. -func (client *VolumesClient) Update(ctx context.Context, volumeName string, volumeResource VolumeResource, options *VolumesClientUpdateOptions) (VolumesClientUpdateResponse, error) { +func (client *VolumesClient) update(ctx context.Context, volumeName string, properties VolumeResourceUpdate, options *VolumesClientBeginUpdateOptions) (*http.Response, error) { var err error - req, err := client.updateCreateRequest(ctx, volumeName, volumeResource, options) + req, err := client.updateCreateRequest(ctx, volumeName, properties, options) if err != nil { - return VolumesClientUpdateResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return VolumesClientUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusNoContent) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return VolumesClientUpdateResponse{}, err + return nil, err } - resp, err := client.updateHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateCreateRequest creates the Update request. -func (client *VolumesClient) updateCreateRequest(ctx context.Context, volumeName string, volumeResource VolumeResource, options *VolumesClientUpdateOptions) (*policy.Request, error) { +func (client *VolumesClient) updateCreateRequest(ctx context.Context, volumeName string, properties VolumeResourceUpdate, options *VolumesClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Core/volumes/{volumeName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if volumeName == "" { @@ -289,18 +338,9 @@ func (client *VolumesClient) updateCreateRequest(ctx context.Context, volumeName reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, volumeResource); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil } -// updateHandleResponse handles the Update response. -func (client *VolumesClient) updateHandleResponse(resp *http.Response) (VolumesClientUpdateResponse, error) { - result := VolumesClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VolumeResource); err != nil { - return VolumesClientUpdateResponse{}, err - } - return result, nil -} - diff --git a/pkg/corerp/backend/controller/createorupdateresource.go b/pkg/corerp/backend/controller/createorupdateresource.go index b9c7bd133f..3ca8c6787b 100644 --- a/pkg/corerp/backend/controller/createorupdateresource.go +++ b/pkg/corerp/backend/controller/createorupdateresource.go @@ -23,16 +23,16 @@ import ( "net/http" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers/container" - "github.com/project-radius/radius/pkg/corerp/renderers/gateway" - "github.com/project-radius/radius/pkg/corerp/renderers/httproute" - "github.com/project-radius/radius/pkg/corerp/renderers/volume" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers/container" + "github.com/radius-project/radius/pkg/corerp/renderers/gateway" + "github.com/radius-project/radius/pkg/corerp/renderers/httproute" + "github.com/radius-project/radius/pkg/corerp/renderers/volume" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" ) var _ ctrl.Controller = (*CreateOrUpdateResource)(nil) diff --git a/pkg/corerp/backend/controller/createorupdateresource_test.go b/pkg/corerp/backend/controller/createorupdateresource_test.go index 7096da50b6..51107f2dde 100644 --- a/pkg/corerp/backend/controller/createorupdateresource_test.go +++ b/pkg/corerp/backend/controller/createorupdateresource_test.go @@ -27,16 +27,16 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - deployment "github.com/project-radius/radius/pkg/corerp/backend/deployment" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/corerp/renderers/container" - "github.com/project-radius/radius/pkg/corerp/renderers/gateway" - "github.com/project-radius/radius/pkg/corerp/renderers/httproute" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + deployment "github.com/radius-project/radius/pkg/corerp/backend/deployment" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/corerp/renderers/container" + "github.com/radius-project/radius/pkg/corerp/renderers/gateway" + "github.com/radius-project/radius/pkg/corerp/renderers/httproute" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" ) func TestCreateOrUpdateResourceRun_20220315PrivatePreview(t *testing.T) { @@ -150,9 +150,9 @@ func TestCreateOrUpdateResourceRun_20220315PrivatePreview(t *testing.T) { }, { "unsupported-type-put", - linkrp.RedisCachesResourceType, - "APPLICATIONS.LINK/REDISCACHES|PUT", - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/rc0", + portableresources.RedisCachesResourceType, + "APPLICATIONS.DATASTORES/REDISCACHES|PUT", + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/rc0", nil, true, nil, @@ -347,9 +347,9 @@ func TestCreateOrUpdateResourceRun_20220315PrivatePreview(t *testing.T) { }, { "unsupported-type-patch", - linkrp.RedisCachesResourceType, - "APPLICATIONS.LINK/REDISCACHES|PATCH", - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/rc0", + portableresources.RedisCachesResourceType, + "APPLICATIONS.DATASTORES/REDISCACHES|PATCH", + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/rc0", nil, true, nil, diff --git a/pkg/corerp/backend/controller/deleteresource.go b/pkg/corerp/backend/controller/deleteresource.go index 5ac28c1c48..de31e5c484 100644 --- a/pkg/corerp/backend/controller/deleteresource.go +++ b/pkg/corerp/backend/controller/deleteresource.go @@ -19,10 +19,10 @@ package controller import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" ) var _ ctrl.Controller = (*DeleteResource)(nil) diff --git a/pkg/corerp/backend/controller/deleteresource_test.go b/pkg/corerp/backend/controller/deleteresource_test.go index 11246cfcbb..03a9e87c35 100644 --- a/pkg/corerp/backend/controller/deleteresource_test.go +++ b/pkg/corerp/backend/controller/deleteresource_test.go @@ -24,9 +24,9 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - deployment "github.com/project-radius/radius/pkg/corerp/backend/deployment" - "github.com/project-radius/radius/pkg/ucp/store" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + deployment "github.com/radius-project/radius/pkg/corerp/backend/deployment" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/backend/deployment/deploymentprocessor.go b/pkg/corerp/backend/deployment/deploymentprocessor.go index 12cf223f5e..36e550feec 100644 --- a/pkg/corerp/backend/deployment/deploymentprocessor.go +++ b/pkg/corerp/backend/deployment/deploymentprocessor.go @@ -24,25 +24,23 @@ import ( "os" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/resourcemodel" - rp_util "github.com/project-radius/radius/pkg/rp/util" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - - corerp_dm "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/model" - "github.com/project-radius/radius/pkg/corerp/renderers" - - dapr_dm "github.com/project-radius/radius/pkg/daprrp/datamodel" - datastores_dm "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - link_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - msg_dm "github.com/project-radius/radius/pkg/messagingrp/datamodel" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rp_util "github.com/radius-project/radius/pkg/rp/util" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + + corerp_dm "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/model" + "github.com/radius-project/radius/pkg/corerp/renderers" + + dapr_dm "github.com/radius-project/radius/pkg/daprrp/datamodel" + datastores_dm "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + msg_dm "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/ucplog" "github.com/go-openapi/jsonpointer" corev1 "k8s.io/api/core/v1" @@ -50,7 +48,7 @@ import ( controller_runtime "sigs.k8s.io/controller-runtime/pkg/client" ) -//go:generate mockgen -destination=./mock_deploymentprocessor.go -package=deployment -self_package github.com/project-radius/radius/pkg/corerp/backend/deployment github.com/project-radius/radius/pkg/corerp/backend/deployment DeploymentProcessor +//go:generate mockgen -destination=./mock_deploymentprocessor.go -package=deployment -self_package github.com/radius-project/radius/pkg/corerp/backend/deployment github.com/radius-project/radius/pkg/corerp/backend/deployment DeploymentProcessor type DeploymentProcessor interface { Render(ctx context.Context, id resources.ID, resource v1.DataModelInterface) (renderers.RendererOutput, error) Deploy(ctx context.Context, id resources.ID, rendererOutput renderers.RendererOutput) (rpv1.DeploymentOutput, error) @@ -80,8 +78,8 @@ type ResourceData struct { OutputResources []rpv1.OutputResource ComputedValues map[string]any SecretValues map[string]rpv1.SecretValueReference - AppID *resources.ID // Application ID for which the resource is created - RecipeData linkrp.RecipeData // Relevant only for links created with recipes to find relevant connections created by that recipe + AppID *resources.ID // Application ID for which the resource is created + RecipeData portableresources.RecipeData // Relevant only for portable resources created with recipes to find relevant connections created by that recipe } // Render fetches the resource renderer, the application, environment and application options, and the dependencies of the @@ -149,11 +147,12 @@ func (dp *deploymentProcessor) Render(ctx context.Context, resourceID resources. // Check if the output resources have the corresponding provider supported in Radius for _, or := range rendererOutput.Resources { - if or.ResourceType.Provider == "" { + resourceType := or.GetResourceType() + if resourceType.Provider == "" { return renderers.RendererOutput{}, fmt.Errorf("output resource %q does not have a provider specified", or.LocalID) } - if !dp.appmodel.IsProviderSupported(or.ResourceType.Provider) { - return renderers.RendererOutput{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("provider %s is not configured. Cannot support resource type %s", or.ResourceType.Provider, or.ResourceType.Type)) + if !dp.appmodel.IsProviderSupported(resourceType.Provider) { + return renderers.RendererOutput{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("provider %s is not configured. Cannot support resource type %s", resourceType.Provider, resourceType.Type)) } } @@ -176,9 +175,10 @@ func (dp *deploymentProcessor) deployOutputResource(ctx context.Context, id reso logger := ucplog.FromContextOrDiscard(ctx) or := putOptions.Resource - logger.Info(fmt.Sprintf("Deploying output resource: LocalID: %s, resource type: %q\n", or.LocalID, or.ResourceType)) + resourceType := or.GetResourceType() + logger.Info(fmt.Sprintf("Deploying output resource: LocalID: %s, resource type: %q\n", or.LocalID, resourceType)) - outputResourceModel, err := dp.appmodel.LookupOutputResourceModel(or.ResourceType) + outputResourceModel, err := dp.appmodel.LookupOutputResourceModel(resourceType) if err != nil { return err } @@ -194,8 +194,8 @@ func (dp *deploymentProcessor) deployOutputResource(ctx context.Context, id reso return err } - if or.Identity.ResourceType == nil { - err = fmt.Errorf("output resource %q does not have an identity. This is a bug in the handler", or.LocalID) + if or.ID.IsEmpty() { + err = fmt.Errorf("output resource %q does not have an id. This is a bug in the handler", or.LocalID) return err } @@ -216,7 +216,7 @@ func (dp *deploymentProcessor) deployOutputResource(ctx context.Context, id reso return fmt.Errorf("failed to process JSON Pointer %q for resource: %w", v.JSONPointer, err) } - value, _, err := pointer.Get(or.Resource) + value, _, err := pointer.Get(or.CreateResource) if err != nil { return fmt.Errorf("failed to process JSON Pointer %q for resource: %w", v.JSONPointer, err) } @@ -250,26 +250,22 @@ func (dp *deploymentProcessor) Deploy(ctx context.Context, id resources.ID, rend deployedOutputResourceProperties := map[string]map[string]string{} for _, outputResource := range orderedOutputResources { - logger.Info(fmt.Sprintf("Deploying output resource: LocalID: %s, resource type: %q\n", outputResource.LocalID, outputResource.ResourceType)) + resourceType := outputResource.GetResourceType() + logger.Info(fmt.Sprintf("Deploying output resource: LocalID: %s, resource type: %q\n", outputResource.LocalID, resourceType)) err := dp.deployOutputResource(ctx, id, rendererOutput, computedValues, &handlers.PutOptions{Resource: &outputResource, DependencyProperties: deployedOutputResourceProperties}) if err != nil { return rpv1.DeploymentOutput{}, err } - if outputResource.Identity.ResourceType == nil { - return rpv1.DeploymentOutput{}, fmt.Errorf("output resource %q does not have an identity. This is a bug in the handler", outputResource.LocalID) + if outputResource.ID.IsEmpty() { + return rpv1.DeploymentOutput{}, fmt.Errorf("output resource %q does not have an id. This is a bug in the handler", outputResource.LocalID) } // Build database resource - copy updated properties to Resource field outputResource := rpv1.OutputResource{ - LocalID: outputResource.LocalID, - ResourceType: outputResource.ResourceType, - Identity: outputResource.Identity, - Status: rpv1.OutputResourceStatus{ - ProvisioningState: string(v1.ProvisioningStateProvisioned), - ProvisioningErrorDetails: "", - }, + LocalID: outputResource.LocalID, + ID: outputResource.ID, } deployedOutputResources = append(deployedOutputResources, outputResource) } @@ -304,12 +300,13 @@ func (dp *deploymentProcessor) Delete(ctx context.Context, id resources.ID, depl // Loop over each output resource and delete in reverse dependency order - resource deployed last should be deleted first for i := len(deployedOutputResources) - 1; i >= 0; i-- { outputResource := deployedOutputResources[i] - outputResourceModel, err := dp.appmodel.LookupOutputResourceModel(outputResource.ResourceType) + resourceType := outputResource.GetResourceType() + outputResourceModel, err := dp.appmodel.LookupOutputResourceModel(resourceType) if err != nil { return err } - logger.Info(fmt.Sprintf("Deleting output resource: LocalID: %s, resource type: %q\n", outputResource.LocalID, outputResource.ResourceType)) + logger.Info(fmt.Sprintf("Deleting output resource: LocalID: %s, resource type: %q\n", outputResource.LocalID, resourceType)) err = outputResourceModel.ResourceHandler.Delete(ctx, &handlers.DeleteOptions{Resource: &outputResource}) if err != nil { return err @@ -467,133 +464,85 @@ func (dp *deploymentProcessor) getResourceDataByID(ctx context.Context, resource if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, linkrp.RecipeData{}) + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) case strings.ToLower(corerp_dm.GatewayResourceType): obj := &corerp_dm.Gateway{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, linkrp.RecipeData{}) + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) case strings.ToLower(corerp_dm.VolumeResourceType): obj := &corerp_dm.VolumeResource{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, linkrp.RecipeData{}) + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) case strings.ToLower(corerp_dm.HTTPRouteResourceType): obj := &corerp_dm.HTTPRoute{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, linkrp.RecipeData{}) + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) case strings.ToLower(corerp_dm.SecretStoreResourceType): obj := &corerp_dm.SecretStore{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, linkrp.RecipeData{}) - case strings.ToLower(linkrp.MongoDatabasesResourceType): - obj := &link_dm.MongoDatabase{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.SqlDatabasesResourceType): - obj := &link_dm.SqlDatabase{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.RedisCachesResourceType): - obj := &link_dm.RedisCache{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.RabbitMQMessageQueuesResourceType): - obj := &link_dm.RabbitMQMessageQueue{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.ExtendersResourceType): - obj := &link_dm.Extender{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, linkrp.RecipeData{}) - case strings.ToLower(linkrp.DaprStateStoresResourceType): - obj := &link_dm.DaprStateStore{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.DaprSecretStoresResourceType): - obj := &link_dm.DaprSecretStore{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.DaprPubSubBrokersResourceType): - obj := &link_dm.DaprPubSubBroker{} - if err = resource.As(obj); err != nil { - return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) - } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.N_MongoDatabasesResourceType): + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) + case strings.ToLower(portableresources.MongoDatabasesResourceType): obj := &datastores_dm.MongoDatabase{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.N_SqlDatabasesResourceType): + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) + case strings.ToLower(portableresources.SqlDatabasesResourceType): obj := &datastores_dm.SqlDatabase{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.N_RedisCachesResourceType): + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) + case strings.ToLower(portableresources.RedisCachesResourceType): obj := &datastores_dm.RedisCache{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.N_RabbitMQQueuesResourceType): + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) + case strings.ToLower(portableresources.RabbitMQQueuesResourceType): obj := &msg_dm.RabbitMQQueue{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) case strings.ToLower(corerp_dm.ExtenderResourceType): obj := &corerp_dm.Extender{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, linkrp.RecipeData{}) - case strings.ToLower(linkrp.N_DaprStateStoresResourceType): + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) + case strings.ToLower(portableresources.DaprStateStoresResourceType): obj := &dapr_dm.DaprStateStore{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.N_DaprSecretStoresResourceType): + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) + case strings.ToLower(portableresources.DaprSecretStoresResourceType): obj := &dapr_dm.DaprSecretStore{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) - case strings.ToLower(linkrp.N_DaprPubSubBrokersResourceType): + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) + case strings.ToLower(portableresources.DaprPubSubBrokersResourceType): obj := &dapr_dm.DaprPubSubBroker{} if err = resource.As(obj); err != nil { return ResourceData{}, fmt.Errorf(errMsg, resourceID.String(), err) } - return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, obj.RecipeData) + return dp.buildResourceDependency(resourceID, obj.Properties.Application, obj, obj.Properties.Status.OutputResources, obj.ComputedValues, obj.SecretValues, portableresources.RecipeData{}) default: return ResourceData{}, fmt.Errorf("unsupported resource type: %q for resource ID: %q", resourceType, resourceID.String()) } } -func (dp *deploymentProcessor) buildResourceDependency(resourceID resources.ID, applicationID string, resource v1.DataModelInterface, outputResources []rpv1.OutputResource, computedValues map[string]any, secretValues map[string]rpv1.SecretValueReference, recipeData linkrp.RecipeData) (ResourceData, error) { +func (dp *deploymentProcessor) buildResourceDependency(resourceID resources.ID, applicationID string, resource v1.DataModelInterface, outputResources []rpv1.OutputResource, computedValues map[string]any, secretValues map[string]rpv1.SecretValueReference, recipeData portableresources.RecipeData) (ResourceData, error) { var appID *resources.ID if applicationID != "" { parsedID, err := resources.ParseResource(applicationID) @@ -601,8 +550,8 @@ func (dp *deploymentProcessor) buildResourceDependency(resourceID resources.ID, return ResourceData{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("application ID %q for the resource %q is not a valid id. Error: %s", applicationID, resourceID.String(), err.Error())) } appID = &parsedID - } else if strings.EqualFold(resourceID.ProviderNamespace(), resources.LinkRPNamespace) { - // Application id is optional for link resource types + } else if portableresources.IsValidPortableResourceType(resourceID.TypeSegments()[0].Type) { + // Application id is optional for portable resource types appID = nil } else { return ResourceData{}, fmt.Errorf("missing required application id for the resource %q", resourceID.String()) @@ -621,9 +570,9 @@ func (dp *deploymentProcessor) buildResourceDependency(resourceID resources.ID, func (dp *deploymentProcessor) getRendererDependency(ctx context.Context, dependency ResourceData) (renderers.RendererDependency, error) { // Get dependent resource identity - outputResourceIdentity := map[string]resourcemodel.ResourceIdentity{} + outputResourceIDs := map[string]resources.ID{} for _, outputResource := range dependency.OutputResources { - outputResourceIdentity[outputResource.LocalID] = outputResource.Identity + outputResourceIDs[outputResource.LocalID] = outputResource.ID } // Get dependent resource computedValues @@ -648,7 +597,7 @@ func (dp *deploymentProcessor) getRendererDependency(ctx context.Context, depend ResourceID: dependency.ID, Resource: dependency.Resource, ComputedValues: computedValues, - OutputResources: outputResourceIdentity, + OutputResources: outputResourceIDs, } return rendererDependency, nil diff --git a/pkg/corerp/backend/deployment/deploymentprocessor_test.go b/pkg/corerp/backend/deployment/deploymentprocessor_test.go index db29ee605a..15f34ee043 100644 --- a/pkg/corerp/backend/deployment/deploymentprocessor_test.go +++ b/pkg/corerp/backend/deployment/deploymentprocessor_test.go @@ -23,26 +23,27 @@ import ( "os" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/azure/azresources" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/model" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/corerp/renderers/container" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - linkrp_renderers "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testcontext" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/azure/clientv2" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/model" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/corerp/renderers/container" + dsrp_dm "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + pr_renderers "github.com/radius-project/radius/pkg/portableresources/renderers" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -73,28 +74,21 @@ func setup(t *testing.T) SharedMocks { []model.OutputResourceModel{ { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Deployment, + Type: model.AnyResourceType, Provider: resourcemodel.ProviderKubernetes, }, ResourceHandler: resourceHandler, }, { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Secret, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: resourceHandler, - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, + Type: resources_azure.ResourceTypeAuthorizationRoleAssignment, Provider: resourcemodel.ProviderAzure, }, }, { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Service, - Provider: resourcemodel.ProviderKubernetes, + Type: "Test.Namespace/testResources", + Provider: "test", }, ResourceHandler: resourceHandler, }, @@ -139,9 +133,11 @@ func getTestRendererOutput() renderers.RendererOutput { testOutputResources := []rpv1.OutputResource{ { LocalID: rpv1.LocalIDService, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Service, - Provider: resourcemodel.ProviderKubernetes, + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_kubernetes.ResourceTypeService, + Provider: resourcemodel.ProviderKubernetes, + }, }, }, } @@ -166,23 +162,23 @@ func getTestResourceID(id string) resources.ID { return resourceID } -func buildMongoDBLinkWithRecipe() linkrp_dm.MongoDatabase { - return linkrp_dm.MongoDatabase{ +func buildMongoDBWithRecipe() dsrp_dm.MongoDatabase { + return dsrp_dm.MongoDatabase{ BaseResource: v1.BaseResource{ TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Link/mongoDatabases/test-mongo", + ID: "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Datastores/mongoDatabases/test-mongo", }, }, - Properties: linkrp_dm.MongoDatabaseProperties{ + Properties: dsrp_dm.MongoDatabaseProperties{ BasicResourceProperties: rpv1.BasicResourceProperties{ Application: "/subscriptions/test-sub/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", Environment: "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/environments/env0", }, }, - LinkMetadata: linkrp_dm.LinkMetadata{ - RecipeData: linkrp.RecipeData{ - RecipeProperties: linkrp.RecipeProperties{ - LinkRecipe: linkrp.LinkRecipe{ + PortableResourceMetadata: pr_dm.PortableResourceMetadata{ + RecipeData: portableresources.RecipeData{ + RecipeProperties: portableresources.RecipeProperties{ + ResourceRecipe: portableresources.ResourceRecipe{ Name: "mongoDB", Parameters: map[string]any{ "ResourceGroup": "testRG", @@ -200,62 +196,45 @@ func buildMongoDBLinkWithRecipe() linkrp_dm.MongoDatabase { } func buildMongoDBResourceDataWithRecipeAndSecrets() ResourceData { - testResource := buildMongoDBLinkWithRecipe() + testResource := buildMongoDBWithRecipe() secretValues := map[string]rpv1.SecretValueReference{} - secretValues[linkrp_renderers.ConnectionStringValue] = rpv1.SecretValueReference{ + secretValues[pr_renderers.ConnectionStringValue] = rpv1.SecretValueReference{ Value: "test-connection-string", } computedValues := map[string]any{ - linkrp_renderers.DatabaseNameValue: "db", + pr_renderers.DatabaseNameValue: "db", } testResource.ComputedValues = computedValues testResource.SecretValues = secretValues - accountResourceType := resourcemodel.ResourceType{ - Type: resourcekinds.AzureCosmosAccount, - Provider: resourcemodel.ProviderAzure, - } dbResourceType := resourcemodel.ResourceType{ - Type: resourcekinds.AzureCosmosDBMongo, + Type: "Microsoft.DocumentDB/databaseAccounts/mongodbDatabases", Provider: resourcemodel.ProviderAzure, } outputResources := []rpv1.OutputResource{ { - LocalID: rpv1.LocalIDAzureCosmosAccount, - ResourceType: accountResourceType, - ProviderResourceType: azresources.DocumentDBDatabaseAccounts, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &accountResourceType, - Data: resourcemodel.ARMIdentity{ - ID: "/subscriptions/test-sub/resourceGroups/test-group/providers/Microsoft.DocumentDB/databaseAccounts/test-account", - APIVersion: clientv2.DocumentDBManagementClientAPIVersion, - }, - }, + LocalID: rpv1.LocalIDAzureCosmosAccount, + ID: resources.MustParse("/subscriptions/test-sub/resourceGroups/test-group/providers/Microsoft.DocumentDB/databaseAccounts/test-account"), RadiusManaged: to.Ptr(true), }, { - LocalID: rpv1.LocalIDAzureCosmosDBMongo, - ResourceType: dbResourceType, - ProviderResourceType: azresources.DocumentDBDatabaseAccounts + "/" + azresources.DocumentDBDatabaseAccountsMongoDBDatabases, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &dbResourceType, - Data: resourcemodel.ARMIdentity{ - ID: "/subscriptions/test-sub/resourceGroups/test-group/providers/Microsoft.DocumentDB/databaseAccounts/test-account/mongodbDatabases/test-database", - APIVersion: clientv2.DocumentDBManagementClientAPIVersion, - }, - }, - Resource: map[string]any{ - "properties": map[string]any{ - "resource": map[string]string{ - "id": "test-database", + LocalID: rpv1.LocalIDAzureCosmosDBMongo, + ID: resources.MustParse("/subscriptions/test-sub/resourceGroups/test-group/providers/Microsoft.DocumentDB/databaseAccounts/test-account/mongodbDatabases/test-database"), + CreateResource: &rpv1.Resource{ + ResourceType: dbResourceType, + Data: map[string]any{ + "properties": map[string]any{ + "resource": map[string]string{ + "id": "test-database", + }, }, }, + Dependencies: []string{rpv1.LocalIDAzureCosmosAccount}, }, RadiusManaged: to.Ptr(true), - Dependencies: []rpv1.Dependency{{LocalID: rpv1.LocalIDAzureCosmosAccount}}, }, } @@ -296,7 +275,7 @@ func Test_Render(t *testing.T) { resourceID := getTestResourceID(testResource.ID) depId1, _ := resources.ParseResource("/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/httpRoutes/A") - depId2, _ := resources.ParseResource("/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Link/mongoDatabases/test-mongo") + depId2, _ := resources.ParseResource("/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Datastores/mongoDatabases/test-mongo") requiredResources := []resources.ID{depId1, depId2} mocks.renderer.EXPECT().Render(gomock.Any(), gomock.Any(), gomock.Any()).Times(1).Return(testRendererOutput, nil) @@ -357,13 +336,13 @@ func Test_Render(t *testing.T) { mocks.db.EXPECT().Get(gomock.Any(), gomock.Any()).Times(1).Return(&nr, nil) - mongoResource := linkrp_dm.MongoDatabase{ + mongoResource := dsrp_dm.MongoDatabase{ BaseResource: v1.BaseResource{ TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Link/mongoDatabases/test-mongo", + ID: "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Datastores/mongoDatabases/test-mongo", }, }, - Properties: linkrp_dm.MongoDatabaseProperties{ + Properties: dsrp_dm.MongoDatabaseProperties{ BasicResourceProperties: rpv1.BasicResourceProperties{ Environment: "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/environments/env0", }, @@ -704,7 +683,7 @@ func Test_Render(t *testing.T) { testRendererOutput := getTestRendererOutput() resourceID := getTestResourceID(testResource.ID) - testRendererOutput.Resources[0].ResourceType.Provider = "" + testRendererOutput.Resources[0].CreateResource.ResourceType.Provider = "" depId1, _ := resources.ParseResource("/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/httpRoutes/A") requiredResources := []resources.ID{depId1} @@ -774,7 +753,7 @@ func Test_Render(t *testing.T) { testRendererOutput := getTestRendererOutput() resourceID := getTestResourceID(testResource.ID) - testRendererOutput.Resources[0].ResourceType.Provider = "unknown" + testRendererOutput.Resources[0].CreateResource.ResourceType.Provider = "unknown" depId1, _ := resources.ParseResource("/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/httpRoutes/A") requiredResources := []resources.ID{depId1} @@ -841,39 +820,33 @@ func Test_Render(t *testing.T) { } func Test_Deploy(t *testing.T) { - ctx := testcontext.New(t) - mocks := setup(t) - dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} - t.Run("Verify deploy success", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() testRendererOutput := getTestRendererOutput() resourceID := getTestResourceID(testResource.ID) kubeProp := map[string]string{ - handlers.KubernetesKindKey: resourcekinds.Service, + handlers.KubernetesKindKey: "Service", handlers.KubernetesAPIVersionKey: "v1", handlers.KubernetesNamespaceKey: "test-namespace", handlers.ResourceName: "test-deployment", } - expectedIdentity := resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.Service, - Provider: resourcemodel.ProviderKubernetes, - }, - Data: resourcemodel.KubernetesIdentity{ - Name: kubeProp[handlers.ResourceName], - Namespace: kubeProp[handlers.KubernetesNamespaceKey], - Kind: kubeProp[handlers.KubernetesKindKey], - APIVersion: kubeProp[handlers.ResourceName], - }, - } + expectedID := resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "", + kubeProp[handlers.KubernetesKindKey], + kubeProp[handlers.KubernetesNamespaceKey], + kubeProp[handlers.ResourceName]) mocks.resourceHandler. EXPECT(). Put(gomock.Any(), gomock.Any()).Times(1). DoAndReturn(func(ctx context.Context, options *handlers.PutOptions) (map[string]string, error) { - options.Resource.Identity = expectedIdentity + options.Resource.ID = expectedID return kubeProp, nil }) @@ -881,11 +854,15 @@ func Test_Deploy(t *testing.T) { require.NoError(t, err) require.Equal(t, len(testRendererOutput.Resources), len(deploymentOutput.DeployedOutputResources)) - require.NotEqual(t, resourcemodel.ResourceIdentity{}, deploymentOutput.DeployedOutputResources[0].Identity) + require.NotEqual(t, resources.ID{}, deploymentOutput.DeployedOutputResources[0].ID) require.Equal(t, map[string]any{"url": testRendererOutput.ComputedValues["url"].Value}, deploymentOutput.ComputedValues) }) t.Run("Verify deploy failure", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() testRendererOutput := getTestRendererOutput() resourceID := getTestResourceID(testResource.ID) @@ -897,13 +874,15 @@ func Test_Deploy(t *testing.T) { }) t.Run("Output resource dependency missing local ID", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() testRendererOutput := getTestRendererOutput() resourceID := getTestResourceID(testResource.ID) - testRendererOutput.Resources[0].Dependencies = []rpv1.Dependency{ - {LocalID: ""}, - } + testRendererOutput.Resources[0].CreateResource.Dependencies = []string{""} _, err := dp.Deploy(ctx, resourceID, testRendererOutput) @@ -911,18 +890,26 @@ func Test_Deploy(t *testing.T) { }) t.Run("Invalid output resource type", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() testRendererOutput := getTestRendererOutput() resourceID := getTestResourceID(testResource.ID) - testRendererOutput.Resources[0].ResourceType.Type = "foo" + testRendererOutput.Resources[0].CreateResource.ResourceType = resourcemodel.ResourceType{Provider: resourcemodel.ProviderAzure, Type: "foo"} _, err := dp.Deploy(ctx, resourceID, testRendererOutput) - require.ErrorContains(t, err, "output resource kind 'Provider: kubernetes, Type: foo' is unsupported") + require.ErrorContains(t, err, "output resource kind 'Provider: azure, Type: foo' is unsupported") }) t.Run("Missing output resource identity", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() testRendererOutput := getTestRendererOutput() resourceID := getTestResourceID(testResource.ID) @@ -931,23 +918,23 @@ func Test_Deploy(t *testing.T) { EXPECT(). Put(gomock.Any(), gomock.Any()).Times(1). DoAndReturn(func(ctx context.Context, options *handlers.PutOptions) (map[string]string, error) { - options.Resource.Identity = resourcemodel.ResourceIdentity{} + options.Resource.ID = resources.ID{} return map[string]string{}, nil }) _, err := dp.Deploy(ctx, resourceID, testRendererOutput) - require.ErrorContains(t, err, `output resource "Service" does not have an identity. This is a bug in the handler`) + require.ErrorContains(t, err, `output resource "Service" does not have an id. This is a bug in the handler`) }) } func Test_Delete(t *testing.T) { - ctx := testcontext.New(t) - - mocks := setup(t) - dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} t.Run("Verify delete success", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() resourceID := getTestResourceID(testResource.ID) @@ -958,6 +945,10 @@ func Test_Delete(t *testing.T) { }) t.Run("Verify delete failure", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() resourceID := getTestResourceID(testResource.ID) @@ -968,6 +959,10 @@ func Test_Delete(t *testing.T) { }) t.Run("Verify delete with no output resources", func(t *testing.T) { + ctx := testcontext.New(t) + mocks := setup(t) + dp := deploymentProcessor{mocks.model, mocks.dbProvider, nil, nil} + testResource := getTestResource() resourceID := getTestResourceID(testResource.ID) testResource.Properties.Status.OutputResources = []rpv1.OutputResource{} @@ -1046,8 +1041,9 @@ func Test_getResourceDataByID(t *testing.T) { t.Run("Get recipe data from connected mongoDB resources", func(t *testing.T) { mocks.dbProvider.EXPECT().GetStorageClient(gomock.Any(), gomock.Any()).Times(1).Return(mocks.db, nil) - depId, _ := resources.ParseResource("/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Link/mongoDatabases/test-mongo") - mongoResource := buildMongoDBLinkWithRecipe() + depId, _ := resources.ParseResource("/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Datastores/mongoDatabases/test-mongo") + mongoResource := buildMongoDBWithRecipe() + mongoResource.PortableResourceMetadata.RecipeData = portableresources.RecipeData{} mr := store.Object{ Metadata: store.Metadata{ ID: mongoResource.ID, @@ -1073,10 +1069,10 @@ func Test_fetchSecrets(t *testing.T) { mongoResource := buildMongoDBResourceDataWithRecipeAndSecrets() secret := "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255/db?ssl=true" - mongoResource.SecretValues[linkrp_renderers.ConnectionStringValue] = rpv1.SecretValueReference{Value: secret} + mongoResource.SecretValues[pr_renderers.ConnectionStringValue] = rpv1.SecretValueReference{Value: secret} secretValues, err := dp.FetchSecrets(ctx, mongoResource) require.NoError(t, err) require.Equal(t, 1, len(secretValues)) - require.Equal(t, secret, secretValues[linkrp_renderers.ConnectionStringValue]) + require.Equal(t, secret, secretValues[pr_renderers.ConnectionStringValue]) }) } diff --git a/pkg/corerp/backend/deployment/mock_deploymentprocessor.go b/pkg/corerp/backend/deployment/mock_deploymentprocessor.go index 66112b6ce0..81a7fc471a 100644 --- a/pkg/corerp/backend/deployment/mock_deploymentprocessor.go +++ b/pkg/corerp/backend/deployment/mock_deploymentprocessor.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/corerp/backend/deployment (interfaces: DeploymentProcessor) +// Source: github.com/radius-project/radius/pkg/corerp/backend/deployment (interfaces: DeploymentProcessor) // Package deployment is a generated GoMock package. package deployment @@ -9,10 +9,10 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - renderers "github.com/project-radius/radius/pkg/corerp/renderers" - v10 "github.com/project-radius/radius/pkg/rp/v1" - resources "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + renderers "github.com/radius-project/radius/pkg/corerp/renderers" + v10 "github.com/radius-project/radius/pkg/rp/v1" + resources "github.com/radius-project/radius/pkg/ucp/resources" ) // MockDeploymentProcessor is a mock of DeploymentProcessor interface. diff --git a/pkg/corerp/backend/deployment/testdata/containerresourcedatamodel.json b/pkg/corerp/backend/deployment/testdata/containerresourcedatamodel.json index 5e299411e6..1d96b85b8e 100644 --- a/pkg/corerp/backend/deployment/testdata/containerresourcedatamodel.json +++ b/pkg/corerp/backend/deployment/testdata/containerresourcedatamodel.json @@ -17,11 +17,7 @@ "status": { "outputResources": [ { - "LocalID": "Service", - "ResourceType": { - "Type": "Service", - "Provider": "kubernetes" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/corerp/backend/deployment/testdata/containerresourcedatamodellowercase.json b/pkg/corerp/backend/deployment/testdata/containerresourcedatamodellowercase.json index 98276b35b0..b2f9911782 100644 --- a/pkg/corerp/backend/deployment/testdata/containerresourcedatamodellowercase.json +++ b/pkg/corerp/backend/deployment/testdata/containerresourcedatamodellowercase.json @@ -1,60 +1,58 @@ { - "id": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/containers/test-resource", - "name": "test-resource", - "type": "applications.core/containers", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/containers/test-resource", + "name": "test-resource", + "type": "applications.core/containers", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "provisioningState": "Succeeded", + "application": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application", + "connections": { + "inventory": { + "source": "inventory_route_id", + "iam": { + "kind": "Http", + "roles": [ + "administrator" + ] + } + } }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Service", - "ResourceType": { - "Type": "Service", - "Provider": "kubernetes" - } - }] - }, - "provisioningState": "Succeeded", - "application": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application", - "connections": { - "inventory": { - "source": "inventory_route_id", - "iam": { - "kind": "Http", - "roles": [ - "administrator" - ] - } - } + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "livenessProbe": { + "kind": "tcp", + "tcp": { + "healthProbeBase": { + "failureThreshold": 5, + "initialDelaySeconds": 5, + "periodSeconds": 5 }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "livenessProbe": { - "kind": "tcp", - "tcp": { - "healthProbeBase": { - "failureThreshold": 5, - "initialDelaySeconds": 5, - "periodSeconds": 5 - }, - "containerPort": 8080 - } - }, - "ports": { - "web":{ - "containerPort": 5000, - "provides": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application/HttpRoute/B" - } - } + "containerPort": 8080 + } + }, + "ports": { + "web": { + "containerPort": 5000, + "provides": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application/HttpRoute/B" } + } } -} + } +} \ No newline at end of file diff --git a/pkg/corerp/backend/deployment/testdata/containerresourcedatamodeluppercase.json b/pkg/corerp/backend/deployment/testdata/containerresourcedatamodeluppercase.json index 0b9ed597f8..cb012548cb 100644 --- a/pkg/corerp/backend/deployment/testdata/containerresourcedatamodeluppercase.json +++ b/pkg/corerp/backend/deployment/testdata/containerresourcedatamodeluppercase.json @@ -1,60 +1,58 @@ { - "id": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/containers/test-resource", - "name": "test-resource", - "type": "APPLICATIONS.CORE/CONTAINERS", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/containers/test-resource", + "name": "test-resource", + "type": "APPLICATIONS.CORE/CONTAINERS", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "provisioningState": "Succeeded", + "application": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application", + "connections": { + "inventory": { + "source": "inventory_route_id", + "iam": { + "kind": "Http", + "roles": [ + "administrator" + ] + } + } }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Service", - "ResourceType": { - "Type": "Service", - "Provider": "kubernetes" - } - }] - }, - "provisioningState": "Succeeded", - "application": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application", - "connections": { - "inventory": { - "source": "inventory_route_id", - "iam": { - "kind": "Http", - "roles": [ - "administrator" - ] - } - } + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "livenessProbe": { + "kind": "tcp", + "tcp": { + "healthProbeBase": { + "failureThreshold": 5, + "initialDelaySeconds": 5, + "periodSeconds": 5 }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "livenessProbe": { - "kind": "tcp", - "tcp": { - "healthProbeBase": { - "failureThreshold": 5, - "initialDelaySeconds": 5, - "periodSeconds": 5 - }, - "containerPort": 8080 - } - }, - "ports": { - "web":{ - "containerPort": 5000, - "provides": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application/HttpRoute/B" - } - } + "containerPort": 8080 + } + }, + "ports": { + "web": { + "containerPort": 5000, + "provides": "/subscriptions/test-subscription/resourceGroups/test-resource-group/providers/Applications.Core/applications/test-application/HttpRoute/B" } + } } -} + } +} \ No newline at end of file diff --git a/pkg/corerp/backend/service.go b/pkg/corerp/backend/service.go deleted file mode 100644 index df466eba62..0000000000 --- a/pkg/corerp/backend/service.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package backend - -import ( - "context" - "fmt" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/worker" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - backend_ctrl "github.com/project-radius/radius/pkg/corerp/backend/controller" - "github.com/project-radius/radius/pkg/corerp/backend/deployment" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/model" - "github.com/project-radius/radius/pkg/corerp/processors/extenders" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_backend_ctrl "github.com/project-radius/radius/pkg/linkrp/backend/controller" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/configloader" - "github.com/project-radius/radius/pkg/recipes/driver" - "github.com/project-radius/radius/pkg/recipes/engine" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/sdk/clients" - "github.com/project-radius/radius/pkg/ucp/secret/provider" - "k8s.io/client-go/discovery" -) - -const ( - providerName = "Applications.Core" -) - -var ( - // ResourceTypeNames is the array that holds resource types that needs async processing. - // We use this array to generate generic backend controller for each resource. - ResourceTypeNames = []string{ - "Applications.Core/containers", - "Applications.Core/gateways", - "Applications.Core/httpRoutes", - "Applications.Core/volumes", - } -) - -// Service is a service to run AsyncReqeustProcessWorker. -type Service struct { - worker.Service -} - -// NewService creates a new Service instance to run AsyncReqeustProcessWorker. -func NewService(options hostoptions.HostOptions) *Service { - return &Service{ - worker.Service{ - ProviderName: providerName, - Options: options, - }, - } -} - -// Name returns a string containing the service name. -func (w *Service) Name() string { - return fmt.Sprintf("%s async worker", providerName) -} - -// Run initializes the application model, registers controllers for different resource types, and starts the worker with -// the given options. -func (w *Service) Run(ctx context.Context) error { - if err := w.Init(ctx); err != nil { - return err - } - - coreAppModel, err := model.NewApplicationModel(w.Options.Arm, w.KubeClient, w.KubeClientSet) - if err != nil { - return fmt.Errorf("failed to initialize application model: %w", err) - } - - opts := ctrl.Options{ - DataProvider: w.StorageProvider, - KubeClient: w.KubeClient, - GetDeploymentProcessor: func() deployment.DeploymentProcessor { - return deployment.NewDeploymentProcessor(coreAppModel, w.StorageProvider, w.KubeClient, w.KubeClientSet) - }, - } - - for _, rt := range ResourceTypeNames { - // Register controllers - err = w.Controllers.Register(ctx, rt, v1.OperationPut, backend_ctrl.NewCreateOrUpdateResource, opts) - if err != nil { - panic(err) - } - err = w.Controllers.Register(ctx, rt, v1.OperationPatch, backend_ctrl.NewCreateOrUpdateResource, opts) - if err != nil { - panic(err) - } - err = w.Controllers.Register(ctx, rt, v1.OperationDelete, backend_ctrl.NewDeleteResource, opts) - if err != nil { - panic(err) - } - } - - // Setup to run backend controller for extenders. - runtimeClient, err := kubeutil.NewRuntimeClient(w.Options.K8sConfig) - if err != nil { - return err - } - - discoveryClient, err := discovery.NewDiscoveryClientForConfig(w.Options.K8sConfig) - if err != nil { - return err - } - - // Use legacy discovery client to avoid the issue of the staled GroupVersion discovery(api.ucp.dev/v1alpha3). - // TODO: Disable UseLegacyDiscovery once https://github.com/project-radius/radius/issues/5974 is resolved. - discoveryClient.UseLegacyDiscovery = true - - client := processors.NewResourceClient(w.Options.Arm, w.Options.UCPConnection, runtimeClient, discoveryClient) - clientOptions := sdk.NewClientOptions(w.Options.UCPConnection) - - deploymentEngineClient, err := clients.NewResourceDeploymentsClient(&clients.Options{ - Cred: &aztoken.AnonymousCredential{}, - BaseURI: w.Options.UCPConnection.Endpoint(), - ARMClientOptions: sdk.NewClientOptions(w.Options.UCPConnection), - }) - if err != nil { - return err - } - - configLoader := configloader.NewEnvironmentLoader(clientOptions) - engine := engine.NewEngine(engine.Options{ - ConfigurationLoader: configLoader, - Drivers: map[string]driver.Driver{ - recipes.TemplateKindBicep: driver.NewBicepDriver(clientOptions, deploymentEngineClient, client), - recipes.TemplateKindTerraform: driver.NewTerraformDriver(w.Options.UCPConnection, provider.NewSecretProvider(w.Options.Config.SecretProvider), - driver.TerraformOptions{ - Path: w.Options.Config.Terraform.Path, - }, w.KubeClientSet), - }, - }) - - opts.GetDeploymentProcessor = nil - extenderCreateOrUpdateController := func(options ctrl.Options) (ctrl.Controller, error) { - processor := &extenders.Processor{} - return linkrp_backend_ctrl.NewCreateOrUpdateResource[*datamodel.Extender, datamodel.Extender](processor, engine, client, configLoader, options) - } - - // Register controllers to run backend processing for extenders. - err = w.Controllers.Register(ctx, linkrp.N_ExtendersResourceType, v1.OperationPut, extenderCreateOrUpdateController, opts) - if err != nil { - return err - } - err = w.Controllers.Register( - ctx, - linkrp.N_ExtendersResourceType, - v1.OperationDelete, - func(options ctrl.Options) (ctrl.Controller, error) { - return linkrp_backend_ctrl.NewDeleteResource(options, engine) - }, - opts) - if err != nil { - return err - } - - workerOpts := worker.Options{} - if w.Options.Config.WorkerServer != nil { - if w.Options.Config.WorkerServer.MaxOperationConcurrency != nil { - workerOpts.MaxOperationConcurrency = *w.Options.Config.WorkerServer.MaxOperationConcurrency - } - if w.Options.Config.WorkerServer.MaxOperationRetryCount != nil { - workerOpts.MaxOperationRetryCount = *w.Options.Config.WorkerServer.MaxOperationRetryCount - } - } - - return w.Start(ctx, workerOpts) -} diff --git a/pkg/corerp/backend/systemservice.go b/pkg/corerp/backend/systemservice.go deleted file mode 100644 index 1f07c3e0f1..0000000000 --- a/pkg/corerp/backend/systemservice.go +++ /dev/null @@ -1,86 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package backend - -import ( - "context" - "fmt" - "net" - "net/http" - - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "github.com/project-radius/radius/pkg/version" -) - -// SystemService represents the service which provides the basic health status and metric server. -type SystemService struct { - options hostoptions.HostOptions -} - -// NewSystemService creates a new SystemService instance with the given options. -func NewSystemService(options hostoptions.HostOptions) *SystemService { - return &SystemService{ - options: options, - } -} - -// Name returns the name of the system service. -func (s *SystemService) Name() string { - return "system service" -} - -// Run sets up an HTTP server to handle requests on the given port and handles shutdown based on the -// context. It returns an error if the server fails to start. -func (s *SystemService) Run(ctx context.Context) error { - logger := ucplog.FromContextOrDiscard(ctx) - - mux := http.NewServeMux() - mux.HandleFunc("/version", version.ReportVersionHandler) - mux.HandleFunc("/healthz", version.ReportVersionHandler) - - // TODO: Add prometheus metric later. - - address := fmt.Sprintf(":%d", *s.options.Config.WorkerServer.Port) - - server := &http.Server{ - Addr: address, - Handler: mux, - BaseContext: func(ln net.Listener) context.Context { - return ctx - }, - } - - // Handle shutdown based on the context - go func() { - <-ctx.Done() - // We don't care about shutdown errors - _ = server.Shutdown(ctx) - }() - - logger.Info(fmt.Sprintf("System service endpoint on: '%s'...", address)) - if err := server.ListenAndServe(); err == http.ErrServerClosed { - // We expect this, safe to ignore. - logger.Info("Server stopped...") - return nil - } else if err != nil { - return err - } - - logger.Info("Server stopped...") - return nil -} diff --git a/pkg/corerp/datamodel/application.go b/pkg/corerp/datamodel/application.go index 11aeadbd13..0eac1217ae 100644 --- a/pkg/corerp/datamodel/application.go +++ b/pkg/corerp/datamodel/application.go @@ -17,8 +17,8 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const ApplicationResourceType = "Applications.Core/applications" diff --git a/pkg/corerp/datamodel/container.go b/pkg/corerp/datamodel/container.go index baa4a89801..87fe8ec615 100644 --- a/pkg/corerp/datamodel/container.go +++ b/pkg/corerp/datamodel/container.go @@ -17,8 +17,8 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const ContainerResourceType = "Applications.Core/containers" @@ -28,7 +28,7 @@ type ContainerResource struct { v1.BaseResource // TODO: remove this from CoreRP - LinkMetadata + PortableResourceMetadata // Properties is the properties of the resource. Properties ContainerProperties `json:"properties"` @@ -75,6 +75,22 @@ type ContainerProperties struct { Container Container `json:"container,omitempty"` Extensions []Extension `json:"extensions,omitempty"` Identity *rpv1.IdentitySettings `json:"identity,omitempty"` + Runtimes *RuntimeProperties `json:"runtimes,omitempty"` +} + +// KubernetesRuntime represents the Kubernetes runtime configuration. +type KubernetesRuntime struct { + // Base represents the Kubernetes resource definition in the serialized YAML format + Base string `json:"base,omitempty"` + + // Pod represents the Kuberetes PodSpec strategic merge patch to be applied to the rendered PodSpec. This is stored as a JSON-encoded string. + Pod string `json:"pod,omitempty"` +} + +// RuntimeProperties represents the runtime configuration for the platform-specific functionalities. +type RuntimeProperties struct { + // Kubernetes represents the Kubernetes runtime configuration. + Kubernetes *KubernetesRuntime `json:"kubernetes,omitempty"` } // ConnectionProperties represents the properties of Connection. @@ -86,15 +102,16 @@ type ConnectionProperties struct { // Container - Definition of a container. type Container struct { - Image string `json:"image,omitempty"` - Env map[string]string `json:"env,omitempty"` - LivenessProbe HealthProbeProperties `json:"livenessProbe,omitempty"` - Ports map[string]ContainerPort `json:"ports,omitempty"` - ReadinessProbe HealthProbeProperties `json:"readinessProbe,omitempty"` - Volumes map[string]VolumeProperties `json:"volumes,omitempty"` - Command []string `json:"command,omitempty"` - Args []string `json:"args,omitempty"` - WorkingDir string `json:"workingDir,omitempty"` + Image string `json:"image,omitempty"` + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + Env map[string]string `json:"env,omitempty"` + LivenessProbe HealthProbeProperties `json:"livenessProbe,omitempty"` + Ports map[string]ContainerPort `json:"ports,omitempty"` + ReadinessProbe HealthProbeProperties `json:"readinessProbe,omitempty"` + Volumes map[string]VolumeProperties `json:"volumes,omitempty"` + Command []string `json:"command,omitempty"` + Args []string `json:"args,omitempty"` + WorkingDir string `json:"workingDir,omitempty"` } // ContainerPort - Specifies a listening port for the container diff --git a/pkg/corerp/datamodel/converter/application_converter.go b/pkg/corerp/datamodel/converter/application_converter.go index cf593a97f1..d55534c7f8 100644 --- a/pkg/corerp/datamodel/converter/application_converter.go +++ b/pkg/corerp/datamodel/converter/application_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // ApplicationDataModelToVersioned converts version agnostic application datamodel to versioned model. diff --git a/pkg/corerp/datamodel/converter/application_converter_test.go b/pkg/corerp/datamodel/converter/application_converter_test.go index 4644be2763..b884834868 100644 --- a/pkg/corerp/datamodel/converter/application_converter_test.go +++ b/pkg/corerp/datamodel/converter/application_converter_test.go @@ -20,9 +20,9 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/converter/container_converter.go b/pkg/corerp/datamodel/converter/container_converter.go index c2d9a0264e..42a5506966 100644 --- a/pkg/corerp/datamodel/converter/container_converter.go +++ b/pkg/corerp/datamodel/converter/container_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // ContainerDataModelToVersioned converts version agnostic Container datamodel to versioned model. diff --git a/pkg/corerp/datamodel/converter/container_converter_test.go b/pkg/corerp/datamodel/converter/container_converter_test.go index 014fbe75db..046c9dbaa1 100644 --- a/pkg/corerp/datamodel/converter/container_converter_test.go +++ b/pkg/corerp/datamodel/converter/container_converter_test.go @@ -20,9 +20,9 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/converter/environment_converter.go b/pkg/corerp/datamodel/converter/environment_converter.go index 6ee54d4c03..9858949ff4 100644 --- a/pkg/corerp/datamodel/converter/environment_converter.go +++ b/pkg/corerp/datamodel/converter/environment_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // EnvironmentDataModelToVersioned converts version agnostic environment datamodel to versioned model. diff --git a/pkg/corerp/datamodel/converter/environment_converter_test.go b/pkg/corerp/datamodel/converter/environment_converter_test.go index 96b6f46d28..dc9ceb76cb 100644 --- a/pkg/corerp/datamodel/converter/environment_converter_test.go +++ b/pkg/corerp/datamodel/converter/environment_converter_test.go @@ -21,9 +21,9 @@ import ( "os" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter.go b/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter.go index 48bf952318..6076e294d7 100644 --- a/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter.go +++ b/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter.go @@ -19,16 +19,16 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // EnvironmentRecipePropertiesDataModelToVersioned converts version agnostic environment recipe properties datamodel to versioned model. func EnvironmentRecipePropertiesDataModelToVersioned(model *datamodel.EnvironmentRecipeProperties, version string) (v1.VersionedModelInterface, error) { switch version { case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.RecipeMetadataProperties{} + versioned := &v20220315privatepreview.RecipeGetMetadataResponse{} if err := versioned.ConvertFrom(model); err != nil { return nil, err } @@ -43,7 +43,7 @@ func EnvironmentRecipePropertiesDataModelToVersioned(model *datamodel.Environmen func RecipeDataModelFromVersioned(content []byte, version string) (*datamodel.Recipe, error) { switch version { case v20220315privatepreview.Version: - am := &v20220315privatepreview.Recipe{} + am := &v20220315privatepreview.RecipeGetMetadata{} if err := json.Unmarshal(content, am); err != nil { return nil, err } diff --git a/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter_test.go b/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter_test.go index 4ea201d3f1..5178154a19 100644 --- a/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter_test.go +++ b/pkg/corerp/datamodel/converter/environmentrecipeproperties_converter_test.go @@ -20,9 +20,9 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) @@ -39,7 +39,7 @@ func TestEnvironmentRecipePropertiesDataModelToVersioned(t *testing.T) { { "../../api/v20220315privatepreview/testdata/environmentrecipepropertiesdatamodel.json", "2022-03-15-privatepreview", - &v20220315privatepreview.RecipeMetadataProperties{}, + &v20220315privatepreview.RecipeGetMetadataResponse{}, nil, }, // TODO: add new conversion tests. diff --git a/pkg/corerp/datamodel/converter/extender_converter.go b/pkg/corerp/datamodel/converter/extender_converter.go index e85a9b6c92..11904f44af 100644 --- a/pkg/corerp/datamodel/converter/extender_converter.go +++ b/pkg/corerp/datamodel/converter/extender_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // ExtenderDataModelToVersioned converts a datamodel.Extender to a versioned model interface based on the given version diff --git a/pkg/corerp/datamodel/converter/extender_converter_test.go b/pkg/corerp/datamodel/converter/extender_converter_test.go index ddb30057d3..45b02def98 100644 --- a/pkg/corerp/datamodel/converter/extender_converter_test.go +++ b/pkg/corerp/datamodel/converter/extender_converter_test.go @@ -21,9 +21,9 @@ import ( "errors" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/converter/gateway_converter.go b/pkg/corerp/datamodel/converter/gateway_converter.go index 208f5ada34..9e3d34c392 100644 --- a/pkg/corerp/datamodel/converter/gateway_converter.go +++ b/pkg/corerp/datamodel/converter/gateway_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // GatewayDataModelToVersioned converts version agnostic Gateway datamodel to versioned model. diff --git a/pkg/corerp/datamodel/converter/gateway_converter_test.go b/pkg/corerp/datamodel/converter/gateway_converter_test.go index 5abc0ab08c..b61b1602ca 100644 --- a/pkg/corerp/datamodel/converter/gateway_converter_test.go +++ b/pkg/corerp/datamodel/converter/gateway_converter_test.go @@ -20,9 +20,9 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/converter/httproute_converter.go b/pkg/corerp/datamodel/converter/httproute_converter.go index e2bf3e273a..e38d4ef8d8 100644 --- a/pkg/corerp/datamodel/converter/httproute_converter.go +++ b/pkg/corerp/datamodel/converter/httproute_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // HTTPRouteDataModelToVersioned converts version agnostic HTTPRoute datamodel to versioned model. diff --git a/pkg/corerp/datamodel/converter/httproute_converter_test.go b/pkg/corerp/datamodel/converter/httproute_converter_test.go index b4ace08f13..014b96cd79 100644 --- a/pkg/corerp/datamodel/converter/httproute_converter_test.go +++ b/pkg/corerp/datamodel/converter/httproute_converter_test.go @@ -20,9 +20,9 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/converter/secretstore_converter.go b/pkg/corerp/datamodel/converter/secretstore_converter.go index 7c3431236d..f51ed9a419 100644 --- a/pkg/corerp/datamodel/converter/secretstore_converter.go +++ b/pkg/corerp/datamodel/converter/secretstore_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // SecretStoreModelToVersioned converts version agnostic SecretStore datamodel to versioned model. diff --git a/pkg/corerp/datamodel/converter/secretstore_converter_test.go b/pkg/corerp/datamodel/converter/secretstore_converter_test.go index 9784e655a9..8d4fe5a53f 100644 --- a/pkg/corerp/datamodel/converter/secretstore_converter_test.go +++ b/pkg/corerp/datamodel/converter/secretstore_converter_test.go @@ -20,9 +20,9 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/converter/volume_converter.go b/pkg/corerp/datamodel/converter/volume_converter.go index 230b6fc2f4..19bc6e53cc 100644 --- a/pkg/corerp/datamodel/converter/volume_converter.go +++ b/pkg/corerp/datamodel/converter/volume_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // VolumeResourceModelToVersioned converts version agnostic Volume datamodel to versioned model. diff --git a/pkg/corerp/datamodel/converter/volume_converter_test.go b/pkg/corerp/datamodel/converter/volume_converter_test.go index ead05fc681..e0895dc04b 100644 --- a/pkg/corerp/datamodel/converter/volume_converter_test.go +++ b/pkg/corerp/datamodel/converter/volume_converter_test.go @@ -20,9 +20,9 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/datamodel/environment.go b/pkg/corerp/datamodel/environment.go index f05962f774..da36c496b4 100644 --- a/pkg/corerp/datamodel/environment.go +++ b/pkg/corerp/datamodel/environment.go @@ -17,8 +17,8 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const EnvironmentResourceType = "Applications.Core/environments" @@ -54,8 +54,8 @@ type EnvironmentRecipeProperties struct { // Recipe represents input properties for recipe getMetadata api. type Recipe struct { - // Type of the link this recipe can be consumed by. For example: 'Applications.Link/mongoDatabases' - LinkType string `json:"linkType,omitempty"` + // Type of the portable resource this recipe can be consumed by. For example: 'Applications.Datastores/mongoDatabases' + ResourceType string `json:"resourceType,omitempty"` // Name of the recipe registered to the environment. Name string `json:"recipeName,omitempty"` diff --git a/pkg/corerp/datamodel/extender.go b/pkg/corerp/datamodel/extender.go index bd443df4bf..a0780546a3 100644 --- a/pkg/corerp/datamodel/extender.go +++ b/pkg/corerp/datamodel/extender.go @@ -17,23 +17,23 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) -// ExtenderResourceType is the resource type for Extender link resources. +// ExtenderResourceType is the resource type for Extender portable resources. const ExtenderResourceType = "Applications.Core/extenders" -// Extender represents Extender link resource. +// Extender represents Extender portable resource. type Extender struct { v1.BaseResource // Properties is the properties of the resource. Properties ExtenderProperties `json:"properties"` - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata + // PortableResourceMetadata represents internal DataModel properties common to all portable resource types. + PortableResourceMetadata } // ApplyDeploymentOutput updates the Status of Properties of the Extender resource with the DeployedOutputResources and returns no error. @@ -57,10 +57,10 @@ func (extender *Extender) ResourceTypeName() string { return ExtenderResourceType } -// Recipe returns the LinkRecipe associated with the Extender if the ResourceProvisioning is not set to Manual, +// Recipe returns the ResourceRecipe associated with the Extender if the ResourceProvisioning is not set to Manual, // otherwise it returns nil. -func (extender *Extender) Recipe() *linkrp.LinkRecipe { - if extender.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (extender *Extender) Recipe() *portableresources.ResourceRecipe { + if extender.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &extender.Properties.ResourceRecipe @@ -74,7 +74,7 @@ type ExtenderProperties struct { // Secrets values provided for the resource Secrets map[string]any `json:"secrets,omitempty"` // The recipe used to automatically deploy underlying infrastructure for the Extender - ResourceRecipe linkrp.LinkRecipe `json:"recipe,omitempty"` + ResourceRecipe portableresources.ResourceRecipe `json:"recipe,omitempty"` // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` } diff --git a/pkg/corerp/datamodel/gateway.go b/pkg/corerp/datamodel/gateway.go index f6e15b9bc5..052cf17dae 100644 --- a/pkg/corerp/datamodel/gateway.go +++ b/pkg/corerp/datamodel/gateway.go @@ -17,8 +17,8 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const GatewayResourceType = "Applications.Core/gateways" @@ -28,7 +28,7 @@ type Gateway struct { v1.BaseResource // TODO: remove this from CoreRP - LinkMetadata + PortableResourceMetadata // Properties is the properties of the resource. Properties GatewayProperties `json:"properties"` } diff --git a/pkg/corerp/datamodel/httproute.go b/pkg/corerp/datamodel/httproute.go index b10a9d43f0..7cfa894b37 100644 --- a/pkg/corerp/datamodel/httproute.go +++ b/pkg/corerp/datamodel/httproute.go @@ -17,8 +17,8 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const HTTPRouteResourceType = "Applications.Core/httpRoutes" @@ -28,7 +28,7 @@ type HTTPRoute struct { v1.BaseResource // TODO: remove this from CoreRP - LinkMetadata + PortableResourceMetadata // Properties is the properties of the resource. Properties *HTTPRouteProperties `json:"properties"` } diff --git a/pkg/corerp/datamodel/linkmetadata.go b/pkg/corerp/datamodel/linkmetadata.go deleted file mode 100644 index 0c032eb281..0000000000 --- a/pkg/corerp/datamodel/linkmetadata.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// LinkMetadata represents internal DataModel properties common to all link types. -type LinkMetadata struct { - // TODO: stop using this type in CoreRP models. - - // ComputedValues map is any resource values that will be needed for more operations. - // For example; database name to generate secrets for cosmos DB. - ComputedValues map[string]any `json:"computedValues,omitempty"` - - // Stores action to retrieve secret values. For Azure, connectionstring is accessed through cosmos listConnectionString operation, if secrets are not provided as input - SecretValues map[string]rpv1.SecretValueReference `json:"secretValues,omitempty"` -} diff --git a/pkg/corerp/datamodel/portableresourcemetadata.go b/pkg/corerp/datamodel/portableresourcemetadata.go new file mode 100644 index 0000000000..e7bf3ffbee --- /dev/null +++ b/pkg/corerp/datamodel/portableresourcemetadata.go @@ -0,0 +1,33 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package datamodel + +import ( + rpv1 "github.com/radius-project/radius/pkg/rp/v1" +) + +// PortableResourceMetadata represents internal DataModel properties common to all portable resource types. +type PortableResourceMetadata struct { + // TODO: stop using this type in CoreRP models. + + // ComputedValues map is any resource values that will be needed for more operations. + // For example; database name to generate secrets for cosmos DB. + ComputedValues map[string]any `json:"computedValues,omitempty"` + + // Stores action to retrieve secret values. For Azure, connectionstring is accessed through cosmos listConnectionString operation, if secrets are not provided as input + SecretValues map[string]rpv1.SecretValueReference `json:"secretValues,omitempty"` +} diff --git a/pkg/corerp/datamodel/secretstore.go b/pkg/corerp/datamodel/secretstore.go index c5a8988fa7..5ec0993538 100644 --- a/pkg/corerp/datamodel/secretstore.go +++ b/pkg/corerp/datamodel/secretstore.go @@ -17,8 +17,8 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const SecretStoreResourceType = "Applications.Core/secretStores" @@ -52,7 +52,7 @@ type SecretStore struct { v1.BaseResource // TODO: remove this from CoreRP - LinkMetadata + PortableResourceMetadata // Properties is the properties of the resource. Properties *SecretStoreProperties `json:"properties"` } @@ -66,6 +66,8 @@ func (s *SecretStore) ResourceTypeName() string { // object and returns no error. func (s *SecretStore) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { s.Properties.Status.OutputResources = do.DeployedOutputResources + s.ComputedValues = do.ComputedValues + s.SecretValues = do.SecretValues return nil } diff --git a/pkg/corerp/datamodel/volume.go b/pkg/corerp/datamodel/volume.go index 8b1d4cf8d7..e7aee0521b 100644 --- a/pkg/corerp/datamodel/volume.go +++ b/pkg/corerp/datamodel/volume.go @@ -17,8 +17,8 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const VolumeResourceType = "Applications.Core/volumes" @@ -33,7 +33,7 @@ type VolumeResource struct { v1.BaseResource // TODO: remove this from CoreRP - LinkMetadata + PortableResourceMetadata // Properties is the properties of the resource. Properties VolumeResourceProperties `json:"properties"` diff --git a/pkg/corerp/frontend/controller/applications/updatefilter.go b/pkg/corerp/frontend/controller/applications/updatefilter.go index 6e596e546f..caf3db25fd 100644 --- a/pkg/corerp/frontend/controller/applications/updatefilter.go +++ b/pkg/corerp/frontend/controller/applications/updatefilter.go @@ -20,16 +20,16 @@ import ( "context" "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/frontend/controller/util" - "github.com/project-radius/radius/pkg/kubernetes" - rp_kube "github.com/project-radius/radius/pkg/rp/kube" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/frontend/controller/util" + "github.com/radius-project/radius/pkg/kubernetes" + rp_kube "github.com/radius-project/radius/pkg/rp/kube" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/ucplog" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -120,7 +120,7 @@ func CreateAppScopedNamespace(ctx context.Context, newResource, oldResource *dat KubernetesCompute: rpv1.KubernetesComputeProperties{Namespace: kubeNamespace}, } - // TODO: Move it to backend controller - https://github.com/project-radius/radius/issues/4742 + // TODO: Move it to backend controller - https://github.com/radius-project/radius/issues/4742 err = opt.KubeClient.Create(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: kubeNamespace}}) if apierrors.IsAlreadyExists(err) { logger.Info("Using existing namespace", "namespace", kubeNamespace) diff --git a/pkg/corerp/frontend/controller/applications/updatefilter_test.go b/pkg/corerp/frontend/controller/applications/updatefilter_test.go index 4ccb851cc7..d7318f6b3d 100644 --- a/pkg/corerp/frontend/controller/applications/updatefilter_test.go +++ b/pkg/corerp/frontend/controller/applications/updatefilter_test.go @@ -21,17 +21,17 @@ import ( "strings" "testing" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/k8sutil" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/k8sutil" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_datamodel.json b/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_datamodel.json index fee530dfc2..ee20dc9fd2 100644 --- a/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_datamodel.json +++ b/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_datamodel.json @@ -1,74 +1,63 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/containers/test-container-0", - "name": "test-container-0", - "type": "applications.core/containers", - "location": "West US", - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "test@microsoft.com", - "createdByType": "Test", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "test@microsoft.com", - "lastModifiedByType": "Test" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/containers/test-container-0", + "name": "test-container-0", + "type": "applications.core/containers", + "location": "West US", + "tenantId": "00000000-0000-0000-0000-000000000000", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroup": "radius-test-rg", + "createdApiVersion": "2022-03-15-privatepreview", + "updatedApiVersion": "2022-03-15-privatepreview", + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "test@microsoft.com", + "createdByType": "Test", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "test@microsoft.com", + "lastModifiedByType": "Test" + }, + "provisioningState": "Updating", + "properties": { + "application": "test-application", + "connections": { + "test-connection": { + "source": "test", + "disableDefaultEnvVars": false, + "iam": { + "kind": "azure", + "roles": [ + "admin" + ] + } + } + }, + "container": { + "image": "test-image", + "env": { + "env-variable-0": "test-env-variable-0", + "env-variable-1": "test-env-variable-1" + }, + "livenessProbe": { + "kind": "tcp", + "tcp": { + "containerPort": 8080, + "initialDelaySeconds": 5 + } + }, + "ports": { + "default": { + "containerPort": 80, + "protocol": "http", + "provides": "/" + } + } }, - "provisioningState": "Updating", - "properties": { - "application": "test-application", - "connections": { - "test-connection": { - "source": "test", - "disableDefaultEnvVars": false, - "iam": { - "kind": "azure", - "roles": [ - "admin" - ] - } - } - }, - "container": { - "image": "test-image", - "env": { - "env-variable-0": "test-env-variable-0", - "env-variable-1": "test-env-variable-1" - }, - "livenessProbe": { - "kind": "tcp", - "tcp": { - "containerPort": 8080, - "initialDelaySeconds": 5 - } - }, - "ports": { - "default": { - "containerPort": 80, - "protocol": "http", - "provides": "/" - } - } - }, - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Provider": "azure", - "Type": "aks" - }, - "Identity": { - "data": null, - "resourceType": { - "Type": "aks", - "Provider": "azure" - } - } - } - ] + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] } + } } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_output.json b/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_output.json index c3ac91f02e..bc90e95068 100644 --- a/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_output.json +++ b/pkg/corerp/frontend/controller/containers/testdata/container20220315privatepreview_output.json @@ -1,64 +1,59 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/containers/test-container-0", - "name": "test-container-0", - "type": "applications.core/containers", - "location": "West US", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "test@microsoft.com", - "createdByType": "Test", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "test@microsoft.com", - "lastModifiedByType": "Test" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/containers/test-container-0", + "name": "test-container-0", + "type": "applications.core/containers", + "location": "West US", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroup": "radius-test-rg", + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "test@microsoft.com", + "createdByType": "Test", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "test@microsoft.com", + "lastModifiedByType": "Test" + }, + "tags": {}, + "properties": { + "application": "test-application", + "connections": { + "test-connection": { + "source": "test", + "disableDefaultEnvVars": false, + "iam": { + "kind": "azure", + "roles": [ + "admin" + ] + } + } + }, + "container": { + "image": "test-image", + "env": { + "env-variable-0": "test-env-variable-0", + "env-variable-1": "test-env-variable-1" + }, + "ports": { + "default": { + "containerPort": 80, + "protocol": "http", + "provides": "/" + } + }, + "livenessProbe": { + "containerPort": 8080, + "initialDelaySeconds": 5, + "kind": "tcp" + } }, - "tags": {}, - "properties": { - "application": "test-application", - "connections": { - "test-connection": { - "source": "test", - "disableDefaultEnvVars": false, - "iam": { - "kind": "azure", - "roles": [ - "admin" - ] - } - } - }, - "container": { - "image": "test-image", - "env": { - "env-variable-0": "test-env-variable-0", - "env-variable-1": "test-env-variable-1" - }, - "ports": { - "default": { - "containerPort": 80, - "protocol": "http", - "provides": "/" - } - }, - "livenessProbe": { - "containerPort": 8080, - "initialDelaySeconds": 5, - "kind": "tcp" - } - }, - "provisioningState": "Updating", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "Provider": "azure", - "Identity": { - "apiVersion": "", - "id": "" - } - } - ] + "provisioningState": "Updating", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] } + } } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/containers/validator.go b/pkg/corerp/frontend/controller/containers/validator.go index 12d76950a6..00a75dfc40 100644 --- a/pkg/corerp/frontend/controller/containers/validator.go +++ b/pkg/corerp/frontend/controller/containers/validator.go @@ -18,10 +18,24 @@ package containers import ( "context" + "encoding/json" + "fmt" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/kubeutil" +) + +const ( + manifestTargetProperty = "$.properties.runtimes.kubernetes.base" + podTargetProperty = "$.properties.runtimes.kubernetes.pod" ) // ValidateAndMutateRequest checks if the newResource has a user-defined identity and if so, returns a bad request @@ -38,5 +52,161 @@ func ValidateAndMutateRequest(ctx context.Context, newResource, oldResource *dat newResource.Properties.Identity = oldResource.Properties.Identity } + runtimes := newResource.Properties.Runtimes + if runtimes != nil && runtimes.Kubernetes != nil { + if runtimes.Kubernetes.Base != "" { + err := validateBaseManifest([]byte(runtimes.Kubernetes.Base), newResource) + if err != nil { + return rest.NewBadRequestARMResponse(v1.ErrorResponse{Error: err.(v1.ErrorDetails)}), nil + } + } + + if runtimes.Kubernetes.Pod != "" { + err := validatePodSpec([]byte(runtimes.Kubernetes.Pod)) + if err != nil { + return rest.NewBadRequestARMResponse(v1.ErrorResponse{Error: err.(v1.ErrorDetails)}), nil + } + } + } + return nil, nil } + +// validatePodSpec is doing only syntactic validation for PodSpec by deserialzing the given JSON patch +// to PodSpec object at this time. The semantic validation will be done when Radius applies the +// patched object to Kubernetes API server. +func validatePodSpec(patch []byte) error { + podSpec := &corev1.PodSpec{} + err := json.Unmarshal(patch, podSpec) + if err != nil { + return v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: podTargetProperty, + Message: fmt.Sprintf("Invalid PodSpec for patching: %s.", err.Error()), + } + } + return nil +} + +func errMultipleResources(typeName string, num int) v1.ErrorDetails { + return v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: fmt.Sprintf("only one %s is allowed, but the manifest includes %d resources.", typeName, num), + } +} + +func errUnmatchedName(obj runtime.Object, name string) v1.ErrorDetails { + meta := obj.(metav1.ObjectMetaAccessor) + typeName := obj.GetObjectKind().GroupVersionKind().Kind + resourceName := meta.GetObjectMeta().GetName() + + return v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: fmt.Sprintf("%s name %s in manifest does not match resource name %s.", typeName, resourceName, name), + } +} + +// validateBaseManifest deserializes the given YAML manifest and validates the allowed number of resources +// and ensures that the resource names of allowed resources match the name of the container resource. +// +// Allowed resource numbers in the manifest: +// - Deployment : 0-1 +// - Service : 0-1 +// - ServiceAccount : 0-1 +// - ConfigMap : 0-N +// - Secret : 0-N +func validateBaseManifest(manifest []byte, newResource *datamodel.ContainerResource) error { + errDetails := []v1.ErrorDetails{} + + resourceMap, err := kubeutil.ParseManifest(manifest) + if err != nil { + return v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: err.Error(), + } + } + + for k, resources := range resourceMap { + // Currently, it returns error immediately if namespaces in resources are set. We may need to override + // the namespace of the resources in the manifest. + for _, resource := range resources { + meta := resource.(metav1.ObjectMetaAccessor) + if meta.GetObjectMeta().GetNamespace() != "" { + errDetails = append(errDetails, v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: fmt.Sprintf("namespace is not allowed in resources: %s.", meta.GetObjectMeta().GetNamespace()), + }) + } + } + + switch k { + case appsv1.SchemeGroupVersion.WithKind("Deployment"): + if len(resources) != 1 { + errDetails = append(errDetails, errMultipleResources("Deployment", len(resources))) + } + deployment := resources[0].(*appsv1.Deployment) + if deployment.Name != newResource.Name { + errDetails = append(errDetails, errUnmatchedName(deployment, newResource.Name)) + } + + case corev1.SchemeGroupVersion.WithKind("Service"): + if len(resources) != 1 { + errDetails = append(errDetails, errMultipleResources("Service", len(resources))) + } + srv := resources[0].(*corev1.Service) + if srv.Name != newResource.Name { + errDetails = append(errDetails, errUnmatchedName(srv, newResource.Name)) + } + + case corev1.SchemeGroupVersion.WithKind("ServiceAccount"): + if len(resources) != 1 { + errDetails = append(errDetails, errMultipleResources("ServiceAccount", len(resources))) + } + sa := resources[0].(*corev1.ServiceAccount) + if sa.Name != newResource.Name { + errDetails = append(errDetails, errUnmatchedName(sa, newResource.Name)) + } + + deployment := resourceMap.GetFirst(appsv1.SchemeGroupVersion.WithKind("Deployment")) + if deployment == nil { + // skip if there is no deployment. + continue + } + + podSA := deployment.(*appsv1.Deployment).Spec.Template.Spec.ServiceAccountName + if podSA != sa.Name { + errDetails = append(errDetails, v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: fmt.Sprintf("ServiceAccount name %s in PodSpec does not match the name %s in ServiceAccount.", podSA, sa.Name), + }) + } + + // No limitations for ConfigMap and Secret resources. + case corev1.SchemeGroupVersion.WithKind("Secret"): + case corev1.SchemeGroupVersion.WithKind("ConfigMap"): + + default: + errDetails = append(errDetails, v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: fmt.Sprintf("%s is not supported.", k), + }) + } + } + + if len(errDetails) > 0 { + return v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: errDetails, + } + } + + return nil +} diff --git a/pkg/corerp/frontend/controller/containers/validator_test.go b/pkg/corerp/frontend/controller/containers/validator_test.go index 82534da6dc..f32a3d0cc7 100644 --- a/pkg/corerp/frontend/controller/containers/validator_test.go +++ b/pkg/corerp/frontend/controller/containers/validator_test.go @@ -18,15 +18,23 @@ package containers import ( "context" + "fmt" + "strings" "testing" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/require" ) func TestValidateAndMutateRequest_IdentityProperty(t *testing.T) { + fakeDeployment := fmt.Sprintf(k8sutil.FakeDeploymentTemplate, "magpie", "", "magpie") + fakeService := fmt.Sprintf(k8sutil.FakeServiceTemplate, "magpie", "") + fakeServiceAccount := fmt.Sprintf(k8sutil.FakeServiceAccountTemplate, "magpie") + requestTests := []struct { desc string newResource *datamodel.ContainerResource @@ -84,6 +92,88 @@ func TestValidateAndMutateRequest_IdentityProperty(t *testing.T) { }, resp: nil, }, + { + desc: "valid runtime.kubernetes.base", + newResource: &datamodel.ContainerResource{ + BaseResource: v1.BaseResource{ + TrackedResource: v1.TrackedResource{ + Name: "magpie", + }, + }, + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: strings.Join([]string{fakeDeployment, fakeService, fakeServiceAccount}, k8sutil.YAMLSeparater), + }, + }, + }, + }, + mutatedResource: &datamodel.ContainerResource{ + BaseResource: v1.BaseResource{ + TrackedResource: v1.TrackedResource{ + Name: "magpie", + }, + }, + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: strings.Join([]string{fakeDeployment, fakeService, fakeServiceAccount}, k8sutil.YAMLSeparater), + }, + }, + }, + }, + resp: nil, + }, + { + desc: "empty runtime.kubernetes.base", + newResource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: "", + }, + }, + }, + }, + mutatedResource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: "", + }, + }, + }, + }, + resp: nil, + }, + { + desc: "invalid runtime.kubernetes.base", + newResource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: "invalid", + }, + }, + }, + }, + mutatedResource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: "invalid", + }, + }, + }, + }, + resp: rest.NewBadRequestARMResponse(v1.ErrorResponse{ + Error: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: "$.properties.runtimes.kubernetes.base", + Message: "couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string \"json:\\\"apiVersion,omitempty\\\"\"; Kind string \"json:\\\"kind,omitempty\\\"\" }", + }, + }), + }, } for _, tc := range requestTests { @@ -100,3 +190,257 @@ func TestValidateAndMutateRequest_IdentityProperty(t *testing.T) { }) } } + +func TestValidateManifest(t *testing.T) { + fakeDeployment := fmt.Sprintf(k8sutil.FakeDeploymentTemplate, "magpie", "", "magpie") + fakeService := fmt.Sprintf(k8sutil.FakeServiceTemplate, "magpie", "") + fakeServiceAccount := fmt.Sprintf(k8sutil.FakeServiceAccountTemplate, "magpie") + fakeSecret := fmt.Sprintf(k8sutil.FakeSecretTemplate, "magpie") + fakeConfigMap := fmt.Sprintf(k8sutil.FakeSecretTemplate, "magpie") + fakeServiceWithNamespace := fmt.Sprintf(k8sutil.FakeServiceTemplate, "magpie", "namespace: app-scoped") + + validResource := &datamodel.ContainerResource{ + BaseResource: v1.BaseResource{ + TrackedResource: v1.TrackedResource{ + Name: "magpie", + }, + }, + Properties: datamodel.ContainerProperties{}, + } + + manifestTests := []struct { + name string + manifest string + resource *datamodel.ContainerResource + err error + }{ + { + name: "valid manifest with deployments/services/serviceaccounts", + manifest: strings.Join([]string{fakeDeployment, fakeService, fakeServiceAccount}, k8sutil.YAMLSeparater), + resource: validResource, + err: nil, + }, + { + name: "valid manifest with deployments/services/secrets/configmaps", + manifest: strings.Join([]string{fakeDeployment, fakeService, fakeSecret, fakeSecret}, k8sutil.YAMLSeparater), + resource: validResource, + err: nil, + }, + { + name: "valid manifest with multiple secrets and multiple configmaps", + manifest: strings.Join([]string{fakeDeployment, fakeService, fakeSecret, fakeSecret, fakeSecret, fakeConfigMap, fakeConfigMap}, k8sutil.YAMLSeparater), + resource: validResource, + err: nil, + }, + { + name: "invalid manifest with multiple deployments", + manifest: strings.Join([]string{fakeDeployment, fakeDeployment}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "only one Deployment is allowed, but the manifest includes 2 resources.", + }, + }, + }, + }, + { + name: "invalid manifest with multiple services", + manifest: strings.Join([]string{fakeDeployment, fakeService, fakeService}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "only one Service is allowed, but the manifest includes 2 resources.", + }, + }, + }, + }, + { + name: "invalid manifest with multiple serviceaccounts", + manifest: strings.Join([]string{fakeDeployment, fakeService, fakeServiceAccount, fakeServiceAccount}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "only one ServiceAccount is allowed, but the manifest includes 2 resources.", + }, + }, + }, + }, + { + name: "invalid manifest with resource including namespace", + manifest: strings.Join([]string{fakeDeployment, fakeServiceWithNamespace, fakeServiceAccount}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "namespace is not allowed in resources: app-scoped.", + }, + }, + }, + }, + { + name: "invalid manifest with unmatched deployment name", + manifest: strings.Join([]string{fmt.Sprintf(k8sutil.FakeDeploymentTemplate, "pie", "", "magpie"), fakeService, fakeServiceAccount}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "Deployment name pie in manifest does not match resource name magpie.", + }, + }, + }, + }, + { + name: "invalid manifest with unmatched service name", + manifest: strings.Join([]string{fakeDeployment, fmt.Sprintf(k8sutil.FakeServiceTemplate, "pie", ""), fakeServiceAccount}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "Service name pie in manifest does not match resource name magpie.", + }, + }, + }, + }, + { + name: "invalid manifest with unmatched serviceaccount name", + manifest: strings.Join([]string{fakeDeployment, fakeService, fmt.Sprintf(k8sutil.FakeServiceAccountTemplate, "pie")}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "ServiceAccount name pie in manifest does not match resource name magpie.", + }, + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "ServiceAccount name magpie in PodSpec does not match the name pie in ServiceAccount.", + }, + }, + }, + }, + { + name: "invalid manifest with multiple errors", + manifest: strings.Join([]string{fakeDeployment, fakeService, fakeService, fmt.Sprintf(k8sutil.FakeServiceAccountTemplate, "pie")}, k8sutil.YAMLSeparater), + resource: validResource, + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "The manifest includes invalid resources.", + Details: []v1.ErrorDetails{ + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "only one Service is allowed, but the manifest includes 2 resources.", + }, + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "ServiceAccount name pie in manifest does not match resource name magpie.", + }, + { + Code: v1.CodeInvalidRequestContent, + Target: manifestTargetProperty, + Message: "ServiceAccount name magpie in PodSpec does not match the name pie in ServiceAccount.", + }, + }, + }, + }, + } + + for _, tc := range manifestTests { + t.Run(tc.name, func(t *testing.T) { + err := validateBaseManifest([]byte(tc.manifest), tc.resource) + if tc.err != nil { + expected := tc.err.(v1.ErrorDetails) + actual := err.(v1.ErrorDetails) + require.Equal(t, expected.Code, actual.Code) + require.Equal(t, expected.Target, actual.Target) + require.Equal(t, expected.Message, actual.Message) + require.ElementsMatch(t, expected.Details, actual.Details) + } else { + require.NoError(t, err) + } + }) + } +} + +const patching = ` +{ + "containers": [ + { + "name": "test" + } + ], + "nodeName": "test" +} +` + +func TestValidatePodSpec(t *testing.T) { + patchTests := []struct { + name string + patchSpec string + err error + }{ + { + name: "valid patch PodSpec", + patchSpec: patching, + err: nil, + }, + { + name: "invalid patch PodSpec", + patchSpec: "invalid", + err: v1.ErrorDetails{ + Code: v1.CodeInvalidRequestContent, + Target: podTargetProperty, + Message: "Invalid PodSpec for patching: invalid character 'i' looking for beginning of value.", + }, + }, + } + + for _, tc := range patchTests { + t.Run(tc.name, func(t *testing.T) { + err := validatePodSpec([]byte(tc.patchSpec)) + if tc.err != nil { + require.Equal(t, tc.err, err) + } + }) + } +} diff --git a/pkg/corerp/frontend/controller/environments/createorupdateenvironment.go b/pkg/corerp/frontend/controller/environments/createorupdateenvironment.go index 4dc768c685..c011b2675d 100644 --- a/pkg/corerp/frontend/controller/environments/createorupdateenvironment.go +++ b/pkg/corerp/frontend/controller/environments/createorupdateenvironment.go @@ -21,12 +21,12 @@ import ( "fmt" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/datamodel/converter" - "github.com/project-radius/radius/pkg/corerp/frontend/controller/util" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/datamodel/converter" + "github.com/radius-project/radius/pkg/corerp/frontend/controller/util" ) var _ ctrl.Controller = (*CreateOrUpdateEnvironment)(nil) diff --git a/pkg/corerp/frontend/controller/environments/createorupdateenvironment_test.go b/pkg/corerp/frontend/controller/environments/createorupdateenvironment_test.go index befbf87945..869ea008b8 100644 --- a/pkg/corerp/frontend/controller/environments/createorupdateenvironment_test.go +++ b/pkg/corerp/frontend/controller/environments/createorupdateenvironment_test.go @@ -24,10 +24,10 @@ import ( "net/http/httptest" "testing" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/ucp/store" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/google/uuid" diff --git a/pkg/corerp/frontend/controller/environments/getrecipemetadata.go b/pkg/corerp/frontend/controller/environments/getrecipemetadata.go index 11412b93ff..dacf58a561 100644 --- a/pkg/corerp/frontend/controller/environments/getrecipemetadata.go +++ b/pkg/corerp/frontend/controller/environments/getrecipemetadata.go @@ -22,13 +22,14 @@ import ( "net/http" "sort" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/datamodel/converter" - linkrp "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/rp/util" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/datamodel/converter" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/engine" "golang.org/x/exp/maps" ) @@ -37,10 +38,11 @@ var _ ctrl.Controller = (*GetRecipeMetadata)(nil) // GetRecipeMetadata is the controller implementation to get recipe metadata such as parameters and the details of those parameters(type/minValue/etc.). type GetRecipeMetadata struct { ctrl.Operation[*datamodel.Environment, datamodel.Environment] + engine.Engine } // NewGetRecipeMetadata creates a new controller for retrieving recipe metadata from an environment. -func NewGetRecipeMetadata(opts ctrl.Options) (ctrl.Controller, error) { +func NewGetRecipeMetadata(opts ctrl.Options, engine engine.Engine) (ctrl.Controller, error) { return &GetRecipeMetadata{ ctrl.NewOperation(opts, ctrl.ResourceOptions[datamodel.Environment]{ @@ -48,6 +50,7 @@ func NewGetRecipeMetadata(opts ctrl.Options) (ctrl.Controller, error) { ResponseConverter: converter.EnvironmentDataModelToVersioned, }, ), + engine, }, nil } @@ -71,15 +74,15 @@ func (r *GetRecipeMetadata) Run(ctx context.Context, w http.ResponseWriter, req return nil, err } var recipeProperties datamodel.EnvironmentRecipeProperties - recipe, exists := resource.Properties.Recipes[recipeDatamodel.LinkType] + recipe, exists := resource.Properties.Recipes[recipeDatamodel.ResourceType] if exists { recipeProperties, exists = recipe[recipeDatamodel.Name] } if !exists { - return rest.NewNotFoundMessageResponse(fmt.Sprintf("Either recipe with name %q or resource type %q not found on environment with id %q", recipeDatamodel.Name, recipeDatamodel.LinkType, serviceCtx.ResourceID)), nil + return rest.NewNotFoundMessageResponse(fmt.Sprintf("Either recipe with name %q or resource type %q not found on environment with id %q", recipeDatamodel.Name, recipeDatamodel.ResourceType, serviceCtx.ResourceID)), nil } - recipeParams, err := getRecipeMetadataFromRegistry(ctx, recipeProperties.TemplatePath, recipeDatamodel.Name) + recipeParams, err := r.GetRecipeMetadataFromRegistry(ctx, recipeProperties, recipeDatamodel) if err != nil { return nil, err } @@ -98,10 +101,18 @@ func (r *GetRecipeMetadata) Run(ctx context.Context, w http.ResponseWriter, req return rest.NewOKResponse(versioned), nil } -func getRecipeMetadataFromRegistry(ctx context.Context, templatePath string, recipeName string) (recipeParameters map[string]any, err error) { +func (r *GetRecipeMetadata) GetRecipeMetadataFromRegistry(ctx context.Context, recipeProperties datamodel.EnvironmentRecipeProperties, recipeDataModel *datamodel.Recipe) (recipeParameters map[string]any, err error) { + recipeDefinition := recipes.EnvironmentDefinition{ + Name: recipeDataModel.Name, + Driver: recipeProperties.TemplateKind, + Parameters: recipeProperties.Parameters, + TemplatePath: recipeProperties.TemplatePath, + TemplateVersion: recipeProperties.TemplateVersion, + ResourceType: recipeDataModel.ResourceType, + } + recipeParameters = make(map[string]any) - recipeData := make(map[string]any) - err = util.ReadFromRegistry(ctx, templatePath, &recipeData) + recipeData, err := r.Engine.GetRecipeMetadata(ctx, recipeDefinition) if err != nil { return recipeParameters, err } @@ -115,24 +126,6 @@ func getRecipeMetadataFromRegistry(ctx context.Context, templatePath string, rec } func parseAndFormatRecipeParams(recipeData map[string]any, recipeParameters map[string]any) error { - // Recipe parameters can be found in the recipe data pulled from the registry in the following format: - // { - // "parameters": { - // : { - // : - // } - // } - // } - // For example: - // { - // "parameters": { - // "location": { - // "type": "string", - // "defaultValue" : "[resourceGroup().location]" - // } - // } - // } - if recipeData["parameters"] == nil { return nil } @@ -142,8 +135,8 @@ func parseAndFormatRecipeParams(recipeData map[string]any, recipeParameters map[ } for paramName, paramValue := range recipeParam { - if paramName == linkrp.RecipeContextParameter { - // context parameter is only revelant to operator and is generated and passed by linkrp instead of the developer/operators. + if paramName == pr_dm.RecipeContextParameter { + // context parameter is only revelant to operator and is generated and passed by resource provider instead of the developer/operators. continue } diff --git a/pkg/corerp/frontend/controller/environments/getrecipemetadata_test.go b/pkg/corerp/frontend/controller/environments/getrecipemetadata_test.go index cf32f0a6f9..ce1c3259e3 100644 --- a/pkg/corerp/frontend/controller/environments/getrecipemetadata_test.go +++ b/pkg/corerp/frontend/controller/environments/getrecipemetadata_test.go @@ -19,17 +19,20 @@ package environments import ( "context" "encoding/json" + "fmt" "io" "net/http/httptest" "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/engine" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -37,8 +40,8 @@ func TestGetRecipeMetadataRun_20220315PrivatePreview(t *testing.T) { mctrl := gomock.NewController(t) defer mctrl.Finish() mStorageClient := store.NewMockStorageClient(mctrl) + mEngine := engine.NewMockEngine(mctrl) ctx := context.Background() - t.Parallel() t.Run("get recipe metadata run", func(t *testing.T) { envInput, envDataModel, expectedOutput := getTestModelsGetRecipeMetadata20220315privatepreview() @@ -56,18 +59,82 @@ func TestGetRecipeMetadataRun_20220315PrivatePreview(t *testing.T) { }, nil }) ctx := rpctest.NewARMRequestContext(req) + recipeDefinition := recipes.EnvironmentDefinition{ + Name: *envInput.Name, + Parameters: nil, + TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/parameters/mongodatabases/azure:1.0", + TemplateVersion: "", + Driver: "bicep", + ResourceType: *envInput.ResourceType, + } + recipeData := map[string]any{ + "parameters": map[string]any{ + "documentdbName": map[string]any{"type": "string"}, + "location": map[string]any{"defaultValue": "[resourceGroup().location]", "type": "string"}, + "mongodbName": map[string]any{"type": "string"}, + }, + } + mEngine.EXPECT().GetRecipeMetadata(ctx, recipeDefinition).Return(recipeData, nil) + + opts := ctrl.Options{ + StorageClient: mStorageClient, + } + ctl, err := NewGetRecipeMetadata(opts, mEngine) + require.NoError(t, err) + resp, err := ctl.Run(ctx, w, req) + require.NoError(t, err) + _ = resp.Apply(ctx, w, req) + require.Equal(t, 200, w.Result().StatusCode) + + actualOutput := &v20220315privatepreview.RecipeGetMetadataResponse{} + _ = json.Unmarshal(w.Body.Bytes(), actualOutput) + require.Equal(t, expectedOutput, actualOutput) + }) + + t.Run("get recipe metadata run -- terraform", func(t *testing.T) { + envInput, envDataModel, expectedOutput := getTestModelsGetTFRecipeMetadata20220315privatepreview() + w := httptest.NewRecorder() + req, err := rpctest.NewHTTPRequestFromJSON(ctx, v1.OperationPost.HTTPMethod(), testHeaderfilegetrecipemetadata, envInput) + require.NoError(t, err) + + mStorageClient. + EXPECT(). + Get(gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { + return &store.Object{ + Metadata: store.Metadata{ID: id, ETag: "etag"}, + Data: envDataModel, + }, nil + }) + ctx := rpctest.NewARMRequestContext(req) + recipeDefinition := recipes.EnvironmentDefinition{ + Name: *envInput.Name, + Parameters: nil, + TemplatePath: "Azure/cosmosdb/azurerm", + TemplateVersion: "1.1.0", + Driver: "terraform", + ResourceType: *envInput.ResourceType, + } + recipeData := map[string]any{ + "parameters": map[string]any{ + "documentdbName": map[string]any{"type": "string"}, + "location": map[string]any{"defaultValue": "[resourceGroup().location]", "type": "string"}, + "mongodbName": map[string]any{"type": "string"}, + }, + } + mEngine.EXPECT().GetRecipeMetadata(ctx, recipeDefinition).Return(recipeData, nil) opts := ctrl.Options{ StorageClient: mStorageClient, } - ctl, err := NewGetRecipeMetadata(opts) + ctl, err := NewGetRecipeMetadata(opts, mEngine) require.NoError(t, err) resp, err := ctl.Run(ctx, w, req) require.NoError(t, err) _ = resp.Apply(ctx, w, req) require.Equal(t, 200, w.Result().StatusCode) - actualOutput := &v20220315privatepreview.RecipeMetadataProperties{} + actualOutput := &v20220315privatepreview.RecipeGetMetadataResponse{} _ = json.Unmarshal(w.Body.Bytes(), actualOutput) require.Equal(t, expectedOutput, actualOutput) }) @@ -87,7 +154,7 @@ func TestGetRecipeMetadataRun_20220315PrivatePreview(t *testing.T) { opts := ctrl.Options{ StorageClient: mStorageClient, } - ctl, err := NewGetRecipeMetadata(opts) + ctl, err := NewGetRecipeMetadata(opts, mEngine) require.NoError(t, err) resp, err := ctl.Run(ctx, w, req) require.NoError(t, err) @@ -128,7 +195,7 @@ func TestGetRecipeMetadataRun_20220315PrivatePreview(t *testing.T) { opts := ctrl.Options{ StorageClient: mStorageClient, } - ctl, err := NewGetRecipeMetadata(opts) + ctl, err := NewGetRecipeMetadata(opts, mEngine) require.NoError(t, err) resp, err := ctl.Run(ctx, w, req) require.NoError(t, err) @@ -145,17 +212,44 @@ func TestGetRecipeMetadataRun_20220315PrivatePreview(t *testing.T) { err = json.Unmarshal(payload, &armerr) require.NoError(t, err) require.Equal(t, v1.CodeNotFound, armerr.Error.Code) - require.Contains(t, armerr.Error.Message, "Either recipe with name \"mongodb\" or resource type \"Applications.Link/mongoDatabases\" not found on environment with id") + require.Contains(t, armerr.Error.Message, "Either recipe with name \"mongodb\" or resource type \"Applications.Datastores/mongoDatabases\" not found on environment with id") }) -} -func TestGetRecipeMetadataFromRegistry(t *testing.T) { - ctx := context.Background() + t.Run("get recipe metadata engine failure", func(t *testing.T) { + envInput, envDataModel, _ := getTestModelsGetRecipeMetadata20220315privatepreview() + w := httptest.NewRecorder() + req, err := rpctest.NewHTTPRequestFromJSON(ctx, v1.OperationPost.HTTPMethod(), testHeaderfilegetrecipemetadata, envInput) + require.NoError(t, err) + + mStorageClient. + EXPECT(). + Get(gomock.Any(), gomock.Any()). + DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { + return &store.Object{ + Metadata: store.Metadata{ID: id, ETag: "etag"}, + Data: envDataModel, + }, nil + }) + ctx := rpctest.NewARMRequestContext(req) + recipeDefinition := recipes.EnvironmentDefinition{ + Name: *envInput.Name, + Parameters: nil, + TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/parameters/mongodatabases/azure:1.0", + TemplateVersion: "", + Driver: "bicep", + ResourceType: *envInput.ResourceType, + } + engineErr := fmt.Errorf("could not find driver %s", "invalidDriver") + mEngine.EXPECT().GetRecipeMetadata(ctx, recipeDefinition).Return(nil, engineErr) - t.Run("get recipe metadata from registry with invalid path", func(t *testing.T) { - templatePath := "radiusdev.azurecr.io/recipes/functionaltest/test/mongodatabases/azure:1.0" - _, err := getRecipeMetadataFromRegistry(ctx, templatePath, "mongodb") - require.ErrorContains(t, err, "failed to fetch repository from the path \"radiusdev.azurecr.io/recipes/functionaltest/test/mongodatabases/azure:1.0\": radiusdev.azurecr.io/recipes/functionaltest/test/mongodatabases/azure:1.0: not found") + opts := ctrl.Options{ + StorageClient: mStorageClient, + } + ctl, err := NewGetRecipeMetadata(opts, mEngine) + require.NoError(t, err) + _, err = ctl.Run(ctx, w, req) + require.Error(t, err) + require.Equal(t, err, engineErr) }) } diff --git a/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_datamodel.json b/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_datamodel.json index 01b02372ea..06af66d527 100644 --- a/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_datamodel.json +++ b/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_datamodel.json @@ -21,7 +21,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "mongo-azure": { "templateKind": "bicep", "templatePath": "radiusdev.azurecr.io/recipes/mongodatabases/azure:1.0", diff --git a/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_input.json b/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_input.json index ce5e238e83..eee49c2497 100644 --- a/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_input.json +++ b/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_input.json @@ -7,7 +7,7 @@ "namespace": "default" }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "mongo-azure": { "templateKind": "bicep", "templatePath": "radiusdev.azurecr.io/recipes/mongodatabases/azure:1.0", diff --git a/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_output.json b/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_output.json index 7fda8a0eea..39139c8cfb 100644 --- a/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_output.json +++ b/pkg/corerp/frontend/controller/environments/testdata/environment20220315privatepreview_output.json @@ -14,7 +14,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "mongo-azure": { "templateKind": "bicep", "templatePath": "radiusdev.azurecr.io/recipes/mongodatabases/azure:1.0", diff --git a/pkg/corerp/frontend/controller/environments/testdata/environmentgetmetadatanonexistingrecipe20220315privatepreview_input.json b/pkg/corerp/frontend/controller/environments/testdata/environmentgetmetadatanonexistingrecipe20220315privatepreview_input.json index b7c1b73f45..f059c65f10 100644 --- a/pkg/corerp/frontend/controller/environments/testdata/environmentgetmetadatanonexistingrecipe20220315privatepreview_input.json +++ b/pkg/corerp/frontend/controller/environments/testdata/environmentgetmetadatanonexistingrecipe20220315privatepreview_input.json @@ -1,4 +1,4 @@ { "name":"mongodb", - "linkType":"Applications.Link/mongoDatabases" + "resourceType":"Applications.Datastores/mongoDatabases" } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_datamodel.json b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_datamodel.json index 582b6604b6..8fddd740f6 100644 --- a/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_datamodel.json +++ b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_datamodel.json @@ -21,7 +21,7 @@ } }, "recipes": { - "Applications.Link/mongoDatabases":{ + "Applications.Datastores/mongoDatabases":{ "mongo-parameters": { "templateKind": "bicep", "templatePath": "radiusdev.azurecr.io/recipes/functionaltest/parameters/mongodatabases/azure:1.0" @@ -32,7 +32,7 @@ "templateVersion": "1.1.0" } }, - "Applications.Link/redisCache":{ + "Applications.Datastores/redisCache":{ "redis": { "templateKind": "bicep", "templatePath": "radiusdev.azurecr.io/redis:1.0" diff --git a/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_input.json b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_input.json index 911329ca7b..7b16bdeca8 100644 --- a/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_input.json +++ b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_input.json @@ -1,4 +1,4 @@ { "name":"mongo-parameters", - "linkType":"Applications.Link/mongoDatabases" + "resourceType":"Applications.Datastores/mongoDatabases" } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_input_terraform.json b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_input_terraform.json new file mode 100644 index 0000000000..5939a0fc83 --- /dev/null +++ b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_input_terraform.json @@ -0,0 +1,4 @@ +{ + "name":"mongo-terraform", + "resourceType":"Applications.Datastores/mongoDatabases" +} \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_output_terraform.json b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_output_terraform.json new file mode 100644 index 0000000000..d032b18270 --- /dev/null +++ b/pkg/corerp/frontend/controller/environments/testdata/environmentgetrecipemetadata20220315privatepreview_output_terraform.json @@ -0,0 +1,17 @@ +{ + "templateKind": "terraform", + "templatePath": "Azure/cosmosdb/azurerm", + "templateVersion": "1.1.0", + "parameters": { + "mongodbName": { + "type" : "string" + }, + "documentdbName": { + "type" : "string" + }, + "location": { + "type" : "string", + "defaultValue" : "[resourceGroup().location]" + } + } + } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/environments/v20220315privatepreview_test.go b/pkg/corerp/frontend/controller/environments/v20220315privatepreview_test.go index 2b9d2aef64..8cfc30b3a5 100644 --- a/pkg/corerp/frontend/controller/environments/v20220315privatepreview_test.go +++ b/pkg/corerp/frontend/controller/environments/v20220315privatepreview_test.go @@ -19,9 +19,9 @@ package environments import ( "encoding/json" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/test/testutil" + v20220315privatepreview "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/test/testutil" ) const testHeaderfile = "requestheaders20220315privatepreview.json" @@ -44,9 +44,9 @@ func getTestModels20220315privatepreview() (*v20220315privatepreview.Environment return envInput, envDataModel, expectedOutput } -func getTestModelsGetRecipeMetadata20220315privatepreview() (*v20220315privatepreview.Recipe, *datamodel.Environment, *v20220315privatepreview.RecipeMetadataProperties) { +func getTestModelsGetRecipeMetadata20220315privatepreview() (*v20220315privatepreview.RecipeGetMetadata, *datamodel.Environment, *v20220315privatepreview.RecipeGetMetadataResponse) { rawInput := testutil.ReadFixture("environmentgetrecipemetadata20220315privatepreview_input.json") - envInput := &v20220315privatepreview.Recipe{} + envInput := &v20220315privatepreview.RecipeGetMetadata{} _ = json.Unmarshal(rawInput, envInput) rawExistingDataModel := testutil.ReadFixture("environmentgetrecipemetadata20220315privatepreview_datamodel.json") @@ -54,15 +54,31 @@ func getTestModelsGetRecipeMetadata20220315privatepreview() (*v20220315privatepr _ = json.Unmarshal(rawExistingDataModel, envExistingDataModel) rawExpectedOutput := testutil.ReadFixture("environmentgetrecipemetadata20220315privatepreview_output.json") - expectedOutput := &v20220315privatepreview.RecipeMetadataProperties{} + expectedOutput := &v20220315privatepreview.RecipeGetMetadataResponse{} _ = json.Unmarshal(rawExpectedOutput, expectedOutput) return envInput, envExistingDataModel, expectedOutput } -func getTestModelsGetRecipeMetadataForNonExistingRecipe20220315privatepreview() (*v20220315privatepreview.Recipe, *datamodel.Environment) { +func getTestModelsGetTFRecipeMetadata20220315privatepreview() (*v20220315privatepreview.RecipeGetMetadata, *datamodel.Environment, *v20220315privatepreview.RecipeGetMetadataResponse) { + rawInput := testutil.ReadFixture("environmentgetrecipemetadata20220315privatepreview_input_terraform.json") + envInput := &v20220315privatepreview.RecipeGetMetadata{} + _ = json.Unmarshal(rawInput, envInput) + + rawExistingDataModel := testutil.ReadFixture("environmentgetrecipemetadata20220315privatepreview_datamodel.json") + envExistingDataModel := &datamodel.Environment{} + _ = json.Unmarshal(rawExistingDataModel, envExistingDataModel) + + rawExpectedOutput := testutil.ReadFixture("environmentgetrecipemetadata20220315privatepreview_output_terraform.json") + expectedOutput := &v20220315privatepreview.RecipeGetMetadataResponse{} + _ = json.Unmarshal(rawExpectedOutput, expectedOutput) + + return envInput, envExistingDataModel, expectedOutput +} + +func getTestModelsGetRecipeMetadataForNonExistingRecipe20220315privatepreview() (*v20220315privatepreview.RecipeGetMetadata, *datamodel.Environment) { rawInput := testutil.ReadFixture("environmentgetmetadatanonexistingrecipe20220315privatepreview_input.json") - envInput := &v20220315privatepreview.Recipe{} + envInput := &v20220315privatepreview.RecipeGetMetadata{} _ = json.Unmarshal(rawInput, envInput) rawExistingDataModel := testutil.ReadFixture("environmentgetrecipemetadata20220315privatepreview_datamodel.json") diff --git a/pkg/corerp/frontend/controller/extenders/listsecretsextender.go b/pkg/corerp/frontend/controller/extenders/listsecretsextender.go index 8e83791981..88d0bc79dd 100644 --- a/pkg/corerp/frontend/controller/extenders/listsecretsextender.go +++ b/pkg/corerp/frontend/controller/extenders/listsecretsextender.go @@ -20,11 +20,11 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/datamodel/converter" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/datamodel/converter" ) var _ ctrl.Controller = (*ListSecretsExtender)(nil) diff --git a/pkg/corerp/frontend/controller/extenders/listsecretsextender_test.go b/pkg/corerp/frontend/controller/extenders/listsecretsextender_test.go index c788061996..d18a5ea924 100644 --- a/pkg/corerp/frontend/controller/extenders/listsecretsextender_test.go +++ b/pkg/corerp/frontend/controller/extenders/listsecretsextender_test.go @@ -24,10 +24,10 @@ import ( "net/http/httptest" "testing" - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreview_output.json b/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreview_output.json index d863564809..40b1996539 100644 --- a/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreview_output.json +++ b/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreview_output.json @@ -1,29 +1,33 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/extenders/extender0", - "location": "West US", - "name": "extender0", - "properties": { - "status": { - "outputResources": null - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual", - "provisioningState": "Succeeded" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/extenders/extender0", + "location": "West US", + "name": "extender0", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" }, - "tags": {}, - "type": "applications.core/extenders" + "resourceProvisioning": "manual", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "tags": {}, + "type": "applications.core/extenders" } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreviewgetandlist_output.json b/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreviewgetandlist_output.json index b3b88bba73..d52141f508 100644 --- a/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreviewgetandlist_output.json +++ b/pkg/corerp/frontend/controller/extenders/testdata/20220315privatepreviewgetandlist_output.json @@ -1,25 +1,29 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/extenders/extender0", - "location": "West US", - "name": "extender0", - "properties": { - "status": { - "outputResources": null - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "resourceProvisioning": "manual", - "provisioningState": "Succeeded" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/extenders/extender0", + "location": "West US", + "name": "extender0", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "tags": {}, - "type": "applications.core/extenders" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "resourceProvisioning": "manual", + "provisioningState": "Succeeded" + }, + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "tags": {}, + "type": "applications.core/extenders" } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/extenders/v20220315privatepreview_test.go b/pkg/corerp/frontend/controller/extenders/v20220315privatepreview_test.go index 270db9cd41..ee2bd2dd4f 100644 --- a/pkg/corerp/frontend/controller/extenders/v20220315privatepreview_test.go +++ b/pkg/corerp/frontend/controller/extenders/v20220315privatepreview_test.go @@ -19,9 +19,9 @@ package extenders import ( "encoding/json" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/test/testutil" ) const testHeaderfile = "20220315privatepreview_requestheaders.json" diff --git a/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_datamodel.json b/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_datamodel.json index e3a2369390..33732108df 100644 --- a/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_datamodel.json +++ b/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_datamodel.json @@ -1,51 +1,43 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "location": "West US", + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "tags": { + "env": "dev" + }, + "provisioningState": "Succeeded", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" }, - "provisioningState": "Succeeded", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Gateway", - "Provider": "kubernetes" - }, - "Identity": { - "data": null, - "resourceType": { - "Type": "httproutes", - "Provider": "aks" - } - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix":"myprefix" - }, - "routes": [{ - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls":{ - "sslPassthrough": false - }, - "url": "myprefix.myapp.mydomain.com" - } -} + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "sslPassthrough": false + }, + "url": "myprefix.myapp.mydomain.com" + } +} \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_output.json b/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_output.json index f8cbab5e60..c7331f640c 100644 --- a/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_output.json +++ b/pkg/corerp/frontend/controller/gateways/testdata/gateway20220315privatepreview_output.json @@ -1,46 +1,43 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "location": "West US", + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": { + "fullyQualifiedHostname": "myapp.mydomain.com", + "prefix": "myprefix" }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "Provider": "kubernetes", - "Identity": { - "aksClusterName": "", - "name": "", - "namespace": "" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": { - "fullyQualifiedHostname": "myapp.mydomain.com", - "prefix":"myprefix" - }, - "routes": [{ - "destination": "mydestination", - "path": "mypath", - "replacePrefix": "myreplaceprefix" - } - ], - "tls":{ - "sslPassthrough": false - }, - "url": "myprefix.myapp.mydomain.com", - "provisioningState": "Succeeded" - } + "routes": [ + { + "destination": "mydestination", + "path": "mypath", + "replacePrefix": "myreplaceprefix" + } + ], + "tls": { + "sslPassthrough": false + }, + "url": "myprefix.myapp.mydomain.com", + "provisioningState": "Succeeded" + } } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/gateways/validator.go b/pkg/corerp/frontend/controller/gateways/validator.go index 6b9f1f847e..5d6c2ed17e 100644 --- a/pkg/corerp/frontend/controller/gateways/validator.go +++ b/pkg/corerp/frontend/controller/gateways/validator.go @@ -19,9 +19,9 @@ package gateways import ( "context" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // ValidateAndMutateRequest checks if the TLS configuration is valid and sets the TLS protocol version to 1.2 if it is not diff --git a/pkg/corerp/frontend/controller/gateways/validator_test.go b/pkg/corerp/frontend/controller/gateways/validator_test.go index dc3551b4eb..50ed82cd2c 100644 --- a/pkg/corerp/frontend/controller/gateways/validator_test.go +++ b/pkg/corerp/frontend/controller/gateways/validator_test.go @@ -20,8 +20,8 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_datamodel.json b/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_datamodel.json index 2f35c05da0..a561056795 100644 --- a/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_datamodel.json +++ b/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_datamodel.json @@ -1,44 +1,34 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/httproutes/hrt0", - "name": "hrt0", - "type": "applications.core/httproutes", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/httproutes/hrt0", + "name": "hrt0", + "type": "applications.core/httproutes", + "location": "West US", + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "provisioningState": "Succeeded", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "provisioningState": "Succeeded", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "httproutes", - "Provider": "aks" - }, - "Resource": null, - "Identity": { - "data": null, - "resourceType": { - "Type": "httproutes", - "Provider": "aks" - } - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": "foo.example.com", - "port": 8080, - "scheme": "https", - "url": "https://foo.example.com" - }, - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": "foo.example.com", + "port": 8080, + "scheme": "https", + "url": "https://foo.example.com" + }, + "tenantId": "00000000-0000-0000-0000-000000000000", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroup": "radius-test-rg", + "createdApiVersion": "2022-03-15-privatepreview", + "updatedApiVersion": "2022-03-15-privatepreview" } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_output.json b/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_output.json index 33a7fb6ea0..3c6c0f4d96 100644 --- a/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_output.json +++ b/pkg/corerp/frontend/controller/httproutes/testdata/httproute20220315privatepreview_output.json @@ -1,34 +1,30 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/httproutes/hrt0", - "location": "West US", - "name": "hrt0", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "Provider": "aks", - "Identity": { - "aksClusterName": "", - "name": "", - "namespace": "" - } - }] - }, - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "hostname": "foo.example.com", - "port": 8080, - "scheme": "https", - "url": "https://foo.example.com" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.core/httproutes/hrt0", + "location": "West US", + "name": "hrt0", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "tags": {}, - "type": "applications.core/httproutes" + "provisioningState": "Succeeded", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "hostname": "foo.example.com", + "port": 8080, + "scheme": "https", + "url": "https://foo.example.com" + }, + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "tags": {}, + "type": "applications.core/httproutes" } \ No newline at end of file diff --git a/pkg/corerp/frontend/controller/secretstores/kubernetes.go b/pkg/corerp/frontend/controller/secretstores/kubernetes.go index 5acde7887b..f25562c2c7 100644 --- a/pkg/corerp/frontend/controller/secretstores/kubernetes.go +++ b/pkg/corerp/frontend/controller/secretstores/kubernetes.go @@ -23,16 +23,15 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/pkg/ucp/store" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -267,18 +266,12 @@ func UpsertSecret(ctx context.Context, newResource, old *datamodel.SecretStore, newResource.Properties.Status.OutputResources = []rpv1.OutputResource{ { LocalID: rpv1.LocalIDSecret, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.Secret, - Provider: resourcemodel.ProviderKubernetes, - }, - Data: resourcemodel.KubernetesIdentity{ - Kind: resourcekinds.Secret, - APIVersion: "v1", - Name: name, - Namespace: ns, - }, - }, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "", + resources_kubernetes.KindSecret, + ns, + name), }, } @@ -305,33 +298,17 @@ func DeleteRadiusSecret(ctx context.Context, oldResource *datamodel.SecretStore, return nil, nil } -func getIdentityFromOutputResources(resources []rpv1.OutputResource) (*resourcemodel.KubernetesIdentity, error) { - for _, r := range resources { - ri := r.Identity - if ri.ResourceType.Provider == resourcemodel.ProviderKubernetes && ri.ResourceType.Type == resourcekinds.Secret { - ki := &resourcemodel.KubernetesIdentity{} - if err := store.DecodeMap(ri.Data, ki); err != nil { - return nil, err - } - return ki, nil - } - } - - return nil, nil -} - func getSecretFromOutputResources(resources []rpv1.OutputResource, options *controller.Options) (*corev1.Secret, error) { - ki, err := getIdentityFromOutputResources(resources) - if err != nil { - return nil, err - } - - if ki == nil { - return nil, nil + name, ns := "", "" + for _, resource := range resources { + if strings.EqualFold(resource.ID.Type(), "core/Secret") { + _, _, ns, name = resources_kubernetes.ToParts(resource.ID) + break + } } ksecret := &corev1.Secret{} - err = options.KubeClient.Get(context.Background(), runtimeclient.ObjectKey{Namespace: ki.Namespace, Name: ki.Name}, ksecret) + err := options.KubeClient.Get(context.Background(), runtimeclient.ObjectKey{Namespace: ns, Name: name}, ksecret) if apierrors.IsNotFound(err) { return nil, nil } else if err != nil { diff --git a/pkg/corerp/frontend/controller/secretstores/kubernetes_test.go b/pkg/corerp/frontend/controller/secretstores/kubernetes_test.go index 27d12f4ff5..1b300409e1 100644 --- a/pkg/corerp/frontend/controller/secretstores/kubernetes_test.go +++ b/pkg/corerp/frontend/controller/secretstores/kubernetes_test.go @@ -23,16 +23,15 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/k8sutil" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/k8sutil" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -399,18 +398,12 @@ func TestUpsertSecret(t *testing.T) { require.Equal(t, "MTAwMDAwMDAtMTAwMC0xMDAwLTAwMDAtMDAwMDAwMDAwMDAw", string(ksecret.Data["servicePrincipalPassword"])) require.Equal(t, rpv1.OutputResource{ LocalID: "Secret", - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.Secret, - Provider: resourcemodel.ProviderKubernetes, - }, - Data: resourcemodel.KubernetesIdentity{ - Kind: resourcekinds.Secret, - APIVersion: "v1", - Name: "secret0", - Namespace: "app0-ns", - }, - }, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "", + resources_kubernetes.KindSecret, + "app0-ns", + "secret0"), }, newResource.Properties.Status.OutputResources[0]) }) diff --git a/pkg/corerp/frontend/controller/secretstores/listsecrets.go b/pkg/corerp/frontend/controller/secretstores/listsecrets.go index a72cc52f01..11edf39697 100644 --- a/pkg/corerp/frontend/controller/secretstores/listsecrets.go +++ b/pkg/corerp/frontend/controller/secretstores/listsecrets.go @@ -23,12 +23,12 @@ import ( "fmt" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/datamodel/converter" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/datamodel/converter" + "github.com/radius-project/radius/pkg/to" ) const ( diff --git a/pkg/corerp/frontend/controller/secretstores/listsecrets_test.go b/pkg/corerp/frontend/controller/secretstores/listsecrets_test.go index 28a0af4e7f..8de872eb7c 100644 --- a/pkg/corerp/frontend/controller/secretstores/listsecrets_test.go +++ b/pkg/corerp/frontend/controller/secretstores/listsecrets_test.go @@ -24,14 +24,14 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/k8sutil" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/k8sutil" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_cert_valuefrom.json b/pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_cert_valuefrom.json index cda623d0d1..c1ee1af09b 100644 --- a/pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_cert_valuefrom.json +++ b/pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_cert_valuefrom.json @@ -23,18 +23,7 @@ "status": { "outputResources": [ { - "identity": { - "resourceType": { - "type": "Secret", - "provider": "kubernetes" - }, - "data": { - "kind": "Secret", - "apiVersion": "v1", - "namespace": "default", - "name": "letsencrypt-prod" - } - } + "id": "/planes/kubernetes/local/namespaces/default/providers/core/Secret/letsencrypt-prod" } ] } diff --git a/pkg/corerp/frontend/controller/util/query.go b/pkg/corerp/frontend/controller/util/query.go index 52b1b779f6..a6a8c76f94 100644 --- a/pkg/corerp/frontend/controller/util/query.go +++ b/pkg/corerp/frontend/controller/util/query.go @@ -19,7 +19,7 @@ package util import ( "context" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/store" ) // FindResources searches for resources of a given type with a given filter key and value, and returns the query result. diff --git a/pkg/corerp/frontend/controller/volumes/validator.go b/pkg/corerp/frontend/controller/volumes/validator.go index 5b95aa9a6b..ad274b08d9 100644 --- a/pkg/corerp/frontend/controller/volumes/validator.go +++ b/pkg/corerp/frontend/controller/volumes/validator.go @@ -20,9 +20,9 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/corerp/frontend/controller/volumes/validator_test.go b/pkg/corerp/frontend/controller/volumes/validator_test.go index 3c5ec877d7..3271632021 100644 --- a/pkg/corerp/frontend/controller/volumes/validator_test.go +++ b/pkg/corerp/frontend/controller/volumes/validator_test.go @@ -22,12 +22,12 @@ import ( "net/http" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/k8sutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/require" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" diff --git a/pkg/corerp/frontend/handler/getoperations.go b/pkg/corerp/frontend/handler/getoperations.go deleted file mode 100644 index b742bb67eb..0000000000 --- a/pkg/corerp/frontend/handler/getoperations.go +++ /dev/null @@ -1,299 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - "net/http" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" -) - -var _ ctrl.Controller = (*GetOperations)(nil) - -// GetOperations is the controller implementation to get arm rpc available operations. -type GetOperations struct { - ctrl.BaseController -} - -// NewGetOperations creates a new GetOperations controller with the given options. -func NewGetOperations(opts ctrl.Options) (ctrl.Controller, error) { - return &GetOperations{ctrl.NewBaseController(opts)}, nil -} - -// Run checks the API version of the request and returns the available operations for the resource provider at tenant level. -// Spec: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/proxy-api-reference.md#exposing-available-operations -func (opctrl *GetOperations) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { - sCtx := v1.ARMRequestContextFromContext(ctx) - - switch sCtx.APIVersion { - case v20220315privatepreview.Version: - return rest.NewOKResponse(opctrl.availableOperationsV1()), nil - } - - return rest.NewNotFoundAPIVersionResponse("operations", ProviderNamespaceName, sCtx.APIVersion), nil -} - -func (opctrl *GetOperations) availableOperationsV1() *v1.PaginatedList { - return &v1.PaginatedList{ - Value: []any{ - &v1.Operation{ - Name: "Applications.Core/operations/read", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "operations", - Operation: "Get operations", - Description: "Get the list of operations", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/environments/read", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "environments", - Operation: "List environments", - Description: "Get the list of environments.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/environments/write", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "environments", - Operation: "Create/Update environment", - Description: "Create or update an environment.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/environments/delete", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "environments", - Operation: "Delete environment", - Description: "Delete an environment.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/environments/getmetadata/action", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "environments", - Operation: "Get recipe metadata", - Description: "Get recipe metadata.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/environments/join/action", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "environments", - Operation: "Join environment", - Description: "Join to application environment.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/register/action", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: ProviderNamespaceName, - Operation: "Register Applications.Core", - Description: "Register the subscription for Applications.Core.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/unregister/action", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: ProviderNamespaceName, - Operation: "Unregister Applications.Core", - Description: "Unregister the subscription for Applications.Core.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/httproutes/read", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "httproutes", - Operation: "List httproutes", - Description: "Get the list of httproutes.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/httproutes/write", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "httproutes", - Operation: "Create/Update httproute", - Description: "Create or update an httproute.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/httproutes/delete", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "httproutes", - Operation: "Delete httproute", - Description: "Delete an httproute.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/applications/read", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "applications", - Operation: "List applications", - Description: "Get the list of applications.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/applications/write", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "applications", - Operation: "Create/Update application", - Description: "Create or update an application.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/applications/delete", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "applications", - Operation: "Delete application", - Description: "Delete an application.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/gateways/read", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "gateways", - Operation: "List gateways", - Description: "Get the list of gateways.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/gateways/write", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "gateways", - Operation: "Create/Update gateway", - Description: "Create or Updateg a gateway.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/gateways/delete", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "gateways", - Operation: "delete gateway", - Description: "Delete a gateway.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/containers/read", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "containers", - Operation: "List containers", - Description: "Get the list of containers.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/containers/write", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "containers", - Operation: "Create/Update container", - Description: "Create or update a container.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/containers/delete", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "containers", - Operation: "Delete container", - Description: "Delete a container.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/extenders/read", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "extenders", - Operation: "Get/List extenders", - Description: "Gets/Lists extender link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/extenders/write", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "extenders", - Operation: "Create/Update extenders", - Description: "Creates or updates a extender link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/extenders/delete", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "extenders", - Operation: "Delete extender", - Description: "Deletes a extender link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Core/extenders/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: ProviderNamespaceName, - Resource: "extenders", - Operation: "List secrets", - Description: "Lists extender secrets.", - }, - IsDataAction: false, - }, - }, - } -} diff --git a/pkg/corerp/frontend/handler/getoperations_test.go b/pkg/corerp/frontend/handler/getoperations_test.go deleted file mode 100644 index f8a34d1a4a..0000000000 --- a/pkg/corerp/frontend/handler/getoperations_test.go +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - "net/http/httptest" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - v20220315privatepreview "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/stretchr/testify/require" -) - -func TestRunWith20220315PrivatePreview(t *testing.T) { - // arrange - opts := ctrl.Options{} - op, err := NewGetOperations(opts) - require.NoError(t, err) - ctx := v1.WithARMRequestContext(context.Background(), &v1.ARMRequestContext{ - APIVersion: v20220315privatepreview.Version, - }) - w := httptest.NewRecorder() - - // act - resp, err := op.Run(ctx, w, nil) - - // assert - require.NoError(t, err) - switch v := resp.(type) { - case *rest.OKResponse: - pagination, ok := v.Body.(*v1.PaginatedList) - require.True(t, ok) - require.Equal(t, 24, len(pagination.Value)) - default: - require.Truef(t, false, "should not return error") - } -} - -func TestRunWithUnsupportedAPIVersion(t *testing.T) { - // arrange - opts := ctrl.Options{} - op, err := NewGetOperations(opts) - require.NoError(t, err) - ctx := v1.WithARMRequestContext(context.Background(), &v1.ARMRequestContext{ - APIVersion: "unknownversion", - }) - w := httptest.NewRecorder() - - // act - resp, err := op.Run(ctx, w, nil) - - // assert - require.NoError(t, err) - switch v := resp.(type) { - case *rest.NotFoundResponse: - armerr := v.Body - require.Equal(t, v1.CodeInvalidResourceType, armerr.Error.Code) - default: - require.Truef(t, false, "should not return error") - } -} diff --git a/pkg/corerp/frontend/handler/routes.go b/pkg/corerp/frontend/handler/routes.go deleted file mode 100644 index aa7d591b5c..0000000000 --- a/pkg/corerp/frontend/handler/routes.go +++ /dev/null @@ -1,852 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - "time" - - "github.com/go-chi/chi/v5" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - frontend_ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - rp_frontend "github.com/project-radius/radius/pkg/rp/frontend" - "github.com/project-radius/radius/pkg/validator" - "github.com/project-radius/radius/swagger" - - "github.com/project-radius/radius/pkg/corerp/datamodel" - converter "github.com/project-radius/radius/pkg/corerp/datamodel/converter" - - app_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/applications" - ctr_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/containers" - env_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/environments" - ext_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/extenders" - gtwy_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/gateways" - hrt_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/httproutes" - secret_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/secretstores" - vol_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/volumes" -) - -const ( - ProviderNamespaceName = "Applications.Core" - - // AsyncOperationRetryAfter is polling interval for async create/update or delete resource operations. - AsyncOperationRetryAfter = time.Duration(5) * time.Second -) - -// AddRoutes registers handlers for Container, Application, Gateway, Volume and Secret Store resources, allowing for -// operations such as List, Get, Put, Patch and Delete. -func AddRoutes(ctx context.Context, r chi.Router, isARM bool, ctrlOpts frontend_ctrl.Options) error { - rootScopePath := ctrlOpts.PathBase - if isARM { - rootScopePath += "/subscriptions/{subscriptionID}" - } else { - rootScopePath += "/planes/radius/{planeName}" - } - - resourceGroupPath := "/resourcegroups/{resourceGroupName}" - - // Configure the default ARM handlers. - err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, ProviderNamespaceName, NewGetOperations, ctrlOpts) - if err != nil { - return err - } - - // URLs may use either the subscription/plane scope or resource group scope. - // - // These paths are order sensitive and the longer path MUST be registered first. - prefixes := []string{ - rootScopePath + resourceGroupPath, - rootScopePath, - } - - specLoader, err := validator.LoadSpec(ctx, ProviderNamespaceName, swagger.SpecFiles, prefixes, "rootScope") - if err != nil { - return err - } - - validator := validator.APIValidator(validator.Options{ - SpecLoader: specLoader, - ResourceTypeGetter: validator.RadiusResourceTypeGetter, - }) - - // Register resource routers. - // - // Note: We have to follow the below rules to enable API validators: - // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. - // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. - - // Environments resource routers. - envPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/environments", validator) - envResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/environments", validator) - envResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/environments/{environmentName}", validator) - - handlerOptions := []server.HandlerOptions{ - // Environments resource handler registration. - { - ParentRouter: envPlaneRouter, - ResourceType: env_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources( - opt, - frontend_ctrl.ResourceOptions[datamodel.Environment]{ - ResponseConverter: converter.EnvironmentDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: envResourceGroupRouter, - ResourceType: env_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Environment]{ - ResponseConverter: converter.EnvironmentDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: envResourceRouter, - ResourceType: env_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.Environment]{ - ResponseConverter: converter.EnvironmentDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: envResourceRouter, - ResourceType: env_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: env_ctrl.NewCreateOrUpdateEnvironment, - }, - { - ParentRouter: envResourceRouter, - ResourceType: env_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: env_ctrl.NewCreateOrUpdateEnvironment, - }, - { - ParentRouter: envResourceRouter, - ResourceType: env_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultSyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.Environment]{ - RequestConverter: converter.EnvironmentDataModelFromVersioned, - ResponseConverter: converter.EnvironmentDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: envResourceRouter, - Path: "/getmetadata", - ResourceType: env_ctrl.ResourceTypeName, - Method: env_ctrl.OperationGetRecipeMetadata, - ControllerFactory: env_ctrl.NewGetRecipeMetadata, - }, - } - - // httpRoute resource handler registration. - httpRoutePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/httproutes", validator) - httpRouteResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/httproutes", validator) - httpRouteResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/httproutes/{httpRouteName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: httpRoutePlaneRouter, - ResourceType: hrt_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.HTTPRoute]{ - ResponseConverter: converter.HTTPRouteDataModelToVersioned, - ListRecursiveQuery: true, - }, - ) - }, - }, - { - ParentRouter: httpRouteResourceGroupRouter, - ResourceType: hrt_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.HTTPRoute]{ - ResponseConverter: converter.HTTPRouteDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: httpRouteResourceRouter, - ResourceType: hrt_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.HTTPRoute]{ - ResponseConverter: converter.HTTPRouteDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: httpRouteResourceRouter, - ResourceType: hrt_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.HTTPRoute]{ - RequestConverter: converter.HTTPRouteDataModelFromVersioned, - ResponseConverter: converter.HTTPRouteDataModelToVersioned, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: httpRouteResourceRouter, - ResourceType: hrt_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.HTTPRoute]{ - RequestConverter: converter.HTTPRouteDataModelFromVersioned, - ResponseConverter: converter.HTTPRouteDataModelToVersioned, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: httpRouteResourceRouter, - ResourceType: hrt_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.HTTPRoute]{ - RequestConverter: converter.HTTPRouteDataModelFromVersioned, - ResponseConverter: converter.HTTPRouteDataModelToVersioned, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - // Container resource handlers. - containerPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/containers", validator) - containerResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/containers", validator) - containerResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/containers/{containerName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: containerPlaneRouter, - ResourceType: ctr_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.ContainerResource]{ - ResponseConverter: converter.ContainerDataModelToVersioned, - ListRecursiveQuery: true, - }, - ) - }, - }, - { - ParentRouter: containerResourceGroupRouter, - ResourceType: ctr_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.ContainerResource]{ - ResponseConverter: converter.ContainerDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: containerResourceRouter, - ResourceType: ctr_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.ContainerResource]{ - ResponseConverter: converter.ContainerDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: containerResourceRouter, - ResourceType: ctr_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.ContainerResource]{ - RequestConverter: converter.ContainerDataModelFromVersioned, - ResponseConverter: converter.ContainerDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.ContainerResource]{ - rp_frontend.PrepareRadiusResource[*datamodel.ContainerResource], - ctr_ctrl.ValidateAndMutateRequest, - }, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: containerResourceRouter, - ResourceType: ctr_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.ContainerResource]{ - RequestConverter: converter.ContainerDataModelFromVersioned, - ResponseConverter: converter.ContainerDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.ContainerResource]{ - rp_frontend.PrepareRadiusResource[*datamodel.ContainerResource], - ctr_ctrl.ValidateAndMutateRequest, - }, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: containerResourceRouter, - ResourceType: ctr_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.ContainerResource]{ - RequestConverter: converter.ContainerDataModelFromVersioned, - ResponseConverter: converter.ContainerDataModelToVersioned, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - // Container resource handlers. - appPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/applications", validator) - appResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/applications", validator) - appResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/applications/{applicationName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - // Applications resource handler registration. - { - ParentRouter: appPlaneRouter, - ResourceType: app_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Application]{ - ResponseConverter: converter.ApplicationDataModelToVersioned, - ListRecursiveQuery: true, - }, - ) - }, - }, - { - ParentRouter: appResourceGroupRouter, - ResourceType: app_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Application]{ - ResponseConverter: converter.ApplicationDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: appResourceRouter, - ResourceType: app_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.Application]{ - ResponseConverter: converter.ApplicationDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: appResourceRouter, - ResourceType: app_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultSyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Application]{ - RequestConverter: converter.ApplicationDataModelFromVersioned, - ResponseConverter: converter.ApplicationDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Application]{ - rp_frontend.PrepareRadiusResource[*datamodel.Application], - app_ctrl.CreateAppScopedNamespace, - }, - }, - ) - }, - }, - { - ParentRouter: appResourceRouter, - ResourceType: app_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultSyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Application]{ - RequestConverter: converter.ApplicationDataModelFromVersioned, - ResponseConverter: converter.ApplicationDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Application]{ - rp_frontend.PrepareRadiusResource[*datamodel.Application], - app_ctrl.CreateAppScopedNamespace, - }, - }, - ) - }, - }, - { - ParentRouter: appResourceRouter, - ResourceType: app_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultSyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.Application]{ - RequestConverter: converter.ApplicationDataModelFromVersioned, - ResponseConverter: converter.ApplicationDataModelToVersioned, - }, - ) - }, - }, - }...) - - // Gateway resource handler registration. - gwPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/gateways", validator) - gwResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/gateways", validator) - gwResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/gateways/{gatewayName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: gwPlaneRouter, - ResourceType: gtwy_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Gateway]{ - ResponseConverter: converter.GatewayDataModelToVersioned, - ListRecursiveQuery: true, - }, - ) - }, - }, - { - ParentRouter: gwResourceGroupRouter, - ResourceType: gtwy_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Gateway]{ - ResponseConverter: converter.GatewayDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: gwResourceRouter, - ResourceType: gtwy_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.Gateway]{ - ResponseConverter: converter.GatewayDataModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: gwResourceRouter, - ResourceType: gtwy_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Gateway]{ - RequestConverter: converter.GatewayDataModelFromVersioned, - ResponseConverter: converter.GatewayDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Gateway]{ - rp_frontend.PrepareRadiusResource[*datamodel.Gateway], - gtwy_ctrl.ValidateAndMutateRequest, - }, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: gwResourceRouter, - ResourceType: gtwy_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Gateway]{ - RequestConverter: converter.GatewayDataModelFromVersioned, - ResponseConverter: converter.GatewayDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Gateway]{ - rp_frontend.PrepareRadiusResource[*datamodel.Gateway], - gtwy_ctrl.ValidateAndMutateRequest, - }, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: gwResourceRouter, - ResourceType: gtwy_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.Gateway]{ - RequestConverter: converter.GatewayDataModelFromVersioned, - ResponseConverter: converter.GatewayDataModelToVersioned, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - // Volumes resource handler registration. - volPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/volumes", validator) - volResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/volumes", validator) - volRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/volumes/{volumeName}", validator) - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: volPlaneRouter, - ResourceType: vol_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ - RequestConverter: converter.VolumeResourceModelFromVersioned, - ResponseConverter: converter.VolumeResourceModelToVersioned, - ListRecursiveQuery: true, - }, - ) - }, - }, - { - ParentRouter: volResourceGroupRouter, - ResourceType: vol_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ - RequestConverter: converter.VolumeResourceModelFromVersioned, - ResponseConverter: converter.VolumeResourceModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: volRouter, - ResourceType: vol_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ - RequestConverter: converter.VolumeResourceModelFromVersioned, - ResponseConverter: converter.VolumeResourceModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: volRouter, - ResourceType: vol_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ - RequestConverter: converter.VolumeResourceModelFromVersioned, - ResponseConverter: converter.VolumeResourceModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.VolumeResource]{ - rp_frontend.PrepareRadiusResource[*datamodel.VolumeResource], - vol_ctrl.ValidateRequest, - }, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: volRouter, - ResourceType: vol_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ - RequestConverter: converter.VolumeResourceModelFromVersioned, - ResponseConverter: converter.VolumeResourceModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.VolumeResource]{ - rp_frontend.PrepareRadiusResource[*datamodel.VolumeResource], - vol_ctrl.ValidateRequest, - }, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: volRouter, - ResourceType: vol_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ - RequestConverter: converter.VolumeResourceModelFromVersioned, - ResponseConverter: converter.VolumeResourceModelToVersioned, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - // Secret Store resource handler. - secretStorePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/secretstores", validator) - secretStoreResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/secretstores", validator) - secretStoreResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/secretstores/{secretStoreName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: secretStorePlaneRouter, - ResourceType: secret_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.SecretStore]{ - ResponseConverter: converter.SecretStoreModelToVersioned, - ListRecursiveQuery: true, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceGroupRouter, - ResourceType: secret_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.SecretStore]{ - ResponseConverter: converter.SecretStoreModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: secret_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.SecretStore]{ - ResponseConverter: converter.SecretStoreModelToVersioned, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: secret_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultSyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.SecretStore]{ - RequestConverter: converter.SecretStoreModelFromVersioned, - ResponseConverter: converter.SecretStoreModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.SecretStore]{ - rp_frontend.PrepareRadiusResource[*datamodel.SecretStore], - secret_ctrl.ValidateAndMutateRequest, - secret_ctrl.UpsertSecret, - }, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: secret_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultSyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.SecretStore]{ - RequestConverter: converter.SecretStoreModelFromVersioned, - ResponseConverter: converter.SecretStoreModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.SecretStore]{ - rp_frontend.PrepareRadiusResource[*datamodel.SecretStore], - secret_ctrl.ValidateAndMutateRequest, - secret_ctrl.UpsertSecret, - }, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: secret_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultSyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.SecretStore]{ - ResponseConverter: converter.SecretStoreModelToVersioned, - DeleteFilters: []frontend_ctrl.DeleteFilter[datamodel.SecretStore]{ - secret_ctrl.DeleteRadiusSecret, - }, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - Path: "/listsecrets", - ResourceType: secret_ctrl.ResourceTypeName, - Method: secret_ctrl.OperationListSecrets, - ControllerFactory: secret_ctrl.NewListSecrets, - }, - }...) - - extPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.core/extenders", validator) - extResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/extenders", validator) - extResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.core/extenders/{extenderName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: extPlaneRouter, - ResourceType: ext_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: extResourceGroupRouter, - ResourceType: ext_ctrl.ResourceTypeName, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - }) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: ext_ctrl.ResourceTypeName, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - }) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: ext_ctrl.ResourceTypeName, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Extender]{ - rp_frontend.PrepareRadiusResource[*datamodel.Extender], - }, - AsyncOperationTimeout: ext_ctrl.AsyncCreateOrUpdateExtenderTimeout, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: ext_ctrl.ResourceTypeName, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Extender]{ - rp_frontend.PrepareRadiusResource[*datamodel.Extender], - }, - AsyncOperationTimeout: ext_ctrl.AsyncCreateOrUpdateExtenderTimeout, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: ext_ctrl.ResourceTypeName, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - AsyncOperationTimeout: ext_ctrl.AsyncDeleteExtenderTimeout, - AsyncOperationRetryAfter: AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: extResourceRouter, - Path: "/listsecrets", - ResourceType: ext_ctrl.ResourceTypeName, - Method: ext_ctrl.OperationListSecrets, - ControllerFactory: ext_ctrl.NewListSecretsExtender, - }, - }...) - - for _, h := range handlerOptions { - if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { - return err - } - } - - return nil -} diff --git a/pkg/corerp/frontend/handler/routes_test.go b/pkg/corerp/frontend/handler/routes_test.go deleted file mode 100644 index b3588d8ed0..0000000000 --- a/pkg/corerp/frontend/handler/routes_test.go +++ /dev/null @@ -1,263 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - "net/http" - "testing" - - "github.com/go-chi/chi/v5" - "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/store" - - app_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/applications" - ctr_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/containers" - env_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/environments" - gtwy_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/gateways" - hrt_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/httproutes" - secret_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/secretstores" - vol_ctrl "github.com/project-radius/radius/pkg/corerp/frontend/controller/volumes" -) - -var handlerTests = []rpctest.HandlerTestSpec{ - { - OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/providers/applications.core/applications", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.core/applications", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/providers/applications.core/containers", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.core/containers", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/providers/applications.core/environments", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.core/environments", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: env_ctrl.OperationGetRecipeMetadata}, - Path: "/resourcegroups/testrg/providers/applications.core/environments/env0/getmetadata", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/providers/applications.core/gateways", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.core/gateways", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/providers/applications.core/httproutes", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.core/httproutes", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/providers/applications.core/secretstores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.core/secretstores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: secret_ctrl.OperationListSecrets}, - Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/providers/applications.core/volumes", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.core/volumes", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: "Applications.Core/operationStatuses", Method: v1.OperationGetOperationStatuses}, - Path: "/providers/applications.core/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: "Applications.Core/operationStatuses", Method: v1.OperationGetOperationResult}, - Path: "/providers/applications.core/locations/global/operationresults/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, -} - -func TestHandlers(t *testing.T) { - mctrl := gomock.NewController(t) - - mockSP := dataprovider.NewMockDataStorageProvider(mctrl) - mockSC := store.NewMockStorageClient(mctrl) - - mockSC.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(&store.Object{}, nil).AnyTimes() - mockSC.EXPECT().Save(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - mockSP.EXPECT().GetStorageClient(gomock.Any(), gomock.Any()).Return(store.StorageClient(mockSC), nil).AnyTimes() - - t.Run("UCP", func(t *testing.T) { - // Test handlers for UCP resources. - rpctest.AssertRouters(t, handlerTests, "/api.ucp.dev", "/planes/radius/local", func(ctx context.Context) (chi.Router, error) { - r := chi.NewRouter() - return r, AddRoutes(ctx, r, false, ctrl.Options{PathBase: "/api.ucp.dev", DataProvider: mockSP}) - }) - }) - - t.Run("Azure", func(t *testing.T) { - // Add azure specific handlers. - azureHandlerTests := append(handlerTests, - rpctest.HandlerTestSpec{ - OperationType: v1.OperationType{Type: "Applications.Core/providers", Method: v1.OperationGet}, - Path: "/providers/applications.core/operations", - Method: http.MethodGet, - WithoutRootScope: true, - SkipOperationTypeValidation: true, - }) - // Test handlers for Azure resources - rpctest.AssertRouters(t, azureHandlerTests, "", "/subscriptions/00000000-0000-0000-0000-000000000000", func(ctx context.Context) (chi.Router, error) { - r := chi.NewRouter() - return r, AddRoutes(ctx, r, true, ctrl.Options{PathBase: "", DataProvider: mockSP}) - }) - }) -} diff --git a/pkg/corerp/frontend/service.go b/pkg/corerp/frontend/service.go deleted file mode 100644 index 0dea840574..0000000000 --- a/pkg/corerp/frontend/service.go +++ /dev/null @@ -1,81 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package frontend - -import ( - "context" - "fmt" - - "github.com/go-chi/chi/v5" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/corerp/frontend/handler" -) - -type Service struct { - server.Service -} - -// NewService creates a new Service instance with the given options. -func NewService(options hostoptions.HostOptions) *Service { - return &Service{ - server.Service{ - Options: options, - ProviderName: handler.ProviderNamespaceName, - }, - } -} - -// Name returns the namespace name of the provider. -func (s *Service) Name() string { - return handler.ProviderNamespaceName -} - -// Run initializes the service and starts the server with the specified options. -func (s *Service) Run(ctx context.Context) error { - if err := s.Init(ctx); err != nil { - return err - } - - opts := ctrl.Options{ - Address: fmt.Sprintf("%s:%d", s.Options.Config.Server.Host, s.Options.Config.Server.Port), - PathBase: s.Options.Config.Server.PathBase, - DataProvider: s.StorageProvider, - KubeClient: s.KubeClient, - StatusManager: s.OperationStatusManager, - } - - err := s.Start(ctx, server.Options{ - Address: opts.Address, - ProviderNamespace: s.ProviderName, - Location: s.Options.Config.Env.RoleLocation, - PathBase: s.Options.Config.Server.PathBase, - // set the arm cert manager for managing client certificate - ArmCertMgr: s.ARMCertManager, - EnableArmAuth: s.Options.Config.Server.EnableArmAuth, // when enabled the client cert validation will be done - Configure: func(router chi.Router) error { - err := handler.AddRoutes(ctx, router, !hostoptions.IsSelfHosted(), opts) - if err != nil { - return err - } - - return nil - }}, - ) - return err -} diff --git a/pkg/corerp/handlers/arm_handler.go b/pkg/corerp/handlers/arm_handler.go index 1be04b5f1f..2352136537 100644 --- a/pkg/corerp/handlers/arm_handler.go +++ b/pkg/corerp/handlers/arm_handler.go @@ -18,15 +18,14 @@ package handlers import ( "context" - "encoding/json" - "errors" "fmt" + "strings" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/resourcemodel" - ucpresources "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/clientv2" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" ) // NewARMHandler creates a new ARMHandler instance with the given ARM configuration, for 'generic' ARM resources. @@ -38,22 +37,14 @@ type armHandler struct { arm *armauth.ArmConfig } -// Put validates that the resource exists and returns the resource so renderers can use it for computed values. It -// returns an error if the resource does not exist. +// Put validates that the resource exists. It returns an error if the resource does not exist. func (handler *armHandler) Put(ctx context.Context, options *PutOptions) (map[string]string, error) { // Do a GET just to validate that the resource exists. - resource, err := getByID(ctx, &handler.arm.ClientOptions, options.Resource.Identity) + _, err := handler.getByID(ctx, options.Resource.ID) if err != nil { return nil, err } - // Return the resource so renderers can use it for computed values. - serialized, err := handler.serializeResource(resource) - if err != nil { - return nil, err - } - options.Resource.Resource = serialized - return map[string]string{}, nil } @@ -62,43 +53,53 @@ func (handler *armHandler) Delete(ctx context.Context, options *DeleteOptions) e return nil } -func (handler *armHandler) serializeResource(resource *armresources.GenericResource) (map[string]interface{}, error) { - // We turn the resource into a weakly-typed representation. This is needed because JSON Pointer - // will have trouble with the autorest embdedded types. - b, err := json.Marshal(&resource) +func (handler *armHandler) getByID(ctx context.Context, id resources.ID) (*armresources.GenericResource, error) { + client, err := clientv2.NewGenericResourceClient(id.FindScope(resources_azure.ScopeSubscriptions), &handler.arm.ClientOptions, nil) if err != nil { - return nil, fmt.Errorf("failed to marshal %T", resource) + return nil, err } - data := map[string]any{} - err = json.Unmarshal(b, &data) + apiVersion, err := handler.lookupARMAPIVersion(ctx, id) if err != nil { - return nil, errors.New("failed to umarshal resource data") + return nil, fmt.Errorf("failed to access resource %q", id) } - return data, nil -} - -func getByID(ctx context.Context, options *clientv2.Options, identity resourcemodel.ResourceIdentity) (*armresources.GenericResource, error) { - id, apiVersion, err := identity.RequireARM() + resp, err := client.GetByID(ctx, id.String(), apiVersion, &armresources.ClientGetByIDOptions{}) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to access resource %q", id) } - parsed, err := ucpresources.ParseResource(id) + return &resp.GenericResource, nil +} + +func (handler *armHandler) lookupARMAPIVersion(ctx context.Context, id resources.ID) (string, error) { + client, err := clientv2.NewProvidersClient(id.FindScope(resources_azure.ScopeSubscriptions), &handler.arm.ClientOptions, nil) if err != nil { - return nil, err + return "", err } - client, err := clientv2.NewGenericResourceClient(parsed.FindScope(ucpresources.SubscriptionsSegment), options, nil) + resp, err := client.Get(ctx, id.ProviderNamespace(), nil) if err != nil { - return nil, err + return "", err } - resp, err := client.GetByID(ctx, id, apiVersion, &armresources.ClientGetByIDOptions{}) - if err != nil { - return nil, fmt.Errorf("failed to access resource %q", id) + // We need to match on the resource type name without the provider namespace. + shortType := strings.TrimPrefix(id.TypeSegments()[0].Type, id.ProviderNamespace()+"/") + for _, rt := range resp.ResourceTypes { + if !strings.EqualFold(shortType, *rt.ResourceType) { + continue + } + if rt.DefaultAPIVersion != nil { + return *rt.DefaultAPIVersion, nil + } + + if len(rt.APIVersions) > 0 { + return *rt.APIVersions[0], nil + } + + return "", fmt.Errorf("could not find API version for type %q, no supported API versions", id.Type()) + } - return &resp.GenericResource, nil + return "", fmt.Errorf("could not find API version for type %q, type was not found", id.Type()) } diff --git a/pkg/corerp/handlers/azure_federatedidentity.go b/pkg/corerp/handlers/azure_federatedidentity.go index 5ed8934622..fe3c4912df 100644 --- a/pkg/corerp/handlers/azure_federatedidentity.go +++ b/pkg/corerp/handlers/azure_federatedidentity.go @@ -24,16 +24,14 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/logging" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/clientv2" + "github.com/radius-project/radius/pkg/logging" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) const ( @@ -109,7 +107,7 @@ func (handler *azureFederatedIdentityHandler) Put(ctx context.Context, options * return nil, errors.New("fails to get identity resource id") } - rs := options.Resource.Resource + rs := options.Resource.CreateResource.Data federatedName, err := GetMapValue[string](rs, FederatedIdentityNameKey) if err != nil { return nil, err @@ -141,8 +139,8 @@ func (handler *azureFederatedIdentityHandler) Put(ctx context.Context, options * return nil, err } - subID := rID.FindScope(resources.SubscriptionsSegment) - rgName := rID.FindScope(resources.ResourceGroupsSegment) + subID := rID.FindScope(resources_azure.ScopeSubscriptions) + rgName := rID.FindScope(resources_azure.ScopeResourceGroups) client, err := clientv2.NewFederatedIdentityClient(subID, &handler.arm.ClientOptions) if err != nil { @@ -156,25 +154,17 @@ func (handler *azureFederatedIdentityHandler) Put(ctx context.Context, options * } // WORKAROUND: Ensure that federal identity credential is populated. (Why not they provide async api?) - _, err = client.Get(ctx, rgName, rID.Name(), federatedName, nil) + response, err := client.Get(ctx, rgName, rID.Name(), federatedName, nil) if err != nil { return nil, err } - options.Resource.Identity = resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - Data: resourcemodel.AzureFederatedIdentity{ - Resource: identityID, - OIDCIssuer: issuer, - Subject: subject, - Audience: AzureFederatedIdentityAudience, - Name: federatedName, - }, + id, err := resources.ParseResource(*response.ID) + if err != nil { + return nil, err } + options.Resource.ID = id logger.Info("Created federated identity for Azure AD identity.", logging.LogFieldLocalID, rpv1.LocalIDFederatedIdentity) return map[string]string{}, nil @@ -186,23 +176,32 @@ func (handler *azureFederatedIdentityHandler) Put(ctx context.Context, options * // azureFederatedIdentityHandler.Delete deletes an Azure Federated Identity resource from the Azure cloud given the // resource's data and subscription ID. func (handler *azureFederatedIdentityHandler) Delete(ctx context.Context, options *DeleteOptions) error { - fi := &resourcemodel.AzureFederatedIdentity{} - if err := store.DecodeMap(options.Resource.Identity.Data, fi); err != nil { - return err - } + subscriptionID := options.Resource.ID.FindScope(resources_azure.ScopeSubscriptions) - rID, err := resources.ParseResource(fi.Resource) + client, err := clientv2.NewFederatedIdentityClient(subscriptionID, &handler.arm.ClientOptions) if err != nil { return err } - subscriptionID := rID.FindScope(resources.SubscriptionsSegment) - - client, err := clientv2.NewFederatedIdentityClient(subscriptionID, &handler.arm.ClientOptions) + // Validate the ID matches the expected type before we start taking it apart to get the names. + expected := resources.KnownType{ + Types: []resources.TypeSegment{ + { + Type: "Microsoft.ManagedIdentity/userAssignedIdentities", + Name: "*", + }, + { + Type: "federatedIdentityCredentials", + Name: "*", + }, + }, + } + err = options.Resource.ID.ValidateResourceType(expected) if err != nil { return err } - _, err = client.Delete(ctx, rID.FindScope(resources.ResourceGroupsSegment), rID.Name(), fi.Name, nil) + typeSegments := options.Resource.ID.TypeSegments() + _, err = client.Delete(ctx, options.Resource.ID.FindScope(resources_azure.ScopeResourceGroups), typeSegments[0].Name, typeSegments[1].Name, nil) return err } diff --git a/pkg/corerp/handlers/azure_fileshare.go b/pkg/corerp/handlers/azure_fileshare.go deleted file mode 100644 index 84678fa980..0000000000 --- a/pkg/corerp/handlers/azure_fileshare.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handlers - -import ( - "context" - "fmt" - - "github.com/project-radius/radius/pkg/azure/armauth" -) - -const ( - FileShareNameKey = "fileshare" - FileShareIDKey = "fileshareid" -) - -// NewAzureFileShareHandler creates a new instance of azureFileShareHandler with the given arm config. -func NewAzureFileShareHandler(arm *armauth.ArmConfig) ResourceHandler { - return &azureFileShareHandler{arm: arm} -} - -type azureFileShareHandler struct { - arm *armauth.ArmConfig -} - -// Put validates the required properties for the resource and creates/modifies the resource using the ARMHandler. -func (handler *azureFileShareHandler) Put(ctx context.Context, options *PutOptions) (map[string]string, error) { - properties, ok := options.Resource.Resource.(map[string]string) - if !ok { - return properties, fmt.Errorf("invalid required properties for resource") - } - - // This assertion is important so we don't start creating/modifying a resource - err := ValidateResourceIDsForResource(properties, FileShareStorageAccountIDKey, FileShareIDKey, FileShareNameKey) - if err != nil { - return nil, err - } - - armhandler := NewARMHandler(handler.arm) - properties, err = armhandler.Put(ctx, options) - if err != nil { - return nil, err - } - return properties, nil -} - -// No-op. Just returns nil. -func (handler *azureFileShareHandler) Delete(ctx context.Context, options *DeleteOptions) error { - return nil -} diff --git a/pkg/corerp/handlers/azure_fileshare_storageaccount.go b/pkg/corerp/handlers/azure_fileshare_storageaccount.go deleted file mode 100644 index 62c8e52065..0000000000 --- a/pkg/corerp/handlers/azure_fileshare_storageaccount.go +++ /dev/null @@ -1,91 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handlers - -import ( - "context" - "fmt" - - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/ucp/resources" -) - -const ( - FileShareStorageAccountNameKey = "filesharestorageaccount" - FileShareStorageAccountIDKey = "filesharestorageaccountid" - AzureFileShareStorageAccountBaseName = "storageaccountbase" -) - -// NewAzureFileShareStorageAccountHandler creates a new instance of the azureFileShareStorageAccountHandler object. -func NewAzureFileShareStorageAccountHandler(arm *armauth.ArmConfig) ResourceHandler { - return &azureFileShareStorageAccountHandler{arm: arm} -} - -type azureFileShareStorageAccountHandler struct { - arm *armauth.ArmConfig -} - -// Put validates the required properties for the resource and checks if the storage account exists. -func (handler *azureFileShareStorageAccountHandler) Put(ctx context.Context, options *PutOptions) (map[string]string, error) { - properties, ok := options.Resource.Resource.(map[string]string) - if !ok { - return nil, fmt.Errorf("invalid required properties for resource") - } - - // This assertion is important so we don't start creating/modifying a resource - err := ValidateResourceIDsForResource(properties, FileShareStorageAccountIDKey, FileShareStorageAccountNameKey) - if err != nil { - return nil, err - } - - _, err = getStorageAccountByID(ctx, *handler.arm, properties[FileShareStorageAccountIDKey]) - if err != nil { - return nil, err - } - - options.Resource.Identity = resourcemodel.NewARMIdentity(&options.Resource.ResourceType, properties[FileShareStorageAccountIDKey], clientv2.StateStoreClientAPIVersion) - - return nil, nil -} - -// No-op. Just returns nil. -func (handler *azureFileShareStorageAccountHandler) Delete(ctx context.Context, options *DeleteOptions) error { - return nil -} - -func getStorageAccountByID(ctx context.Context, arm armauth.ArmConfig, accountID string) (*armstorage.Account, error) { - parsed, err := resources.ParseResource(accountID) - if err != nil { - return nil, fmt.Errorf("failed to parse Storage Account resource id: %w", err) - } - - client, err := clientv2.NewAccountsClient(parsed.FindScope(resources.SubscriptionsSegment), &arm.ClientOptions) - if err != nil { - return nil, fmt.Errorf("failed to create Storage Account client: %w", err) - } - - resp, err := client.GetProperties(ctx, parsed.FindScope(resources.ResourceGroupsSegment), - parsed.TypeSegments()[0].Name, &armstorage.AccountsClientGetPropertiesOptions{}) - if err != nil { - return nil, fmt.Errorf("failed to get Storage Account: %w", err) - } - - return &resp.Account, nil -} diff --git a/pkg/corerp/handlers/azure_roleassignment.go b/pkg/corerp/handlers/azure_roleassignment.go index 1ffa831059..c6f4e062ad 100644 --- a/pkg/corerp/handlers/azure_roleassignment.go +++ b/pkg/corerp/handlers/azure_roleassignment.go @@ -21,14 +21,13 @@ import ( "errors" "fmt" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/azure/roleassignment" - "github.com/project-radius/radius/pkg/logging" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/roleassignment" + "github.com/radius-project/radius/pkg/logging" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) const ( @@ -52,7 +51,7 @@ type azureRoleAssignmentHandler struct { func (handler *azureRoleAssignmentHandler) Put(ctx context.Context, options *PutOptions) (map[string]string, error) { logger := ucplog.FromContextOrDiscard(ctx) - properties, ok := options.Resource.Resource.(map[string]string) + properties, ok := options.Resource.CreateResource.Data.(map[string]string) if !ok { return properties, fmt.Errorf("invalid required properties for resource") } @@ -79,7 +78,7 @@ func (handler *azureRoleAssignmentHandler) Put(ctx context.Context, options *Put // Assign Key Vault Secrets User role to grant managed identity read-only access to the keyvault for secrets. // Assign Key Vault Crypto User role to grant managed identity permissions to perform operations using encryption keys. - roleAssignment, err := roleassignment.Create(ctx, handler.arm, parsedScope.FindScope(resources.SubscriptionsSegment), principalID, scope, roleName) + roleAssignment, err := roleassignment.Create(ctx, handler.arm, parsedScope.FindScope(resources_azure.ScopeSubscriptions), principalID, scope, roleName) if err != nil { return nil, fmt.Errorf( "failed to assign '%s' role to the managed identity '%s' within resource '%s' scope : %w", @@ -87,16 +86,17 @@ func (handler *azureRoleAssignmentHandler) Put(ctx context.Context, options *Put } logger.Info(fmt.Sprintf("Created %s role assignment for %s to access %s", roleName, principalID, scope), logging.LogFieldLocalID, rpv1.LocalIDRoleAssignmentKVKeys) - options.Resource.Identity = resourcemodel.NewARMIdentity(&options.Resource.ResourceType, *roleAssignment.ID, clientv2.RoleAssignmentClientAPIVersion) + id, err := resources.ParseResource(*roleAssignment.ID) + if err != nil { + return nil, err + } + + options.Resource.ID = id return properties, nil } // Delete deletes an Azure role assignment using the provided DeleteOptions. It returns an error if the role assignment // cannot be deleted. func (handler *azureRoleAssignmentHandler) Delete(ctx context.Context, options *DeleteOptions) error { - roleID, _, err := options.Resource.Identity.RequireARM() - if err != nil { - return err - } - return roleassignment.Delete(ctx, handler.arm, roleID) + return roleassignment.Delete(ctx, handler.arm, options.Resource.ID.String()) } diff --git a/pkg/corerp/handlers/azure_userassigned_managedidentity.go b/pkg/corerp/handlers/azure_userassigned_managedidentity.go index 85fad6bf55..32ababcf12 100644 --- a/pkg/corerp/handlers/azure_userassigned_managedidentity.go +++ b/pkg/corerp/handlers/azure_userassigned_managedidentity.go @@ -21,14 +21,14 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - "github.com/project-radius/radius/pkg/logging" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/clientv2" + "github.com/radius-project/radius/pkg/logging" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) const ( @@ -56,7 +56,7 @@ type azureUserAssignedManagedIdentityHandler struct { func (handler *azureUserAssignedManagedIdentityHandler) Put(ctx context.Context, options *PutOptions) (map[string]string, error) { logger := ucplog.FromContextOrDiscard(ctx) - properties, ok := options.Resource.Resource.(map[string]string) + properties, ok := options.Resource.CreateResource.Data.(map[string]string) if !ok { return properties, fmt.Errorf("invalid required properties for resource") } @@ -105,7 +105,12 @@ func (handler *azureUserAssignedManagedIdentityHandler) Put(ctx context.Context, properties[UserAssignedIdentityClientIDKey] = to.String(identity.Properties.ClientID) properties[UserAssignedIdentityTenantIDKey] = to.String(identity.Properties.TenantID) - options.Resource.Identity = resourcemodel.NewARMIdentity(&options.Resource.ResourceType, properties[UserAssignedIdentityIDKey], clientv2.MSIClientAPIVersion) + id, err := resources.ParseResource(properties[UserAssignedIdentityIDKey]) + if err != nil { + return nil, err + } + + options.Resource.ID = id logger.Info("Created managed identity for KeyVault access", logging.LogFieldLocalID, rpv1.LocalIDUserAssignedManagedIdentity) return properties, nil @@ -113,24 +118,14 @@ func (handler *azureUserAssignedManagedIdentityHandler) Put(ctx context.Context, // Delete deletes a user assigned managed identity from Azure using the provided DeleteOptions. func (handler *azureUserAssignedManagedIdentityHandler) Delete(ctx context.Context, options *DeleteOptions) error { - msiResourceID, _, err := options.Resource.Identity.RequireARM() - if err != nil { - return err - } - - parsed, err := resources.ParseResource(msiResourceID) - if err != nil { - return err - } - - subscriptionID := parsed.FindScope(resources.SubscriptionsSegment) + subscriptionID := options.Resource.ID.FindScope(resources_azure.ScopeSubscriptions) msiClient, err := clientv2.NewUserAssignedIdentityClient(subscriptionID, &handler.arm.ClientOptions) if err != nil { return err } - _, err = msiClient.Delete(ctx, parsed.FindScope(resources.ResourceGroupsSegment), parsed.Name(), nil) + _, err = msiClient.Delete(ctx, options.Resource.ID.FindScope(resources_azure.ScopeResourceGroups), options.Resource.ID.Name(), nil) if err != nil { return fmt.Errorf("failed to delete user assigned managed identity: %w", err) diff --git a/pkg/corerp/handlers/kubernetes.go b/pkg/corerp/handlers/kubernetes.go index a870419d78..cbcfa770a3 100644 --- a/pkg/corerp/handlers/kubernetes.go +++ b/pkg/corerp/handlers/kubernetes.go @@ -23,19 +23,21 @@ import ( "strings" "time" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/pkg/ucp/ucplog" - v1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/discovery" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/dynamic/dynamicinformer" "k8s.io/client-go/informers" k8s "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" @@ -43,29 +45,33 @@ import ( ) const ( - // MaxDeploymentTimeout is the max timeout for waiting for a deployment to be ready. - // Deployment duration should not reach to this timeout since async operation worker will time out context before MaxDeploymentTimeout. - MaxDeploymentTimeout = time.Minute * time.Duration(10) // DefaultCacheResyncInterval is the interval for resyncing informer. DefaultCacheResyncInterval = time.Second * time.Duration(30) ) +// Create an interface for deployment waiter and http proxy waiter +type ResourceWaiter interface { + addDynamicEventHandler(ctx context.Context, informerFactory dynamicinformer.DynamicSharedInformerFactory, informer cache.SharedIndexInformer, item client.Object, doneCh chan<- error) + addEventHandler(ctx context.Context, informerFactory informers.SharedInformerFactory, informer cache.SharedIndexInformer, item client.Object, doneCh chan<- error) + waitUntilReady(ctx context.Context, item client.Object) error +} + // NewKubernetesHandler creates a new KubernetesHandler which is used to handle Kubernetes resources. -func NewKubernetesHandler(client client.Client, clientSet k8s.Interface) ResourceHandler { +func NewKubernetesHandler(client client.Client, clientSet k8s.Interface, discoveryClient discovery.ServerResourcesInterface, dynamicClientSet dynamic.Interface) ResourceHandler { return &kubernetesHandler{ - client: client, - clientSet: clientSet, - deploymentTimeOut: MaxDeploymentTimeout, - cacheResyncInterval: DefaultCacheResyncInterval, + client: client, + k8sDiscoveryClient: discoveryClient, + httpProxyWaiter: NewHTTPProxyWaiter(dynamicClientSet), + deploymentWaiter: NewDeploymentWaiter(clientSet), } } type kubernetesHandler struct { - client client.Client - clientSet k8s.Interface - - deploymentTimeOut time.Duration - cacheResyncInterval time.Duration + client client.Client + // k8sDiscoveryClient is the Kubernetes client to used for API version lookups on Kubernetes resources. Override this for testing. + k8sDiscoveryClient discovery.ServerResourcesInterface + httpProxyWaiter ResourceWaiter + deploymentWaiter ResourceWaiter } // Put stores the Kubernetes resource in the cluster and returns the properties of the resource. If the resource is a @@ -90,356 +96,119 @@ func (handler *kubernetesHandler) Put(ctx context.Context, options *PutOptions) return nil, err } - if options.Resource.Deployed { - return properties, nil - } - err = handler.client.Patch(ctx, &item, client.Apply, &client.PatchOptions{FieldManager: kubernetes.FieldManager}) if err != nil { return nil, err } - options.Resource.Identity = resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: options.Resource.ResourceType.Type, - Provider: resourcemodel.ProviderKubernetes, - }, - Data: resourcemodel.KubernetesIdentity{ - Name: item.GetName(), - Namespace: item.GetNamespace(), - Kind: item.GetKind(), - APIVersion: item.GetAPIVersion(), - }, + groupVersion, err := schema.ParseGroupVersion(item.GetAPIVersion()) + if err != nil { + return nil, err } + id := resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + groupVersion.Group, + item.GetKind(), + item.GetNamespace(), + item.GetName()) + options.Resource.ID = id + // Monitor the created or updated resource until it is ready. switch strings.ToLower(item.GetKind()) { case "deployment": // Monitor the deployment until it is ready. - err = handler.waitUntilDeploymentIsReady(ctx, &item) + err = handler.deploymentWaiter.waitUntilReady(ctx, &item) if err != nil { return nil, err } logger.Info(fmt.Sprintf("Deployment %s in namespace %s is ready", item.GetName(), item.GetNamespace())) return properties, nil + case "httpproxy": + err = handler.httpProxyWaiter.waitUntilReady(ctx, &item) + if err != nil { + return nil, err + } + logger.Info(fmt.Sprintf("HTTP Proxy %s in namespace %s is ready", item.GetName(), item.GetNamespace())) + return properties, nil default: // We do not monitor the other resource types. return properties, nil } } -func (handler *kubernetesHandler) waitUntilDeploymentIsReady(ctx context.Context, item client.Object) error { - logger := ucplog.FromContextOrDiscard(ctx) - - // When the deployment is done, an error nil will be sent - // In case of an error, the error will be sent - doneCh := make(chan error, 1) - - ctx, cancel := context.WithTimeout(ctx, handler.deploymentTimeOut) - // This ensures that the informer is stopped when this function is returned. - defer cancel() - - err := handler.startInformers(ctx, item, doneCh) +// Delete decodes the identity data from the DeleteOptions, creates an unstructured object from the identity data, +// and then attempts to delete the object from the Kubernetes cluster, returning an error if one occurs. +func (handler *kubernetesHandler) Delete(ctx context.Context, options *DeleteOptions) error { + apiVersion, err := handler.lookupKubernetesAPIVersion(ctx, options.Resource.ID) if err != nil { - logger.Error(err, "failed to start deployment informer") - return err - } - - select { - case <-ctx.Done(): - // Get the final deployment status - dep, err := handler.clientSet.AppsV1().Deployments(item.GetNamespace()).Get(ctx, item.GetName(), metav1.GetOptions{}) - if err != nil { - return fmt.Errorf("deployment timed out, name: %s, namespace %s, error occured while fetching latest status: %w", item.GetName(), item.GetNamespace(), err) - } - - // Now get the latest available observation of deployment current state - // note that there can be a race condition here, by the time it fetches the latest status, deployment might be succeeded - status := v1.DeploymentCondition{} - if len(dep.Status.Conditions) > 0 { - status = dep.Status.Conditions[len(dep.Status.Conditions)-1] - } - return fmt.Errorf("deployment timed out, name: %s, namespace %s, status: %s, reason: %s", item.GetName(), item.GetNamespace(), status.Message, status.Reason) - - case err := <-doneCh: - if err == nil { - logger.Info(fmt.Sprintf("Marking deployment %s in namespace %s as complete", item.GetName(), item.GetNamespace())) - } return err } -} -func (handler *kubernetesHandler) addEventHandler(ctx context.Context, informerFactory informers.SharedInformerFactory, informer cache.SharedIndexInformer, item client.Object, doneCh chan<- error) { - logger := ucplog.FromContextOrDiscard(ctx) - - _, err := informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj any) { - handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) - }, - UpdateFunc: func(_, newObj any) { - handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + group, kind, namespace, name := resources_kubernetes.ToParts(options.Resource.ID) + item := unstructured.Unstructured{ + Object: map[string]any{ + "apiVersion": schema.GroupVersion{Group: group, Version: apiVersion}.String(), + "kind": kind, + "metadata": map[string]any{ + "namespace": namespace, + "name": name, + }, }, - }) - - if err != nil { - logger.Error(err, "failed to add event handler") - } -} - -func (handler *kubernetesHandler) startInformers(ctx context.Context, item client.Object, doneCh chan<- error) error { - logger := ucplog.FromContextOrDiscard(ctx) - informerFactory := informers.NewSharedInformerFactoryWithOptions(handler.clientSet, handler.cacheResyncInterval, informers.WithNamespace(item.GetNamespace())) - // Add event handlers to the pod informer - handler.addEventHandler(ctx, informerFactory, informerFactory.Core().V1().Pods().Informer(), item, doneCh) - - // Add event handlers to the deployment informer - handler.addEventHandler(ctx, informerFactory, informerFactory.Apps().V1().Deployments().Informer(), item, doneCh) - - // Add event handlers to the replicaset informer - handler.addEventHandler(ctx, informerFactory, informerFactory.Apps().V1().ReplicaSets().Informer(), item, doneCh) - - // Start the informers - informerFactory.Start(ctx.Done()) - - // Wait for the deployment and pod informer's cache to be synced. - informerFactory.WaitForCacheSync(ctx.Done()) - - logger.Info(fmt.Sprintf("Informers started and caches synced for deployment: %s in namespace: %s", item.GetName(), item.GetNamespace())) - return nil -} - -// Check if all the pods in the deployment are ready -func (handler *kubernetesHandler) checkDeploymentStatus(ctx context.Context, informerFactory informers.SharedInformerFactory, item client.Object, doneCh chan<- error) bool { - logger := ucplog.FromContextOrDiscard(ctx).WithValues("deploymentName", item.GetName(), "namespace", item.GetNamespace()) - - // Get the deployment - deployment, err := informerFactory.Apps().V1().Deployments().Lister().Deployments(item.GetNamespace()).Get(item.GetName()) - if err != nil { - logger.Info("Unable to find deployment") - return false - } - - deploymentReplicaSet := handler.getCurrentReplicaSetForDeployment(ctx, informerFactory, deployment) - if deploymentReplicaSet == nil { - logger.Info("Unable to find replica set for deployment") - return false - } - - allReady := handler.checkAllPodsReady(ctx, informerFactory, deployment, deploymentReplicaSet, doneCh) - if !allReady { - logger.Info("All pods are not ready yet for deployment") - return false - } - - // Check if the deployment is ready - if deployment.Status.ObservedGeneration != deployment.Generation { - logger.Info(fmt.Sprintf("Deployment status is not ready: Observed generation: %d, Generation: %d, Deployment Replicaset: %s", deployment.Status.ObservedGeneration, deployment.Generation, deploymentReplicaSet.Name)) - return false } - // ObservedGeneration should be updated to latest generation to avoid stale replicas - for _, c := range deployment.Status.Conditions { - // check for complete deployment condition - // Reference https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#complete-deployment - if c.Type == v1.DeploymentProgressing && c.Status == corev1.ConditionTrue && strings.EqualFold(c.Reason, "NewReplicaSetAvailable") { - logger.Info(fmt.Sprintf("Deployment is ready. Observed generation: %d, Generation: %d, Deployment Replicaset: %s", deployment.Status.ObservedGeneration, deployment.Generation, deploymentReplicaSet.Name)) - doneCh <- nil - return true - } else { - logger.Info(fmt.Sprintf("Deployment status is: %s - %s, Reason: %s, Deployment replicaset: %s", c.Type, c.Status, c.Reason, deploymentReplicaSet.Name)) - } - } - return false + return client.IgnoreNotFound(handler.client.Delete(ctx, &item)) } -// Gets the current replica set for the deployment -func (handler *kubernetesHandler) getCurrentReplicaSetForDeployment(ctx context.Context, informerFactory informers.SharedInformerFactory, deployment *v1.Deployment) *v1.ReplicaSet { - if deployment == nil { - return nil - } - - logger := ucplog.FromContextOrDiscard(ctx).WithValues("deploymentName", deployment.Name, "namespace", deployment.Namespace) - - // List all replicasets for this deployment - rl, err := informerFactory.Apps().V1().ReplicaSets().Lister().ReplicaSets(deployment.Namespace).List(labels.Everything()) - if err != nil { - // This is a valid state which will eventually be resolved. Therefore, only log the error here. - logger.Info(fmt.Sprintf("Unable to list replicasets for deployment: %s", err.Error())) - return nil - } - - if len(rl) == 0 { - // This is a valid state which will eventually be resolved. Therefore, only log the error here. - return nil - } - - deploymentRevision := deployment.Annotations["deployment.kubernetes.io/revision"] - - // Find the latest ReplicaSet associated with the deployment - for _, rs := range rl { - if !metav1.IsControlledBy(rs, deployment) { - continue - } - if rs.Annotations == nil { - continue - } - revision, ok := rs.Annotations["deployment.kubernetes.io/revision"] - if !ok { - continue +func (handler *kubernetesHandler) lookupKubernetesAPIVersion(ctx context.Context, id resources.ID) (string, error) { + group, kind, namespace, _ := resources_kubernetes.ToParts(id) + var resourceLists []*metav1.APIResourceList + var err error + if namespace == "" { + resourceLists, err = handler.k8sDiscoveryClient.ServerPreferredResources() + if err != nil { + return "", fmt.Errorf("could not find API version for type %q: %w", id.Type(), err) } - - // The first answer here https://stackoverflow.com/questions/59848252/kubectl-retrieving-the-current-new-replicaset-for-a-deployment-in-json-forma - // looks like the best way to determine the current replicaset. - // Match the replica set revision with the deployment revision - if deploymentRevision == revision { - return rs + } else { + resourceLists, err = handler.k8sDiscoveryClient.ServerPreferredNamespacedResources() + if err != nil { + return "", fmt.Errorf("could not find API version for type %q: %w", id.Type(), err) } } - return nil -} - -func (handler *kubernetesHandler) checkAllPodsReady(ctx context.Context, informerFactory informers.SharedInformerFactory, obj *v1.Deployment, deploymentReplicaSet *v1.ReplicaSet, doneCh chan<- error) bool { - logger := ucplog.FromContextOrDiscard(ctx).WithValues("deploymentName", obj.GetName(), "namespace", obj.GetNamespace()) - logger.Info("Checking if all pods in the deployment are ready") - - podsInDeployment, err := handler.getPodsInDeployment(ctx, informerFactory, obj, deploymentReplicaSet) - if err != nil { - logger.Info(fmt.Sprintf("Error getting pods for deployment: %s", err.Error())) - return false - } - - allReady := true - for _, pod := range podsInDeployment { - podReady, err := handler.checkPodStatus(ctx, &pod) + for _, resourceList := range resourceLists { + // We know the group but not the version. This will give us the the list of resources and their preferred versions. + gv, err := schema.ParseGroupVersion(resourceList.GroupVersion) if err != nil { - // Terminate the deployment and return the error encountered - doneCh <- err - return false - } - if !podReady { - allReady = false + return "", err } - } - - if allReady { - logger.Info(fmt.Sprintf("All %d pods in the deployment are ready", len(podsInDeployment))) - } - return allReady -} - -func (handler *kubernetesHandler) getPodsInDeployment(ctx context.Context, informerFactory informers.SharedInformerFactory, deployment *v1.Deployment, deploymentReplicaSet *v1.ReplicaSet) ([]corev1.Pod, error) { - logger := ucplog.FromContextOrDiscard(ctx) - - pods := []corev1.Pod{} - - // List all pods that match the current replica set - pl, err := informerFactory.Core().V1().Pods().Lister().Pods(deployment.GetNamespace()).List(labels.Set(deployment.Spec.Selector.MatchLabels).AsSelector()) - if err != nil { - logger.Info(fmt.Sprintf("Unable to find pods for deployment %s in namespace %s", deployment.GetName(), deployment.GetNamespace())) - return []corev1.Pod{}, nil - } - // Filter out the pods that are not in the Deployment's current ReplicaSet - for _, p := range pl { - if !metav1.IsControlledBy(p, deploymentReplicaSet) { + if group != gv.Group { continue } - pods = append(pods, *p) - } - - return pods, nil -} - -func (handler *kubernetesHandler) checkPodStatus(ctx context.Context, pod *corev1.Pod) (bool, error) { - logger := ucplog.FromContextOrDiscard(ctx).WithValues("podName", pod.Name, "namespace", pod.Namespace) - - conditionPodReady := true - for _, cc := range pod.Status.Conditions { - if cc.Type == corev1.PodReady && cc.Status != corev1.ConditionTrue { - // Do not return false here else if the pod transitions to a crash loop backoff state, - // we won't be able to detect that condition. - conditionPodReady = false - } - - if cc.Type == corev1.ContainersReady && cc.Status != corev1.ConditionTrue { - // Do not return false here else if the pod transitions to a crash loop backoff state, - // we won't be able to detect that condition. - conditionPodReady = false - } - } - - // Sometimes container statuses are not yet available and we do not want to falsely return that the containers are ready - if len(pod.Status.ContainerStatuses) <= 0 { - return false, nil - } - for _, cs := range pod.Status.ContainerStatuses { - // Check if the container state is terminated or unable to start due to crash loop, image pull back off or error - // Note that sometimes a pod can go into running state but can crash later and can go undetected by this condition - // We will rely on the user defining a readiness probe to ensure that the pod is ready to serve traffic for those cases - if cs.State.Terminated != nil { - logger.Info(fmt.Sprintf("Container state is terminated Reason: %s, Message: %s", cs.State.Terminated.Reason, cs.State.Terminated.Message)) - return false, fmt.Errorf("Container state is 'Terminated' Reason: %s, Message: %s", cs.State.Terminated.Reason, cs.State.Terminated.Message) - } else if cs.State.Waiting != nil { - if cs.State.Waiting.Reason == "ErrImagePull" || cs.State.Waiting.Reason == "CrashLoopBackOff" || cs.State.Waiting.Reason == "ImagePullBackOff" { - message := cs.State.Waiting.Message - if cs.LastTerminationState.Terminated != nil { - message += " LastTerminationState: " + cs.LastTerminationState.Terminated.Message - } - return false, fmt.Errorf("Container state is 'Waiting' Reason: %s, Message: %s", cs.State.Waiting.Reason, message) - } else { - return false, nil + for _, resource := range resourceList.APIResources { + if resource.Kind == kind { + return gv.Version, nil } - } else if cs.State.Running == nil { - // The container is not yet running - return false, nil - } else if !cs.Ready { - // The container is running but has not passed its readiness probe yet - return false, nil } } - if !conditionPodReady { - return false, nil - } - logger.Info("All containers for pod are ready") - return true, nil -} - -// Delete decodes the identity data from the DeleteOptions, creates an unstructured object from the identity data, -// and then attempts to delete the object from the Kubernetes cluster, returning an error if one occurs. -func (handler *kubernetesHandler) Delete(ctx context.Context, options *DeleteOptions) error { - identity := &resourcemodel.KubernetesIdentity{} - if err := store.DecodeMap(options.Resource.Identity.Data, identity); err != nil { - return err - } - - item := unstructured.Unstructured{ - Object: map[string]any{ - "apiVersion": identity.APIVersion, - "kind": identity.Kind, - "metadata": map[string]any{ - "namespace": identity.Namespace, - "name": identity.Name, - }, - }, - } - - return client.IgnoreNotFound(handler.client.Delete(ctx, &item)) + return "", fmt.Errorf("could not find API version for type %q, type was not found", id.Type()) } func convertToUnstructured(resource rpv1.OutputResource) (unstructured.Unstructured, error) { - if resource.ResourceType.Provider != resourcemodel.ProviderKubernetes { - return unstructured.Unstructured{}, fmt.Errorf("invalid resource type provider: %s", resource.ResourceType.Provider) - } - - obj, ok := resource.Resource.(runtime.Object) + obj, ok := resource.CreateResource.Data.(runtime.Object) if !ok { return unstructured.Unstructured{}, errors.New("inner type was not a runtime.Object") } - c, err := runtime.DefaultUnstructuredConverter.ToUnstructured(resource.Resource) + resourceType := resource.GetResourceType() + if resourceType.Provider != resourcemodel.ProviderKubernetes { + return unstructured.Unstructured{}, fmt.Errorf("invalid resource type provider: %s", resourceType.Provider) + } + + c, err := runtime.DefaultUnstructuredConverter.ToUnstructured(resource.CreateResource.Data) if err != nil { return unstructured.Unstructured{}, fmt.Errorf("could not convert object %v to unstructured: %w", obj.GetObjectKind(), err) } diff --git a/pkg/corerp/handlers/kubernetes_deployment_waiter.go b/pkg/corerp/handlers/kubernetes_deployment_waiter.go new file mode 100644 index 0000000000..71d61ebff0 --- /dev/null +++ b/pkg/corerp/handlers/kubernetes_deployment_waiter.go @@ -0,0 +1,323 @@ +package handlers + +import ( + "context" + "fmt" + "strings" + "time" + + "github.com/radius-project/radius/pkg/ucp/ucplog" + v1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/dynamic/dynamicinformer" + "k8s.io/client-go/informers" + k8s "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/cache" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const ( + // MaxDeploymentTimeout is the max timeout for waiting for a deployment to be ready. + // Deployment duration should not reach to this timeout since async operation worker will time out context before MaxDeploymentTimeout. + MaxDeploymentTimeout = time.Minute * time.Duration(10) +) + +type deploymentWaiter struct { + clientSet k8s.Interface + deploymentTimeOut time.Duration + cacheResyncInterval time.Duration +} + +func NewDeploymentWaiter(clientSet k8s.Interface) *deploymentWaiter { + return &deploymentWaiter{ + clientSet: clientSet, + deploymentTimeOut: MaxDeploymentTimeout, + cacheResyncInterval: DefaultCacheResyncInterval, + } +} + +func (handler *deploymentWaiter) addEventHandler(ctx context.Context, informerFactory informers.SharedInformerFactory, informer cache.SharedIndexInformer, item client.Object, doneCh chan<- error) { + logger := ucplog.FromContextOrDiscard(ctx) + + _, err := informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj any) { + handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + }, + UpdateFunc: func(_, newObj any) { + handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + }, + }) + + if err != nil { + logger.Error(err, "failed to add event handler") + } +} + +// addDynamicEventHandler is not implemented for deploymentWaiter +func (handler *deploymentWaiter) addDynamicEventHandler(ctx context.Context, informerFactory dynamicinformer.DynamicSharedInformerFactory, informer cache.SharedIndexInformer, item client.Object, doneCh chan<- error) { +} + +func (handler *deploymentWaiter) waitUntilReady(ctx context.Context, item client.Object) error { + logger := ucplog.FromContextOrDiscard(ctx) + + // When the deployment is done, an error nil will be sent + // In case of an error, the error will be sent + doneCh := make(chan error, 1) + + ctx, cancel := context.WithTimeout(ctx, handler.deploymentTimeOut) + // This ensures that the informer is stopped when this function is returned. + defer cancel() + + err := handler.startInformers(ctx, item, doneCh) + if err != nil { + logger.Error(err, "failed to start deployment informer") + return err + } + + select { + case <-ctx.Done(): + // Get the final deployment status + dep, err := handler.clientSet.AppsV1().Deployments(item.GetNamespace()).Get(ctx, item.GetName(), metav1.GetOptions{}) + if err != nil { + return fmt.Errorf("deployment timed out, name: %s, namespace %s, error occured while fetching latest status: %w", item.GetName(), item.GetNamespace(), err) + } + + // Now get the latest available observation of deployment current state + // note that there can be a race condition here, by the time it fetches the latest status, deployment might be succeeded + status := v1.DeploymentCondition{} + if len(dep.Status.Conditions) > 0 { + status = dep.Status.Conditions[len(dep.Status.Conditions)-1] + } + return fmt.Errorf("deployment timed out, name: %s, namespace %s, status: %s, reason: %s", item.GetName(), item.GetNamespace(), status.Message, status.Reason) + + case err := <-doneCh: + if err == nil { + logger.Info(fmt.Sprintf("Marking deployment %s in namespace %s as complete", item.GetName(), item.GetNamespace())) + } + return err + } +} + +// Check if all the pods in the deployment are ready +func (handler *deploymentWaiter) checkDeploymentStatus(ctx context.Context, informerFactory informers.SharedInformerFactory, item client.Object, doneCh chan<- error) bool { + logger := ucplog.FromContextOrDiscard(ctx).WithValues("deploymentName", item.GetName(), "namespace", item.GetNamespace()) + + // Get the deployment + deployment, err := informerFactory.Apps().V1().Deployments().Lister().Deployments(item.GetNamespace()).Get(item.GetName()) + if err != nil { + logger.Info("Unable to find deployment") + return false + } + + deploymentReplicaSet := handler.getCurrentReplicaSetForDeployment(ctx, informerFactory, deployment) + if deploymentReplicaSet == nil { + logger.Info("Unable to find replica set for deployment") + return false + } + + allReady := handler.checkAllPodsReady(ctx, informerFactory, deployment, deploymentReplicaSet, doneCh) + if !allReady { + logger.Info("All pods are not ready yet for deployment") + return false + } + + // Check if the deployment is ready + if deployment.Status.ObservedGeneration != deployment.Generation { + logger.Info(fmt.Sprintf("Deployment status is not ready: Observed generation: %d, Generation: %d, Deployment Replicaset: %s", deployment.Status.ObservedGeneration, deployment.Generation, deploymentReplicaSet.Name)) + return false + } + + // ObservedGeneration should be updated to latest generation to avoid stale replicas + for _, c := range deployment.Status.Conditions { + // check for complete deployment condition + // Reference https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#complete-deployment + if c.Type == v1.DeploymentProgressing && c.Status == corev1.ConditionTrue && strings.EqualFold(c.Reason, "NewReplicaSetAvailable") { + logger.Info(fmt.Sprintf("Deployment is ready. Observed generation: %d, Generation: %d, Deployment Replicaset: %s", deployment.Status.ObservedGeneration, deployment.Generation, deploymentReplicaSet.Name)) + doneCh <- nil + return true + } else { + logger.Info(fmt.Sprintf("Deployment status is: %s - %s, Reason: %s, Deployment replicaset: %s", c.Type, c.Status, c.Reason, deploymentReplicaSet.Name)) + } + } + return false +} + +func (handler *deploymentWaiter) startInformers(ctx context.Context, item client.Object, doneCh chan<- error) error { + logger := ucplog.FromContextOrDiscard(ctx) + + informerFactory := informers.NewSharedInformerFactoryWithOptions(handler.clientSet, handler.cacheResyncInterval, informers.WithNamespace(item.GetNamespace())) + // Add event handlers to the pod informer + handler.addEventHandler(ctx, informerFactory, informerFactory.Core().V1().Pods().Informer(), item, doneCh) + + // Add event handlers to the deployment informer + handler.addEventHandler(ctx, informerFactory, informerFactory.Apps().V1().Deployments().Informer(), item, doneCh) + + // Add event handlers to the replicaset informer + handler.addEventHandler(ctx, informerFactory, informerFactory.Apps().V1().ReplicaSets().Informer(), item, doneCh) + + // Start the informers + informerFactory.Start(ctx.Done()) + + // Wait for the deployment and pod informer's cache to be synced. + informerFactory.WaitForCacheSync(ctx.Done()) + + logger.Info(fmt.Sprintf("Informers started and caches synced for deployment: %s in namespace: %s", item.GetName(), item.GetNamespace())) + return nil +} + +// Gets the current replica set for the deployment +func (handler *deploymentWaiter) getCurrentReplicaSetForDeployment(ctx context.Context, informerFactory informers.SharedInformerFactory, deployment *v1.Deployment) *v1.ReplicaSet { + if deployment == nil { + return nil + } + + logger := ucplog.FromContextOrDiscard(ctx).WithValues("deploymentName", deployment.Name, "namespace", deployment.Namespace) + + // List all replicasets for this deployment + rl, err := informerFactory.Apps().V1().ReplicaSets().Lister().ReplicaSets(deployment.Namespace).List(labels.Everything()) + if err != nil { + // This is a valid state which will eventually be resolved. Therefore, only log the error here. + logger.Info(fmt.Sprintf("Unable to list replicasets for deployment: %s", err.Error())) + return nil + } + + if len(rl) == 0 { + // This is a valid state which will eventually be resolved. Therefore, only log the error here. + return nil + } + + deploymentRevision := deployment.Annotations["deployment.kubernetes.io/revision"] + + // Find the latest ReplicaSet associated with the deployment + for _, rs := range rl { + if !metav1.IsControlledBy(rs, deployment) { + continue + } + if rs.Annotations == nil { + continue + } + revision, ok := rs.Annotations["deployment.kubernetes.io/revision"] + if !ok { + continue + } + + // The first answer here https://stackoverflow.com/questions/59848252/kubectl-retrieving-the-current-new-replicaset-for-a-deployment-in-json-forma + // looks like the best way to determine the current replicaset. + // Match the replica set revision with the deployment revision + if deploymentRevision == revision { + return rs + } + } + + return nil +} + +func (handler *deploymentWaiter) checkAllPodsReady(ctx context.Context, informerFactory informers.SharedInformerFactory, obj *v1.Deployment, deploymentReplicaSet *v1.ReplicaSet, doneCh chan<- error) bool { + logger := ucplog.FromContextOrDiscard(ctx).WithValues("deploymentName", obj.GetName(), "namespace", obj.GetNamespace()) + logger.Info("Checking if all pods in the deployment are ready") + + podsInDeployment, err := handler.getPodsInDeployment(ctx, informerFactory, obj, deploymentReplicaSet) + if err != nil { + logger.Info(fmt.Sprintf("Error getting pods for deployment: %s", err.Error())) + return false + } + + allReady := true + for _, pod := range podsInDeployment { + podReady, err := handler.checkPodStatus(ctx, &pod) + if err != nil { + // Terminate the deployment and return the error encountered + doneCh <- err + return false + } + if !podReady { + allReady = false + } + } + + if allReady { + logger.Info(fmt.Sprintf("All %d pods in the deployment are ready", len(podsInDeployment))) + } + return allReady +} + +func (handler *deploymentWaiter) getPodsInDeployment(ctx context.Context, informerFactory informers.SharedInformerFactory, deployment *v1.Deployment, deploymentReplicaSet *v1.ReplicaSet) ([]corev1.Pod, error) { + logger := ucplog.FromContextOrDiscard(ctx) + + pods := []corev1.Pod{} + + // List all pods that match the current replica set + pl, err := informerFactory.Core().V1().Pods().Lister().Pods(deployment.GetNamespace()).List(labels.Set(deployment.Spec.Selector.MatchLabels).AsSelector()) + if err != nil { + logger.Info(fmt.Sprintf("Unable to find pods for deployment %s in namespace %s", deployment.GetName(), deployment.GetNamespace())) + return []corev1.Pod{}, nil + } + + // Filter out the pods that are not in the Deployment's current ReplicaSet + for _, p := range pl { + if !metav1.IsControlledBy(p, deploymentReplicaSet) { + continue + } + pods = append(pods, *p) + } + + return pods, nil +} + +func (handler *deploymentWaiter) checkPodStatus(ctx context.Context, pod *corev1.Pod) (bool, error) { + logger := ucplog.FromContextOrDiscard(ctx).WithValues("podName", pod.Name, "namespace", pod.Namespace) + + conditionPodReady := true + for _, cc := range pod.Status.Conditions { + if cc.Type == corev1.PodReady && cc.Status != corev1.ConditionTrue { + // Do not return false here else if the pod transitions to a crash loop backoff state, + // we won't be able to detect that condition. + conditionPodReady = false + } + + if cc.Type == corev1.ContainersReady && cc.Status != corev1.ConditionTrue { + // Do not return false here else if the pod transitions to a crash loop backoff state, + // we won't be able to detect that condition. + conditionPodReady = false + } + } + + // Sometimes container statuses are not yet available and we do not want to falsely return that the containers are ready + if len(pod.Status.ContainerStatuses) <= 0 { + return false, nil + } + + for _, cs := range pod.Status.ContainerStatuses { + // Check if the container state is terminated or unable to start due to crash loop, image pull back off or error + // Note that sometimes a pod can go into running state but can crash later and can go undetected by this condition + // We will rely on the user defining a readiness probe to ensure that the pod is ready to serve traffic for those cases + if cs.State.Terminated != nil { + logger.Info(fmt.Sprintf("Container state is terminated Reason: %s, Message: %s", cs.State.Terminated.Reason, cs.State.Terminated.Message)) + return false, fmt.Errorf("Container state is 'Terminated' Reason: %s, Message: %s", cs.State.Terminated.Reason, cs.State.Terminated.Message) + } else if cs.State.Waiting != nil { + if cs.State.Waiting.Reason == "ErrImagePull" || cs.State.Waiting.Reason == "CrashLoopBackOff" || cs.State.Waiting.Reason == "ImagePullBackOff" { + message := cs.State.Waiting.Message + if cs.LastTerminationState.Terminated != nil { + message += " LastTerminationState: " + cs.LastTerminationState.Terminated.Message + } + return false, fmt.Errorf("Container state is 'Waiting' Reason: %s, Message: %s", cs.State.Waiting.Reason, message) + } else { + return false, nil + } + } else if cs.State.Running == nil { + // The container is not yet running + return false, nil + } else if !cs.Ready { + // The container is running but has not passed its readiness probe yet + return false, nil + } + } + + if !conditionPodReady { + return false, nil + } + logger.Info("All containers for pod are ready") + return true, nil +} diff --git a/pkg/corerp/handlers/kubernetes_deployment_waiter_test.go b/pkg/corerp/handlers/kubernetes_deployment_waiter_test.go new file mode 100644 index 0000000000..c7b48968a4 --- /dev/null +++ b/pkg/corerp/handlers/kubernetes_deployment_waiter_test.go @@ -0,0 +1,1116 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handlers + +import ( + "context" + "testing" + "time" + + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/k8sutil" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + v1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes/fake" +) + +var testDeployment = &v1.Deployment{ + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + }, + Spec: v1.DeploymentSpec{ + Replicas: to.Ptr(int32(1)), + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app": "test", + }, + }, + }, + Status: v1.DeploymentStatus{ + Conditions: []v1.DeploymentCondition{ + { + Type: v1.DeploymentProgressing, + Status: corev1.ConditionTrue, + Reason: "NewReplicaSetAvailable", + Message: "Deployment has minimum availability", + }, + }, + }, +} + +func addReplicaSetToDeployment(t *testing.T, ctx context.Context, clientset *fake.Clientset, deployment *v1.Deployment) *v1.ReplicaSet { + replicaSet := &v1.ReplicaSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-replicaset-1", + Namespace: deployment.Namespace, + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ + Group: v1.SchemeGroupVersion.Group, + Version: v1.SchemeGroupVersion.Version, + Kind: "Deployment", + }), + }, + }, + } + + // Add the ReplicaSet objects to the fake Kubernetes clientset + _, err := clientset.AppsV1().ReplicaSets(replicaSet.Namespace).Create(ctx, replicaSet, metav1.CreateOptions{}) + require.NoError(t, err) + + _, err = clientset.AppsV1().Deployments(deployment.Namespace).Update(ctx, deployment, metav1.UpdateOptions{}) + require.NoError(t, err) + + return replicaSet +} + +func startInformers(ctx context.Context, clientSet *fake.Clientset, handler *kubernetesHandler) informers.SharedInformerFactory { + // Create a fake replicaset informer and start + informerFactory := informers.NewSharedInformerFactory(clientSet, 0) + + // Add informers + informerFactory.Apps().V1().Deployments().Informer() + informerFactory.Apps().V1().ReplicaSets().Informer() + informerFactory.Core().V1().Pods().Informer() + + informerFactory.Start(context.Background().Done()) + informerFactory.WaitForCacheSync(ctx.Done()) + return informerFactory +} + +func TestWaitUntilReady_NewResource(t *testing.T) { + ctx := context.Background() + + // Create first deployment that will be watched + deployment := &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + Labels: map[string]string{ + kubernetes.LabelManagedBy: kubernetes.LabelManagedByRadiusRP, + }, + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + }, + Spec: v1.DeploymentSpec{ + Replicas: to.Ptr(int32(1)), + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app": "test", + }, + }, + }, + Status: v1.DeploymentStatus{ + Conditions: []v1.DeploymentCondition{ + { + Type: v1.DeploymentProgressing, + Status: corev1.ConditionTrue, + Reason: "NewReplicaSetAvailable", + Message: "Deployment has minimum availability", + }, + }, + }, + } + + clientset := fake.NewSimpleClientset(deployment) + + // The deployment is not marked as ready till we find a replica set. Therefore, we need to create one. + addReplicaSetToDeployment(t, ctx, clientset, deployment) + + handler := kubernetesHandler{ + client: k8sutil.NewFakeKubeClient(nil), + deploymentWaiter: &deploymentWaiter{ + clientSet: clientset, + deploymentTimeOut: time.Duration(50) * time.Second, + cacheResyncInterval: time.Duration(10) * time.Second, + }, + } + + err := handler.deploymentWaiter.waitUntilReady(ctx, deployment) + require.NoError(t, err, "Failed to wait for deployment to be ready") +} + +func TestWaitUntilReady_Timeout(t *testing.T) { + ctx := context.Background() + // Create first deployment that will be watched + deployment := &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + }, + Status: v1.DeploymentStatus{ + Conditions: []v1.DeploymentCondition{ + { + Type: v1.DeploymentProgressing, + Status: corev1.ConditionFalse, + Reason: "NewReplicaSetAvailable", + Message: "Deployment has minimum availability", + }, + }, + }, + } + + deploymentClient := fake.NewSimpleClientset(deployment) + + handler := kubernetesHandler{ + client: k8sutil.NewFakeKubeClient(nil), + deploymentWaiter: &deploymentWaiter{ + clientSet: deploymentClient, + deploymentTimeOut: time.Duration(1) * time.Second, + cacheResyncInterval: time.Duration(10) * time.Second, + }, + } + + err := handler.deploymentWaiter.waitUntilReady(ctx, deployment) + require.Error(t, err) + require.Equal(t, "deployment timed out, name: test-deployment, namespace test-namespace, status: Deployment has minimum availability, reason: NewReplicaSetAvailable", err.Error()) +} + +func TestWaitUntilReady_DifferentResourceName(t *testing.T) { + ctx := context.Background() + // Create first deployment that will be watched + deployment := &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + }, + Status: v1.DeploymentStatus{ + Conditions: []v1.DeploymentCondition{ + { + Type: v1.DeploymentProgressing, + Status: corev1.ConditionTrue, + Reason: "NewReplicaSetAvailable", + Message: "Deployment has minimum availability", + }, + }, + }, + } + + clientset := fake.NewSimpleClientset(deployment) + + handler := kubernetesHandler{ + deploymentWaiter: &deploymentWaiter{ + clientSet: clientset, + deploymentTimeOut: time.Duration(1) * time.Second, + cacheResyncInterval: time.Duration(10) * time.Second, + }, + } + + err := handler.deploymentWaiter.waitUntilReady(ctx, &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "not-matched-deployment", + Namespace: "test-namespace", + }, + }) + + // It must be timed out because the name of the deployment does not match. + require.Error(t, err) + require.Equal(t, "deployment timed out, name: not-matched-deployment, namespace test-namespace, error occured while fetching latest status: deployments.apps \"not-matched-deployment\" not found", err.Error()) +} + +func TestGetPodsInDeployment(t *testing.T) { + // Create a fake Kubernetes clientset + fakeClient := fake.NewSimpleClientset() + + // Create a Deployment object + deployment := &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + }, + Spec: v1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app": "test-app", + }, + }, + }, + } + + // Create a ReplicaSet object + replicaset := &v1.ReplicaSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-replicaset", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test-app", + }, + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + UID: "1234", + }, + } + + // Create a Pod object + pod1 := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod1", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test-app", + }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: "ReplicaSet", + Name: replicaset.Name, + Controller: to.Ptr(true), + UID: "1234", + }, + }, + }, + } + + // Create a Pod object + pod2 := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod2", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "doesnotmatch", + }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: "ReplicaSet", + Name: "xyz", + Controller: to.Ptr(true), + UID: "1234", + }, + }, + }, + } + + // Add the Pod object to the fake Kubernetes clientset + _, err := fakeClient.CoreV1().Pods(pod1.Namespace).Create(context.Background(), pod1, metav1.CreateOptions{}) + require.NoError(t, err, "Failed to create Pod: %v", err) + + _, err = fakeClient.CoreV1().Pods(pod2.Namespace).Create(context.Background(), pod2, metav1.CreateOptions{}) + require.NoError(t, err, "Failed to create Pod: %v", err) + + // Create a KubernetesHandler object with the fake clientset + deploymentWaiter := &deploymentWaiter{ + clientSet: fakeClient, + } + handler := &kubernetesHandler{ + deploymentWaiter: deploymentWaiter, + } + + ctx := context.Background() + informerFactory := startInformers(ctx, fakeClient, handler) + + // Call the getPodsInDeployment function + pods, err := deploymentWaiter.getPodsInDeployment(ctx, informerFactory, deployment, replicaset) + require.NoError(t, err) + require.Equal(t, 1, len(pods)) + require.Equal(t, pod1.Name, pods[0].Name) +} + +func TestGetCurrentReplicaSetForDeployment(t *testing.T) { + // Create a fake Kubernetes clientset + fakeClient := fake.NewSimpleClientset() + + // Create a Deployment object + deployment := &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + }, + } + + // Create a ReplicaSet object with a higher revision than the other ReplicaSet + replicaSet1 := &v1.ReplicaSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-replicaset-1", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ + Group: v1.SchemeGroupVersion.Group, + Version: v1.SchemeGroupVersion.Version, + Kind: "Deployment", + }), + }, + }, + } + // Create another ReplicaSet object with a lower revision than the other ReplicaSet + replicaSet2 := &v1.ReplicaSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-replicaset-2", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "0"}, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ + Group: v1.SchemeGroupVersion.Group, + Version: v1.SchemeGroupVersion.Version, + Kind: "Deployment", + }), + }, + }, + } + + // Create another ReplicaSet object with a higher revision than the other ReplicaSet + replicaSet3 := &v1.ReplicaSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-replicaset-3", + Namespace: "test-namespace", + Annotations: map[string]string{"deployment.kubernetes.io/revision": "3"}, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ + Group: v1.SchemeGroupVersion.Group, + Version: v1.SchemeGroupVersion.Version, + Kind: "Deployment", + }), + }, + }, + } + + // Add the ReplicaSet objects to the fake Kubernetes clientset + _, err := fakeClient.AppsV1().ReplicaSets(replicaSet1.Namespace).Create(context.Background(), replicaSet1, metav1.CreateOptions{}) + require.NoError(t, err) + _, err = fakeClient.AppsV1().ReplicaSets(replicaSet2.Namespace).Create(context.Background(), replicaSet2, metav1.CreateOptions{}) + require.NoError(t, err) + _, err = fakeClient.AppsV1().ReplicaSets(replicaSet2.Namespace).Create(context.Background(), replicaSet3, metav1.CreateOptions{}) + require.NoError(t, err) + + // Add the Deployment object to the fake Kubernetes clientset + _, err = fakeClient.AppsV1().Deployments(deployment.Namespace).Create(context.Background(), deployment, metav1.CreateOptions{}) + require.NoError(t, err) + + // Create a KubernetesHandler object with the fake clientset + deploymentWaiter := &deploymentWaiter{ + clientSet: fakeClient, + } + handler := &kubernetesHandler{ + deploymentWaiter: deploymentWaiter, + } + + ctx := context.Background() + informerFactory := startInformers(ctx, fakeClient, handler) + + // Call the getNewestReplicaSetForDeployment function + rs := deploymentWaiter.getCurrentReplicaSetForDeployment(ctx, informerFactory, deployment) + require.Equal(t, replicaSet1.Name, rs.Name) +} + +func TestCheckPodStatus(t *testing.T) { + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod", + Namespace: "test-namespace", + }, + Status: corev1.PodStatus{}, + } + + podTests := []struct { + podCondition []corev1.PodCondition + containerStatus []corev1.ContainerStatus + isReady bool + expectedError string + }{ + { + // Container is in Terminated state + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ + Reason: "Error", + Message: "Container terminated due to an error", + }, + }, + }, + }, + isReady: false, + expectedError: "Container state is 'Terminated' Reason: Error, Message: Container terminated due to an error", + }, + { + // Container is in CrashLoopBackOff state + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Waiting: &corev1.ContainerStateWaiting{ + Reason: "CrashLoopBackOff", + Message: "Back-off 5m0s restarting failed container=test-container pod=test-pod", + }, + }, + }, + }, + isReady: false, + expectedError: "Container state is 'Waiting' Reason: CrashLoopBackOff, Message: Back-off 5m0s restarting failed container=test-container pod=test-pod", + }, + { + // Container is in ErrImagePull state + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Waiting: &corev1.ContainerStateWaiting{ + Reason: "ErrImagePull", + Message: "Cannot pull image", + }, + }, + }, + }, + isReady: false, + expectedError: "Container state is 'Waiting' Reason: ErrImagePull, Message: Cannot pull image", + }, + { + // Container is in ImagePullBackOff state + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Waiting: &corev1.ContainerStateWaiting{ + Reason: "ImagePullBackOff", + Message: "ImagePullBackOff", + }, + }, + }, + }, + isReady: false, + expectedError: "Container state is 'Waiting' Reason: ImagePullBackOff, Message: ImagePullBackOff", + }, + { + // No container statuses available + isReady: false, + expectedError: "", + }, + { + // Container is in Waiting state but not a terminally failed state + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Waiting: &corev1.ContainerStateWaiting{ + Reason: "ContainerCreating", + Message: "Container is being created", + }, + }, + Ready: false, + }, + }, + isReady: false, + expectedError: "", + }, + { + // Container's Running state is nil + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Running: nil, + }, + Ready: false, + }, + }, + isReady: false, + expectedError: "", + }, + { + // Readiness check is not yet passed + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + Ready: false, + }, + }, + isReady: false, + expectedError: "", + }, + { + // Container is in Ready state + podCondition: nil, + containerStatus: []corev1.ContainerStatus{ + { + State: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + Ready: true, + }, + }, + isReady: true, + expectedError: "", + }, + } + + ctx := context.Background() + deploymentWaiter := NewDeploymentWaiter(fake.NewSimpleClientset()) + for _, tc := range podTests { + pod.Status.Conditions = tc.podCondition + pod.Status.ContainerStatuses = tc.containerStatus + isReady, err := deploymentWaiter.checkPodStatus(ctx, pod) + if tc.expectedError != "" { + require.Error(t, err) + require.Equal(t, tc.expectedError, err.Error()) + } else { + require.NoError(t, err) + } + require.Equal(t, tc.isReady, isReady) + } +} + +func TestCheckAllPodsReady_Success(t *testing.T) { + // Create a fake Kubernetes clientset + clientset := fake.NewSimpleClientset() + + ctx := context.Background() + + _, err := clientset.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) + require.NoError(t, err) + + replicaSet := addReplicaSetToDeployment(t, ctx, clientset, testDeployment) + + // Create a pod + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "test-container", + Image: "test-image", + }, + }, + }, + Status: corev1.PodStatus{ + Phase: corev1.PodRunning, + ContainerStatuses: []corev1.ContainerStatus{ + { + Name: "test-container", + Ready: true, + }, + }, + }, + } + _, err = clientset.CoreV1().Pods("test-namespace").Create(context.Background(), pod, metav1.CreateOptions{}) + assert.NoError(t, err) + + // Create an informer factory and add the deployment and replica set to the cache + informerFactory := informers.NewSharedInformerFactory(clientset, 0) + addTestObjects(t, clientset, informerFactory, testDeployment, replicaSet, pod) + + // Create a done channel + doneCh := make(chan error) + + // Create a handler with the fake clientset + deploymentWaiter := &deploymentWaiter{ + clientSet: clientset, + } + + // Call the checkAllPodsReady function + allReady := deploymentWaiter.checkAllPodsReady(ctx, informerFactory, testDeployment, replicaSet, doneCh) + + // Check that all pods are ready + require.True(t, allReady) +} + +func TestCheckAllPodsReady_Fail(t *testing.T) { + // Create a fake Kubernetes clientset + clientset := fake.NewSimpleClientset() + + ctx := context.Background() + + _, err := clientset.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) + require.NoError(t, err) + + replicaSet := addReplicaSetToDeployment(t, ctx, clientset, testDeployment) + + // Create a pod + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod1", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test", + }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: "ReplicaSet", + Name: replicaSet.Name, + Controller: to.Ptr(true), + }, + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "test-container", + Image: "test-image", + }, + }, + }, + Status: corev1.PodStatus{ + Phase: corev1.PodRunning, + ContainerStatuses: []corev1.ContainerStatus{ + { + Name: "test-container", + Ready: false, + }, + }, + }, + } + _, err = clientset.CoreV1().Pods(pod.Namespace).Create(context.Background(), pod, metav1.CreateOptions{}) + require.NoError(t, err) + + // Create an informer factory and add the deployment and replica set to the cache + informerFactory := informers.NewSharedInformerFactory(clientset, 0) + addTestObjects(t, clientset, informerFactory, testDeployment, replicaSet, pod) + + // Create a done channel + doneCh := make(chan error) + + // Create a handler with the fake clientset + deploymentWaiter := &deploymentWaiter{ + clientSet: clientset, + } + + // Call the checkAllPodsReady function + allReady := deploymentWaiter.checkAllPodsReady(ctx, informerFactory, testDeployment, replicaSet, doneCh) + + // Check that all pods are ready + require.False(t, allReady) +} + +func TestCheckDeploymentStatus_AllReady(t *testing.T) { + // Create a fake Kubernetes fakeClient + fakeClient := fake.NewSimpleClientset() + + ctx := context.Background() + _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) + require.NoError(t, err) + replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, testDeployment) + + // Create a Pod object + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod1", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test", + }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: "ReplicaSet", + Name: replicaSet.Name, + Controller: to.Ptr(true), + }, + }, + }, + Status: corev1.PodStatus{ + Conditions: []corev1.PodCondition{ + { + Type: corev1.PodScheduled, + Status: corev1.ConditionTrue, + }, + }, + ContainerStatuses: []corev1.ContainerStatus{ + { + Name: "test-container", + Ready: true, + State: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + }, + }, + }, + } + + // Add the Pod object to the fake Kubernetes clientset + _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) + require.NoError(t, err, "Failed to create Pod: %v", err) + + // Create an informer factory and add the deployment to the cache + informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) + addTestObjects(t, fakeClient, informerFactory, testDeployment, replicaSet, pod) + + // Create a fake item and object + item := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "metadata": map[string]interface{}{ + "name": "test-deployment", + "namespace": "test-namespace", + }, + }, + } + + // Create a done channel + doneCh := make(chan error, 1) + + // Call the checkDeploymentStatus function + deploymentWaiter := &deploymentWaiter{ + clientSet: fakeClient, + } + + deploymentWaiter.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + + err = <-doneCh + + // Check that the deployment readiness was checked + require.Nil(t, err) +} + +func TestCheckDeploymentStatus_NoReplicaSetsFound(t *testing.T) { + // Create a fake Kubernetes fakeClient + fakeClient := fake.NewSimpleClientset() + + ctx := context.Background() + _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) + require.NoError(t, err) + + // Create a Pod object + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod1", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test", + }, + }, + Status: corev1.PodStatus{ + Conditions: []corev1.PodCondition{ + { + Type: corev1.PodScheduled, + Status: corev1.ConditionTrue, + }, + }, + ContainerStatuses: []corev1.ContainerStatus{ + { + Name: "test-container", + Ready: true, + State: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + }, + }, + }, + } + + // Add the Pod object to the fake Kubernetes clientset + _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) + require.NoError(t, err, "Failed to create Pod: %v", err) + + // Create an informer factory and add the deployment to the cache + informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) + err = informerFactory.Apps().V1().Deployments().Informer().GetIndexer().Add(testDeployment) + require.NoError(t, err, "Failed to add deployment to informer cache") + err = informerFactory.Core().V1().Pods().Informer().GetIndexer().Add(pod) + require.NoError(t, err, "Failed to add pod to informer cache") + // Note: No replica set added + + // Create a fake item and object + item := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "metadata": map[string]interface{}{ + "name": "test-deployment", + "namespace": "test-namespace", + }, + }, + } + + // Create a done channel + doneCh := make(chan error, 1) + + // Call the checkDeploymentStatus function + deploymentWaiter := &deploymentWaiter{ + clientSet: fakeClient, + } + + allReady := deploymentWaiter.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + + // Check that the deployment readiness was checked + require.False(t, allReady) +} + +func TestCheckDeploymentStatus_PodsNotReady(t *testing.T) { + // Create a fake Kubernetes fakeClient + fakeClient := fake.NewSimpleClientset() + + ctx := context.Background() + _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) + require.NoError(t, err) + replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, testDeployment) + + // Create a Pod object + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod1", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test", + }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: "ReplicaSet", + Name: replicaSet.Name, + Controller: to.Ptr(true), + }, + }, + }, + Status: corev1.PodStatus{ + Conditions: []corev1.PodCondition{ + { + Type: corev1.PodScheduled, + Status: corev1.ConditionTrue, + }, + }, + ContainerStatuses: []corev1.ContainerStatus{ + { + Name: "test-container", + Ready: true, + State: corev1.ContainerState{ + Terminated: &corev1.ContainerStateTerminated{ + Reason: "Error", + Message: "Container terminated due to an error", + }, + }, + }, + }, + }, + } + + // Add the Pod object to the fake Kubernetes clientset + _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) + require.NoError(t, err, "Failed to create Pod: %v", err) + + // Create an informer factory and add the deployment to the cache + informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) + addTestObjects(t, fakeClient, informerFactory, testDeployment, replicaSet, pod) + + // Create a fake item and object + item := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "metadata": map[string]interface{}{ + "name": "test-deployment", + "namespace": "test-namespace", + }, + }, + } + + // Create a done channel + doneCh := make(chan error, 1) + + // Call the checkDeploymentStatus function + deploymentWaiter := &deploymentWaiter{ + clientSet: fakeClient, + } + + go deploymentWaiter.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + err = <-doneCh + + // Check that the deployment readiness was checked + require.Error(t, err) + require.Equal(t, err.Error(), "Container state is 'Terminated' Reason: Error, Message: Container terminated due to an error") +} + +func TestCheckDeploymentStatus_ObservedGenerationMismatch(t *testing.T) { + // Modify testDeployment to have a different generation than the observed generation + generationMismatchDeployment := testDeployment.DeepCopy() + generationMismatchDeployment.Generation = 2 + + // Create a fake Kubernetes fakeClient + fakeClient := fake.NewSimpleClientset() + + ctx := context.Background() + _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, generationMismatchDeployment, metav1.CreateOptions{}) + require.NoError(t, err) + replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, generationMismatchDeployment) + + // Create a Pod object + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod1", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test", + }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: "ReplicaSet", + Name: replicaSet.Name, + Controller: to.Ptr(true), + }, + }, + }, + Status: corev1.PodStatus{ + Conditions: []corev1.PodCondition{ + { + Type: corev1.PodScheduled, + Status: corev1.ConditionTrue, + }, + }, + ContainerStatuses: []corev1.ContainerStatus{ + { + Name: "test-container", + Ready: true, + State: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + }, + }, + }, + } + + // Add the Pod object to the fake Kubernetes clientset + _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) + require.NoError(t, err, "Failed to create Pod: %v", err) + + // Create an informer factory and add the deployment to the cache + informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) + addTestObjects(t, fakeClient, informerFactory, generationMismatchDeployment, replicaSet, pod) + + // Create a fake item and object + item := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "metadata": map[string]interface{}{ + "name": "test-deployment", + "namespace": "test-namespace", + }, + }, + } + + // Create a done channel + doneCh := make(chan error, 1) + + // Call the checkDeploymentStatus function + deploymentWaiter := &deploymentWaiter{ + clientSet: fakeClient, + } + + deploymentWaiter.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + + // Check that the deployment readiness was checked + require.Zero(t, len(doneCh)) +} + +func TestCheckDeploymentStatus_DeploymentNotProgressing(t *testing.T) { + // Create a fake Kubernetes fakeClient + fakeClient := fake.NewSimpleClientset() + + deploymentNotProgressing := testDeployment.DeepCopy() + + ctx := context.Background() + _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, deploymentNotProgressing, metav1.CreateOptions{}) + require.NoError(t, err) + replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, deploymentNotProgressing) + + // Create a Pod object + pod := &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pod1", + Namespace: "test-namespace", + Labels: map[string]string{ + "app": "test", + }, + OwnerReferences: []metav1.OwnerReference{ + { + Kind: "ReplicaSet", + Name: replicaSet.Name, + Controller: to.Ptr(true), + }, + }, + }, + Status: corev1.PodStatus{ + Conditions: []corev1.PodCondition{ + { + Type: corev1.PodScheduled, + Status: corev1.ConditionTrue, + }, + }, + ContainerStatuses: []corev1.ContainerStatus{ + { + Name: "test-container", + Ready: true, + State: corev1.ContainerState{ + Running: &corev1.ContainerStateRunning{}, + }, + }, + }, + }, + } + + // Add the Pod object to the fake Kubernetes clientset + _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) + require.NoError(t, err, "Failed to create Pod: %v", err) + + // Create an informer factory and add the deployment to the cache + informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) + addTestObjects(t, fakeClient, informerFactory, deploymentNotProgressing, replicaSet, pod) + + deploymentNotProgressing.Status = v1.DeploymentStatus{ + Conditions: []v1.DeploymentCondition{ + { + Type: v1.DeploymentProgressing, + Status: corev1.ConditionFalse, + Reason: "NewReplicaSetAvailable", + Message: "Deployment has minimum availability", + }, + }, + } + + // Create a fake item and object + item := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "metadata": map[string]interface{}{ + "name": "test-deployment", + "namespace": "test-namespace", + }, + }, + } + + // Create a done channel + doneCh := make(chan error, 1) + + // Call the checkDeploymentStatus function + deploymentWaiter := &deploymentWaiter{ + clientSet: fakeClient, + } + + ready := deploymentWaiter.checkDeploymentStatus(ctx, informerFactory, item, doneCh) + require.False(t, ready) +} + +func addTestObjects(t *testing.T, fakeClient *fake.Clientset, informerFactory informers.SharedInformerFactory, deployment *v1.Deployment, replicaSet *v1.ReplicaSet, pod *corev1.Pod) { + err := informerFactory.Apps().V1().Deployments().Informer().GetIndexer().Add(deployment) + require.NoError(t, err, "Failed to add deployment to informer cache") + err = informerFactory.Apps().V1().ReplicaSets().Informer().GetIndexer().Add(replicaSet) + require.NoError(t, err, "Failed to add replica set to informer cache") + err = informerFactory.Core().V1().Pods().Informer().GetIndexer().Add(pod) + require.NoError(t, err, "Failed to add pod to informer cache") +} diff --git a/pkg/corerp/handlers/kubernetes_http_proxy_waiter.go b/pkg/corerp/handlers/kubernetes_http_proxy_waiter.go new file mode 100644 index 0000000000..03edcfd88b --- /dev/null +++ b/pkg/corerp/handlers/kubernetes_http_proxy_waiter.go @@ -0,0 +1,171 @@ +package handlers + +import ( + "context" + "errors" + "fmt" + "strings" + "time" + + contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/ucp/ucplog" + + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/dynamic/dynamicinformer" + "k8s.io/client-go/informers" + "k8s.io/client-go/tools/cache" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const ( + MaxHTTPProxyDeploymentTimeout = time.Minute * time.Duration(10) + HTTPProxyConditionValid = "Valid" + HTTPProxyStatusInvalid = "invalid" + HTTPProxyStatusValid = "valid" +) + +type httpProxyWaiter struct { + dynamicClientSet dynamic.Interface + httpProxyDeploymentTimeout time.Duration + cacheResyncInterval time.Duration +} + +// NewHTTPProxyWaiter returns a new instance of HTTPProxyWaiter +func NewHTTPProxyWaiter(dynamicClientSet dynamic.Interface) *httpProxyWaiter { + return &httpProxyWaiter{ + dynamicClientSet: dynamicClientSet, + httpProxyDeploymentTimeout: MaxHTTPProxyDeploymentTimeout, + cacheResyncInterval: DefaultCacheResyncInterval, + } +} + +func (handler *httpProxyWaiter) addDynamicEventHandler(ctx context.Context, informerFactory dynamicinformer.DynamicSharedInformerFactory, informer cache.SharedIndexInformer, item client.Object, doneCh chan<- error) { + logger := ucplog.FromContextOrDiscard(ctx) + + _, err := informer.AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj any) { + handler.checkHTTPProxyStatus(ctx, informerFactory, item, doneCh) + }, + UpdateFunc: func(_, newObj any) { + handler.checkHTTPProxyStatus(ctx, informerFactory, item, doneCh) + }, + }) + + if err != nil { + logger.Error(err, "failed to add event handler") + } +} + +// addEventHandler is not implemented for HTTPProxyWaiter +func (handler *httpProxyWaiter) addEventHandler(ctx context.Context, informerFactory informers.SharedInformerFactory, informer cache.SharedIndexInformer, item client.Object, doneCh chan<- error) { +} + +func (handler *httpProxyWaiter) waitUntilReady(ctx context.Context, obj client.Object) error { + logger := ucplog.FromContextOrDiscard(ctx).WithValues("httpProxyName", obj.GetName(), "namespace", obj.GetNamespace()) + + doneCh := make(chan error, 1) + + ctx, cancel := context.WithTimeout(ctx, handler.httpProxyDeploymentTimeout) + // This ensures that the informer is stopped when this function is returned. + defer cancel() + + // Create dynamic informer for HTTPProxy + dynamicInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(handler.dynamicClientSet, 0, obj.GetNamespace(), nil) + httpProxyInformer := dynamicInformerFactory.ForResource(contourv1.HTTPProxyGVR) + // Add event handlers to the http proxy informer + handler.addDynamicEventHandler(ctx, dynamicInformerFactory, httpProxyInformer.Informer(), obj, doneCh) + + // Start the informers + dynamicInformerFactory.Start(ctx.Done()) + + // Wait for the cache to be synced. + dynamicInformerFactory.WaitForCacheSync(ctx.Done()) + + select { + case <-ctx.Done(): + // Get the final status + proxy, err := httpProxyInformer.Lister().Get(obj.GetName()) + + if err != nil { + return fmt.Errorf("proxy deployment timed out, name: %s, namespace %s, error occured while fetching latest status: %w", obj.GetName(), obj.GetNamespace(), err) + } + + p := contourv1.HTTPProxy{} + err = runtime.DefaultUnstructuredConverter.FromUnstructured(proxy.(*unstructured.Unstructured).Object, &p) + if err != nil { + return fmt.Errorf("proxy deployment timed out, name: %s, namespace %s, error occured while fetching latest status: %w", obj.GetName(), obj.GetNamespace(), err) + } + + status := contourv1.DetailedCondition{} + if len(p.Status.Conditions) > 0 { + status = p.Status.Conditions[len(p.Status.Conditions)-1] + } + return fmt.Errorf("HTTP proxy deployment timed out, name: %s, namespace %s, status: %s, reason: %s", obj.GetName(), obj.GetNamespace(), status.Message, status.Reason) + case err := <-doneCh: + if err == nil { + logger.Info(fmt.Sprintf("Marking HTTP proxy deployment %s in namespace %s as complete", obj.GetName(), obj.GetNamespace())) + } + return err + } +} + +func (handler *httpProxyWaiter) checkHTTPProxyStatus(ctx context.Context, dynamicInformerFactory dynamicinformer.DynamicSharedInformerFactory, obj client.Object, doneCh chan<- error) bool { + logger := ucplog.FromContextOrDiscard(ctx).WithValues("httpProxyName", obj.GetName(), "namespace", obj.GetNamespace()) + selector := labels.SelectorFromSet( + map[string]string{ + kubernetes.LabelManagedBy: kubernetes.LabelManagedByRadiusRP, + kubernetes.LabelName: obj.GetName(), + }, + ) + proxies, err := dynamicInformerFactory.ForResource(contourv1.HTTPProxyGVR).Lister().List(selector) + if err != nil { + logger.Info(fmt.Sprintf("Unable to list http proxies: %s", err.Error())) + return false + } + + for _, proxy := range proxies { + p := contourv1.HTTPProxy{} + err = runtime.DefaultUnstructuredConverter.FromUnstructured(proxy.(*unstructured.Unstructured).Object, &p) + if err != nil { + logger.Info(fmt.Sprintf("Unable to convert http proxy: %s", err.Error())) + continue + } + + if len(p.Spec.Includes) == 0 && len(p.Spec.Routes) > 0 { + // This is a route HTTP proxy. We will not validate deployment completion for it and return success here + logger.Info("Not validating the deployment of route HTTP proxy for ", p.Name) + doneCh <- nil + return true + } + + // We will check the status for the root HTTP proxy + if p.Status.CurrentStatus == HTTPProxyStatusInvalid { + if strings.Contains(p.Status.Description, "see Errors for details") { + var msg string + for _, c := range p.Status.Conditions { + if c.ObservedGeneration != p.Generation { + continue + } + if c.Type == HTTPProxyConditionValid && c.Status == "False" { + for _, e := range c.Errors { + msg += fmt.Sprintf("Error - Type: %s, Status: %s, Reason: %s, Message: %s\n", e.Type, e.Status, e.Reason, e.Message) + } + } + } + doneCh <- errors.New(msg) + } else { + doneCh <- fmt.Errorf("Failed to deploy HTTP proxy. Description: %s", p.Status.Description) + } + return false + } else if p.Status.CurrentStatus == HTTPProxyStatusValid { + // The HTTPProxy is ready + doneCh <- nil + return true + } + } + return false +} diff --git a/pkg/corerp/handlers/kubernetes_http_proxy_waiter_test.go b/pkg/corerp/handlers/kubernetes_http_proxy_waiter_test.go new file mode 100644 index 0000000000..44837ef551 --- /dev/null +++ b/pkg/corerp/handlers/kubernetes_http_proxy_waiter_test.go @@ -0,0 +1,326 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handlers + +import ( + "context" + "testing" + + contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/dynamic/dynamicinformer" + fakedynamic "k8s.io/client-go/dynamic/fake" +) + +func TestCheckHTTPProxyStatus_ValidStatus(t *testing.T) { + + httpProxy := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "example.com", + Labels: map[string]string{ + kubernetes.LabelManagedBy: kubernetes.LabelManagedByRadiusRP, + kubernetes.LabelName: "example.com", + }, + }, + Status: contourv1.HTTPProxyStatus{ + CurrentStatus: HTTPProxyStatusValid, + }, + } + // create fake dynamic clientset + s := runtime.NewScheme() + err := contourv1.AddToScheme(s) + require.NoError(t, err) + fakeClient := fakedynamic.NewSimpleDynamicClient(s, httpProxy) + + // create a fake dynamic informer factory with a mock HTTPProxy informer + dynamicInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(fakeClient, 0, "default", nil) + err = dynamicInformerFactory.ForResource(contourv1.HTTPProxyGVR).Informer().GetIndexer().Add(httpProxy) + require.NoError(t, err, "Could not add test http proxy to informer cache") + + // create a mock object + obj := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "example.com", + }, + } + + // create a channel for the done signal + doneCh := make(chan error) + + httpProxyWaiter := &httpProxyWaiter{ + dynamicClientSet: fakeClient, + } + + ctx := context.Background() + dynamicInformerFactory.Start(ctx.Done()) + dynamicInformerFactory.WaitForCacheSync(ctx.Done()) + + // call the function with the fake clientset, informer factory, logger, object, and done channel + go httpProxyWaiter.checkHTTPProxyStatus(context.Background(), dynamicInformerFactory, obj, doneCh) + err = <-doneCh + require.NoError(t, err) +} + +func TestCheckHTTPProxyStatus_InvalidStatusForRootProxy(t *testing.T) { + + httpProxy := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "example.com", + Labels: map[string]string{ + kubernetes.LabelManagedBy: kubernetes.LabelManagedByRadiusRP, + kubernetes.LabelName: "example.com", + }, + }, + Spec: contourv1.HTTPProxySpec{ + VirtualHost: &contourv1.VirtualHost{ + Fqdn: "example.com", + }, + Includes: []contourv1.Include{ + { + Name: "example.com", + Namespace: "default", + }, + }, + }, + Status: contourv1.HTTPProxyStatus{ + CurrentStatus: HTTPProxyStatusInvalid, + Description: "Failed to deploy HTTP proxy. see Errors for details", + Conditions: []contourv1.DetailedCondition{ + { + // specify Condition of type json + Condition: metav1.Condition{ + Type: HTTPProxyConditionValid, + Status: contourv1.ConditionFalse, + }, + Errors: []contourv1.SubCondition{ + { + Type: HTTPProxyConditionValid, + Status: contourv1.ConditionFalse, + Reason: "RouteNotDefined", + Message: "HTTPProxy is invalid", + }, + }, + }, + }, + }, + } + // create fake dynamic clientset + s := runtime.NewScheme() + err := contourv1.AddToScheme(s) + require.NoError(t, err) + fakeClient := fakedynamic.NewSimpleDynamicClient(s, httpProxy) + + // create a fake dynamic informer factory with a mock HTTPProxy informer + dynamicInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(fakeClient, 0, "default", nil) + err = dynamicInformerFactory.ForResource(contourv1.HTTPProxyGVR).Informer().GetIndexer().Add(httpProxy) + require.NoError(t, err, "Could not add test http proxy to informer cache") + + // create a mock object + obj := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "example.com", + }, + } + + // create a channel for the done signal + doneCh := make(chan error) + + httpProxyWaiter := &httpProxyWaiter{ + dynamicClientSet: fakeClient, + } + + ctx := context.Background() + dynamicInformerFactory.Start(ctx.Done()) + dynamicInformerFactory.WaitForCacheSync(ctx.Done()) + + // call the function with the fake clientset, informer factory, logger, object, and done channel + go httpProxyWaiter.checkHTTPProxyStatus(context.Background(), dynamicInformerFactory, obj, doneCh) + err = <-doneCh + require.EqualError(t, err, "Error - Type: Valid, Status: False, Reason: RouteNotDefined, Message: HTTPProxy is invalid\n") +} + +func TestCheckHTTPProxyStatus_InvalidStatusForRouteProxy(t *testing.T) { + httpProxyRoute := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "example.com", + Labels: map[string]string{ + kubernetes.LabelManagedBy: kubernetes.LabelManagedByRadiusRP, + kubernetes.LabelName: "example.com", + }, + }, + Spec: contourv1.HTTPProxySpec{ + Routes: []contourv1.Route{ + { + Conditions: []contourv1.MatchCondition{ + { + Prefix: "/", + }, + }, + Services: []contourv1.Service{ + { + Name: "test", + Port: 80, + }, + }, + }, + }, + }, + Status: contourv1.HTTPProxyStatus{ + CurrentStatus: HTTPProxyStatusInvalid, + Description: "Failed to deploy HTTP proxy. see Errors for details", + Conditions: []contourv1.DetailedCondition{ + { + // specify Condition of type json + Condition: metav1.Condition{ + Type: HTTPProxyConditionValid, + Status: contourv1.ConditionFalse, + }, + Errors: []contourv1.SubCondition{ + { + Type: HTTPProxyConditionValid, + Status: contourv1.ConditionFalse, + Reason: "orphaned", + Message: "HTTPProxy is invalid", + }, + }, + }, + }, + }, + } + // create fake dynamic clientset + s := runtime.NewScheme() + err := contourv1.AddToScheme(s) + require.NoError(t, err) + fakeClient := fakedynamic.NewSimpleDynamicClient(s, httpProxyRoute) + + // create a fake dynamic informer factory with a mock HTTPProxy informer + dynamicInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(fakeClient, 0, "default", nil) + err = dynamicInformerFactory.ForResource(contourv1.HTTPProxyGVR).Informer().GetIndexer().Add(httpProxyRoute) + require.NoError(t, err, "Could not add test http proxy to informer cache") + + // create a mock object + obj := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "example.com", + }, + } + + // create a channel for the done signal + doneCh := make(chan error) + + httpProxyWaiter := &httpProxyWaiter{ + dynamicClientSet: fakeClient, + } + + ctx := context.Background() + dynamicInformerFactory.Start(ctx.Done()) + dynamicInformerFactory.WaitForCacheSync(ctx.Done()) + + // call the function with the fake clientset, informer factory, logger, object, and done channel + go httpProxyWaiter.checkHTTPProxyStatus(context.Background(), dynamicInformerFactory, obj, doneCh) + err = <-doneCh + require.NoError(t, err) +} + +func TestCheckHTTPProxyStatus_WrongSelector(t *testing.T) { + + httpProxy := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "abcd.com", + Labels: map[string]string{ + kubernetes.LabelManagedBy: kubernetes.LabelManagedByRadiusRP, + kubernetes.LabelName: "abcd.com", + }, + }, + Spec: contourv1.HTTPProxySpec{ + VirtualHost: &contourv1.VirtualHost{ + Fqdn: "abcd.com", + }, + Includes: []contourv1.Include{ + { + Name: "abcd.com", + Namespace: "default", + }, + }, + }, + Status: contourv1.HTTPProxyStatus{ + CurrentStatus: HTTPProxyStatusInvalid, + Description: "Failed to deploy HTTP proxy. see Errors for details", + Conditions: []contourv1.DetailedCondition{ + { + // specify Condition of type json + Condition: metav1.Condition{ + Type: HTTPProxyConditionValid, + Status: contourv1.ConditionFalse, + }, + Errors: []contourv1.SubCondition{ + { + Type: HTTPProxyConditionValid, + Status: contourv1.ConditionFalse, + Reason: "RouteNotDefined", + Message: "HTTPProxy is invalid", + }, + }, + }, + }, + }, + } + + // create fake dynamic clientset + s := runtime.NewScheme() + err := contourv1.AddToScheme(s) + require.NoError(t, err) + fakeClient := fakedynamic.NewSimpleDynamicClient(s, httpProxy) + + // create a fake dynamic informer factory with a mock HTTPProxy informer + dynamicInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(fakeClient, 0, "default", nil) + err = dynamicInformerFactory.ForResource(contourv1.HTTPProxyGVR).Informer().GetIndexer().Add(httpProxy) + require.NoError(t, err, "Could not add test http proxy to informer cache") + + // create a mock object + obj := &contourv1.HTTPProxy{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "example.com", + }, + } + + // create a channel for the done signal + doneCh := make(chan error) + + httpProxyWaiter := &httpProxyWaiter{ + dynamicClientSet: fakeClient, + } + + ctx := context.Background() + dynamicInformerFactory.Start(ctx.Done()) + dynamicInformerFactory.WaitForCacheSync(ctx.Done()) + + // call the function with the fake clientset, informer factory, logger, object, and done channel + status := httpProxyWaiter.checkHTTPProxyStatus(context.Background(), dynamicInformerFactory, obj, doneCh) + require.False(t, status) +} diff --git a/pkg/corerp/handlers/kubernetes_test.go b/pkg/corerp/handlers/kubernetes_test.go index ca116f8711..0403b340f9 100644 --- a/pkg/corerp/handlers/kubernetes_test.go +++ b/pkg/corerp/handlers/kubernetes_test.go @@ -22,93 +22,19 @@ import ( "testing" "time" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/k8sutil" - "github.com/stretchr/testify/assert" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/require" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" ) -var testDeployment = &v1.Deployment{ - TypeMeta: metav1.TypeMeta{ - Kind: "Deployment", - APIVersion: "apps/v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - }, - Spec: v1.DeploymentSpec{ - Replicas: to.Ptr(int32(1)), - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app": "test", - }, - }, - }, - Status: v1.DeploymentStatus{ - Conditions: []v1.DeploymentCondition{ - { - Type: v1.DeploymentProgressing, - Status: corev1.ConditionTrue, - Reason: "NewReplicaSetAvailable", - Message: "Deployment has minimum availability", - }, - }, - }, -} - -func addReplicaSetToDeployment(t *testing.T, ctx context.Context, clientset *fake.Clientset, deployment *v1.Deployment) *v1.ReplicaSet { - replicaSet := &v1.ReplicaSet{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-replicaset-1", - Namespace: deployment.Namespace, - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ - Group: v1.SchemeGroupVersion.Group, - Version: v1.SchemeGroupVersion.Version, - Kind: "Deployment", - }), - }, - }, - } - - // Add the ReplicaSet objects to the fake Kubernetes clientset - _, err := clientset.AppsV1().ReplicaSets(replicaSet.Namespace).Create(ctx, replicaSet, metav1.CreateOptions{}) - require.NoError(t, err) - - _, err = clientset.AppsV1().Deployments(deployment.Namespace).Update(ctx, deployment, metav1.UpdateOptions{}) - require.NoError(t, err) - - return replicaSet -} - -func startInformers(ctx context.Context, clientSet *fake.Clientset, handler *kubernetesHandler) informers.SharedInformerFactory { - // Create a fake replicaset informer and start - informerFactory := informers.NewSharedInformerFactory(clientSet, 0) - - // Add informers - informerFactory.Apps().V1().Deployments().Informer() - informerFactory.Apps().V1().ReplicaSets().Informer() - informerFactory.Core().V1().Pods().Informer() - - informerFactory.Start(context.Background().Done()) - informerFactory.WaitForCacheSync(ctx.Done()) - return informerFactory -} - func TestPut(t *testing.T) { putTests := []struct { name string @@ -119,17 +45,20 @@ func TestPut(t *testing.T) { name: "secret resource", in: &PutOptions{ Resource: &rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Provider: resourcemodel.ProviderKubernetes, - }, - Resource: &corev1.Secret{ - TypeMeta: metav1.TypeMeta{ - Kind: "Secret", - APIVersion: "core/v1", + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Provider: resourcemodel.ProviderKubernetes, + Type: "core/Secret", }, - ObjectMeta: metav1.ObjectMeta{ - Name: "test-secret", - Namespace: "test-namespace", + Data: &corev1.Secret{ + TypeMeta: metav1.TypeMeta{ + Kind: "Secret", + APIVersion: "core/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-secret", + Namespace: "test-namespace", + }, }, }, }, @@ -145,10 +74,13 @@ func TestPut(t *testing.T) { name: "deploment resource", in: &PutOptions{ Resource: &rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Provider: resourcemodel.ProviderKubernetes, + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Provider: resourcemodel.ProviderKubernetes, + Type: "apps/Deployment", + }, + Data: testDeployment, }, - Resource: testDeployment, }, }, out: map[string]string{ @@ -164,18 +96,18 @@ func TestPut(t *testing.T) { t.Run(tc.name, func(t *testing.T) { ctx := context.Background() + clientSet := fake.NewSimpleClientset(tc.in.Resource.CreateResource.Data.(runtime.Object)) handler := kubernetesHandler{ - client: k8sutil.NewFakeKubeClient(nil), - clientSet: nil, - deploymentTimeOut: time.Duration(50) * time.Second, - cacheResyncInterval: time.Duration(1) * time.Second, + client: k8sutil.NewFakeKubeClient(nil), + deploymentWaiter: &deploymentWaiter{ + clientSet: clientSet, + deploymentTimeOut: time.Duration(50) * time.Second, + cacheResyncInterval: time.Duration(1) * time.Second, + }, } - clientSet := fake.NewSimpleClientset(tc.in.Resource.Resource.(runtime.Object)) - handler.clientSet = clientSet - // If the resource is a deployment, we need to add a replica set to it - if tc.in.Resource.Resource.(runtime.Object).GetObjectKind().GroupVersionKind().Kind == "Deployment" { + if tc.in.Resource.CreateResource.Data.(runtime.Object).GetObjectKind().GroupVersionKind().Kind == "Deployment" { // The deployment is not marked as ready till we find a replica set. Therefore, we need to create one. addReplicaSetToDeployment(t, ctx, clientSet, testDeployment) } @@ -202,10 +134,28 @@ func TestDelete(t *testing.T) { }, } + dc := &k8sutil.DiscoveryClient{ + Resources: []*metav1.APIResourceList{ + { + GroupVersion: "apps/v1", + APIResources: []metav1.APIResource{ + { + Name: "deployments", + Version: "v1", + Kind: "Deployment", + }, + }, + }, + }, + } + handler := kubernetesHandler{ - client: k8sutil.NewFakeKubeClient(nil), - deploymentTimeOut: time.Duration(1) * time.Second, - cacheResyncInterval: time.Duration(10) * time.Second, + client: k8sutil.NewFakeKubeClient(nil), + k8sDiscoveryClient: dc, + deploymentWaiter: &deploymentWaiter{ + deploymentTimeOut: time.Duration(1) * time.Second, + cacheResyncInterval: time.Duration(10) * time.Second, + }, } err := handler.client.Create(ctx, deployment) @@ -214,35 +164,12 @@ func TestDelete(t *testing.T) { t.Run("existing resource", func(t *testing.T) { err := handler.Delete(ctx, &DeleteOptions{ Resource: &rpv1.OutputResource{ - Identity: resourcemodel.ResourceIdentity{ - Data: map[string]any{ - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": map[string]any{ - "name": "test-deployment", - "namespace": "test-namespace", - }, - }, - }, - }, - }) - - require.NoError(t, err) - }) - - t.Run("existing resource", func(t *testing.T) { - err := handler.Delete(ctx, &DeleteOptions{ - Resource: &rpv1.OutputResource{ - Identity: resourcemodel.ResourceIdentity{ - Data: map[string]any{ - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": map[string]any{ - "name": "test-deployment1", - "namespace": "test-namespace", - }, - }, - }, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "apps", + "Deployment", + "test-namespace", + "test-deployment"), }, }) @@ -260,13 +187,16 @@ func TestConvertToUnstructured(t *testing.T) { { name: "valid resource", in: rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Provider: resourcemodel.ProviderKubernetes, - }, - Resource: &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Provider: resourcemodel.ProviderKubernetes, + Type: "apps/Deployment", + }, + Data: &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + }, }, }, }, @@ -296,13 +226,16 @@ func TestConvertToUnstructured(t *testing.T) { { name: "invalid provider", in: rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Provider: resourcemodel.ProviderAzure, - }, - Resource: &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Provider: resourcemodel.ProviderAzure, + Type: "apps/Deployment", + }, + Data: &v1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + }, }, }, }, @@ -311,10 +244,13 @@ func TestConvertToUnstructured(t *testing.T) { { name: "invalid resource", in: rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Provider: resourcemodel.ProviderKubernetes, + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Provider: resourcemodel.ProviderAzure, + Type: "apps/Deployment", + }, + Data: map[string]any{"invalid": "type"}, }, - Resource: map[string]any{"invalid": "type"}, }, err: errors.New("inner type was not a runtime.Object"), }, @@ -332,996 +268,3 @@ func TestConvertToUnstructured(t *testing.T) { }) } } - -func TestWaitUntilDeploymentIsReady_NewResource(t *testing.T) { - ctx := context.Background() - - // Create first deployment that will be watched - deployment := &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", - Labels: map[string]string{ - kubernetes.LabelManagedBy: kubernetes.LabelManagedByRadiusRP, - }, - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - }, - Spec: v1.DeploymentSpec{ - Replicas: to.Ptr(int32(1)), - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app": "test", - }, - }, - }, - Status: v1.DeploymentStatus{ - Conditions: []v1.DeploymentCondition{ - { - Type: v1.DeploymentProgressing, - Status: corev1.ConditionTrue, - Reason: "NewReplicaSetAvailable", - Message: "Deployment has minimum availability", - }, - }, - }, - } - - clientset := fake.NewSimpleClientset(deployment) - - // The deployment is not marked as ready till we find a replica set. Therefore, we need to create one. - addReplicaSetToDeployment(t, ctx, clientset, deployment) - - handler := kubernetesHandler{ - clientSet: clientset, - deploymentTimeOut: time.Duration(50) * time.Second, - cacheResyncInterval: time.Duration(10) * time.Second, - } - - err := handler.waitUntilDeploymentIsReady(ctx, deployment) - require.NoError(t, err, "Failed to wait for deployment to be ready") -} - -func TestWaitUntilDeploymentIsReady_Timeout(t *testing.T) { - ctx := context.Background() - // Create first deployment that will be watched - deployment := &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - }, - Status: v1.DeploymentStatus{ - Conditions: []v1.DeploymentCondition{ - { - Type: v1.DeploymentProgressing, - Status: corev1.ConditionFalse, - Reason: "NewReplicaSetAvailable", - Message: "Deployment has minimum availability", - }, - }, - }, - } - - deploymentClient := fake.NewSimpleClientset(deployment) - - handler := kubernetesHandler{ - clientSet: deploymentClient, - deploymentTimeOut: time.Duration(1) * time.Second, - cacheResyncInterval: time.Duration(10) * time.Second, - } - - err := handler.waitUntilDeploymentIsReady(ctx, deployment) - require.Error(t, err) - require.Equal(t, "deployment timed out, name: test-deployment, namespace test-namespace, status: Deployment has minimum availability, reason: NewReplicaSetAvailable", err.Error()) -} - -func TestWaitUntilDeploymentIsReady_DifferentResourceName(t *testing.T) { - ctx := context.Background() - // Create first deployment that will be watched - deployment := &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - }, - Status: v1.DeploymentStatus{ - Conditions: []v1.DeploymentCondition{ - { - Type: v1.DeploymentProgressing, - Status: corev1.ConditionTrue, - Reason: "NewReplicaSetAvailable", - Message: "Deployment has minimum availability", - }, - }, - }, - } - - clientset := fake.NewSimpleClientset(deployment) - - handler := kubernetesHandler{ - clientSet: clientset, - deploymentTimeOut: time.Duration(1) * time.Second, - cacheResyncInterval: time.Duration(10) * time.Second, - } - - err := handler.waitUntilDeploymentIsReady(ctx, &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "not-matched-deployment", - Namespace: "test-namespace", - }, - }) - - // It must be timed out because the name of the deployment does not match. - require.Error(t, err) - require.Equal(t, "deployment timed out, name: not-matched-deployment, namespace test-namespace, error occured while fetching latest status: deployments.apps \"not-matched-deployment\" not found", err.Error()) -} - -func TestGetPodsInDeployment(t *testing.T) { - // Create a fake Kubernetes clientset - fakeClient := fake.NewSimpleClientset() - - // Create a Deployment object - deployment := &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - }, - Spec: v1.DeploymentSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app": "test-app", - }, - }, - }, - } - - // Create a ReplicaSet object - replicaset := &v1.ReplicaSet{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-replicaset", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test-app", - }, - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - UID: "1234", - }, - } - - // Create a Pod object - pod1 := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod1", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test-app", - }, - OwnerReferences: []metav1.OwnerReference{ - { - Kind: "ReplicaSet", - Name: replicaset.Name, - Controller: to.Ptr(true), - UID: "1234", - }, - }, - }, - } - - // Create a Pod object - pod2 := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod2", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "doesnotmatch", - }, - OwnerReferences: []metav1.OwnerReference{ - { - Kind: "ReplicaSet", - Name: "xyz", - Controller: to.Ptr(true), - UID: "1234", - }, - }, - }, - } - - // Add the Pod object to the fake Kubernetes clientset - _, err := fakeClient.CoreV1().Pods(pod1.Namespace).Create(context.Background(), pod1, metav1.CreateOptions{}) - require.NoError(t, err, "Failed to create Pod: %v", err) - - _, err = fakeClient.CoreV1().Pods(pod2.Namespace).Create(context.Background(), pod2, metav1.CreateOptions{}) - require.NoError(t, err, "Failed to create Pod: %v", err) - - // Create a KubernetesHandler object with the fake clientset - handler := &kubernetesHandler{ - clientSet: fakeClient, - } - - ctx := context.Background() - informerFactory := startInformers(ctx, fakeClient, handler) - - // Call the getPodsInDeployment function - pods, err := handler.getPodsInDeployment(ctx, informerFactory, deployment, replicaset) - require.NoError(t, err) - require.Equal(t, 1, len(pods)) - require.Equal(t, pod1.Name, pods[0].Name) -} - -func TestGetCurrentReplicaSetForDeployment(t *testing.T) { - // Create a fake Kubernetes clientset - fakeClient := fake.NewSimpleClientset() - - // Create a Deployment object - deployment := &v1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-deployment", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - }, - } - - // Create a ReplicaSet object with a higher revision than the other ReplicaSet - replicaSet1 := &v1.ReplicaSet{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-replicaset-1", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "1"}, - OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ - Group: v1.SchemeGroupVersion.Group, - Version: v1.SchemeGroupVersion.Version, - Kind: "Deployment", - }), - }, - }, - } - // Create another ReplicaSet object with a lower revision than the other ReplicaSet - replicaSet2 := &v1.ReplicaSet{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-replicaset-2", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "0"}, - OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ - Group: v1.SchemeGroupVersion.Group, - Version: v1.SchemeGroupVersion.Version, - Kind: "Deployment", - }), - }, - }, - } - - // Create another ReplicaSet object with a higher revision than the other ReplicaSet - replicaSet3 := &v1.ReplicaSet{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-replicaset-3", - Namespace: "test-namespace", - Annotations: map[string]string{"deployment.kubernetes.io/revision": "3"}, - OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(deployment, schema.GroupVersionKind{ - Group: v1.SchemeGroupVersion.Group, - Version: v1.SchemeGroupVersion.Version, - Kind: "Deployment", - }), - }, - }, - } - - // Add the ReplicaSet objects to the fake Kubernetes clientset - _, err := fakeClient.AppsV1().ReplicaSets(replicaSet1.Namespace).Create(context.Background(), replicaSet1, metav1.CreateOptions{}) - require.NoError(t, err) - _, err = fakeClient.AppsV1().ReplicaSets(replicaSet2.Namespace).Create(context.Background(), replicaSet2, metav1.CreateOptions{}) - require.NoError(t, err) - _, err = fakeClient.AppsV1().ReplicaSets(replicaSet2.Namespace).Create(context.Background(), replicaSet3, metav1.CreateOptions{}) - require.NoError(t, err) - - // Add the Deployment object to the fake Kubernetes clientset - _, err = fakeClient.AppsV1().Deployments(deployment.Namespace).Create(context.Background(), deployment, metav1.CreateOptions{}) - require.NoError(t, err) - - // Create a KubernetesHandler object with the fake clientset - handler := &kubernetesHandler{ - clientSet: fakeClient, - } - - ctx := context.Background() - informerFactory := startInformers(ctx, fakeClient, handler) - - // Call the getNewestReplicaSetForDeployment function - rs := handler.getCurrentReplicaSetForDeployment(ctx, informerFactory, deployment) - require.Equal(t, replicaSet1.Name, rs.Name) -} - -func TestCheckPodStatus(t *testing.T) { - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod", - Namespace: "test-namespace", - }, - Status: corev1.PodStatus{}, - } - - podTests := []struct { - podCondition []corev1.PodCondition - containerStatus []corev1.ContainerStatus - isReady bool - expectedError string - }{ - { - // Container is in Terminated state - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ - Reason: "Error", - Message: "Container terminated due to an error", - }, - }, - }, - }, - isReady: false, - expectedError: "Container state is 'Terminated' Reason: Error, Message: Container terminated due to an error", - }, - { - // Container is in CrashLoopBackOff state - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Waiting: &corev1.ContainerStateWaiting{ - Reason: "CrashLoopBackOff", - Message: "Back-off 5m0s restarting failed container=test-container pod=test-pod", - }, - }, - }, - }, - isReady: false, - expectedError: "Container state is 'Waiting' Reason: CrashLoopBackOff, Message: Back-off 5m0s restarting failed container=test-container pod=test-pod", - }, - { - // Container is in ErrImagePull state - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Waiting: &corev1.ContainerStateWaiting{ - Reason: "ErrImagePull", - Message: "Cannot pull image", - }, - }, - }, - }, - isReady: false, - expectedError: "Container state is 'Waiting' Reason: ErrImagePull, Message: Cannot pull image", - }, - { - // Container is in ImagePullBackOff state - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Waiting: &corev1.ContainerStateWaiting{ - Reason: "ImagePullBackOff", - Message: "ImagePullBackOff", - }, - }, - }, - }, - isReady: false, - expectedError: "Container state is 'Waiting' Reason: ImagePullBackOff, Message: ImagePullBackOff", - }, - { - // No container statuses available - isReady: false, - expectedError: "", - }, - { - // Container is in Waiting state but not a terminally failed state - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Waiting: &corev1.ContainerStateWaiting{ - Reason: "ContainerCreating", - Message: "Container is being created", - }, - }, - Ready: false, - }, - }, - isReady: false, - expectedError: "", - }, - { - // Container's Running state is nil - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Running: nil, - }, - Ready: false, - }, - }, - isReady: false, - expectedError: "", - }, - { - // Readiness check is not yet passed - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - Ready: false, - }, - }, - isReady: false, - expectedError: "", - }, - { - // Container is in Ready state - podCondition: nil, - containerStatus: []corev1.ContainerStatus{ - { - State: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - Ready: true, - }, - }, - isReady: true, - expectedError: "", - }, - } - - ctx := context.Background() - handler := &kubernetesHandler{} - for _, tc := range podTests { - pod.Status.Conditions = tc.podCondition - pod.Status.ContainerStatuses = tc.containerStatus - isReady, err := handler.checkPodStatus(ctx, pod) - if tc.expectedError != "" { - require.Error(t, err) - require.Equal(t, tc.expectedError, err.Error()) - } else { - require.NoError(t, err) - } - require.Equal(t, tc.isReady, isReady) - } -} - -func TestCheckAllPodsReady_Success(t *testing.T) { - // Create a fake Kubernetes clientset - clientset := fake.NewSimpleClientset() - - ctx := context.Background() - - _, err := clientset.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) - require.NoError(t, err) - - replicaSet := addReplicaSetToDeployment(t, ctx, clientset, testDeployment) - - // Create a pod - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test", - }, - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{ - { - Name: "test-container", - Image: "test-image", - }, - }, - }, - Status: corev1.PodStatus{ - Phase: corev1.PodRunning, - ContainerStatuses: []corev1.ContainerStatus{ - { - Name: "test-container", - Ready: true, - }, - }, - }, - } - _, err = clientset.CoreV1().Pods("test-namespace").Create(context.Background(), pod, metav1.CreateOptions{}) - assert.NoError(t, err) - - // Create an informer factory and add the deployment and replica set to the cache - informerFactory := informers.NewSharedInformerFactory(clientset, 0) - addTestObjects(t, clientset, informerFactory, testDeployment, replicaSet, pod) - - // Create a done channel - doneCh := make(chan error) - - // Create a handler with the fake clientset - handler := &kubernetesHandler{ - clientSet: clientset, - } - - // Call the checkAllPodsReady function - allReady := handler.checkAllPodsReady(ctx, informerFactory, testDeployment, replicaSet, doneCh) - - // Check that all pods are ready - require.True(t, allReady) -} - -func TestCheckAllPodsReady_Fail(t *testing.T) { - // Create a fake Kubernetes clientset - clientset := fake.NewSimpleClientset() - - ctx := context.Background() - - _, err := clientset.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) - require.NoError(t, err) - - replicaSet := addReplicaSetToDeployment(t, ctx, clientset, testDeployment) - - // Create a pod - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod1", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test", - }, - OwnerReferences: []metav1.OwnerReference{ - { - Kind: "ReplicaSet", - Name: replicaSet.Name, - Controller: to.Ptr(true), - }, - }, - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{ - { - Name: "test-container", - Image: "test-image", - }, - }, - }, - Status: corev1.PodStatus{ - Phase: corev1.PodRunning, - ContainerStatuses: []corev1.ContainerStatus{ - { - Name: "test-container", - Ready: false, - }, - }, - }, - } - _, err = clientset.CoreV1().Pods(pod.Namespace).Create(context.Background(), pod, metav1.CreateOptions{}) - require.NoError(t, err) - - // Create an informer factory and add the deployment and replica set to the cache - informerFactory := informers.NewSharedInformerFactory(clientset, 0) - addTestObjects(t, clientset, informerFactory, testDeployment, replicaSet, pod) - - // Create a done channel - doneCh := make(chan error) - - // Create a handler with the fake clientset - handler := &kubernetesHandler{ - clientSet: clientset, - } - - // Call the checkAllPodsReady function - allReady := handler.checkAllPodsReady(ctx, informerFactory, testDeployment, replicaSet, doneCh) - - // Check that all pods are ready - require.False(t, allReady) -} - -func TestCheckDeploymentStatus_AllReady(t *testing.T) { - // Create a fake Kubernetes fakeClient - fakeClient := fake.NewSimpleClientset() - - ctx := context.Background() - _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) - require.NoError(t, err) - replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, testDeployment) - - // Create a Pod object - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod1", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test", - }, - OwnerReferences: []metav1.OwnerReference{ - { - Kind: "ReplicaSet", - Name: replicaSet.Name, - Controller: to.Ptr(true), - }, - }, - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodScheduled, - Status: corev1.ConditionTrue, - }, - }, - ContainerStatuses: []corev1.ContainerStatus{ - { - Name: "test-container", - Ready: true, - State: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - }, - }, - }, - } - - // Add the Pod object to the fake Kubernetes clientset - _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) - require.NoError(t, err, "Failed to create Pod: %v", err) - - // Create an informer factory and add the deployment to the cache - informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) - addTestObjects(t, fakeClient, informerFactory, testDeployment, replicaSet, pod) - - // Create a fake item and object - item := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "metadata": map[string]interface{}{ - "name": "test-deployment", - "namespace": "test-namespace", - }, - }, - } - - // Create a done channel - doneCh := make(chan error, 1) - - // Call the checkDeploymentStatus function - handler := &kubernetesHandler{ - clientSet: fakeClient, - } - - go handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) - - err = <-doneCh - - // Check that the deployment readiness was checked - require.Nil(t, err) -} - -func TestCheckDeploymentStatus_NoReplicaSetsFound(t *testing.T) { - // Create a fake Kubernetes fakeClient - fakeClient := fake.NewSimpleClientset() - - ctx := context.Background() - _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) - require.NoError(t, err) - - // Create a Pod object - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod1", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test", - }, - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodScheduled, - Status: corev1.ConditionTrue, - }, - }, - ContainerStatuses: []corev1.ContainerStatus{ - { - Name: "test-container", - Ready: true, - State: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - }, - }, - }, - } - - // Add the Pod object to the fake Kubernetes clientset - _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) - require.NoError(t, err, "Failed to create Pod: %v", err) - - // Create an informer factory and add the deployment to the cache - informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) - err = informerFactory.Apps().V1().Deployments().Informer().GetIndexer().Add(testDeployment) - require.NoError(t, err, "Failed to add deployment to informer cache") - err = informerFactory.Core().V1().Pods().Informer().GetIndexer().Add(pod) - require.NoError(t, err, "Failed to add pod to informer cache") - // Note: No replica set added - - // Create a fake item and object - item := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "metadata": map[string]interface{}{ - "name": "test-deployment", - "namespace": "test-namespace", - }, - }, - } - - // Create a done channel - doneCh := make(chan error, 1) - - // Call the checkDeploymentStatus function - handler := &kubernetesHandler{ - clientSet: fakeClient, - } - - allReady := handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) - - // Check that the deployment readiness was checked - require.False(t, allReady) -} - -func TestCheckDeploymentStatus_PodsNotReady(t *testing.T) { - // Create a fake Kubernetes fakeClient - fakeClient := fake.NewSimpleClientset() - - ctx := context.Background() - _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) - require.NoError(t, err) - replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, testDeployment) - - // Create a Pod object - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod1", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test", - }, - OwnerReferences: []metav1.OwnerReference{ - { - Kind: "ReplicaSet", - Name: replicaSet.Name, - Controller: to.Ptr(true), - }, - }, - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodScheduled, - Status: corev1.ConditionTrue, - }, - }, - ContainerStatuses: []corev1.ContainerStatus{ - { - Name: "test-container", - Ready: true, - State: corev1.ContainerState{ - Terminated: &corev1.ContainerStateTerminated{ - Reason: "Error", - Message: "Container terminated due to an error", - }, - }, - }, - }, - }, - } - - // Add the Pod object to the fake Kubernetes clientset - _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) - require.NoError(t, err, "Failed to create Pod: %v", err) - - // Create an informer factory and add the deployment to the cache - informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) - addTestObjects(t, fakeClient, informerFactory, testDeployment, replicaSet, pod) - - // Create a fake item and object - item := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "metadata": map[string]interface{}{ - "name": "test-deployment", - "namespace": "test-namespace", - }, - }, - } - - // Create a done channel - doneCh := make(chan error, 1) - - // Call the checkDeploymentStatus function - handler := &kubernetesHandler{ - clientSet: fakeClient, - } - - go handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) - err = <-doneCh - - // Check that the deployment readiness was checked - require.Error(t, err) - require.Equal(t, err.Error(), "Container state is 'Terminated' Reason: Error, Message: Container terminated due to an error") -} - -func TestCheckDeploymentStatus_ObservedGenerationMismatch(t *testing.T) { - // Modify testDeployment to have a different generation than the observed generation - testDeployment.Generation = 2 - - // Create a fake Kubernetes fakeClient - fakeClient := fake.NewSimpleClientset() - - ctx := context.Background() - _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) - require.NoError(t, err) - replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, testDeployment) - - // Create a Pod object - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod1", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test", - }, - OwnerReferences: []metav1.OwnerReference{ - { - Kind: "ReplicaSet", - Name: replicaSet.Name, - Controller: to.Ptr(true), - }, - }, - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodScheduled, - Status: corev1.ConditionTrue, - }, - }, - ContainerStatuses: []corev1.ContainerStatus{ - { - Name: "test-container", - Ready: true, - State: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - }, - }, - }, - } - - // Add the Pod object to the fake Kubernetes clientset - _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) - require.NoError(t, err, "Failed to create Pod: %v", err) - - // Create an informer factory and add the deployment to the cache - informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) - addTestObjects(t, fakeClient, informerFactory, testDeployment, replicaSet, pod) - - // Create a fake item and object - item := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "metadata": map[string]interface{}{ - "name": "test-deployment", - "namespace": "test-namespace", - }, - }, - } - - // Create a done channel - doneCh := make(chan error, 1) - - // Call the checkDeploymentStatus function - handler := &kubernetesHandler{ - clientSet: fakeClient, - } - - handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) - - // Check that the deployment readiness was checked - require.Zero(t, len(doneCh)) -} - -func TestCheckDeploymentStatus_DeploymentNotProgressing(t *testing.T) { - // Create a fake Kubernetes fakeClient - fakeClient := fake.NewSimpleClientset() - - ctx := context.Background() - _, err := fakeClient.AppsV1().Deployments("test-namespace").Create(ctx, testDeployment, metav1.CreateOptions{}) - require.NoError(t, err) - replicaSet := addReplicaSetToDeployment(t, ctx, fakeClient, testDeployment) - - // Create a Pod object - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-pod1", - Namespace: "test-namespace", - Labels: map[string]string{ - "app": "test", - }, - OwnerReferences: []metav1.OwnerReference{ - { - Kind: "ReplicaSet", - Name: replicaSet.Name, - Controller: to.Ptr(true), - }, - }, - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodScheduled, - Status: corev1.ConditionTrue, - }, - }, - ContainerStatuses: []corev1.ContainerStatus{ - { - Name: "test-container", - Ready: true, - State: corev1.ContainerState{ - Running: &corev1.ContainerStateRunning{}, - }, - }, - }, - }, - } - - // Add the Pod object to the fake Kubernetes clientset - _, err = fakeClient.CoreV1().Pods(pod.Namespace).Create(ctx, pod, metav1.CreateOptions{}) - require.NoError(t, err, "Failed to create Pod: %v", err) - - // Create an informer factory and add the deployment to the cache - informerFactory := informers.NewSharedInformerFactory(fakeClient, 0) - addTestObjects(t, fakeClient, informerFactory, testDeployment, replicaSet, pod) - - testDeployment.Status = v1.DeploymentStatus{ - Conditions: []v1.DeploymentCondition{ - { - Type: v1.DeploymentProgressing, - Status: corev1.ConditionFalse, - Reason: "NewReplicaSetAvailable", - Message: "Deployment has minimum availability", - }, - }, - } - - // Create a fake item and object - item := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "metadata": map[string]interface{}{ - "name": "test-deployment", - "namespace": "test-namespace", - }, - }, - } - - // Create a done channel - doneCh := make(chan error, 1) - - // Call the checkDeploymentStatus function - handler := &kubernetesHandler{ - clientSet: fakeClient, - } - - ready := handler.checkDeploymentStatus(ctx, informerFactory, item, doneCh) - require.False(t, ready) -} - -func addTestObjects(t *testing.T, fakeClient *fake.Clientset, informerFactory informers.SharedInformerFactory, deployment *v1.Deployment, replicaSet *v1.ReplicaSet, pod *corev1.Pod) { - err := informerFactory.Apps().V1().Deployments().Informer().GetIndexer().Add(testDeployment) - require.NoError(t, err, "Failed to add deployment to informer cache") - err = informerFactory.Apps().V1().ReplicaSets().Informer().GetIndexer().Add(replicaSet) - require.NoError(t, err, "Failed to add replica set to informer cache") - err = informerFactory.Core().V1().Pods().Informer().GetIndexer().Add(pod) - require.NoError(t, err, "Failed to add pod to informer cache") -} diff --git a/pkg/corerp/handlers/mock_resource_handler.go b/pkg/corerp/handlers/mock_resource_handler.go index 11654a2413..9d13298438 100644 --- a/pkg/corerp/handlers/mock_resource_handler.go +++ b/pkg/corerp/handlers/mock_resource_handler.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/corerp/handlers (interfaces: ResourceHandler) +// Source: github.com/radius-project/radius/pkg/corerp/handlers (interfaces: ResourceHandler) // Package handlers is a generated GoMock package. package handlers diff --git a/pkg/corerp/handlers/resource_handler.go b/pkg/corerp/handlers/resource_handler.go index 0c78efaf38..928b9daa01 100644 --- a/pkg/corerp/handlers/resource_handler.go +++ b/pkg/corerp/handlers/resource_handler.go @@ -19,7 +19,7 @@ package handlers import ( "context" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const ( @@ -57,7 +57,7 @@ type DeleteOptions struct { // ResourceHandler interface defines the methods that every output resource will implement // -//go:generate mockgen -destination=./mock_resource_handler.go -package=handlers -self_package github.com/project-radius/radius/pkg/corerp/handlers github.com/project-radius/radius/pkg/corerp/handlers ResourceHandler +//go:generate mockgen -destination=./mock_resource_handler.go -package=handlers -self_package github.com/radius-project/radius/pkg/corerp/handlers github.com/radius-project/radius/pkg/corerp/handlers ResourceHandler type ResourceHandler interface { // Put deploys the rendered output resource and returns and populates the properties during deployment, // which can be used by the next resource handlers. diff --git a/pkg/corerp/handlers/util.go b/pkg/corerp/handlers/util.go index 79df4b0b6e..d0f7005a8b 100644 --- a/pkg/corerp/handlers/util.go +++ b/pkg/corerp/handlers/util.go @@ -17,7 +17,6 @@ limitations under the License. package handlers import ( - "errors" "fmt" "strings" ) @@ -63,6 +62,7 @@ func GetMapValue[T any](collection any, key string) (T, error) { return defaultValue, fmt.Errorf("value is not %T type", *new(T)) } return s, nil + default: + return defaultValue, fmt.Errorf("unsupported type: %T", c) } - return defaultValue, errors.New("unsupported type") } diff --git a/pkg/corerp/model/application_model.go b/pkg/corerp/model/application_model.go index 205f5c6634..bd86257eaf 100644 --- a/pkg/corerp/model/application_model.go +++ b/pkg/corerp/model/application_model.go @@ -19,28 +19,37 @@ package model import ( "fmt" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers/container" - azcontainer "github.com/project-radius/radius/pkg/corerp/renderers/container/azure" - "github.com/project-radius/radius/pkg/corerp/renderers/daprextension" - "github.com/project-radius/radius/pkg/corerp/renderers/gateway" - "github.com/project-radius/radius/pkg/corerp/renderers/httproute" - "github.com/project-radius/radius/pkg/corerp/renderers/kubernetesmetadata" - "github.com/project-radius/radius/pkg/corerp/renderers/manualscale" - "github.com/project-radius/radius/pkg/corerp/renderers/volume" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - - "github.com/project-radius/radius/pkg/resourcekinds" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers/container" + azcontainer "github.com/radius-project/radius/pkg/corerp/renderers/container/azure" + "github.com/radius-project/radius/pkg/corerp/renderers/daprextension" + "github.com/radius-project/radius/pkg/corerp/renderers/gateway" + "github.com/radius-project/radius/pkg/corerp/renderers/httproute" + "github.com/radius-project/radius/pkg/corerp/renderers/kubernetesmetadata" + "github.com/radius-project/radius/pkg/corerp/renderers/manualscale" + "github.com/radius-project/radius/pkg/corerp/renderers/volume" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + + "k8s.io/client-go/discovery" + "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/client" ) +const ( + // AnyResourceType is used to designate a resource handler that can handle any type that belongs to a provider. AnyResourceType + // should only be used to register handlers, and not as part of an output resource. + AnyResourceType = "*" +) + // NewApplicationModel configures RBAC support on connections based on connection kind, configures the providers supported by the appmodel, // registers the renderers and handlers for various resources, and checks for duplicate registrations. -func NewApplicationModel(arm *armauth.ArmConfig, k8sClient client.Client, k8sClientSet kubernetes.Interface) (ApplicationModel, error) { +func NewApplicationModel(arm *armauth.ArmConfig, k8sClient client.Client, k8sClientSet kubernetes.Interface, discoveryClient discovery.ServerResourcesInterface, k8sDynamicClientSet dynamic.Interface) (ApplicationModel, error) { // Configure RBAC support on connections based connection kind. // Role names can be user input or default roles assigned by Radius. // Leave RoleNames field empty if no default roles are supported for a connection kind. @@ -63,7 +72,7 @@ func NewApplicationModel(arm *armauth.ArmConfig, k8sClient client.Client, k8sCli }, datamodel.KindAzure: { // RBAC for non-Radius Azure resources. Supports user specified roles. - // More information can be found here: https://github.com/project-radius/radius/issues/1321 + // More information can be found here: https://github.com/radius-project/radius/issues/1321 }, } @@ -105,118 +114,47 @@ func NewApplicationModel(arm *armauth.ArmConfig, k8sClient client.Client, k8sCli outputResourceModel := []OutputResourceModel{ { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Kubernetes, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Deployment, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Service, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Secret, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Gateway, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Volume, + Type: AnyResourceType, Provider: resourcemodel.ProviderKubernetes, }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), + ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet, discoveryClient, k8sDynamicClientSet), }, { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.KubernetesHTTPRoute, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.SecretProviderClass, + Type: resources_kubernetes.ResourceTypeSecretProviderClass, Provider: resourcemodel.ProviderKubernetes, }, ResourceTransformer: azcontainer.TransformSecretProviderClass, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), + ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet, discoveryClient, k8sDynamicClientSet), }, { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.ServiceAccount, + Type: resources_kubernetes.ResourceTypeServiceAccount, Provider: resourcemodel.ProviderKubernetes, }, ResourceTransformer: azcontainer.TransformFederatedIdentitySA, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.KubernetesRole, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.KubernetesRoleBinding, - Provider: resourcemodel.ProviderKubernetes, - }, - ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet), + ResourceHandler: handlers.NewKubernetesHandler(k8sClient, k8sClientSet, discoveryClient, k8sDynamicClientSet), }, } azureOutputResourceModel := []OutputResourceModel{ - // Azure CosmosDB and Azure Redis models are consumed by deployment processor to fetch secrets for container dependencies. - // Any new SecretValueTransformer for a link should be added here to support connections from container. - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureCosmosDBMongo, - Provider: resourcemodel.ProviderAzure, - }, - }, { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, + Type: resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentity, Provider: resourcemodel.ProviderAzure, }, ResourceHandler: handlers.NewAzureUserAssignedManagedIdentityHandler(arm), }, { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, + Type: resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentityFederatedIdentityCredential, Provider: resourcemodel.ProviderAzure, }, ResourceHandler: handlers.NewAzureFederatedIdentity(arm), }, { ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - ResourceHandler: handlers.NewAzureRoleAssignmentHandler(arm), - }, - { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, + Type: resources_azure.ResourceTypeAuthorizationRoleAssignment, Provider: resourcemodel.ProviderAzure, }, ResourceHandler: handlers.NewAzureRoleAssignmentHandler(arm), diff --git a/pkg/corerp/model/types.go b/pkg/corerp/model/types.go index 8feff80aa1..b9326522b7 100644 --- a/pkg/corerp/model/types.go +++ b/pkg/corerp/model/types.go @@ -21,9 +21,9 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/resourcemodel" ) // ApplicationModel defines the set of supported resource types and related features. @@ -63,11 +63,17 @@ func (m ApplicationModel) LookupRadiusResourceModel(resourceType string) (*Radiu // or an error if the resourceType is unsupported. func (m ApplicationModel) LookupOutputResourceModel(resourceType resourcemodel.ResourceType) (*OutputResourceModel, error) { resource, ok := m.outputResourceLookup[resourceType] - if !ok { - return nil, fmt.Errorf("output resource kind '%s' is unsupported", resourceType) + if ok { + return &resource, nil } - return &resource, nil + // As a fallback, see if there is a handler for any resource type that belongs to the provider. + resource, ok = m.outputResourceLookup[resourcemodel.ResourceType{Provider: resourceType.Provider, Type: AnyResourceType}] + if ok { + return &resource, nil + } + + return nil, fmt.Errorf("output resource kind '%s' is unsupported", resourceType) } // IsProviderSupported checks if the given provider is supported by the application model. diff --git a/pkg/corerp/processors/extenders/processor.go b/pkg/corerp/processors/extenders/processor.go index 73a90fa626..59b08831b0 100644 --- a/pkg/corerp/processors/extenders/processor.go +++ b/pkg/corerp/processors/extenders/processor.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" ) // Processor is a processor for Extender resources. @@ -48,6 +48,11 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.Extender, o return nil } +// Delete implements the processors.Processor interface for Extender resources. +func (p *Processor) Delete(ctx context.Context, resource *datamodel.Extender, options processors.Options) error { + return nil +} + func mergeOutputValues(properties map[string]any, recipeOutput *recipes.RecipeOutput, secret bool) map[string]any { values := make(map[string]any) for k, val := range properties { diff --git a/pkg/corerp/processors/extenders/processor_test.go b/pkg/corerp/processors/extenders/processor_test.go index 2ea4b280eb..523faf527f 100644 --- a/pkg/corerp/processors/extenders/processor_test.go +++ b/pkg/corerp/processors/extenders/processor_test.go @@ -20,10 +20,10 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/renderers/container/azure/fileshare.go b/pkg/corerp/renderers/container/azure/fileshare.go index b0d2341c39..f448c8f8d2 100644 --- a/pkg/corerp/renderers/container/azure/fileshare.go +++ b/pkg/corerp/renderers/container/azure/fileshare.go @@ -17,9 +17,9 @@ limitations under the License. package azure import ( - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/ucp/resources" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/corerp/renderers/container/azure/identity.go b/pkg/corerp/renderers/container/azure/identity.go index 0943c12a6f..c7e0dfd550 100644 --- a/pkg/corerp/renderers/container/azure/identity.go +++ b/pkg/corerp/renderers/container/azure/identity.go @@ -21,17 +21,15 @@ import ( "errors" "fmt" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -50,7 +48,7 @@ func MakeManagedIdentity(name string, cloudProvider *datamodel.Providers) (*rpv1 var err error if cloudProvider != nil && cloudProvider.Azure.Scope != "" { rID, err = resources.Parse(cloudProvider.Azure.Scope) - if err != nil || rID.FindScope(resources.SubscriptionsSegment) == "" || rID.FindScope(resources.ResourceGroupsSegment) == "" { + if err != nil || rID.FindScope(resources_azure.ScopeSubscriptions) == "" || rID.FindScope(resources_azure.ScopeResourceGroups) == "" { return nil, fmt.Errorf("invalid environment Azure Provider scope: %s", cloudProvider.Azure.Scope) } } else { @@ -58,44 +56,42 @@ func MakeManagedIdentity(name string, cloudProvider *datamodel.Providers) (*rpv1 } return &rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, - Deployed: false, - Resource: map[string]string{ - handlers.UserAssignedIdentityNameKey: name, - handlers.UserAssignedIdentitySubscriptionID: rID.FindScope(resources.SubscriptionsSegment), - handlers.UserAssignedIdentityResourceGroup: rID.FindScope(resources.ResourceGroupsSegment), + LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + CreateResource: &rpv1.Resource{ + Data: map[string]string{ + handlers.UserAssignedIdentityNameKey: name, + handlers.UserAssignedIdentitySubscriptionID: rID.FindScope(resources_azure.ScopeSubscriptions), + handlers.UserAssignedIdentityResourceGroup: rID.FindScope(resources_azure.ScopeResourceGroups), + }, + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentity, + Provider: resourcemodel.ProviderAzure, + }, }, }, nil } // MakeRoleAssignments creates OutputResources and Dependencies for each roleName in the roleNames slice, and adds them to // the outputResources and deps slices respectively. -func MakeRoleAssignments(azResourceID string, roleNames []string) ([]rpv1.OutputResource, []rpv1.Dependency) { - deps := []rpv1.Dependency{} +func MakeRoleAssignments(azResourceID string, roleNames []string) ([]rpv1.OutputResource, []string) { + deps := []string{} outputResources := []rpv1.OutputResource{} for _, roleName := range roleNames { roleAssignment := rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.GenerateLocalIDForRoleAssignment(azResourceID, roleName), - Deployed: false, - Resource: map[string]string{ - handlers.RoleNameKey: roleName, - handlers.RoleAssignmentScope: azResourceID, - }, - Dependencies: []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + LocalID: rpv1.NewLocalID(rpv1.LocalIDRoleAssignmentPrefix, azResourceID, roleName), + CreateResource: &rpv1.Resource{ + Data: map[string]string{ + handlers.RoleNameKey: roleName, + handlers.RoleAssignmentScope: azResourceID, + }, + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeAuthorizationRoleAssignment, + Provider: resourcemodel.ProviderAzure, }, + Dependencies: []string{rpv1.LocalIDUserAssignedManagedIdentity}, }, } - deps = append(deps, rpv1.Dependency{LocalID: roleAssignment.LocalID}) + deps = append(deps, roleAssignment.LocalID) outputResources = append(outputResources, roleAssignment) } @@ -115,28 +111,25 @@ func MakeFederatedIdentity(name string, envOpt *renderers.EnvironmentOptions) (* subject := handlers.GetKubeAzureSubject(envOpt.Namespace, name) return &rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.LocalIDFederatedIdentity, - Deployed: false, - Resource: map[string]string{ - handlers.FederatedIdentityNameKey: name, - handlers.FederatedIdentitySubjectKey: subject, - handlers.FederatedIdentityIssuerKey: envOpt.Identity.OIDCIssuer, - }, - Dependencies: []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + LocalID: rpv1.LocalIDFederatedIdentity, + CreateResource: &rpv1.Resource{ + Data: map[string]string{ + handlers.FederatedIdentityNameKey: name, + handlers.FederatedIdentitySubjectKey: subject, + handlers.FederatedIdentityIssuerKey: envOpt.Identity.OIDCIssuer, + }, + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentityFederatedIdentityCredential, + Provider: resourcemodel.ProviderAzure, }, + Dependencies: []string{rpv1.LocalIDUserAssignedManagedIdentity}, }, }, nil } // TransformFederatedIdentitySA extracts the identity info from the request and adds it to the ServiceAccount annotations. func TransformFederatedIdentitySA(ctx context.Context, options *handlers.PutOptions) error { - sa, ok := options.Resource.Resource.(*corev1.ServiceAccount) + sa, ok := options.Resource.CreateResource.Data.(*corev1.ServiceAccount) if !ok { return errors.New("invalid output resource type") } @@ -146,14 +139,20 @@ func TransformFederatedIdentitySA(ctx context.Context, options *handlers.PutOpti return err } - sa.Annotations[azureWorkloadIdentityClientID] = clientID - sa.Annotations[azureWorkloadIdentityTenantID] = tenantID + if clientID != "" && tenantID != "" { + sa.Annotations[azureWorkloadIdentityClientID] = clientID + sa.Annotations[azureWorkloadIdentityTenantID] = tenantID + } return nil } func extractIdentityInfo(options *handlers.PutOptions) (clientID string, tenantID string, err error) { - mi := options.DependencyProperties[rpv1.LocalIDUserAssignedManagedIdentity] + mi, ok := options.DependencyProperties[rpv1.LocalIDUserAssignedManagedIdentity] + if !ok { + return "", "", nil + } + if mi == nil { err = errors.New("cannot find LocalIDUserAssignedManagedIdentity") return @@ -173,40 +172,15 @@ func extractIdentityInfo(options *handlers.PutOptions) (clientID string, tenantI return } -// MakeFederatedIdentitySA creates a ServiceAccount with descriptive labels and placeholder annotations for Azure Workload +// SetWorkloadIdentityServiceAccount creates a ServiceAccount with descriptive labels and placeholder annotations for Azure Workload // Identity, and returns an OutputResource with the ServiceAccount and a dependency on the FederatedIdentity. -func MakeFederatedIdentitySA(appName, name, namespace string, resource *datamodel.ContainerResource) *rpv1.OutputResource { - labels := kubernetes.MakeDescriptiveLabels(appName, resource.Name, resource.Type) - labels[AzureWorkloadIdentityUseKey] = "true" - - sa := &corev1.ServiceAccount{ - TypeMeta: metav1.TypeMeta{ - Kind: "ServiceAccount", - APIVersion: "v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: kubernetes.NormalizeResourceName(name), - Namespace: namespace, - Labels: labels, - Annotations: map[string]string{ - // ResourceTransformer transforms these values before deploying resource. - azureWorkloadIdentityClientID: "placeholder", - azureWorkloadIdentityTenantID: "placeholder", - }, - }, - } +func SetWorkloadIdentityServiceAccount(base *corev1.ServiceAccount) *rpv1.OutputResource { + base.ObjectMeta.Labels[AzureWorkloadIdentityUseKey] = "true" + base.ObjectMeta.Annotations[azureWorkloadIdentityClientID] = "placeholder" + base.ObjectMeta.Annotations[azureWorkloadIdentityTenantID] = "placeholder" - or := rpv1.NewKubernetesOutputResource( - resourcekinds.ServiceAccount, - rpv1.LocalIDServiceAccount, - sa, - sa.ObjectMeta) - - or.Dependencies = []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDFederatedIdentity, - }, - } + or := rpv1.NewKubernetesOutputResource(rpv1.LocalIDServiceAccount, base, base.ObjectMeta) + or.CreateResource.Dependencies = []string{rpv1.LocalIDFederatedIdentity} return &or } diff --git a/pkg/corerp/renderers/container/azure/identity_test.go b/pkg/corerp/renderers/container/azure/identity_test.go index 0ff45f7153..14115b7107 100644 --- a/pkg/corerp/renderers/container/azure/identity_test.go +++ b/pkg/corerp/renderers/container/azure/identity_test.go @@ -21,16 +21,16 @@ import ( "errors" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -63,16 +63,17 @@ func TestMakeManagedIdentity(t *testing.T) { or, err := MakeManagedIdentity("mi", provider) require.NoError(t, err) require.Equal(t, &rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, - Deployed: false, - Resource: map[string]string{ - handlers.UserAssignedIdentityNameKey: "mi", - handlers.UserAssignedIdentitySubscriptionID: "test-sub-id", - handlers.UserAssignedIdentityResourceGroup: "test-group", + LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentity, + Provider: resourcemodel.ProviderAzure, + }, + Data: map[string]string{ + handlers.UserAssignedIdentityNameKey: "mi", + handlers.UserAssignedIdentitySubscriptionID: "test-sub-id", + handlers.UserAssignedIdentityResourceGroup: "test-group", + }, }, }, or) }) @@ -89,28 +90,33 @@ func TestMakeRoleAssignments(t *testing.T) { require.Len(t, or, 2) require.Len(t, ra, 2) - require.Equal(t, rpv1.LocalIDUserAssignedManagedIdentity, or[0].Dependencies[0].LocalID) - require.Equal(t, rpv1.LocalIDUserAssignedManagedIdentity, or[1].Dependencies[0].LocalID) + require.Equal(t, rpv1.LocalIDUserAssignedManagedIdentity, or[0].CreateResource.Dependencies[0]) + require.Equal(t, rpv1.LocalIDUserAssignedManagedIdentity, or[1].CreateResource.Dependencies[0]) require.NotEqual(t, or[0].LocalID, or[1].LocalID) require.Equal(t, map[string]string{ handlers.RoleNameKey: "Role1", handlers.RoleAssignmentScope: miTestResource, - }, or[0].Resource) + }, or[0].CreateResource.Data) require.Equal(t, map[string]string{ handlers.RoleNameKey: "Role2", handlers.RoleAssignmentScope: miTestResource, - }, or[1].Resource) + }, or[1].CreateResource.Data) } -func TestMakeFederatedIdentitySA(t *testing.T) { - fi := MakeFederatedIdentitySA("app", "sa", "default", &datamodel.ContainerResource{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "test-cntr", - Type: "applications.core/containers", - }, +func TestSetWorkloadIdentityServiceAccount(t *testing.T) { + base := &corev1.ServiceAccount{ + TypeMeta: metav1.TypeMeta{ + Kind: "ServiceAccount", + APIVersion: "v1", }, - }) + ObjectMeta: metav1.ObjectMeta{ + Name: "test-cntr", + Labels: map[string]string{}, + Annotations: map[string]string{}, + }, + } + + fi := SetWorkloadIdentityServiceAccount(base) putOptions := &handlers.PutOptions{ Resource: fi, @@ -126,11 +132,11 @@ func TestMakeFederatedIdentitySA(t *testing.T) { // Transform outputresource err := TransformFederatedIdentitySA(context.Background(), putOptions) require.NoError(t, err) - sa := fi.Resource.(*corev1.ServiceAccount) + sa := fi.CreateResource.Data.(*corev1.ServiceAccount) require.Equal(t, sa.Annotations[azureWorkloadIdentityClientID], "newClientID") require.Equal(t, sa.Annotations[azureWorkloadIdentityTenantID], "newTenantID") - require.Equal(t, rpv1.LocalIDFederatedIdentity, fi.Dependencies[0].LocalID) + require.Equal(t, rpv1.LocalIDFederatedIdentity, fi.CreateResource.Dependencies[0]) } func TestTransformFederatedIdentitySA_Validation(t *testing.T) { @@ -148,7 +154,7 @@ func TestTransformFederatedIdentitySA_Validation(t *testing.T) { { desc: "missing user managed identity", resource: &corev1.ServiceAccount{}, - err: errors.New("cannot find LocalIDUserAssignedManagedIdentity"), + err: nil, }, { desc: "missing client ID", @@ -175,11 +181,15 @@ func TestTransformFederatedIdentitySA_Validation(t *testing.T) { for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { err := TransformFederatedIdentitySA(context.Background(), &handlers.PutOptions{ - Resource: &rpv1.OutputResource{Resource: tc.resource}, + Resource: &rpv1.OutputResource{CreateResource: &rpv1.Resource{Data: tc.resource}}, DependencyProperties: tc.dep, }) - require.ErrorContains(t, err, tc.err.Error()) + if tc.err != nil { + require.EqualError(t, err, tc.err.Error()) + } else { + require.NoError(t, err) + } }) } } @@ -209,11 +219,11 @@ func TestMakeFederatedIdentity(t *testing.T) { require.NoError(t, err) require.Equal(t, rpv1.LocalIDFederatedIdentity, or.LocalID) - require.Equal(t, rpv1.LocalIDUserAssignedManagedIdentity, or.Dependencies[0].LocalID) + require.Equal(t, rpv1.LocalIDUserAssignedManagedIdentity, or.CreateResource.Dependencies[0]) require.Equal(t, map[string]string{ handlers.FederatedIdentityNameKey: "fi", handlers.FederatedIdentitySubjectKey: "system:serviceaccount:default:fi", handlers.FederatedIdentityIssuerKey: "https://radiusoidc/00000000-0000-0000-0000-000000000000", - }, or.Resource) + }, or.CreateResource.Data) }) } diff --git a/pkg/corerp/renderers/container/azure/keyvaultvolume.go b/pkg/corerp/renderers/container/azure/keyvaultvolume.go index bf360ff712..aceedc00c8 100644 --- a/pkg/corerp/renderers/container/azure/keyvaultvolume.go +++ b/pkg/corerp/renderers/container/azure/keyvaultvolume.go @@ -20,14 +20,13 @@ import ( "context" "errors" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -70,7 +69,7 @@ func MakeKeyVaultVolumeSpec(volumeName string, mountPath, spcName string) (corev // TransformSecretProviderClass updates the clientID and tenantID for azure workload identity. func TransformSecretProviderClass(ctx context.Context, options *handlers.PutOptions) error { - spc, ok := options.Resource.Resource.(*csiv1.SecretProviderClass) + spc, ok := options.Resource.CreateResource.Data.(*csiv1.SecretProviderClass) if !ok { return errors.New("cannot transform service account") } @@ -132,17 +131,8 @@ func MakeKeyVaultSecretProviderClass(appName, name string, res *datamodel.Volume }, } - or := rpv1.NewKubernetesOutputResource( - resourcekinds.SecretProviderClass, - rpv1.LocalIDSecretProviderClass, - secretProvider, - secretProvider.ObjectMeta) - - or.Dependencies = []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDServiceAccount, - }, - } + or := rpv1.NewKubernetesOutputResource(rpv1.LocalIDSecretProviderClass, secretProvider, secretProvider.ObjectMeta) + or.CreateResource.Dependencies = []string{rpv1.LocalIDServiceAccount} return &or, nil diff --git a/pkg/corerp/renderers/container/azure/keyvaultvolume_test.go b/pkg/corerp/renderers/container/azure/keyvaultvolume_test.go index 9503a22353..6cc7188988 100644 --- a/pkg/corerp/renderers/container/azure/keyvaultvolume_test.go +++ b/pkg/corerp/renderers/container/azure/keyvaultvolume_test.go @@ -20,13 +20,13 @@ import ( "context" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -120,7 +120,7 @@ func TestMakeKeyVaultSecretProviderClass(t *testing.T) { if tc.err != nil { require.ErrorIs(t, tc.err, err) } else { - r := or.Resource.(*csiv1.SecretProviderClass) + r := or.CreateResource.Data.(*csiv1.SecretProviderClass) require.Equal(t, string(tc.identityKind), r.Annotations[kubernetes.AnnotationIdentityType]) require.Equal(t, tc.beforeParams, r.Spec.Parameters) diff --git a/pkg/corerp/renderers/container/azure/util.go b/pkg/corerp/renderers/container/azure/util.go index b462f82650..5e5fd506fb 100644 --- a/pkg/corerp/renderers/container/azure/util.go +++ b/pkg/corerp/renderers/container/azure/util.go @@ -17,7 +17,7 @@ limitations under the License. package azure import ( - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" ) const ( diff --git a/pkg/corerp/renderers/container/manifest.go b/pkg/corerp/renderers/container/manifest.go new file mode 100644 index 0000000000..538832bdc4 --- /dev/null +++ b/pkg/corerp/renderers/container/manifest.go @@ -0,0 +1,240 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package container + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "strings" + + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubeutil" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/ucplog" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/util/strategicpatch" +) + +var errDeploymentNotFound = errors.New("deployment resource must be in outputResources") + +// fetchBaseManifest fetches the base manifest from the container resource. +func fetchBaseManifest(r *datamodel.ContainerResource) (kubeutil.ObjectManifest, error) { + baseManifest := kubeutil.ObjectManifest{} + runtimes := r.Properties.Runtimes + var err error + + if runtimes != nil && runtimes.Kubernetes != nil && runtimes.Kubernetes.Base != "" { + baseManifest, err = kubeutil.ParseManifest([]byte(runtimes.Kubernetes.Base)) + if err != nil { + return nil, err + } + } + + return baseManifest, nil +} + +// getDeploymentBase returns the deployment resource based on the given base manifest. +// If the container has a base manifest, get the deployment resource from the base manifest. +// Otherwise, populate default resources. +func getDeploymentBase(manifest kubeutil.ObjectManifest, appName string, r *datamodel.ContainerResource, options *renderers.RenderOptions) *appsv1.Deployment { + name := kubernetes.NormalizeResourceName(r.Name) + + defaultDeployment := &appsv1.Deployment{ + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", + }, + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{}, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{}, + Annotations: map[string]string{}, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: name, + }, + }, + }, + }, + }, + } + + if resource := manifest.GetFirst(appsv1.SchemeGroupVersion.WithKind("Deployment")); resource != nil { + defaultDeployment = resource.(*appsv1.Deployment) + } + + defaultDeployment.ObjectMeta = getObjectMeta(defaultDeployment.ObjectMeta, appName, r.Name, r.ResourceTypeName(), *options) + if defaultDeployment.Spec.Selector == nil { + defaultDeployment.Spec.Selector = &metav1.LabelSelector{} + } + + podTemplate := &defaultDeployment.Spec.Template + if podTemplate.ObjectMeta.Labels == nil { + podTemplate.ObjectMeta.Labels = map[string]string{} + } + + if podTemplate.ObjectMeta.Annotations == nil { + podTemplate.ObjectMeta.Annotations = map[string]string{} + } + + if len(podTemplate.Spec.Containers) == 0 { + podTemplate.Spec.Containers = []corev1.Container{} + } + + found := false + for _, container := range podTemplate.Spec.Containers { + if strings.EqualFold(container.Name, name) { + found = true + break + } + } + if !found { + podTemplate.Spec.Containers = append(podTemplate.Spec.Containers, corev1.Container{Name: name}) + } + + return defaultDeployment +} + +// getServiceBase returns the service resource based on the given base manifest. +// If the service has a base manifest, get the service resource from the base manifest. +// Otherwise, populate default resources. +func getServiceBase(manifest kubeutil.ObjectManifest, appName string, r *datamodel.ContainerResource, options *renderers.RenderOptions) *corev1.Service { + defaultService := &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + Kind: "Service", + APIVersion: "v1", + }, + Spec: corev1.ServiceSpec{ + Selector: map[string]string{}, + Type: corev1.ServiceTypeClusterIP, + }, + } + if resource := manifest.GetFirst(corev1.SchemeGroupVersion.WithKind("Service")); resource != nil { + defaultService = resource.(*corev1.Service) + } + defaultService.ObjectMeta = getObjectMeta(defaultService.ObjectMeta, appName, r.Name, r.ResourceTypeName(), *options) + return defaultService +} + +// getServiceAccountBase returns the service account resource based on the given base manifest. +// If the service account has a base manifest, get the service account resource from the base manifest. +// Otherwise, populate default resources. +func getServiceAccountBase(manifest kubeutil.ObjectManifest, appName string, r *datamodel.ContainerResource, options *renderers.RenderOptions) *corev1.ServiceAccount { + defaultAccount := &corev1.ServiceAccount{ + TypeMeta: metav1.TypeMeta{ + Kind: "ServiceAccount", + APIVersion: "v1", + }, + } + + if resource := manifest.GetFirst(corev1.SchemeGroupVersion.WithKind("ServiceAccount")); resource != nil { + defaultAccount = resource.(*corev1.ServiceAccount) + } + + defaultAccount.ObjectMeta = getObjectMeta(defaultAccount.ObjectMeta, appName, r.Name, r.ResourceTypeName(), *options) + + return defaultAccount +} + +func getObjectMeta(metaObj metav1.ObjectMeta, appName, resourceName, resourceType string, options renderers.RenderOptions) metav1.ObjectMeta { + return metav1.ObjectMeta{ + Name: kubernetes.NormalizeResourceName(resourceName), + Namespace: options.Environment.Namespace, + Labels: labels.Merge(metaObj.Labels, renderers.GetLabels(options, appName, resourceName, resourceType)), + Annotations: labels.Merge(metaObj.Annotations, renderers.GetAnnotations(options)), + } +} + +// populateAllBaseResources populates all remaining resources from manifest into outputResources. +// These resources must be deployed before Deployment resource by adding them as a dependency. +func populateAllBaseResources(ctx context.Context, base kubeutil.ObjectManifest, outputResources []rpv1.OutputResource, options renderers.RenderOptions) []rpv1.OutputResource { + logger := ucplog.FromContextOrDiscard(ctx) + + // Find deployment resource from outputResources to add base manifest resources as a dependency. + var deploymentResource *rpv1.Resource + for _, r := range outputResources { + if r.LocalID == rpv1.LocalIDDeployment { + deploymentResource = r.CreateResource + break + } + } + + // This should not happen because deployment resource is created in the first place. + if deploymentResource == nil { + panic(errDeploymentNotFound) + } + + // Populate the remaining objects in base manifest into outputResources. + // These resources must be deployed before Deployment resource by adding them as a dependency. + for k, resources := range base { + localIDPrefix := "" + + switch k { + case corev1.SchemeGroupVersion.WithKind("Secret"): + localIDPrefix = rpv1.LocalIDSecret + case corev1.SchemeGroupVersion.WithKind("ConfigMap"): + localIDPrefix = rpv1.LocalIDConfigMap + + default: + continue + } + + for _, resource := range resources { + objMeta := resource.(metav1.ObjectMetaAccessor).GetObjectMeta().(*metav1.ObjectMeta) + objMeta.Namespace = options.Environment.Namespace + logger.Info(fmt.Sprintf("Adding base manifest resource, kind: %s, name: %s", k, objMeta.Name)) + + localID := rpv1.NewLocalID(localIDPrefix, objMeta.Name) + o := rpv1.NewKubernetesOutputResource(localID, resource, *objMeta) + deploymentResource.Dependencies = append(deploymentResource.Dependencies, localID) + outputResources = append(outputResources, o) + } + } + + return outputResources +} + +func patchPodSpec(sourceSpec *corev1.PodSpec, patchSpec []byte) (*corev1.PodSpec, error) { + podSpecJSON, err := json.Marshal(sourceSpec) + if err != nil { + return nil, err + } + + merged, err := strategicpatch.StrategicMergePatch(podSpecJSON, patchSpec, corev1.PodSpec{}) + if err != nil { + return nil, err + } + + patched := &corev1.PodSpec{} + err = json.Unmarshal(merged, patched) + if err != nil { + return nil, err + } + + return patched, nil +} diff --git a/pkg/corerp/renderers/container/manifest_test.go b/pkg/corerp/renderers/container/manifest_test.go new file mode 100644 index 0000000000..12684ddf97 --- /dev/null +++ b/pkg/corerp/renderers/container/manifest_test.go @@ -0,0 +1,506 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package container + +import ( + "fmt" + "strings" + "testing" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubeutil" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/k8sutil" + "github.com/radius-project/radius/test/testcontext" + + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +var ( + testResource = &datamodel.ContainerResource{ + BaseResource: v1.BaseResource{ + TrackedResource: v1.TrackedResource{ + ID: "/subscriptions/test-sub-id/resourceGroups/test-group/providers/Applications.Core/containers/test-container", + Name: "test-container", + Type: "Applications.Core/containers", + }, + }, + } + testOptions = &renderers.RenderOptions{Environment: renderers.EnvironmentOptions{Namespace: "test-ns"}} +) + +func TestFetchBaseManifest(t *testing.T) { + manifestTests := []struct { + name string + resource *datamodel.ContainerResource + }{ + { + name: "valid manifest", + resource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: fmt.Sprintf(k8sutil.FakeDeploymentTemplate, "magpie", "", "magpie"), + }, + }, + }, + }, + }, + { + name: "nil runtime", + resource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: nil, + }, + }, + }, + { + name: "nil runtime.kubernetes", + resource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: nil, + }, + }, + }, + { + name: "empty runtime.kubernetes.base", + resource: &datamodel.ContainerResource{ + Properties: datamodel.ContainerProperties{ + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Base: "", + }, + }, + }, + }, + }, + } + + for _, tc := range manifestTests { + t.Run(tc.name, func(t *testing.T) { + obj, err := fetchBaseManifest(tc.resource) + require.NoError(t, err) + require.NotNil(t, obj) + }) + } + +} + +func TestGetDeploymentBase(t *testing.T) { + deploymentTests := []struct { + name string + manifest kubeutil.ObjectManifest + expected *appsv1.Deployment + }{ + { + name: "without base manifest", + manifest: kubeutil.ObjectManifest{}, + expected: &appsv1.Deployment{ + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Namespace: "test-ns", + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "radius-rp", + "app.kubernetes.io/name": "test-container", + "app.kubernetes.io/part-of": "test", + "radius.dev/application": "test", + "radius.dev/resource": "test-container", + "radius.dev/resource-type": "applications.core-containers", + }, + Annotations: map[string]string{}, + }, + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{}, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{}, + Annotations: map[string]string{}, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "test-container", + }, + }, + }, + }, + }, + }, + }, + { + name: "with base manifest", + manifest: kubeutil.ObjectManifest{ + appsv1.SchemeGroupVersion.WithKind("Deployment"): []runtime.Object{ + &appsv1.Deployment{ + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Labels: map[string]string{ + "label0": "value0", + }, + Annotations: map[string]string{ + "annotation0": "value0", + }, + }, + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{}, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{}, + Annotations: map[string]string{}, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "sidecar", + }, + }, + }, + }, + }, + }, + }, + }, + expected: &appsv1.Deployment{ + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Namespace: "test-ns", + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "radius-rp", + "app.kubernetes.io/name": "test-container", + "app.kubernetes.io/part-of": "test", + "label0": "value0", + "radius.dev/application": "test", + "radius.dev/resource": "test-container", + "radius.dev/resource-type": "applications.core-containers", + }, + Annotations: map[string]string{ + "annotation0": "value0", + }, + }, + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{}, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{}, + Annotations: map[string]string{}, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "sidecar", + }, + { + Name: "test-container", + }, + }, + }, + }, + }, + }, + }, + } + + for _, tc := range deploymentTests { + t.Run(tc.name, func(t *testing.T) { + deploy := getDeploymentBase(tc.manifest, "test", testResource, testOptions) + require.Equal(t, tc.expected, deploy) + }) + } +} + +func TestGetServiceBase(t *testing.T) { + serviceTests := []struct { + name string + manifest kubeutil.ObjectManifest + expected *corev1.Service + }{ + { + name: "without base manifest", + manifest: kubeutil.ObjectManifest{}, + expected: &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + Kind: "Service", + APIVersion: "v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Namespace: "test-ns", + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "radius-rp", + "app.kubernetes.io/name": "test-container", + "app.kubernetes.io/part-of": "test", + "radius.dev/application": "test", + "radius.dev/resource": "test-container", + "radius.dev/resource-type": "applications.core-containers", + }, + Annotations: map[string]string{}, + }, + Spec: corev1.ServiceSpec{ + Selector: map[string]string{}, + Type: corev1.ServiceTypeClusterIP, + }, + }, + }, + { + name: "with base manifest", + manifest: kubeutil.ObjectManifest{ + corev1.SchemeGroupVersion.WithKind("Service"): []runtime.Object{ + &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + Kind: "Service", + APIVersion: "v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Labels: map[string]string{ + "label0": "value0", + }, + Annotations: map[string]string{ + "annotation0": "value0", + }, + }, + Spec: corev1.ServiceSpec{ + Selector: map[string]string{}, + }, + }, + }, + }, + expected: &corev1.Service{ + TypeMeta: metav1.TypeMeta{ + Kind: "Service", + APIVersion: "v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Namespace: "test-ns", + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "radius-rp", + "app.kubernetes.io/name": "test-container", + "app.kubernetes.io/part-of": "test", + "label0": "value0", + "radius.dev/application": "test", + "radius.dev/resource": "test-container", + "radius.dev/resource-type": "applications.core-containers", + }, + Annotations: map[string]string{ + "annotation0": "value0", + }, + }, + Spec: corev1.ServiceSpec{ + Selector: map[string]string{}, + }, + }, + }, + } + + for _, tc := range serviceTests { + t.Run(tc.name, func(t *testing.T) { + deploy := getServiceBase(tc.manifest, "test", testResource, testOptions) + require.Equal(t, tc.expected, deploy) + }) + } +} + +func TestGetServiceAccountBase(t *testing.T) { + accountTests := []struct { + name string + manifest kubeutil.ObjectManifest + expected *corev1.ServiceAccount + }{ + { + name: "without base manifest", + manifest: kubeutil.ObjectManifest{}, + expected: &corev1.ServiceAccount{ + TypeMeta: metav1.TypeMeta{ + Kind: "ServiceAccount", + APIVersion: "v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Namespace: "test-ns", + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "radius-rp", + "app.kubernetes.io/name": "test-container", + "app.kubernetes.io/part-of": "test", + "radius.dev/application": "test", + "radius.dev/resource": "test-container", + "radius.dev/resource-type": "applications.core-containers", + }, + Annotations: map[string]string{}, + }, + }, + }, + { + name: "with base manifest", + manifest: kubeutil.ObjectManifest{ + corev1.SchemeGroupVersion.WithKind("ServiceAccount"): []runtime.Object{ + &corev1.ServiceAccount{ + TypeMeta: metav1.TypeMeta{ + Kind: "ServiceAccount", + APIVersion: "v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Labels: map[string]string{ + "label0": "value0", + }, + Annotations: map[string]string{ + "annotation0": "value0", + }, + }, + }, + }, + }, + expected: &corev1.ServiceAccount{ + TypeMeta: metav1.TypeMeta{ + Kind: "ServiceAccount", + APIVersion: "v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-container", + Namespace: "test-ns", + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "radius-rp", + "app.kubernetes.io/name": "test-container", + "app.kubernetes.io/part-of": "test", + "label0": "value0", + "radius.dev/application": "test", + "radius.dev/resource": "test-container", + "radius.dev/resource-type": "applications.core-containers", + }, + Annotations: map[string]string{ + "annotation0": "value0", + }, + }, + }, + }, + } + + for _, tc := range accountTests { + t.Run(tc.name, func(t *testing.T) { + deploy := getServiceAccountBase(tc.manifest, "test", testResource, testOptions) + require.Equal(t, tc.expected, deploy) + }) + } +} + +func TestPopulateAllBaseResources(t *testing.T) { + fakeDeployment := fmt.Sprintf(k8sutil.FakeDeploymentTemplate, "magpie", "", "magpie") + + ctx := testcontext.New(t) + + t.Run("deployment resource is not in outputResources", func(t *testing.T) { + manifest, err := kubeutil.ParseManifest([]byte(fakeDeployment)) + require.NoError(t, err) + outputResources := []rpv1.OutputResource{} + require.Panics(t, func() { + populateAllBaseResources(ctx, manifest, outputResources, *testOptions) + }) + }) + + t.Run("populate secret and configmap into outputResource", func(t *testing.T) { + fakeService := fmt.Sprintf(k8sutil.FakeServiceTemplate, "magpie", "") + fakeServiceAccount := fmt.Sprintf(k8sutil.FakeServiceAccountTemplate, "magpie") + fakeSecret0 := fmt.Sprintf(k8sutil.FakeSecretTemplate, "secret0") + fakeSecret1 := fmt.Sprintf(k8sutil.FakeSecretTemplate, "secret1") + fakeConfigMap0 := fmt.Sprintf(k8sutil.FakeConfigMapTemplate, "configmap0") + fakeConfigMap1 := fmt.Sprintf(k8sutil.FakeConfigMapTemplate, "configmap1") + + baseString := strings.Join([]string{fakeDeployment, fakeService, fakeServiceAccount, fakeSecret0, fakeConfigMap0, fakeSecret1, fakeConfigMap1}, k8sutil.YAMLSeparater) + manifest, err := kubeutil.ParseManifest([]byte(baseString)) + require.NoError(t, err) + + outputResources := []rpv1.OutputResource{ + { + LocalID: rpv1.LocalIDDeployment, + CreateResource: &rpv1.Resource{}, + }, + } + + newOutput := populateAllBaseResources(ctx, manifest, outputResources, *testOptions) + require.Len(t, newOutput, 5) + outLocalIDs := []string{} + for _, o := range newOutput { + outLocalIDs = append(outLocalIDs, o.LocalID) + } + require.ElementsMatch(t, []string{"Deployment", "Secret-dtl+8w==", "Secret-ddl9YA==", "ConfigMap-6BU8tQ==", "ConfigMap-5xU7Ig=="}, outLocalIDs) + require.Len(t, outputResources[0].CreateResource.Dependencies, 4) + require.ElementsMatch(t, []string{"Secret-dtl+8w==", "Secret-ddl9YA==", "ConfigMap-6BU8tQ==", "ConfigMap-5xU7Ig=="}, outputResources[0].CreateResource.Dependencies) + }) +} + +func TestPatchPodSpec(t *testing.T) { + podSpec := &corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "sidecar", + }, + { + Name: "test-container", + }, + }, + } + + patchingPod := ` +{ + "containers": [ + { + "name": "sidecar", + "image": "fluent-bit:latest" + } + ], + "nodeName": "test", + "hostNetwork": true +} +` + + expected := &corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "sidecar", + Image: "fluent-bit:latest", + }, + { + Name: "test-container", + }, + }, + NodeName: "test", + HostNetwork: true, + } + + patched, err := patchPodSpec(podSpec, []byte(patchingPod)) + require.NoError(t, err) + require.Equal(t, expected, patched) +} diff --git a/pkg/corerp/renderers/container/rbac.go b/pkg/corerp/renderers/container/rbac.go index 3a29d95cfd..86e9197ab1 100644 --- a/pkg/corerp/renderers/container/rbac.go +++ b/pkg/corerp/renderers/container/rbac.go @@ -20,10 +20,9 @@ import ( rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) func makeRBACRole(appName, name, namespace string, resource *datamodel.ContainerResource) *rpv1.OutputResource { @@ -49,11 +48,7 @@ func makeRBACRole(appName, name, namespace string, resource *datamodel.Container }, } - or := rpv1.NewKubernetesOutputResource( - resourcekinds.KubernetesRole, - rpv1.LocalIDKubernetesRole, - role, - role.ObjectMeta) + or := rpv1.NewKubernetesOutputResource(rpv1.LocalIDKubernetesRole, role, role.ObjectMeta) return &or } @@ -84,16 +79,8 @@ func makeRBACRoleBinding(appName, name, saName, namespace string, resource *data }, } - or := rpv1.NewKubernetesOutputResource( - resourcekinds.KubernetesRoleBinding, - rpv1.LocalIDKubernetesRoleBinding, - bindings, - bindings.ObjectMeta) + or := rpv1.NewKubernetesOutputResource(rpv1.LocalIDKubernetesRoleBinding, bindings, bindings.ObjectMeta) - or.Dependencies = []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDKubernetesRole, - }, - } + or.CreateResource.Dependencies = []string{rpv1.LocalIDKubernetesRole} return &or } diff --git a/pkg/corerp/renderers/container/render.go b/pkg/corerp/renderers/container/render.go index fb7b18be1c..e93338f3c6 100644 --- a/pkg/corerp/renderers/container/render.go +++ b/pkg/corerp/renderers/container/render.go @@ -27,24 +27,25 @@ import ( "strconv" "strings" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/intstr" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers" - azrenderer "github.com/project-radius/radius/pkg/corerp/renderers/container/azure" - azvolrenderer "github.com/project-radius/radius/pkg/corerp/renderers/volume/azure" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers" + azrenderer "github.com/radius-project/radius/pkg/corerp/renderers/container/azure" + azvolrenderer "github.com/radius-project/radius/pkg/corerp/renderers/volume/azure" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" ) const ( @@ -58,11 +59,6 @@ const ( AzureKeyVaultSecretsUserRole = "Key Vault Secrets User" AzureKeyVaultCryptoUserRole = "Key Vault Crypto User" - - defaultServiceAccountName = "default" - httpScheme = "http" - httpsScheme = "https" - httpsPort = 443 ) // GetSupportedKinds returns a list of supported volume kinds. @@ -111,7 +107,7 @@ func (r Renderer) GetDependencyIDs(ctx context.Context, dm v1.DataModelInterface continue } - if resourceID.IsRadiusRPResource() { + if resources_radius.IsRadiusResource(resourceID) { radiusResourceIDs = append(radiusResourceIDs, resourceID) continue } @@ -130,7 +126,7 @@ func (r Renderer) GetDependencyIDs(ctx context.Context, dm v1.DataModelInterface return nil, nil, v1.NewClientErrInvalidRequest(err.Error()) } - if resourceID.IsRadiusRPResource() { + if resources_radius.IsRadiusResource(resourceID) { radiusResourceIDs = append(radiusResourceIDs, resourceID) continue } @@ -144,7 +140,7 @@ func (r Renderer) GetDependencyIDs(ctx context.Context, dm v1.DataModelInterface return nil, nil, v1.NewClientErrInvalidRequest(err.Error()) } - if resourceID.IsRadiusRPResource() { + if resources_radius.IsRadiusResource(resourceID) { radiusResourceIDs = append(radiusResourceIDs, resourceID) continue } @@ -161,15 +157,20 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options if !ok { return renderers.RendererOutput{}, v1.ErrInvalidModelConversion } + properties := resource.Properties + appId, err := resources.ParseResource(properties.Application) + if err != nil { + return renderers.RendererOutput{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid application id: %s ", err.Error())) + } + // this flag is used to indicate whether or not this resource needs a service to be generated. // this flag is triggered when a container has an exposed port(s), but no 'provides' field. var needsServiceGeneration = false // check if connections are valid for _, connection := range properties.Connections { - // if source is a URL, it is valid (example: 'http://containerx:3000'). if isURL(connection.Source) { continue @@ -182,11 +183,16 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options } } - for _, port := range properties.Container.Ports { + for portName, port := range properties.Container.Ports { // if the container has an exposed port, note that down. // A single service will be generated for a container with one or more exposed ports. if port.ContainerPort == 0 { - return renderers.RendererOutput{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid ports definition: must define a ContainerPort, but ContainerPort was: %d.", port.ContainerPort)) + return renderers.RendererOutput{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid ports definition: must define a ContainerPort, but ContainerPort is: %d.", port.ContainerPort)) + } + + if port.Port == 0 { + port.Port = port.ContainerPort + properties.Container.Ports[portName] = port } // if the container has an exposed port, but no 'provides' field, it requires DNS service generation. @@ -195,11 +201,6 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options } } - appId, err := resources.ParseResource(properties.Application) - if err != nil { - return renderers.RendererOutput{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid application id: %s ", err.Error())) - } - outputResources := []rpv1.OutputResource{} dependencies := options.Dependencies @@ -222,10 +223,16 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options outputResources = append(outputResources, roles...) } + // If the container has a base manifest, deserialize base manifest and validation should be done by frontend controller. + baseManifest, err := fetchBaseManifest(resource) + if err != nil { + return renderers.RendererOutput{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid base manifest: %s", err.Error())) + } + computedValues := map[string]rpv1.ComputedValueReference{} // Create the deployment as the primary workload - deploymentResources, secretData, err := r.makeDeployment(ctx, appId.Name(), options, computedValues, resource, roles) + deploymentResources, secretData, err := r.makeDeployment(ctx, baseManifest, appId.Name(), options, computedValues, resource, roles) if err != nil { return renderers.RendererOutput{}, err } @@ -237,89 +244,99 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options outputResources = append(outputResources, r.makeSecret(ctx, *resource, appId.Name(), secretData, options)) } + var servicePorts []corev1.ServicePort + // If the container has an exposed port and uses DNS-SD, generate a service for it. if needsServiceGeneration { - containerPorts := containerPorts{ - values: []int32{}, - names: []string{}, - } - for portName, port := range resource.Properties.Container.Ports { // store portNames and portValues for use in service generation. - containerPorts.names = append(containerPorts.names, portName) - containerPorts.values = append(containerPorts.values, port.ContainerPort) + servicePort := corev1.ServicePort{ + Name: portName, + Port: port.Port, + TargetPort: intstr.FromInt(int(port.ContainerPort)), + Protocol: corev1.ProtocolTCP, + } + servicePorts = append(servicePorts, servicePort) } // if a container has an exposed port, then we need to create a service for it. - serviceResource, err := r.makeService(resource, options, ctx, containerPorts) + basesrv := getServiceBase(baseManifest, appId.Name(), resource, &options) + serviceResource, err := r.makeService(basesrv, resource, options, ctx, servicePorts) if err != nil { return renderers.RendererOutput{}, err } - outputResources = append(outputResources, serviceResource) } + // Populate the remaining resources from the base manifest. + outputResources = populateAllBaseResources(ctx, baseManifest, outputResources, options) + return renderers.RendererOutput{ Resources: outputResources, ComputedValues: computedValues, }, nil } -type containerPorts struct { - values []int32 - names []string -} - -func (r Renderer) makeService(resource *datamodel.ContainerResource, options renderers.RenderOptions, ctx context.Context, containerPorts containerPorts) (rpv1.OutputResource, error) { +func (r Renderer) makeService(base *corev1.Service, resource *datamodel.ContainerResource, options renderers.RenderOptions, ctx context.Context, servicePorts []corev1.ServicePort) (rpv1.OutputResource, error) { appId, err := resources.ParseResource(resource.Properties.Application) if err != nil { return rpv1.OutputResource{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("invalid application id: %s. id: %s", err.Error(), resource.Properties.Application)) } - // create the ports that will be exposed by the service. - ports := []corev1.ServicePort{} - for i, port := range containerPorts.values { - ports = append(ports, corev1.ServicePort{ - Name: containerPorts.names[i], - Port: port, - TargetPort: intstr.FromInt(int(containerPorts.values[i])), - Protocol: corev1.ProtocolTCP, - }) - } + // Ensure that we don't have any duplicate ports. +SKIPINSERT: + for _, newPort := range servicePorts { + // Skip to add new port. Instead, upsert port if it already exists. + for j, p := range base.Spec.Ports { + if strings.EqualFold(p.Name, newPort.Name) || p.Port == newPort.Port || p.TargetPort.IntVal == newPort.TargetPort.IntVal { + base.Spec.Ports[j] = newPort + continue SKIPINSERT + } + } - service := &corev1.Service{ - TypeMeta: metav1.TypeMeta{ - Kind: "Service", - APIVersion: "v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: kubernetes.NormalizeResourceName(resource.Name), - Namespace: options.Environment.Namespace, - Labels: renderers.GetLabels(ctx, options, appId.Name(), resource.Name, resource.ResourceTypeName()), - Annotations: renderers.GetAnnotations(ctx, options), - }, - Spec: corev1.ServiceSpec{ - Selector: kubernetes.MakeSelectorLabels(appId.Name(), resource.Name), - Type: corev1.ServiceTypeClusterIP, - Ports: ports, - }, + // Add new port if it doesn't exist. + base.Spec.Ports = append(base.Spec.Ports, newPort) } - return rpv1.NewKubernetesOutputResource(resourcekinds.Service, rpv1.LocalIDService, service, service.ObjectMeta), nil + base.Spec.Selector = kubernetes.MakeSelectorLabels(appId.Name(), resource.Name) + base.Spec.Type = corev1.ServiceTypeClusterIP + + return rpv1.NewKubernetesOutputResource(rpv1.LocalIDService, base, base.ObjectMeta), nil } -func (r Renderer) makeDeployment(ctx context.Context, applicationName string, options renderers.RenderOptions, computedValues map[string]rpv1.ComputedValueReference, resource *datamodel.ContainerResource, roles []rpv1.OutputResource) ([]rpv1.OutputResource, map[string][]byte, error) { +func (r Renderer) makeDeployment( + ctx context.Context, + manifest kubeutil.ObjectManifest, + applicationName string, + options renderers.RenderOptions, + computedValues map[string]rpv1.ComputedValueReference, + resource *datamodel.ContainerResource, + roles []rpv1.OutputResource) ([]rpv1.OutputResource, map[string][]byte, error) { // Keep track of the set of routes, we will need these to generate labels later routes := []struct { Name string Type string }{} + // If the container requires azure role, it needs to configure workload identity (aka federated identity). identityRequired := len(roles) > 0 dependencies := options.Dependencies properties := resource.Properties + normalizedName := kubernetes.NormalizeResourceName(resource.Name) + + deployment := getDeploymentBase(manifest, applicationName, resource, &options) + podSpec := &deployment.Spec.Template.Spec + + container := &podSpec.Containers[0] + for i, c := range podSpec.Containers { + if strings.EqualFold(c.Name, normalizedName) { + container = &podSpec.Containers[i] + break + } + } + ports := []corev1.ContainerPort{} for _, port := range properties.Container.Ports { if provides := port.Provides; provides != "" { @@ -353,15 +370,15 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op } } - container := corev1.Container{ - Name: kubernetes.NormalizeResourceName(resource.Name), - Image: properties.Container.Image, - Ports: ports, - Env: []corev1.EnvVar{}, - VolumeMounts: []corev1.VolumeMount{}, - Command: properties.Container.Command, - Args: properties.Container.Args, - WorkingDir: properties.Container.WorkingDir, + container.Image = properties.Container.Image + container.Ports = append(container.Ports, ports...) + container.Command = properties.Container.Command + container.Args = properties.Container.Args + container.WorkingDir = properties.Container.WorkingDir + + // If the user has specified an image pull policy, use it. Else, we will use Kubernetes default. + if properties.Container.ImagePullPolicy != "" { + container.ImagePullPolicy = corev1.PullPolicy(properties.Container.ImagePullPolicy) } var err error @@ -396,20 +413,16 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op } outputResources := []rpv1.OutputResource{} - - deps := []rpv1.Dependency{} + deps := []string{} podLabels := kubernetes.MakeDescriptiveLabels(applicationName, resource.Name, resource.ResourceTypeName()) - // This is the default service account name. If a volume is associated with federated identity, new service account - // will be created and set for container pods. - serviceAccountName := defaultServiceAccountName - // Add volumes volumes := []corev1.Volume{} // Create Kubernetes resource name scoped in Kubernetes namespace - kubeIdentityName := kubernetes.NormalizeResourceName(resource.Name) + kubeIdentityName := normalizedName + podSpec.ServiceAccountName = normalizedName // Create Azure resource name for managed/federated identity-scoped in resource group specified by Environment resource. // To avoid the naming conflicts, we add the application name prefix to resource name. @@ -474,7 +487,7 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op return []rpv1.OutputResource{}, nil, err } outputResources = append(outputResources, *secretProvider) - deps = append(deps, rpv1.Dependency{LocalID: rpv1.LocalIDSecretProviderClass}) + deps = append(deps, rpv1.LocalIDSecretProviderClass) // Create volume spec which associated with secretProviderClass. volumeSpec, volumeMountSpec, err = azrenderer.MakeKeyVaultVolumeSpec(volumeName, volumeProperties.Persistent.MountPath, spcName) @@ -497,12 +510,8 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op if value.(string) == rpv1.LocalIDAzureFileShareStorageAccount { // The storage account was not created when the computed value was rendered // Lookup the actual storage account name from the local id - id := properties.OutputResources[value.(string)].Data.(resourcemodel.ARMIdentity).ID - r, err := resources.ParseResource(id) - if err != nil { - return []rpv1.OutputResource{}, nil, v1.NewClientErrInvalidRequest(err.Error()) - } - value = r.Name() + id := properties.OutputResources[value.(string)] + value = id.Name() } secretData[key] = []byte(value.(string)) } @@ -518,6 +527,7 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op podLabels = labels.Merge(routeLabels, podLabels) } + serviceAccountBase := getServiceAccountBase(manifest, applicationName, resource, &options) // In order to enable per-container identity, it creates user-assigned managed identity, federated identity, and service account. if identityRequired { // 1. Create Per-Container managed identity. @@ -528,25 +538,23 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op outputResources = append(outputResources, *managedIdentity) // 2. Create Per-container federated identity resource. - serviceAccountName = kubeIdentityName - fedIdentity, err := azrenderer.MakeFederatedIdentity(serviceAccountName, &options.Environment) + fedIdentity, err := azrenderer.MakeFederatedIdentity(kubeIdentityName, &options.Environment) if err != nil { return []rpv1.OutputResource{}, nil, err } outputResources = append(outputResources, *fedIdentity) // 3. Create Per-container service account. - saAccount := azrenderer.MakeFederatedIdentitySA(applicationName, serviceAccountName, options.Environment.Namespace, resource) + saAccount := azrenderer.SetWorkloadIdentityServiceAccount(serviceAccountBase) outputResources = append(outputResources, *saAccount) + deps = append(deps, rpv1.LocalIDServiceAccount) // This is required to enable workload identity. podLabels[azrenderer.AzureWorkloadIdentityUseKey] = "true" - deps = append(deps, rpv1.Dependency{LocalID: rpv1.LocalIDServiceAccount}) - // 4. Add RBAC resources to the dependencies. for _, role := range roles { - deps = append(deps, rpv1.Dependency{LocalID: role.LocalID}) + deps = append(deps, role.LocalID) } computedValues[handlers.IdentityProperties] = rpv1.ComputedValueReference{ @@ -588,52 +596,40 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op return nil }, } + } else { + // If the container doesn't require identity, we'll use the default service account + or := rpv1.NewKubernetesOutputResource(rpv1.LocalIDServiceAccount, serviceAccountBase, serviceAccountBase.ObjectMeta) + outputResources = append(outputResources, or) + deps = append(deps, rpv1.LocalIDServiceAccount) } // Create the role and role bindings for SA. role := makeRBACRole(applicationName, kubeIdentityName, options.Environment.Namespace, resource) outputResources = append(outputResources, *role) - deps = append(deps, rpv1.Dependency{LocalID: rpv1.LocalIDKubernetesRole}) + deps = append(deps, rpv1.LocalIDKubernetesRole) - roleBinding := makeRBACRoleBinding(applicationName, kubeIdentityName, serviceAccountName, options.Environment.Namespace, resource) + roleBinding := makeRBACRoleBinding(applicationName, kubeIdentityName, podSpec.ServiceAccountName, options.Environment.Namespace, resource) outputResources = append(outputResources, *roleBinding) - deps = append(deps, rpv1.Dependency{LocalID: rpv1.LocalIDKubernetesRoleBinding}) + deps = append(deps, rpv1.LocalIDKubernetesRoleBinding) - deployment := appsv1.Deployment{ - TypeMeta: metav1.TypeMeta{ - Kind: "Deployment", - APIVersion: "apps/v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: kubernetes.NormalizeResourceName(resource.Name), - Namespace: options.Environment.Namespace, - Labels: kubernetes.MakeDescriptiveLabels(applicationName, resource.Name, resource.ResourceTypeName()), - }, - Spec: appsv1.DeploymentSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: kubernetes.MakeSelectorLabels(applicationName, resource.Name), - }, - Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: podLabels, - Annotations: map[string]string{}, - }, - Spec: corev1.PodSpec{ - // See: https://github.com/kubernetes/kubernetes/issues/92226 and - // https://github.com/project-radius/radius/issues/3002 - // - // Service links are a flawed and Kubernetes-only feature that we don't - // want to leak into Radius containers. - EnableServiceLinks: to.Ptr(false), - - ServiceAccountName: serviceAccountName, - Containers: []corev1.Container{container}, - Volumes: volumes, - }, - }, - }, + deployment.Spec.Template.ObjectMeta = metav1.ObjectMeta{ + Labels: podLabels, + Annotations: map[string]string{}, + } + + deployment.Spec.Selector = &metav1.LabelSelector{ + MatchLabels: kubernetes.MakeSelectorLabels(applicationName, resource.Name), } + podSpec.Volumes = append(podSpec.Volumes, volumes...) + + // See: https://github.com/kubernetes/kubernetes/issues/92226 and + // https://github.com/radius-project/radius/issues/3002 + // + // Service links are a flawed and Kubernetes-only feature that we don't + // want to leak into Radius containers. + podSpec.EnableServiceLinks = to.Ptr(false) + // If we have a secret to reference we need to ensure that the deployment will trigger a new revision // when the secret changes. Normally referencing an environment variable from a secret will **NOT** cause // a new revision when the secret changes. @@ -646,13 +642,20 @@ func (r Renderer) makeDeployment(ctx context.Context, applicationName string, op if len(secretData) > 0 { hash := r.hashSecretData(secretData) deployment.Spec.Template.ObjectMeta.Annotations[kubernetes.AnnotationSecretHash] = hash - deps = append(deps, rpv1.Dependency{ - LocalID: rpv1.LocalIDSecret, - }) + deps = append(deps, rpv1.LocalIDSecret) + } + + // Patching Runtimes.Kubernetes.Pod to the PodSpec in deployment resource. + if properties.Runtimes != nil && properties.Runtimes.Kubernetes != nil && properties.Runtimes.Kubernetes.Pod != "" { + patchedPodSpec, err := patchPodSpec(podSpec, []byte(properties.Runtimes.Kubernetes.Pod)) + if err != nil { + return []rpv1.OutputResource{}, nil, fmt.Errorf("failed to patch PodSpec: %w", err) + } + deployment.Spec.Template.Spec = *patchedPodSpec } - deploymentOutput := rpv1.NewKubernetesOutputResource(resourcekinds.Deployment, rpv1.LocalIDDeployment, &deployment, deployment.ObjectMeta) - deploymentOutput.Dependencies = deps + deploymentOutput := rpv1.NewKubernetesOutputResource(rpv1.LocalIDDeployment, deployment, deployment.ObjectMeta) + deploymentOutput.CreateResource.Dependencies = deps outputResources = append(outputResources, deploymentOutput) return outputResources, secretData, nil @@ -683,9 +686,13 @@ func getEnvVarsAndSecretData(resource *datamodel.ContainerResource, applicationN return map[string]corev1.EnvVar{}, map[string][]byte{}, fmt.Errorf("failed to parse source URL: %w", err) } - env["CONNECTIONS_"+name+"_SCHEME"] = corev1.EnvVar{Name: "CONNECTIONS_" + name + "_SCHEME", Value: scheme} - env["CONNECTIONS_"+name+"_HOSTNAME"] = corev1.EnvVar{Name: "CONNECTIONS_" + name + "_HOSTNAME", Value: hostname} - env["CONNECTIONS_"+name+"_PORT"] = corev1.EnvVar{Name: "CONNECTIONS_" + name + "_PORT", Value: port} + schemeKey := fmt.Sprintf("%s_%s_%s", "CONNECTION", strings.ToUpper(name), "SCHEME") + hostnameKey := fmt.Sprintf("%s_%s_%s", "CONNECTION", strings.ToUpper(name), "HOSTNAME") + portKey := fmt.Sprintf("%s_%s_%s", "CONNECTION", strings.ToUpper(name), "PORT") + + env[schemeKey] = corev1.EnvVar{Name: schemeKey, Value: scheme} + env[hostnameKey] = corev1.EnvVar{Name: hostnameKey, Value: hostname} + env[portKey] = corev1.EnvVar{Name: portKey, Value: port} continue } @@ -818,8 +825,7 @@ func (r Renderer) makeSecret(ctx context.Context, resource datamodel.ContainerRe Data: secrets, } - // Skip registration of the secret resource with the HealthService since health as a concept is not quite applicable to it - output := rpv1.NewKubernetesOutputResource(resourcekinds.Secret, rpv1.LocalIDSecret, &secret, secret.ObjectMeta) + output := rpv1.NewKubernetesOutputResource(rpv1.LocalIDSecret, &secret, secret.ObjectMeta) return output } @@ -880,34 +886,30 @@ func (r Renderer) makeRoleAssignmentsForResource(ctx context.Context, connection return nil, v1.NewClientErrInvalidRequest(fmt.Sprintf("output resource %q was not found in the outputs of dependency %q", roleAssignmentData.LocalID, connection.Source)) } - // Now we know the resource ID to assign roles against. - arm, ok := target.Data.(resourcemodel.ARMIdentity) - if !ok { + if !resources_azure.IsAzureResource(target) { return nil, v1.NewClientErrInvalidRequest(fmt.Sprintf("output resource %q must be an ARM resource to support role assignments. Was: %+v", roleAssignmentData.LocalID, target)) } - armResourceIdentifier = arm.ID + armResourceIdentifier = target.String() roleNames = roleAssignmentData.RoleNames } outputResources := []rpv1.OutputResource{} for _, roleName := range roleNames { - localID := rpv1.GenerateLocalIDForRoleAssignment(armResourceIdentifier, roleName) + localID := rpv1.NewLocalID(rpv1.LocalIDRoleAssignmentPrefix, armResourceIdentifier, roleName) roleAssignment := rpv1.OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: localID, - Deployed: false, - Resource: map[string]string{ - handlers.RoleNameKey: roleName, - handlers.RoleAssignmentScope: armResourceIdentifier, - }, - Dependencies: []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + + LocalID: localID, + CreateResource: &rpv1.Resource{ + Data: map[string]string{ + handlers.RoleNameKey: roleName, + handlers.RoleAssignmentScope: armResourceIdentifier, + }, + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeAuthorizationRoleAssignment, + Provider: resourcemodel.ProviderAzure, }, + Dependencies: []string{rpv1.LocalIDUserAssignedManagedIdentity}, }, } diff --git a/pkg/corerp/renderers/container/render_test.go b/pkg/corerp/renderers/container/render_test.go index 5bf0dce5bb..6bb274415d 100644 --- a/pkg/corerp/renderers/container/render_test.go +++ b/pkg/corerp/renderers/container/render_test.go @@ -20,25 +20,25 @@ import ( "fmt" "testing" - apiv1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/handlers" - "github.com/project-radius/radius/pkg/corerp/renderers" - azrenderer "github.com/project-radius/radius/pkg/corerp/renderers/container/azure" - azvolrenderer "github.com/project-radius/radius/pkg/corerp/renderers/volume/azure" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/testcontext" + apiv1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/handlers" + "github.com/radius-project/radius/pkg/corerp/renderers" + azrenderer "github.com/radius-project/radius/pkg/corerp/renderers/container/azure" + azvolrenderer "github.com/radius-project/radius/pkg/corerp/renderers/volume/azure" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/test/testcontext" "github.com/google/uuid" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" ) @@ -103,16 +103,33 @@ func makeResource(t *testing.T, properties datamodel.ContainerProperties) *datam return &resource } -func makeResourceID(t *testing.T, resourceType string, resourceName string) resources.ID { +func makeAzureResourceID(t *testing.T, resourceType string, resourceName string) resources.ID { id, err := resources.ParseResource(resources.MakeRelativeID( []resources.ScopeSegment{ {Type: "subscriptions", Name: "test-subscription"}, {Type: "resourceGroups", Name: "test-resourcegroup"}, }, - resources.TypeSegment{ - Type: resourceType, - Name: resourceName, - })) + []resources.TypeSegment{ + {Type: resourceType, Name: resourceName}, + }, nil)) + require.NoError(t, err) + + return id +} + +func makeRadiusResourceID(t *testing.T, resourceType string, resourceName string) resources.ID { + id, err := resources.ParseResource(resources.MakeRelativeID( + []resources.ScopeSegment{ + {Type: "radius", Name: "local"}, + {Type: "resourceGroups", Name: "test-resourcegroup"}, + }, + []resources.TypeSegment{ + { + Type: resourceType, + Name: resourceName, + }, + }, + nil)) require.NoError(t, err) return id @@ -120,17 +137,17 @@ func makeResourceID(t *testing.T, resourceType string, resourceName string) reso func Test_GetDependencyIDs_Success(t *testing.T) { testStorageResourceID := "/subscriptions/test-sub-id/resourceGroups/test-rg/providers/Microsoft.Storage/storageaccounts/testaccount/fileservices/default/shares/testShareName" - testAzureResourceID := makeResourceID(t, "Microsoft.ServiceBus/namespaces", "testAzureResource") + testAzureResourceID := makeAzureResourceID(t, "Microsoft.ServiceBus/namespaces", "testAzureResource") properties := datamodel.ContainerProperties{ BasicResourceProperties: rpv1.BasicResourceProperties{ Application: applicationResourceID, }, Connections: map[string]datamodel.ConnectionProperties{ "A": { - Source: makeResourceID(t, "Applications.Core/httpRoutes", "A").String(), + Source: makeRadiusResourceID(t, "Applications.Core/httpRoutes", "A").String(), }, "B": { - Source: makeResourceID(t, "Applications.Core/httpRoutes", "B").String(), + Source: makeRadiusResourceID(t, "Applications.Core/httpRoutes", "B").String(), IAM: datamodel.IAMProperties{ Kind: datamodel.KindHTTP, Roles: []string{"administrator"}, @@ -152,7 +169,7 @@ func Test_GetDependencyIDs_Success(t *testing.T) { Ports: map[string]datamodel.ContainerPort{ "web": { ContainerPort: 5000, - Provides: makeResourceID(t, "Applications.Core/httpRoutes", "C").String(), + Provides: makeRadiusResourceID(t, "Applications.Core/httpRoutes", "C").String(), }, }, Volumes: map[string]datamodel.VolumeProperties{ @@ -179,9 +196,9 @@ func Test_GetDependencyIDs_Success(t *testing.T) { require.Len(t, azureResourceIDs, 1) expectedRadiusResourceIDs := []resources.ID{ - makeResourceID(t, "Applications.Core/httpRoutes", "A"), - makeResourceID(t, "Applications.Core/httpRoutes", "B"), - makeResourceID(t, "Applications.Core/httpRoutes", "C"), + makeRadiusResourceID(t, "Applications.Core/httpRoutes", "A"), + makeRadiusResourceID(t, "Applications.Core/httpRoutes", "B"), + makeRadiusResourceID(t, "Applications.Core/httpRoutes", "C"), } require.ElementsMatch(t, expectedRadiusResourceIDs, radiusResourceIDs) @@ -220,7 +237,7 @@ func Test_GetDependencyIDs_InvalidAzureResourceId(t *testing.T) { properties := datamodel.ContainerProperties{ // Simulating error code path - // Revert this once TODO: https://github.com/project-radius/core-team/issues/238 is done. + // Revert this once TODO: https://github.com/radius-project/core-team/issues/238 is done. Connections: map[string]datamodel.ConnectionProperties{ "AzureResourceTest": { Source: "//subscriptions/test-sub-id/providers/Microsoft.ServiceBus/namespaces/testNamespace", @@ -278,15 +295,8 @@ func Test_Render_Basic(t *testing.T) { deployment, outputResource := kubernetes.FindDeployment(output.Resources) require.NotNil(t, deployment) - expected := rpv1.NewKubernetesOutputResource(resourcekinds.Deployment, rpv1.LocalIDDeployment, deployment, deployment.ObjectMeta) - expected.Dependencies = []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDKubernetesRole, - }, - { - LocalID: rpv1.LocalIDKubernetesRoleBinding, - }, - } + expected := rpv1.NewKubernetesOutputResource(rpv1.LocalIDDeployment, deployment, deployment.ObjectMeta) + expected.CreateResource.Dependencies = []string{rpv1.LocalIDServiceAccount, rpv1.LocalIDKubernetesRole, rpv1.LocalIDKubernetesRoleBinding} require.Equal(t, outputResource, expected) // Only real thing to verify here is the image and the labels @@ -294,7 +304,7 @@ func Test_Render_Basic(t *testing.T) { require.Equal(t, labels, deployment.Spec.Template.Labels) require.Equal(t, matchLabels, deployment.Spec.Selector.MatchLabels) - // See https://github.com/project-radius/radius/issues/3002 + // See https://github.com/radius-project/radius/issues/3002 // // We disable service links and rely on Radius' connections feature instead. require.NotNil(t, deployment.Spec.Template.Spec.EnableServiceLinks) @@ -313,14 +323,14 @@ func Test_Render_Basic(t *testing.T) { require.Equal(t, args, container.Args) require.Equal(t, "", container.WorkingDir) - expectedEnv := []v1.EnvVar{ + expectedEnv := []corev1.EnvVar{ {Name: envVarName1, Value: envVarValue1}, {Name: envVarName2, Value: envVarValue2}, } require.Equal(t, expectedEnv, container.Env) }) - require.Len(t, output.Resources, 3) + require.Len(t, output.Resources, 4) } func Test_Render_WithCommandArgsWorkingDir(t *testing.T) { @@ -356,15 +366,8 @@ func Test_Render_WithCommandArgsWorkingDir(t *testing.T) { deployment, outputResource := kubernetes.FindDeployment(output.Resources) require.NotNil(t, deployment) - expected := rpv1.NewKubernetesOutputResource(resourcekinds.Deployment, rpv1.LocalIDDeployment, deployment, deployment.ObjectMeta) - expected.Dependencies = []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDKubernetesRole, - }, - { - LocalID: rpv1.LocalIDKubernetesRoleBinding, - }, - } + expected := rpv1.NewKubernetesOutputResource(rpv1.LocalIDDeployment, deployment, deployment.ObjectMeta) + expected.CreateResource.Dependencies = []string{rpv1.LocalIDServiceAccount, rpv1.LocalIDKubernetesRole, rpv1.LocalIDKubernetesRoleBinding} require.Equal(t, outputResource, expected) // Only real thing to verify here is the image and the labels @@ -382,14 +385,14 @@ func Test_Render_WithCommandArgsWorkingDir(t *testing.T) { require.Equal(t, []string{"arg1", "arg2"}, container.Args) require.Equal(t, "/some/path", container.WorkingDir) - expectedEnv := []v1.EnvVar{ + expectedEnv := []corev1.EnvVar{ {Name: envVarName1, Value: envVarValue1}, {Name: envVarName2, Value: envVarValue2}, } require.Equal(t, expectedEnv, container.Env) }) - require.Len(t, output.Resources, 3) + require.Len(t, output.Resources, 4) } func Test_Render_PortWithoutRoute(t *testing.T) { @@ -427,14 +430,14 @@ func Test_Render_PortWithoutRoute(t *testing.T) { require.Len(t, container.Ports, 1) port := container.Ports[0] - expected := v1.ContainerPort{ + expected := corev1.ContainerPort{ ContainerPort: 5000, - Protocol: v1.ProtocolTCP, + Protocol: corev1.ProtocolTCP, } require.Equal(t, expected, port) }) - require.Len(t, output.Resources, 4) + require.Len(t, output.Resources, 5) } func Test_Render_PortConnectedToRoute(t *testing.T) { @@ -448,7 +451,7 @@ func Test_Render_PortConnectedToRoute(t *testing.T) { "web": { ContainerPort: 5000, Protocol: datamodel.ProtocolTCP, - Provides: makeResourceID(t, "Applications.Core/httpRoutes", "A").String(), + Provides: makeRadiusResourceID(t, "Applications.Core/httpRoutes", "A").String(), }, }, }, @@ -481,30 +484,37 @@ func Test_Render_PortConnectedToRoute(t *testing.T) { require.Len(t, container.Ports, 1) port := container.Ports[0] - routeID := makeResourceID(t, "Applications.Core/httpRoutes", "A") + routeID := makeRadiusResourceID(t, "Applications.Core/httpRoutes", "A") - expected := v1.ContainerPort{ + expected := corev1.ContainerPort{ Name: kubernetes.GetShortenedTargetPortName("httpRoutes" + routeID.Name()), ContainerPort: 5000, - Protocol: v1.ProtocolTCP, + Protocol: corev1.ProtocolTCP, } require.Equal(t, expected, port) }) - require.Len(t, output.Resources, 3) + require.Len(t, output.Resources, 4) } func Test_Render_Connections(t *testing.T) { + containerConnectionHostname := "containerB" + containerConnectionScheme := "http" + containerConnectionPort := "80" + properties := datamodel.ContainerProperties{ BasicResourceProperties: rpv1.BasicResourceProperties{ Application: applicationResourceID, }, Connections: map[string]datamodel.ConnectionProperties{ "A": { - Source: makeResourceID(t, "SomeProvider/ResourceType", "A").String(), + Source: makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String(), IAM: datamodel.IAMProperties{ Kind: datamodel.KindHTTP, }, }, + "containerB": { + Source: fmt.Sprintf("%s://%s:%s", containerConnectionScheme, containerConnectionHostname, containerConnectionPort), + }, }, Container: datamodel.Container{ Image: "someimage:latest", @@ -516,8 +526,8 @@ func Test_Render_Connections(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeRadiusResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, @@ -545,12 +555,12 @@ func Test_Render_Connections(t *testing.T) { require.Equal(t, properties.Container.Image, container.Image) require.Empty(t, container.ImagePullPolicy) - expectedEnv := []v1.EnvVar{ + expectedEnv := []corev1.EnvVar{ { Name: "CONNECTION_A_COMPUTEDKEY1", - ValueFrom: &v1.EnvVarSource{ - SecretKeyRef: &v1.SecretKeySelector{ - LocalObjectReference: v1.LocalObjectReference{ + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ Name: secretName, }, Key: "CONNECTION_A_COMPUTEDKEY1", @@ -559,15 +569,27 @@ func Test_Render_Connections(t *testing.T) { }, { Name: "CONNECTION_A_COMPUTEDKEY2", - ValueFrom: &v1.EnvVarSource{ - SecretKeyRef: &v1.SecretKeySelector{ - LocalObjectReference: v1.LocalObjectReference{ + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ Name: secretName, }, Key: "CONNECTION_A_COMPUTEDKEY2", }, }, }, + { + Name: "CONNECTION_CONTAINERB_HOSTNAME", + Value: containerConnectionHostname, + }, + { + Name: "CONNECTION_CONTAINERB_PORT", + Value: containerConnectionPort, + }, + { + Name: "CONNECTION_CONTAINERB_SCHEME", + Value: containerConnectionScheme, + }, {Name: envVarName1, Value: envVarValue1}, {Name: envVarName2, Value: envVarValue2}, } @@ -578,7 +600,7 @@ func Test_Render_Connections(t *testing.T) { secret, outputResource := kubernetes.FindSecret(output.Resources) require.NotNil(t, secret) - expectedOutputResource := rpv1.NewKubernetesOutputResource(resourcekinds.Secret, rpv1.LocalIDSecret, secret, secret.ObjectMeta) + expectedOutputResource := rpv1.NewKubernetesOutputResource(rpv1.LocalIDSecret, secret, secret.ObjectMeta) require.Equal(t, outputResource, expectedOutputResource) require.Equal(t, secretName, secret.Name) @@ -591,7 +613,7 @@ func Test_Render_Connections(t *testing.T) { require.Equal(t, "ComputedValue1", string(secret.Data["CONNECTION_A_COMPUTEDKEY1"])) require.Equal(t, "82", string(secret.Data["CONNECTION_A_COMPUTEDKEY2"])) }) - require.Len(t, output.Resources, 4) + require.Len(t, output.Resources, 5) } func Test_RenderConnections_DisableDefaultEnvVars(t *testing.T) { @@ -601,7 +623,7 @@ func Test_RenderConnections_DisableDefaultEnvVars(t *testing.T) { }, Connections: map[string]datamodel.ConnectionProperties{ "A": { - Source: makeResourceID(t, "SomeProvider/ResourceType", "A").String(), + Source: makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String(), DisableDefaultEnvVars: to.Ptr(true), IAM: datamodel.IAMProperties{ Kind: datamodel.KindHTTP, @@ -614,8 +636,8 @@ func Test_RenderConnections_DisableDefaultEnvVars(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeRadiusResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, @@ -638,8 +660,7 @@ func Test_RenderConnections_DisableDefaultEnvVars(t *testing.T) { require.Equal(t, properties.Container.Image, container.Image) require.Empty(t, container.ImagePullPolicy) - expectedEnv := []v1.EnvVar{} - require.Equal(t, expectedEnv, container.Env) + require.Nil(t, container.Env) } // This test is testing that we hash the connection data and include it in the output. We don't care about the content @@ -651,7 +672,7 @@ func Test_Render_Connections_SecretsGetHashed(t *testing.T) { }, Connections: map[string]datamodel.ConnectionProperties{ "A": { - Source: makeResourceID(t, "SomeProvider/ResourceType", "A").String(), + Source: makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String(), IAM: datamodel.IAMProperties{ Kind: datamodel.KindHTTP, }, @@ -667,8 +688,8 @@ func Test_Render_Connections_SecretsGetHashed(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeRadiusResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, @@ -690,7 +711,7 @@ func Test_Render_Connections_SecretsGetHashed(t *testing.T) { hash1 := deployment.Spec.Template.Annotations[kubernetes.AnnotationSecretHash] // Update and render again - dependencies[makeResourceID(t, "SomeProvider/ResourceType", "A").String()].ComputedValues["ComputedKey1"] = "new value" + dependencies[makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String()].ComputedValues["ComputedKey1"] = "new value" output, err = renderer.Render(ctx, resource, renderers.RenderOptions{Dependencies: dependencies, Environment: renderers.EnvironmentOptions{Namespace: "default"}}) require.NoError(t, err) @@ -710,7 +731,7 @@ func Test_Render_ConnectionWithRoleAssignment(t *testing.T) { }, Connections: map[string]datamodel.ConnectionProperties{ "A": { - Source: makeResourceID(t, "SomeProvider/ResourceType", "A").String(), + Source: makeAzureResourceID(t, "SomeProvider/ResourceType", "A").String(), IAM: datamodel.IAMProperties{ Kind: datamodel.KindHTTP, }, @@ -722,21 +743,15 @@ func Test_Render_ConnectionWithRoleAssignment(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeAzureResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeAzureResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, }, - OutputResources: map[string]resourcemodel.ResourceIdentity{ + OutputResources: map[string]resources.ID{ // This is the resource that the role assignments target! - "TargetLocalID": resourcemodel.NewARMIdentity( - &resourcemodel.ResourceType{ - Type: "dummy", - Provider: resourcemodel.ProviderAzure, - }, - makeResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), - "2020-01-01"), + "TargetLocalID": makeAzureResourceID(t, "SomeProvider/TargetResourceType", "TargetResource"), }, }, } @@ -758,105 +773,98 @@ func Test_Render_ConnectionWithRoleAssignment(t *testing.T) { require.Empty(t, output.SecretValues) require.Len(t, output.Resources, 9) - resourceMap := outputResourcesToKindMap(output.Resources) + resourceMap := outputResourcesToResourceTypeMap(output.Resources) // We're just verifying the role assignments and related things, we'll ignore kubernetes types. - matches := resourceMap[resourcekinds.Deployment] + matches := resourceMap[resources_kubernetes.ResourceTypeDeployment] require.Equal(t, 1, len(matches)) - matches = resourceMap[resourcekinds.Secret] + matches = resourceMap[resources_kubernetes.ResourceTypeSecret] require.Equal(t, 1, len(matches)) - matches = resourceMap[resourcekinds.AzureRoleAssignment] + matches = resourceMap[resources_azure.ResourceTypeAuthorizationRoleAssignment] require.Equal(t, 2, len(matches)) expected := []rpv1.OutputResource{ { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.GenerateLocalIDForRoleAssignment(makeResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), "TestRole1"), - Deployed: false, - Resource: map[string]string{ - handlers.RoleNameKey: "TestRole1", - handlers.RoleAssignmentScope: makeResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), - }, - Dependencies: []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + LocalID: rpv1.NewLocalID(rpv1.LocalIDRoleAssignmentPrefix, makeAzureResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), "TestRole1"), + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeAuthorizationRoleAssignment, + Provider: resourcemodel.ProviderAzure, + }, + Data: map[string]string{ + handlers.RoleNameKey: "TestRole1", + handlers.RoleAssignmentScope: makeAzureResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), }, + Dependencies: []string{rpv1.LocalIDUserAssignedManagedIdentity}, }, }, { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.GenerateLocalIDForRoleAssignment(makeResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), "TestRole2"), - Deployed: false, - Resource: map[string]string{ - handlers.RoleNameKey: "TestRole2", - handlers.RoleAssignmentScope: makeResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), - }, - Dependencies: []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + LocalID: rpv1.NewLocalID(rpv1.LocalIDRoleAssignmentPrefix, makeAzureResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), "TestRole2"), + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeAuthorizationRoleAssignment, + Provider: resourcemodel.ProviderAzure, + }, + Data: map[string]string{ + handlers.RoleNameKey: "TestRole2", + handlers.RoleAssignmentScope: makeAzureResourceID(t, "SomeProvider/TargetResourceType", "TargetResource").String(), }, + Dependencies: []string{rpv1.LocalIDUserAssignedManagedIdentity}, }, }, } require.ElementsMatch(t, expected, matches) - matches = resourceMap[resourcekinds.AzureUserAssignedManagedIdentity] + matches = resourceMap[resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentity] require.Equal(t, 1, len(matches)) expected = []rpv1.OutputResource{ { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, - Deployed: false, - Resource: map[string]string{ - "userassignedidentityname": "test-app-test-container", - "userassignedidentitysubscriptionid": "00000000-0000-0000-0000-000000000000", - "userassignedidentityresourcegroup": "testGroup", + + LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentity, + Provider: resourcemodel.ProviderAzure, + }, + Data: map[string]string{ + "userassignedidentityname": "test-app-test-container", + "userassignedidentitysubscriptionid": "00000000-0000-0000-0000-000000000000", + "userassignedidentityresourcegroup": "testGroup", + }, }, }, } require.ElementsMatch(t, expected, matches) - matches = resourceMap[resourcekinds.AzureFederatedIdentity] + matches = resourceMap[resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentityFederatedIdentityCredential] require.Equal(t, 1, len(matches)) expected = []rpv1.OutputResource{ { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.LocalIDFederatedIdentity, - Deployed: false, - Resource: map[string]string{ - "federatedidentityname": "test-container", - "federatedidentitysubject": "system:serviceaccount:default:test-container", - "federatedidentityissuer": "https://radiusoidc/00000000-0000-0000-0000-000000000000", - }, - Dependencies: []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + LocalID: rpv1.LocalIDFederatedIdentity, + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentityFederatedIdentityCredential, + Provider: resourcemodel.ProviderAzure, + }, + Data: map[string]string{ + "federatedidentityname": "test-container", + "federatedidentitysubject": "system:serviceaccount:default:test-container", + "federatedidentityissuer": "https://radiusoidc/00000000-0000-0000-0000-000000000000", }, + Dependencies: []string{rpv1.LocalIDUserAssignedManagedIdentity}, }, }} require.ElementsMatch(t, expected, matches) - matches = resourceMap[resourcekinds.ServiceAccount] + matches = resourceMap[resources_kubernetes.ResourceTypeServiceAccount] require.Equal(t, 1, len(matches)) } func Test_Render_AzureConnection(t *testing.T) { - testARMID := makeResourceID(t, "SomeProvider/ResourceType", "test-azure-resource").String() + testARMID := makeAzureResourceID(t, "SomeProvider/ResourceType", "test-azure-resource").String() expectedRole := "administrator" properties := datamodel.ContainerProperties{ BasicResourceProperties: rpv1.BasicResourceProperties{ @@ -895,42 +903,40 @@ func Test_Render_AzureConnection(t *testing.T) { require.Empty(t, output.SecretValues) require.Len(t, output.Resources, 7) - kindResourceMap := outputResourcesToKindMap(output.Resources) + resourceMap := outputResourcesToResourceTypeMap(output.Resources) - _, ok := kindResourceMap[resourcekinds.Deployment] + _, ok := resourceMap[resources_kubernetes.ResourceTypeDeployment] require.Equal(t, true, ok) - roleOutputResource, ok := kindResourceMap[resourcekinds.AzureRoleAssignment] + roleOutputResource, ok := resourceMap[resources_azure.ResourceTypeAuthorizationRoleAssignment] require.Equal(t, true, ok) require.Len(t, roleOutputResource, 1) expected := []rpv1.OutputResource{ { - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - LocalID: rpv1.GenerateLocalIDForRoleAssignment(testARMID, expectedRole), - Deployed: false, - Resource: map[string]string{ - handlers.RoleNameKey: expectedRole, - handlers.RoleAssignmentScope: testARMID, - }, - Dependencies: []rpv1.Dependency{ - { - LocalID: rpv1.LocalIDUserAssignedManagedIdentity, + + LocalID: rpv1.NewLocalID(rpv1.LocalIDRoleAssignmentPrefix, testARMID, expectedRole), + CreateResource: &rpv1.Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_azure.ResourceTypeAuthorizationRoleAssignment, + Provider: resourcemodel.ProviderAzure, }, + Data: map[string]string{ + handlers.RoleNameKey: expectedRole, + handlers.RoleAssignmentScope: testARMID, + }, + Dependencies: []string{rpv1.LocalIDUserAssignedManagedIdentity}, }, }, } require.ElementsMatch(t, expected, roleOutputResource) - require.Len(t, kindResourceMap[resourcekinds.AzureUserAssignedManagedIdentity], 1) - require.Len(t, kindResourceMap[resourcekinds.AzureFederatedIdentity], 1) - require.Len(t, kindResourceMap[resourcekinds.ServiceAccount], 1) + require.Len(t, resourceMap[resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentity], 1) + require.Len(t, resourceMap[resources_azure.ResourceTypeManagedIdentityUserAssignedManagedIdentityFederatedIdentityCredential], 1) + require.Len(t, resourceMap[resources_kubernetes.ResourceTypeServiceAccount], 1) } func Test_Render_AzureConnectionEmptyRoleAllowed(t *testing.T) { - testARMID := makeResourceID(t, "SomeProvider/ResourceType", "test-azure-resource").String() + testARMID := makeAzureResourceID(t, "SomeProvider/ResourceType", "test-azure-resource").String() properties := datamodel.ContainerProperties{ BasicResourceProperties: rpv1.BasicResourceProperties{ Application: applicationResourceID, @@ -988,8 +994,8 @@ func Test_Render_EphemeralVolumes(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeRadiusResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeRadiusResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{}, }, } @@ -1011,19 +1017,19 @@ func Test_Render_EphemeralVolumes(t *testing.T) { volumes := deployment.Spec.Template.Spec.Volumes - expectedVolumeMounts := []v1.VolumeMount{ + expectedVolumeMounts := []corev1.VolumeMount{ { Name: tempVolName, MountPath: tempVolMountPath, }, } - expectedVolumes := []v1.Volume{ + expectedVolumes := []corev1.Volume{ { Name: tempVolName, - VolumeSource: v1.VolumeSource{ - EmptyDir: &v1.EmptyDirVolumeSource{ - Medium: v1.StorageMediumMemory, + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{ + Medium: corev1.StorageMediumMemory, }, }, }, @@ -1094,7 +1100,7 @@ func Test_Render_PersistentAzureFileShareVolumes(t *testing.T) { require.NotEmpty(t, secretResource) // Verify deployment - volumes := deploymentResource.Resource.(*appsv1.Deployment).Spec.Template.Spec.Volumes + volumes := deploymentResource.CreateResource.Data.(*appsv1.Deployment).Spec.Template.Spec.Volumes require.Lenf(t, volumes, 1, "expected 1 volume, instead got %+v", len(volumes)) require.Equal(t, tempVolName, volumes[0].Name) require.NotNil(t, volumes[0].VolumeSource.AzureFile, "expected volumesource azurefile to be not nil") @@ -1102,7 +1108,7 @@ func Test_Render_PersistentAzureFileShareVolumes(t *testing.T) { require.Equal(t, volumes[0].VolumeSource.AzureFile.ShareName, testShareName) // Verify Kubernetes secret - secret := secretResource.Resource.(*v1.Secret) + secret := secretResource.CreateResource.Data.(*corev1.Secret) require.Lenf(t, secret.Data, 2, "expected 2 secret key-value pairs, instead got %+v", len(secret.Data)) require.NoError(t, err) } @@ -1160,19 +1166,13 @@ func Test_Render_PersistentAzureKeyVaultVolumes(t *testing.T) { ComputedValues: map[string]any{ azvolrenderer.SPCVolumeObjectSpecKey: "objectspecs", }, - OutputResources: map[string]resourcemodel.ResourceIdentity{ - rpv1.LocalIDSecretProviderClass: { - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.SecretProviderClass, - Provider: resourcemodel.ProviderKubernetes, - }, - Data: resourcemodel.KubernetesIdentity{ - Kind: "SecretProviderClass", - APIVersion: "secrets-store.csi.x-k8s.io/v1alpha1", - Name: testVolName, - Namespace: "test-ns", - }, - }, + OutputResources: map[string]resources.ID{ + rpv1.LocalIDSecretProviderClass: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "secrets-store.csi.x-k8s.io", + "SecretProviderClass", + "test-ns", + testVolName), }, }, } @@ -1187,19 +1187,19 @@ func Test_Render_PersistentAzureKeyVaultVolumes(t *testing.T) { // Verify deployment deploymentSpec := renderOutput.Resources[7] require.Equal(t, rpv1.LocalIDDeployment, deploymentSpec.LocalID, "expected output resource of kind deployment instead got :%v", renderOutput.Resources[0].LocalID) - require.Contains(t, deploymentSpec.Dependencies[0].LocalID, "RoleAssignment") - require.Equal(t, deploymentSpec.Dependencies[1].LocalID, "SecretProviderClass") - require.Equal(t, deploymentSpec.Dependencies[2].LocalID, "ServiceAccount") - require.Equal(t, deploymentSpec.Dependencies[3].LocalID, "KubernetesRole") - require.Equal(t, deploymentSpec.Dependencies[4].LocalID, "KubernetesRoleBinding") - require.Equal(t, deploymentSpec.Dependencies[5].LocalID, "Secret") + require.Contains(t, deploymentSpec.CreateResource.Dependencies[0], "RoleAssignment") + require.Equal(t, deploymentSpec.CreateResource.Dependencies[1], "SecretProviderClass") + require.Equal(t, deploymentSpec.CreateResource.Dependencies[2], "ServiceAccount") + require.Equal(t, deploymentSpec.CreateResource.Dependencies[3], "KubernetesRole") + require.Equal(t, deploymentSpec.CreateResource.Dependencies[4], "KubernetesRoleBinding") + require.Equal(t, deploymentSpec.CreateResource.Dependencies[5], "Secret") // Verify pod template - podTemplate := deploymentSpec.Resource.(*appsv1.Deployment).Spec.Template + podTemplate := deploymentSpec.CreateResource.Data.(*appsv1.Deployment).Spec.Template require.Equal(t, "true", podTemplate.ObjectMeta.Labels[azrenderer.AzureWorkloadIdentityUseKey]) // Verify volume spec - volumes := deploymentSpec.Resource.(*appsv1.Deployment).Spec.Template.Spec.Volumes + volumes := deploymentSpec.CreateResource.Data.(*appsv1.Deployment).Spec.Template.Spec.Volumes require.Lenf(t, volumes, 1, "expected 1 volume, instead got %+v", len(volumes)) require.Equal(t, tempVolName, volumes[0].Name) require.Equal(t, "secrets-store.csi.k8s.io", volumes[0].VolumeSource.CSI.Driver, "expected volumesource azurefile to be not nil") @@ -1207,19 +1207,20 @@ func Test_Render_PersistentAzureKeyVaultVolumes(t *testing.T) { require.Equal(t, true, *volumes[0].VolumeSource.CSI.ReadOnly, "expected readonly attribute to be true") // Verify volume mount spec - volumeMounts := deploymentSpec.Resource.(*appsv1.Deployment).Spec.Template.Spec.Containers[0].VolumeMounts + volumeMounts := deploymentSpec.CreateResource.Data.(*appsv1.Deployment).Spec.Template.Spec.Containers[0].VolumeMounts require.Lenf(t, volumeMounts, 1, "expected 1 volume mount, instead got %+v", len(volumeMounts)) require.Equal(t, tempVolMountPath, volumeMounts[0].MountPath) require.Equal(t, tempVolName, volumeMounts[0].Name) require.Equal(t, true, volumeMounts[0].ReadOnly) } -func outputResourcesToKindMap(resources []rpv1.OutputResource) map[string][]rpv1.OutputResource { +func outputResourcesToResourceTypeMap(resources []rpv1.OutputResource) map[string][]rpv1.OutputResource { results := map[string][]rpv1.OutputResource{} for _, resource := range resources { - matches := results[resource.ResourceType.Type] + resourceType := resource.GetResourceType() + matches := results[resourceType.Type] matches = append(matches, resource) - results[resource.ResourceType.Type] = matches + results[resourceType.Type] = matches } return results @@ -1254,8 +1255,8 @@ func Test_Render_ReadinessProbeHttpGet(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeAzureResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeAzureResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, @@ -1279,16 +1280,16 @@ func Test_Render_ReadinessProbeHttpGet(t *testing.T) { container := deployment.Spec.Template.Spec.Containers[0] require.Equal(t, resourceName, container.Name) - expectedReadinessProbe := &v1.Probe{ + expectedReadinessProbe := &corev1.Probe{ InitialDelaySeconds: 30, FailureThreshold: 10, PeriodSeconds: 2, TimeoutSeconds: 5, - ProbeHandler: v1.ProbeHandler{ - HTTPGet: &v1.HTTPGetAction{ + ProbeHandler: corev1.ProbeHandler{ + HTTPGet: &corev1.HTTPGetAction{ Path: "/healthz", Port: intstr.FromInt(8080), - HTTPHeaders: []v1.HTTPHeader{ + HTTPHeaders: []corev1.HTTPHeader{ { Name: "header1", Value: "value1", @@ -1331,8 +1332,8 @@ func Test_Render_ReadinessProbeTcp(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeAzureResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeAzureResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, @@ -1356,14 +1357,14 @@ func Test_Render_ReadinessProbeTcp(t *testing.T) { container := deployment.Spec.Template.Spec.Containers[0] require.Equal(t, resourceName, container.Name) - expectedReadinessProbe := &v1.Probe{ + expectedReadinessProbe := &corev1.Probe{ InitialDelaySeconds: 30, FailureThreshold: 10, PeriodSeconds: 2, TimeoutSeconds: 5, - ProbeHandler: v1.ProbeHandler{ + ProbeHandler: corev1.ProbeHandler{ HTTPGet: nil, - TCPSocket: &v1.TCPSocketAction{ + TCPSocket: &corev1.TCPSocketAction{ Port: intstr.FromInt(8080), }, Exec: nil, @@ -1401,8 +1402,8 @@ func Test_Render_LivenessProbeExec(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeAzureResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeAzureResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, @@ -1426,15 +1427,15 @@ func Test_Render_LivenessProbeExec(t *testing.T) { container := deployment.Spec.Template.Spec.Containers[0] require.Equal(t, resourceName, container.Name) - expectedLivenessProbe := &v1.Probe{ + expectedLivenessProbe := &corev1.Probe{ InitialDelaySeconds: 30, FailureThreshold: 10, PeriodSeconds: 2, TimeoutSeconds: 5, - ProbeHandler: v1.ProbeHandler{ + ProbeHandler: corev1.ProbeHandler{ HTTPGet: nil, TCPSocket: nil, - Exec: &v1.ExecAction{ + Exec: &corev1.ExecAction{ Command: []string{"a", "b", "c"}, }, }, @@ -1461,8 +1462,8 @@ func Test_Render_LivenessProbeWithDefaults(t *testing.T) { } resource := makeResource(t, properties) dependencies := map[string]renderers.RendererDependency{ - (makeResourceID(t, "SomeProvider/ResourceType", "A").String()): { - ResourceID: makeResourceID(t, "SomeProvider/ResourceType", "A"), + (makeAzureResourceID(t, "SomeProvider/ResourceType", "A").String()): { + ResourceID: makeAzureResourceID(t, "SomeProvider/ResourceType", "A"), ComputedValues: map[string]any{ "ComputedKey1": "ComputedValue1", "ComputedKey2": 82, @@ -1486,16 +1487,16 @@ func Test_Render_LivenessProbeWithDefaults(t *testing.T) { container := deployment.Spec.Template.Spec.Containers[0] require.Equal(t, resourceName, container.Name) - expectedLivenessProbe := &v1.Probe{ + expectedLivenessProbe := &corev1.Probe{ // Aligining with Kubernetes defaults InitialDelaySeconds: DefaultInitialDelaySeconds, FailureThreshold: DefaultFailureThreshold, PeriodSeconds: DefaultPeriodSeconds, TimeoutSeconds: DefaultTimeoutSeconds, - ProbeHandler: v1.ProbeHandler{ + ProbeHandler: corev1.ProbeHandler{ HTTPGet: nil, TCPSocket: nil, - Exec: &v1.ExecAction{ + Exec: &corev1.ExecAction{ Command: []string{"a", "b", "c"}, }, }, @@ -1537,7 +1538,8 @@ func Test_ParseURL(t *testing.T) { } func Test_DNS_Service_Generation(t *testing.T) { - var containerPortNumber int32 = 80 + var containerPortNumber int32 = 3000 + var servicePortNumber int32 = 80 t.Run("verify service generation", func(t *testing.T) { properties := datamodel.ContainerProperties{ BasicResourceProperties: rpv1.BasicResourceProperties{ @@ -1548,6 +1550,7 @@ func Test_DNS_Service_Generation(t *testing.T) { Ports: map[string]datamodel.ContainerPort{ "web": { ContainerPort: int32(containerPortNumber), + Port: int32(servicePortNumber), }, }, }, @@ -1559,20 +1562,20 @@ func Test_DNS_Service_Generation(t *testing.T) { output, err := renderer.Render(ctx, resource, renderOptionsEnvAndAppKubeMetadata()) require.NoError(t, err) - require.Len(t, output.Resources, 4) + require.Len(t, output.Resources, 5) require.Empty(t, output.SecretValues) expectedServicePort := corev1.ServicePort{ Name: "web", - Port: containerPortNumber, - TargetPort: intstr.FromInt(80), + Port: 80, + TargetPort: intstr.FromInt(int(containerPortNumber)), Protocol: "TCP", } require.Len(t, output.ComputedValues, 0) service, outputResource := kubernetes.FindService(output.Resources) - expectedOutputResource := rpv1.NewKubernetesOutputResource(resourcekinds.Service, rpv1.LocalIDService, service, service.ObjectMeta) + expectedOutputResource := rpv1.NewKubernetesOutputResource(rpv1.LocalIDService, service, service.ObjectMeta) require.Equal(t, expectedOutputResource, outputResource) require.Equal(t, kubernetes.NormalizeResourceName(resource.Name), service.Name) @@ -1586,6 +1589,117 @@ func Test_DNS_Service_Generation(t *testing.T) { }) } +func Test_Render_ImagePullPolicySpecified(t *testing.T) { + properties := datamodel.ContainerProperties{ + BasicResourceProperties: rpv1.BasicResourceProperties{ + Application: applicationResourceID, + }, + Container: datamodel.Container{ + Image: "someimage:latest", + ImagePullPolicy: "Never", + Env: map[string]string{ + envVarName1: envVarValue1, + envVarName2: envVarValue2, + }, + }, + } + resource := makeResource(t, properties) + dependencies := map[string]renderers.RendererDependency{} + + ctx := testcontext.New(t) + renderer := Renderer{} + output, err := renderer.Render(ctx, resource, renderers.RenderOptions{Dependencies: dependencies}) + require.NoError(t, err) + require.Empty(t, output.ComputedValues) + require.Empty(t, output.SecretValues) + + t.Run("verify deployment", func(t *testing.T) { + deployment, _ := kubernetes.FindDeployment(output.Resources) + require.NotNil(t, deployment) + + require.Len(t, deployment.Spec.Template.Spec.Containers, 1) + + container := deployment.Spec.Template.Spec.Containers[0] + require.Equal(t, resourceName, container.Name) + require.Equal(t, properties.Container.Image, container.Image) + require.Equal(t, properties.Container.ImagePullPolicy, string(container.ImagePullPolicy)) + }) +} + +func Test_Render_StrategicPatchMerge(t *testing.T) { + const contianerPatchObject = ` +{ + "containers": [ + { + "name": "test", + "image": "magpie" + }, + { + "name": "test-container", + "command": ["echo", "hello"], + "env": [ + { + "name": "env1", + "value": "value1" + } + ] + } + ], + "hostNetwork": true +} +` + properties := datamodel.ContainerProperties{ + BasicResourceProperties: rpv1.BasicResourceProperties{ + Application: applicationResourceID, + }, + Container: datamodel.Container{ + Image: "someimage:latest", + Env: map[string]string{ + envVarName1: envVarValue1, + envVarName2: envVarValue2, + }, + }, + Runtimes: &datamodel.RuntimeProperties{ + Kubernetes: &datamodel.KubernetesRuntime{ + Pod: contianerPatchObject, + }, + }, + } + resource := makeResource(t, properties) + dependencies := map[string]renderers.RendererDependency{} + + ctx := testcontext.New(t) + renderer := Renderer{} + output, err := renderer.Render(ctx, resource, renderers.RenderOptions{Dependencies: dependencies}) + require.NoError(t, err) + + deployment, _ := kubernetes.FindDeployment(output.Resources) + require.NotNil(t, deployment) + + require.True(t, deployment.Spec.Template.Spec.HostNetwork) + require.Len(t, deployment.Spec.Template.Spec.Containers, 2) + + expectedContainers := []corev1.Container{ + { + Name: resourceName, + Command: []string{"echo", "hello"}, + Env: []corev1.EnvVar{ + {Name: "env1", Value: "value1"}, + {Name: envVarName1, Value: envVarValue1}, + {Name: envVarName2, Value: envVarValue2}, + }, + Image: properties.Container.Image, + }, + { + Name: "test", + Env: nil, + Image: "magpie", + }, + } + + require.ElementsMatch(t, expectedContainers, deployment.Spec.Template.Spec.Containers) +} + func renderOptionsEnvAndAppKubeMetadata() renderers.RenderOptions { dependencies := map[string]renderers.RendererDependency{} option := renderers.RenderOptions{Dependencies: dependencies} diff --git a/pkg/corerp/renderers/container/volumes.go b/pkg/corerp/renderers/container/volumes.go index f606540461..b914a89851 100644 --- a/pkg/corerp/renderers/container/volumes.go +++ b/pkg/corerp/renderers/container/volumes.go @@ -17,7 +17,7 @@ limitations under the License. package container import ( - "github.com/project-radius/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/datamodel" corev1 "k8s.io/api/core/v1" ) diff --git a/pkg/corerp/renderers/daprextension/renderer.go b/pkg/corerp/renderers/daprextension/renderer.go index fb6a32638f..d486718ed3 100644 --- a/pkg/corerp/renderers/daprextension/renderer.go +++ b/pkg/corerp/renderers/daprextension/renderer.go @@ -21,11 +21,11 @@ import ( "errors" "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/ucp/resources" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -72,12 +72,13 @@ func (r *Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options // the desired annotations. for i := range output.Resources { - if output.Resources[i].ResourceType.Provider != resourcemodel.ProviderKubernetes { + resourceType := output.Resources[i].GetResourceType() + if resourceType.Provider != resourcemodel.ProviderKubernetes { // Not a Kubernetes resource continue } - o, ok := output.Resources[i].Resource.(runtime.Object) + o, ok := output.Resources[i].CreateResource.Data.(runtime.Object) if !ok { return renderers.RendererOutput{}, errors.New("found Kubernetes resource with non-Kubernetes payload") } diff --git a/pkg/corerp/renderers/daprextension/renderer_test.go b/pkg/corerp/renderers/daprextension/renderer_test.go index 387fb3a256..f1afe3ab67 100644 --- a/pkg/corerp/renderers/daprextension/renderer_test.go +++ b/pkg/corerp/renderers/daprextension/renderer_test.go @@ -20,15 +20,15 @@ import ( "context" "testing" - apiv1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + apiv1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/resourcemodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" ) @@ -45,12 +45,14 @@ func (r *noop) Render(ctx context.Context, dm v1.DataModelInterface, options ren deployment := appsv1.Deployment{} deploymentResource := rpv1.OutputResource{ - Resource: &deployment, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Deployment, - Provider: resourcemodel.ProviderKubernetes, - }, LocalID: rpv1.LocalIDDeployment, + CreateResource: &rpv1.Resource{ + Data: &deployment, + ResourceType: resourcemodel.ResourceType{ + Type: resources_kubernetes.ResourceTypeDeployment, + Provider: resourcemodel.ProviderKubernetes, + }, + }, } output := renderers.RendererOutput{ diff --git a/pkg/corerp/renderers/gateway/render.go b/pkg/corerp/renderers/gateway/render.go index 1acc2c1d72..2fe79fa094 100644 --- a/pkg/corerp/renderers/gateway/render.go +++ b/pkg/corerp/renderers/gateway/render.go @@ -28,13 +28,13 @@ import ( contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" ) type Renderer struct { @@ -103,7 +103,7 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options publicEndpoint = getPublicEndpoint(hostname, options.Environment.Gateway.Port, isHttps) } - gatewayObject, err := MakeGateway(ctx, options, gateway, gateway.Name, applicationName, hostname) + gatewayObject, err := MakeRootHTTPProxy(ctx, options, gateway, gateway.Name, applicationName, hostname) if err != nil { return renderers.RendererOutput{}, err } @@ -116,7 +116,7 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options }, } - httpRouteObjects, err := MakeHttpRoutes(ctx, options, *gateway, &gateway.Properties, gatewayName, applicationName) + httpRouteObjects, err := MakeRoutesHTTPProxies(ctx, options, *gateway, &gateway.Properties, gatewayName, gatewayObject, applicationName) if err != nil { return renderers.RendererOutput{}, err } @@ -128,9 +128,9 @@ func (r Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options }, nil } -// MakeGateway validates the Gateway resource and its dependencies, and creates a Contour HTTPProxy resource +// MakeRootHTTPProxy validates the Gateway resource and its dependencies, and creates a Contour HTTPProxy resource // to act as the Gateway. -func MakeGateway(ctx context.Context, options renderers.RenderOptions, gateway *datamodel.Gateway, resourceName string, applicationName string, hostname string) (rpv1.OutputResource, error) { +func MakeRootHTTPProxy(ctx context.Context, options renderers.RenderOptions, gateway *datamodel.Gateway, resourceName string, applicationName string, hostname string) (rpv1.OutputResource, error) { includes := []contourv1.Include{} dependencies := options.Dependencies @@ -180,19 +180,14 @@ func MakeGateway(ctx context.Context, options renderers.RenderOptions, gateway * return rpv1.OutputResource{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("secretStore resource %s not found", secretStoreResourceId)) } - secretResource := secretStoreResource.OutputResources[rpv1.LocalIDSecret].Data - secretResourceData, ok := secretResource.(map[string]any) + secretResourceID, ok := secretStoreResource.OutputResources[rpv1.LocalIDSecret] if !ok { return rpv1.OutputResource{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("secretStore resource %s not found", secretStoreResourceId)) } - secretName, ok := secretResourceData["name"] - if !ok { - return rpv1.OutputResource{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("secretStore resource %s not found", secretStoreResourceId)) - } - - secretNamespace, ok := secretResourceData["namespace"] - if !ok { + secretName := secretResourceID.Name() + secretNamespace := secretResourceID.FindScope(resources_kubernetes.ScopeNamespaces) + if secretNamespace == "" { return rpv1.OutputResource{}, v1.NewClientErrInvalidRequest(fmt.Sprintf("secretStore resource %s not found", secretStoreResourceId)) } @@ -282,8 +277,8 @@ func MakeGateway(ctx context.Context, options renderers.RenderOptions, gateway * ObjectMeta: metav1.ObjectMeta{ Name: kubernetes.NormalizeResourceName(resourceName), Namespace: options.Environment.Namespace, - Labels: renderers.GetLabels(ctx, options, applicationName, resourceName, gateway.ResourceTypeName()), - Annotations: renderers.GetAnnotations(ctx, options), + Labels: renderers.GetLabels(options, applicationName, resourceName, gateway.ResourceTypeName()), + Annotations: renderers.GetAnnotations(options), }, Spec: contourv1.HTTPProxySpec{ VirtualHost: virtualHost, @@ -294,12 +289,12 @@ func MakeGateway(ctx context.Context, options renderers.RenderOptions, gateway * rootHTTPProxy.Spec.TCPProxy = tcpProxy } - return rpv1.NewKubernetesOutputResource(resourcekinds.Gateway, rpv1.LocalIDGateway, rootHTTPProxy, rootHTTPProxy.ObjectMeta), nil + return rpv1.NewKubernetesOutputResource(rpv1.LocalIDGateway, rootHTTPProxy, rootHTTPProxy.ObjectMeta), nil } -// MakeHttpRoutes creates HTTPProxy objects for each route in the gateway and returns them as OutputResources. It returns +// MakeRoutesHTTPProxies creates HTTPProxy objects for each route in the gateway and returns them as OutputResources. It returns // an error if it fails to get the route name. -func MakeHttpRoutes(ctx context.Context, options renderers.RenderOptions, resource datamodel.Gateway, gateway *datamodel.GatewayProperties, gatewayName string, applicationName string) ([]rpv1.OutputResource, error) { +func MakeRoutesHTTPProxies(ctx context.Context, options renderers.RenderOptions, resource datamodel.Gateway, gateway *datamodel.GatewayProperties, gatewayName string, gatewayOutPutResource rpv1.OutputResource, applicationName string) ([]rpv1.OutputResource, error) { dependencies := options.Dependencies objects := make(map[string]*contourv1.HTTPProxy) @@ -373,8 +368,8 @@ func MakeHttpRoutes(ctx context.Context, options renderers.RenderOptions, resour ObjectMeta: metav1.ObjectMeta{ Name: routeResourceName, Namespace: options.Environment.Namespace, - Labels: renderers.GetLabels(ctx, options, applicationName, routeName, resource.ResourceTypeName()), - Annotations: renderers.GetAnnotations(ctx, options), + Labels: renderers.GetLabels(options, applicationName, routeName, resource.ResourceTypeName()), + Annotations: renderers.GetAnnotations(options), }, Spec: contourv1.HTTPProxySpec{ Routes: []contourv1.Route{ @@ -392,11 +387,14 @@ func MakeHttpRoutes(ctx context.Context, options renderers.RenderOptions, resour } objects[localID] = httpProxyObject + + // Add the route as a dependency of the root http proxy to ensure that the route is created before the root http proxy + gatewayOutPutResource.CreateResource.Dependencies = append(gatewayOutPutResource.CreateResource.Dependencies, localID) } var outputResources []rpv1.OutputResource for localID, object := range objects { - outputResources = append(outputResources, rpv1.NewKubernetesOutputResource(resourcekinds.KubernetesHTTPRoute, localID, object, object.ObjectMeta)) + outputResources = append(outputResources, rpv1.NewKubernetesOutputResource(localID, object, object.ObjectMeta)) } return outputResources, nil diff --git a/pkg/corerp/renderers/gateway/render_test.go b/pkg/corerp/renderers/gateway/render_test.go index 5da0fea925..dab84c49f1 100644 --- a/pkg/corerp/renderers/gateway/render_test.go +++ b/pkg/corerp/renderers/gateway/render_test.go @@ -19,20 +19,20 @@ package gateway import ( "context" "fmt" + "strings" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/corerp/renderers/httproute" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/testcontext" contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/corerp/renderers/httproute" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) @@ -150,7 +150,7 @@ func Test_Render_WithIPAndNoHostname(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_WithIPAndPrefix(t *testing.T) { @@ -185,7 +185,7 @@ func Test_Render_WithIPAndPrefix(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_WithIPAndFQHostname(t *testing.T) { @@ -218,7 +218,7 @@ func Test_Render_WithIPAndFQHostname(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_WithFQHostname_OverridesPrefix(t *testing.T) { @@ -253,7 +253,7 @@ func Test_Render_WithFQHostname_OverridesPrefix(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_PublicEndpointOverride(t *testing.T) { @@ -281,7 +281,7 @@ func Test_Render_PublicEndpointOverride(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_PublicEndpointOverride_OverridesAll(t *testing.T) { @@ -314,7 +314,7 @@ func Test_Render_PublicEndpointOverride_OverridesAll(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_PublicEndpointOverride_WithEmptyIP(t *testing.T) { @@ -344,7 +344,7 @@ func Test_Render_PublicEndpointOverride_WithEmptyIP(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_LocalhostPublicEndpointOverride(t *testing.T) { @@ -374,7 +374,7 @@ func Test_Render_LocalhostPublicEndpointOverride(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_Hostname(t *testing.T) { @@ -403,7 +403,7 @@ func Test_Render_Hostname(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_Hostname_WithPort(t *testing.T) { @@ -433,7 +433,7 @@ func Test_Render_Hostname_WithPort(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_Hostname_WithPrefix(t *testing.T) { @@ -467,7 +467,7 @@ func Test_Render_Hostname_WithPrefix(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_Hostname_WithPrefixAndPort(t *testing.T) { @@ -501,7 +501,7 @@ func Test_Render_Hostname_WithPrefixAndPort(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_WithMissingPublicIP(t *testing.T) { @@ -532,7 +532,7 @@ func Test_Render_WithMissingPublicIP(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_Fails_SSLPassthroughWithRoutePath(t *testing.T) { @@ -659,7 +659,7 @@ func Test_Render_FQDNOverride(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_Render_Fails_WithoutFQHostnameOrPrefix(t *testing.T) { @@ -731,7 +731,7 @@ func Test_Render_Single_Route(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") validateHttpRoute(t, output.Resources, routeName, 80, nil, "") } @@ -804,7 +804,7 @@ func Test_Render_SSLPassthrough(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") validateHttpRoute(t, output.Resources, routeName, 80, nil, "") } @@ -872,7 +872,7 @@ func Test_Render_Multiple_Routes(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") validateHttpRoute(t, output.Resources, routeAName, 80, nil, "") validateHttpRoute(t, output.Resources, routeBName, 80, nil, "") } @@ -927,7 +927,7 @@ func Test_Render_Route_WithPrefixRewrite(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") expectedPathRewritePolicy := &contourv1.PathRewritePolicy{ ReplacePrefix: []contourv1.ReplacePrefix{ @@ -1036,7 +1036,7 @@ func Test_Render_Route_WithMultiplePrefixRewrite(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") expectedPathRewritePolicy := &contourv1.PathRewritePolicy{ ReplacePrefix: []contourv1.ReplacePrefix{ @@ -1115,7 +1115,7 @@ func Test_Render_WithDependencies(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") validateHttpRoute(t, output.Resources, routeName, httpRoutePort, nil, "") } @@ -1167,7 +1167,7 @@ func Test_Render_WithEnvironment_KubernetesMetadata(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, envKubeMetadata) + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, envKubeMetadata) validateHttpRoute(t, output.Resources, routeName, 80, nil, envKubeMetadata) } @@ -1220,7 +1220,7 @@ func Test_Render_WithEnvironmentApplication_KubernetesMetadata(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, envAppKubeMetadata) + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, envAppKubeMetadata) validateHttpRoute(t, output.Resources, routeName, 80, nil, envAppKubeMetadata) } @@ -1275,7 +1275,7 @@ func Test_RenderDNS_WithEnvironmentApplication_KubernetesMetadata(t *testing.T) Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, envAppKubeMetadata) + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, envAppKubeMetadata) } func Test_RenderDNS_WithEnvironment_KubernetesMetadata(t *testing.T) { @@ -1328,7 +1328,7 @@ func Test_RenderDNS_WithEnvironment_KubernetesMetadata(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, envKubeMetadata) + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, envKubeMetadata) } func Test_Render_With_TLSTermination(t *testing.T) { @@ -1365,19 +1365,13 @@ func Test_Render_With_TLSTermination(t *testing.T) { }, }, }, - OutputResources: map[string]resourcemodel.ResourceIdentity{ - "Secret": { - ResourceType: &resourcemodel.ResourceType{ - Type: "Secret", - Provider: "kubernetes", - }, - Data: map[string]any{ - "kind": "Secret", - "apiVersion": "v1", - "name": secretName, - "namespace": environmentOptions.Namespace, - }, - }, + OutputResources: map[string]resources.ID{ + "Secret": resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "", + "Secret", + environmentOptions.Namespace, + secretName), }, }, } @@ -1403,7 +1397,7 @@ func Test_Render_With_TLSTermination(t *testing.T) { Includes: expectedIncludes, } - validateGateway(t, output.Resources, expectedGatewaySpec, "") + validateHTTPProxy(t, output.Resources, expectedGatewaySpec, "") } func Test_ParseURL(t *testing.T) { @@ -1469,27 +1463,33 @@ func Test_IsURL(t *testing.T) { require.True(t, isURL(valid_default_https_url)) } -func validateGateway(t *testing.T, outputResources []rpv1.OutputResource, expectedGatewaySpec *contourv1.HTTPProxySpec, kmeOption string) { - gateway, gatewayOutputResource := kubernetes.FindGateway(outputResources) +func validateHTTPProxy(t *testing.T, outputResources []rpv1.OutputResource, expectedHTTPProxySpec *contourv1.HTTPProxySpec, kmeOption string) { + httpProxy, httpProxyOutputResource := kubernetes.FindContourHTTPProxy(outputResources) + + expectedHTTPProxyOutputResource := rpv1.NewKubernetesOutputResource(rpv1.LocalIDGateway, httpProxy, httpProxy.ObjectMeta) + for _, r := range outputResources { + if strings.Contains(r.LocalID, rpv1.LocalIDHttpRoute) { + expectedHTTPProxyOutputResource.CreateResource.Dependencies = append(expectedHTTPProxyOutputResource.CreateResource.Dependencies, r.LocalID) + } + } - expectedGatewayOutputResource := rpv1.NewKubernetesOutputResource(resourcekinds.Gateway, rpv1.LocalIDGateway, gateway, gateway.ObjectMeta) - require.Equal(t, expectedGatewayOutputResource, gatewayOutputResource) - require.Equal(t, kubernetes.NormalizeResourceName(resourceName), gateway.Name) - require.Equal(t, applicationName, gateway.Namespace) + require.Equal(t, expectedHTTPProxyOutputResource, httpProxyOutputResource) + require.Equal(t, kubernetes.NormalizeResourceName(resourceName), httpProxy.Name) + require.Equal(t, applicationName, httpProxy.Namespace) if !(kmeOption == envKubeMetadata || kmeOption == envAppKubeMetadata) { - require.Equal(t, kubernetes.MakeDescriptiveLabels(applicationName, resourceName, ResourceType), gateway.Labels) + require.Equal(t, kubernetes.MakeDescriptiveLabels(applicationName, resourceName, ResourceType), httpProxy.Labels) } else { - require.Equal(t, getExpectedMaps(true, kmeOption).metaAnn, gateway.Annotations) - require.Equal(t, getExpectedMaps(true, kmeOption).metaLbl, gateway.Labels) + require.Equal(t, getExpectedMaps(true, kmeOption).metaAnn, httpProxy.Annotations) + require.Equal(t, getExpectedMaps(true, kmeOption).metaLbl, httpProxy.Labels) } - require.Equal(t, expectedGatewaySpec, &gateway.Spec) + require.Equal(t, expectedHTTPProxySpec, &httpProxy.Spec) } func validateHttpRoute(t *testing.T, outputResources []rpv1.OutputResource, expectedRouteName string, expectedPort int32, expectedRewrite *contourv1.PathRewritePolicy, kmeOption string) { expectedLocalID := fmt.Sprintf("%s-%s", rpv1.LocalIDHttpRoute, expectedRouteName) - httpRoute, httpRouteOutputResource := kubernetes.FindHttpRouteByLocalID(outputResources, expectedLocalID) - expectedHttpRouteOutputResource := rpv1.NewKubernetesOutputResource(resourcekinds.KubernetesHTTPRoute, expectedLocalID, httpRoute, httpRoute.ObjectMeta) + httpRoute, httpRouteOutputResource := kubernetes.FindContourHTTPProxyByLocalID(outputResources, expectedLocalID) + expectedHttpRouteOutputResource := rpv1.NewKubernetesOutputResource(expectedLocalID, httpRoute, httpRoute.ObjectMeta) require.Equal(t, expectedHttpRouteOutputResource, httpRouteOutputResource) require.Equal(t, kubernetes.NormalizeResourceName(expectedRouteName), httpRoute.Name) require.Equal(t, applicationName, httpRoute.Namespace) diff --git a/pkg/corerp/renderers/httproute/render.go b/pkg/corerp/renderers/httproute/render.go index c4924d8e63..00426a8f78 100644 --- a/pkg/corerp/renderers/httproute/render.go +++ b/pkg/corerp/renderers/httproute/render.go @@ -25,13 +25,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" ) type Renderer struct { @@ -100,8 +99,8 @@ func (r *Renderer) makeService(ctx context.Context, route *datamodel.HTTPRoute, ObjectMeta: metav1.ObjectMeta{ Name: kubernetes.NormalizeResourceName(route.Name), Namespace: options.Environment.Namespace, - Labels: renderers.GetLabels(ctx, options, appId.Name(), route.Name, route.ResourceTypeName()), - Annotations: renderers.GetAnnotations(ctx, options), + Labels: renderers.GetLabels(options, appId.Name(), route.Name, route.ResourceTypeName()), + Annotations: renderers.GetAnnotations(options), }, Spec: corev1.ServiceSpec{ Selector: kubernetes.MakeRouteSelectorLabels(appId.Name(), resourceTypeSuffix, route.Name), @@ -117,5 +116,5 @@ func (r *Renderer) makeService(ctx context.Context, route *datamodel.HTTPRoute, }, } - return rpv1.NewKubernetesOutputResource(resourcekinds.Service, rpv1.LocalIDService, service, service.ObjectMeta), nil + return rpv1.NewKubernetesOutputResource(rpv1.LocalIDService, service, service.ObjectMeta), nil } diff --git a/pkg/corerp/renderers/httproute/render_test.go b/pkg/corerp/renderers/httproute/render_test.go index aed461b8ec..fab3d54993 100644 --- a/pkg/corerp/renderers/httproute/render_test.go +++ b/pkg/corerp/renderers/httproute/render_test.go @@ -22,12 +22,11 @@ import ( "strings" "testing" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -155,7 +154,7 @@ func TestHTTPRouteRenderer(t *testing.T) { require.Equal(t, expectedValues, output.ComputedValues) service, outputResource := kubernetes.FindService(output.Resources) - expectedOutputResource := rpv1.NewKubernetesOutputResource(resourcekinds.Service, rpv1.LocalIDService, service, service.ObjectMeta) + expectedOutputResource := rpv1.NewKubernetesOutputResource(rpv1.LocalIDService, service, service.ObjectMeta) require.Equal(t, expectedOutputResource, outputResource) require.Equal(t, kubernetes.NormalizeResourceName(resource.Name), service.Name) diff --git a/pkg/corerp/renderers/kubernetesmetadata.go b/pkg/corerp/renderers/kubernetesmetadata.go index 4a6f8878c3..3beacebe56 100644 --- a/pkg/corerp/renderers/kubernetesmetadata.go +++ b/pkg/corerp/renderers/kubernetesmetadata.go @@ -17,15 +17,13 @@ limitations under the License. package renderers import ( - "context" - - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/rp/kube" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/rp/kube" ) // GetLabels merges cumulative label values from Environment, Application, Container and InputExt kubernetes metadata and // returns a map of labels. -func GetLabels(ctx context.Context, options RenderOptions, applicationName string, resourceName string, resourceTypeName string) map[string]string { +func GetLabels(options RenderOptions, applicationName string, resourceName string, resourceTypeName string) map[string]string { // Create KubernetesMetadata struct to merge labels lblMap := kube.Metadata{ ObjectMetadata: kubernetes.MakeDescriptiveLabels(applicationName, resourceName, resourceTypeName), @@ -42,7 +40,7 @@ func GetLabels(ctx context.Context, options RenderOptions, applicationName strin // Merge cumulative label values from Env->App->Container->InputExt kubernetes metadata. In case of collisions, Env->App->Container->InputExt // values are merged in that order. Spec labels are not updated. - if metaLabels, _ := lblMap.Merge(ctx); len(metaLabels) > 0 { + if metaLabels, _ := lblMap.Merge(); len(metaLabels) > 0 { return metaLabels } @@ -50,7 +48,7 @@ func GetLabels(ctx context.Context, options RenderOptions, applicationName strin } // GetAnnotations returns the merged annotations from Environment and Application KubernetesMetadata. -func GetAnnotations(ctx context.Context, options RenderOptions) map[string]string { +func GetAnnotations(options RenderOptions) map[string]string { // Create KubernetesMetadata struct to merge annotations annMap := kube.Metadata{} envOpts := &options.Environment @@ -65,7 +63,7 @@ func GetAnnotations(ctx context.Context, options RenderOptions) map[string]strin // Merge cumulative annotations values from Env->App->Container->InputExt kubernetes metadata. In case of collisions, rightmost entity wins // Spec annotations are not updated. - if metaAnnotations, _ := annMap.Merge(ctx); len(metaAnnotations) > 0 { + if metaAnnotations, _ := annMap.Merge(); len(metaAnnotations) > 0 { return metaAnnotations } diff --git a/pkg/corerp/renderers/kubernetesmetadata/render.go b/pkg/corerp/renderers/kubernetesmetadata/render.go index 31ac749542..74ff3d91c3 100644 --- a/pkg/corerp/renderers/kubernetesmetadata/render.go +++ b/pkg/corerp/renderers/kubernetesmetadata/render.go @@ -19,12 +19,12 @@ package kubernetesmetadata import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/rp/kube" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/rp/kube" + "github.com/radius-project/radius/pkg/ucp/resources" appsv1 "k8s.io/api/apps/v1" ) @@ -66,12 +66,13 @@ func (r *Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options } for _, ores := range output.Resources { - if ores.ResourceType.Provider != resourcemodel.ProviderKubernetes { + resourceType := ores.GetResourceType() + if resourceType.Provider != resourcemodel.ProviderKubernetes { // Not a Kubernetes resource continue } - dep, ok := ores.Resource.(*appsv1.Deployment) + dep, ok := ores.CreateResource.Data.(*appsv1.Deployment) if !ok { continue } @@ -106,7 +107,7 @@ func processAnnotations(ctx context.Context, options renderers.RenderOptions, de } // Merge cumulative annotation values from Env->App->Container->InputExt kubernetes metadata. In case of collisions, rightmost entity wins - metaAnnotations, specAnnotations := ann.Merge(ctx) + metaAnnotations, specAnnotations := ann.Merge() setAnnotations(dep, metaAnnotations, specAnnotations) } @@ -133,7 +134,7 @@ func processLabels(ctx context.Context, options renderers.RenderOptions, dep *ap } // Merge cumulative label values from Env->App->Container->InputExt kubernetes metadata. In case of collisions, rightmost entity wins - metaLabels, specLabels := lbl.Merge(ctx) + metaLabels, specLabels := lbl.Merge() setLabels(dep, metaLabels, specLabels) } diff --git a/pkg/corerp/renderers/kubernetesmetadata/render_test.go b/pkg/corerp/renderers/kubernetesmetadata/render_test.go index 82ce341b4a..6720efa234 100644 --- a/pkg/corerp/renderers/kubernetesmetadata/render_test.go +++ b/pkg/corerp/renderers/kubernetesmetadata/render_test.go @@ -4,14 +4,14 @@ import ( "context" "testing" - apiv1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + apiv1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" @@ -33,13 +33,22 @@ func (r *noop) GetDependencyIDs(ctx context.Context, resource v1.DataModelInterf func (r *noop) Render(ctx context.Context, dm v1.DataModelInterface, options renderers.RenderOptions) (renderers.RendererOutput, error) { // Return a deployment so the kubernetes metadata extension renderer can modify it - deployment := appsv1.Deployment{} + deployment := appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + }, + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", + }, + } // Populate Meta labels with existing values deployment.Annotations = map[string]string{"prior.MetaAnnotation1": "prior.MetaAnnotationVal1", "prior.MetaAnnotation2": "prior.MetaAnnotationVal2"} deployment.Labels = map[string]string{"prior.MetaLabel1": "prior.MetaLabelVal1", "prior.MetaLabel2": "prior.MetaLabelVal2"} - resources := []rpv1.OutputResource{rpv1.NewKubernetesOutputResource(resourcekinds.Deployment, rpv1.LocalIDDeployment, &deployment, deployment.ObjectMeta)} + resources := []rpv1.OutputResource{rpv1.NewKubernetesOutputResource(rpv1.LocalIDDeployment, &deployment, deployment.ObjectMeta)} return renderers.RendererOutput{Resources: resources}, nil } diff --git a/pkg/corerp/renderers/manualscale/render.go b/pkg/corerp/renderers/manualscale/render.go index ff2b985aae..6cef43e64d 100644 --- a/pkg/corerp/renderers/manualscale/render.go +++ b/pkg/corerp/renderers/manualscale/render.go @@ -20,11 +20,11 @@ import ( "context" "errors" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/ucp/resources" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -59,11 +59,12 @@ func (r *Renderer) Render(ctx context.Context, dm v1.DataModelInterface, options switch e.Kind { case datamodel.ManualScaling: for _, ores := range output.Resources { - if ores.ResourceType.Provider != resourcemodel.ProviderKubernetes { + resourceType := ores.GetResourceType() + if resourceType.Provider != resourcemodel.ProviderKubernetes { // Not a Kubernetes resource continue } - o, ok := ores.Resource.(runtime.Object) + o, ok := ores.CreateResource.Data.(runtime.Object) if !ok { return renderers.RendererOutput{}, errors.New("found Kubernetes resource with non-Kubernetes payload") } diff --git a/pkg/corerp/renderers/manualscale/render_test.go b/pkg/corerp/renderers/manualscale/render_test.go index 4811715f03..1e526ee76b 100644 --- a/pkg/corerp/renderers/manualscale/render_test.go +++ b/pkg/corerp/renderers/manualscale/render_test.go @@ -20,13 +20,13 @@ import ( "context" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/kubernetes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" @@ -43,8 +43,17 @@ func (r *noop) GetDependencyIDs(ctx context.Context, resource v1.DataModelInterf func (r *noop) Render(ctx context.Context, dm v1.DataModelInterface, options renderers.RenderOptions) (renderers.RendererOutput, error) { // Return a deployment so the manualscale extension can modify it - deployment := appsv1.Deployment{} - resources := []rpv1.OutputResource{rpv1.NewKubernetesOutputResource(resourcekinds.Deployment, rpv1.LocalIDDeployment, &deployment, deployment.ObjectMeta)} + deployment := appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-deployment", + Namespace: "test-namespace", + }, + TypeMeta: metav1.TypeMeta{ + Kind: "Deployment", + APIVersion: "apps/v1", + }, + } + resources := []rpv1.OutputResource{rpv1.NewKubernetesOutputResource(rpv1.LocalIDDeployment, &deployment, deployment.ObjectMeta)} return renderers.RendererOutput{Resources: resources}, nil } diff --git a/pkg/corerp/renderers/mock_renderer.go b/pkg/corerp/renderers/mock_renderer.go index d03fa5ea10..8e9ed8879c 100644 --- a/pkg/corerp/renderers/mock_renderer.go +++ b/pkg/corerp/renderers/mock_renderer.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/corerp/renderers (interfaces: Renderer) +// Source: github.com/radius-project/radius/pkg/corerp/renderers (interfaces: Renderer) // Package renderers is a generated GoMock package. package renderers @@ -9,8 +9,8 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - resources "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + resources "github.com/radius-project/radius/pkg/ucp/resources" ) // MockRenderer is a mock of Renderer interface. diff --git a/pkg/corerp/renderers/types.go b/pkg/corerp/renderers/types.go index a1ef23c001..a4f6ebc87a 100644 --- a/pkg/corerp/renderers/types.go +++ b/pkg/corerp/renderers/types.go @@ -19,11 +19,10 @@ package renderers import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" ) const ( @@ -34,7 +33,7 @@ const ( DefaultSecurePort int32 = 443 ) -//go:generate mockgen -destination=./mock_renderer.go -package=renderers github.com/project-radius/radius/pkg/corerp/renderers Renderer +//go:generate mockgen -destination=./mock_renderer.go -package=renderers github.com/radius-project/radius/pkg/corerp/renderers Renderer type Renderer interface { GetDependencyIDs(ctx context.Context, resource v1.DataModelInterface) (radiusResourceIDs []resources.ID, azureResourceIDs []resources.ID, err error) Render(ctx context.Context, resource v1.DataModelInterface, options RenderOptions) (RendererOutput, error) @@ -57,8 +56,8 @@ type RendererDependency struct { // ComputedValues is a map of the computed values and secrets of the dependency. ComputedValues map[string]any - // OutputResources is a map of the output resource identities of the dependency. The map is keyed on the LocalID of the output resource. - OutputResources map[string]resourcemodel.ResourceIdentity + // OutputResources is a map of the output resource IDs of the dependency. The map is keyed on the LocalID of the output resource. + OutputResources map[string]resources.ID } // EnvironmentOptions represents the options for the linked environment resource. diff --git a/pkg/corerp/renderers/volume/azure/keyvault.go b/pkg/corerp/renderers/volume/azure/keyvault.go index 3af893097d..e303704e5c 100644 --- a/pkg/corerp/renderers/volume/azure/keyvault.go +++ b/pkg/corerp/renderers/volume/azure/keyvault.go @@ -20,11 +20,11 @@ import ( "context" "errors" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" azcsi "github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/provider/types" "gopkg.in/yaml.v3" diff --git a/pkg/corerp/renderers/volume/azure/keyvault_test.go b/pkg/corerp/renderers/volume/azure/keyvault_test.go index 18caf37fbe..cba65f1bfb 100644 --- a/pkg/corerp/renderers/volume/azure/keyvault_test.go +++ b/pkg/corerp/renderers/volume/azure/keyvault_test.go @@ -21,10 +21,10 @@ import ( "encoding/json" "testing" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" azcsi "github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/provider/types" "github.com/stretchr/testify/require" diff --git a/pkg/corerp/renderers/volume/azure/testdata/volume-az-kv-systemassigned.json b/pkg/corerp/renderers/volume/azure/testdata/volume-az-kv-systemassigned.json index 9f8b198115..8bf9f974e1 100644 --- a/pkg/corerp/renderers/volume/azure/testdata/volume-az-kv-systemassigned.json +++ b/pkg/corerp/renderers/volume/azure/testdata/volume-az-kv-systemassigned.json @@ -1,57 +1,55 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/volumes/azkeyvault0", - "name": "azkeyvault0", - "type": "Applications.Core/volumes", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/volumes/azkeyvault0", + "name": "azkeyvault0", + "type": "Applications.Core/volumes", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "provisioningState": "Succeeded", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "provisioningState": "Succeeded", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Volume", - "Provider": "kubernetes" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "azureKeyVault": { - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcIssuer/URL" - }, - "secrets": { - "mysecret": { - "name": "mysecret", - "encoding": "base64" - } - }, - "keys": { - "mykey": { - "name": "mykey" - } - }, - "certificates": { - "mycert": { - "name": "mycert", - "alias": "myalias", - "certType": "certificate", - "encoding": "utf-8" - } - } + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "azureKeyVault": { + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcIssuer/URL" + }, + "secrets": { + "mysecret": { + "name": "mysecret", + "encoding": "base64" + } + }, + "keys": { + "mykey": { + "name": "mykey" + } + }, + "certificates": { + "mycert": { + "name": "mycert", + "alias": "myalias", + "certType": "certificate", + "encoding": "utf-8" } + } } + } } \ No newline at end of file diff --git a/pkg/corerp/renderers/volume/render.go b/pkg/corerp/renderers/volume/render.go index 8153b353d4..ab8ee9fb57 100644 --- a/pkg/corerp/renderers/volume/render.go +++ b/pkg/corerp/renderers/volume/render.go @@ -20,12 +20,12 @@ import ( "context" "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" - azvolrenderer "github.com/project-radius/radius/pkg/corerp/renderers/volume/azure" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" + azvolrenderer "github.com/radius-project/radius/pkg/corerp/renderers/volume/azure" + "github.com/radius-project/radius/pkg/ucp/resources" ) var _ renderers.Renderer = (*Renderer)(nil) diff --git a/pkg/corerp/renderers/volume/render_test.go b/pkg/corerp/renderers/volume/render_test.go index 7532ecaad0..4f6d4824ef 100644 --- a/pkg/corerp/renderers/volume/render_test.go +++ b/pkg/corerp/renderers/volume/render_test.go @@ -20,8 +20,8 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/corerp/renderers" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/renderers" "github.com/stretchr/testify/require" ) diff --git a/pkg/corerp/renderers/volume/types.go b/pkg/corerp/renderers/volume/types.go index a02701990b..dde1845e9a 100644 --- a/pkg/corerp/renderers/volume/types.go +++ b/pkg/corerp/renderers/volume/types.go @@ -19,8 +19,8 @@ package volume import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/renderers" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/renderers" ) const ( diff --git a/pkg/corerp/setup/operations.go b/pkg/corerp/setup/operations.go new file mode 100644 index 0000000000..d132ae4800 --- /dev/null +++ b/pkg/corerp/setup/operations.go @@ -0,0 +1,262 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package setup + +import v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + +var operationList = []v1.Operation{ + { + Name: "Applications.Core/operations/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "operations", + Operation: "Get operations", + Description: "Get the list of operations", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/environments/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "environments", + Operation: "List environments", + Description: "Get the list of environments.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/environments/write", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "environments", + Operation: "Create/Update environment", + Description: "Create or update an environment.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/environments/delete", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "environments", + Operation: "Delete environment", + Description: "Delete an environment.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/environments/getmetadata/action", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "environments", + Operation: "Get recipe metadata", + Description: "Get recipe metadata.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/environments/join/action", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "environments", + Operation: "Join environment", + Description: "Join to application environment.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/register/action", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "Applications.Core", + Operation: "Register Applications.Core", + Description: "Register the subscription for Applications.Core.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/unregister/action", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "Applications.Core", + Operation: "Unregister Applications.Core", + Description: "Unregister the subscription for Applications.Core.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/httproutes/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "httproutes", + Operation: "List httproutes", + Description: "Get the list of httproutes.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/httproutes/write", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "httproutes", + Operation: "Create/Update httproute", + Description: "Create or update an httproute.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/httproutes/delete", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "httproutes", + Operation: "Delete httproute", + Description: "Delete an httproute.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/applications/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "applications", + Operation: "List applications", + Description: "Get the list of applications.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/applications/write", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "applications", + Operation: "Create/Update application", + Description: "Create or update an application.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/applications/delete", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "applications", + Operation: "Delete application", + Description: "Delete an application.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/gateways/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "gateways", + Operation: "List gateways", + Description: "Get the list of gateways.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/gateways/write", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "gateways", + Operation: "Create/Update gateway", + Description: "Create or Update a gateway.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/gateways/delete", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "gateways", + Operation: "delete gateway", + Description: "Delete a gateway.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/containers/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "containers", + Operation: "List containers", + Description: "Get the list of containers.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/containers/write", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "containers", + Operation: "Create/Update container", + Description: "Create or update a container.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/containers/delete", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "containers", + Operation: "Delete container", + Description: "Delete a container.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/extenders/read", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "extenders", + Operation: "Get/List extenders", + Description: "Gets/Lists extender link(s).", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/extenders/write", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "extenders", + Operation: "Create/Update extenders", + Description: "Creates or updates a extender resource.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/extenders/delete", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "extenders", + Operation: "Delete extender", + Description: "Deletes a extender resource.", + }, + IsDataAction: false, + }, + { + Name: "Applications.Core/extenders/listsecrets/action", + Display: &v1.OperationDisplayProperties{ + Provider: "Applications.Core", + Resource: "extenders", + Operation: "List secrets", + Description: "Lists extender secrets.", + }, + IsDataAction: false, + }, +} diff --git a/pkg/corerp/setup/setup.go b/pkg/corerp/setup/setup.go new file mode 100644 index 0000000000..83549c668e --- /dev/null +++ b/pkg/corerp/setup/setup.go @@ -0,0 +1,257 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package setup + +import ( + "time" + + asyncctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/armrpc/builder" + apictrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/datamodel/converter" + "github.com/radius-project/radius/pkg/recipes/controllerconfig" + + backend_ctrl "github.com/radius-project/radius/pkg/corerp/backend/controller" + app_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/applications" + ctr_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/containers" + env_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/environments" + ext_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/extenders" + gw_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/gateways" + secret_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/secretstores" + vol_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/volumes" + rp_frontend "github.com/radius-project/radius/pkg/rp/frontend" + + ext_processor "github.com/radius-project/radius/pkg/corerp/processors/extenders" + pr_ctrl "github.com/radius-project/radius/pkg/portableresources/backend/controller" +) + +const ( + // AsyncOperationRetryAfter is polling interval for async create/update or delete resource operations. + AsyncOperationRetryAfter = time.Duration(5) * time.Second +) + +// SetupNamespace builds the namespace for core resource provider. +func SetupNamespace(recipeControllerConfig *controllerconfig.RecipeControllerConfig) *builder.Namespace { + ns := builder.NewNamespace("Applications.Core") + + _ = ns.AddResource("environments", &builder.ResourceOption[*datamodel.Environment, datamodel.Environment]{ + RequestConverter: converter.EnvironmentDataModelFromVersioned, + ResponseConverter: converter.EnvironmentDataModelToVersioned, + + Put: builder.Operation[datamodel.Environment]{ + APIController: env_ctrl.NewCreateOrUpdateEnvironment, + }, + Patch: builder.Operation[datamodel.Environment]{ + APIController: env_ctrl.NewCreateOrUpdateEnvironment, + }, + Custom: map[string]builder.Operation[datamodel.Environment]{ + "getmetadata": { + APIController: func(opt apictrl.Options) (apictrl.Controller, error) { + return env_ctrl.NewGetRecipeMetadata(opt, recipeControllerConfig.Engine) + }, + }, + }, + }) + + _ = ns.AddResource("applications", &builder.ResourceOption[*datamodel.Application, datamodel.Application]{ + RequestConverter: converter.ApplicationDataModelFromVersioned, + ResponseConverter: converter.ApplicationDataModelToVersioned, + + Put: builder.Operation[datamodel.Application]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.Application]{ + rp_frontend.PrepareRadiusResource[*datamodel.Application], + app_ctrl.CreateAppScopedNamespace, + }, + }, + Patch: builder.Operation[datamodel.Application]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.Application]{ + rp_frontend.PrepareRadiusResource[*datamodel.Application], + app_ctrl.CreateAppScopedNamespace, + }, + }, + }) + + _ = ns.AddResource("httpRoutes", &builder.ResourceOption[*datamodel.HTTPRoute, datamodel.HTTPRoute]{ + RequestConverter: converter.HTTPRouteDataModelFromVersioned, + ResponseConverter: converter.HTTPRouteDataModelToVersioned, + + Put: builder.Operation[datamodel.HTTPRoute]{ + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Patch: builder.Operation[datamodel.HTTPRoute]{ + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Delete: builder.Operation[datamodel.HTTPRoute]{ + AsyncJobController: backend_ctrl.NewDeleteResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + }) + + _ = ns.AddResource("containers", &builder.ResourceOption[*datamodel.ContainerResource, datamodel.ContainerResource]{ + RequestConverter: converter.ContainerDataModelFromVersioned, + ResponseConverter: converter.ContainerDataModelToVersioned, + + Put: builder.Operation[datamodel.ContainerResource]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.ContainerResource]{ + rp_frontend.PrepareRadiusResource[*datamodel.ContainerResource], + ctr_ctrl.ValidateAndMutateRequest, + }, + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Patch: builder.Operation[datamodel.ContainerResource]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.ContainerResource]{ + rp_frontend.PrepareRadiusResource[*datamodel.ContainerResource], + ctr_ctrl.ValidateAndMutateRequest, + }, + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Delete: builder.Operation[datamodel.ContainerResource]{ + AsyncJobController: backend_ctrl.NewDeleteResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + }) + + _ = ns.AddResource("gateways", &builder.ResourceOption[*datamodel.Gateway, datamodel.Gateway]{ + RequestConverter: converter.GatewayDataModelFromVersioned, + ResponseConverter: converter.GatewayDataModelToVersioned, + + Put: builder.Operation[datamodel.Gateway]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.Gateway]{ + rp_frontend.PrepareRadiusResource[*datamodel.Gateway], + gw_ctrl.ValidateAndMutateRequest, + }, + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Patch: builder.Operation[datamodel.Gateway]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.Gateway]{ + rp_frontend.PrepareRadiusResource[*datamodel.Gateway], + gw_ctrl.ValidateAndMutateRequest, + }, + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Delete: builder.Operation[datamodel.Gateway]{ + AsyncJobController: backend_ctrl.NewDeleteResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + }) + + _ = ns.AddResource("volumes", &builder.ResourceOption[*datamodel.VolumeResource, datamodel.VolumeResource]{ + RequestConverter: converter.VolumeResourceModelFromVersioned, + ResponseConverter: converter.VolumeResourceModelToVersioned, + + Put: builder.Operation[datamodel.VolumeResource]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.VolumeResource]{ + rp_frontend.PrepareRadiusResource[*datamodel.VolumeResource], + vol_ctrl.ValidateRequest, + }, + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Patch: builder.Operation[datamodel.VolumeResource]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.VolumeResource]{ + rp_frontend.PrepareRadiusResource[*datamodel.VolumeResource], + vol_ctrl.ValidateRequest, + }, + AsyncJobController: backend_ctrl.NewCreateOrUpdateResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Delete: builder.Operation[datamodel.VolumeResource]{ + AsyncJobController: backend_ctrl.NewDeleteResource, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + }) + + _ = ns.AddResource("secretStores", &builder.ResourceOption[*datamodel.SecretStore, datamodel.SecretStore]{ + RequestConverter: converter.SecretStoreModelFromVersioned, + ResponseConverter: converter.SecretStoreModelToVersioned, + + Put: builder.Operation[datamodel.SecretStore]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.SecretStore]{ + rp_frontend.PrepareRadiusResource[*datamodel.SecretStore], + secret_ctrl.ValidateAndMutateRequest, + secret_ctrl.UpsertSecret, + }, + }, + Patch: builder.Operation[datamodel.SecretStore]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.SecretStore]{ + rp_frontend.PrepareRadiusResource[*datamodel.SecretStore], + secret_ctrl.ValidateAndMutateRequest, + secret_ctrl.UpsertSecret, + }, + }, + Delete: builder.Operation[datamodel.SecretStore]{ + DeleteFilters: []apictrl.DeleteFilter[datamodel.SecretStore]{ + secret_ctrl.DeleteRadiusSecret, + }, + }, + Custom: map[string]builder.Operation[datamodel.SecretStore]{ + "listsecrets": { + APIController: secret_ctrl.NewListSecrets, + }, + }, + }) + + _ = ns.AddResource("extenders", &builder.ResourceOption[*datamodel.Extender, datamodel.Extender]{ + RequestConverter: converter.ExtenderDataModelFromVersioned, + ResponseConverter: converter.ExtenderDataModelToVersioned, + + Put: builder.Operation[datamodel.Extender]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.Extender]{ + rp_frontend.PrepareRadiusResource[*datamodel.Extender], + }, + AsyncJobController: func(options asyncctrl.Options) (asyncctrl.Controller, error) { + return pr_ctrl.NewCreateOrUpdateResource(options, &ext_processor.Processor{}, recipeControllerConfig.Engine, recipeControllerConfig.ResourceClient, recipeControllerConfig.ConfigLoader) + }, + AsyncOperationTimeout: ext_ctrl.AsyncCreateOrUpdateExtenderTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Patch: builder.Operation[datamodel.Extender]{ + UpdateFilters: []apictrl.UpdateFilter[datamodel.Extender]{ + rp_frontend.PrepareRadiusResource[*datamodel.Extender], + }, + AsyncJobController: func(options asyncctrl.Options) (asyncctrl.Controller, error) { + return pr_ctrl.NewCreateOrUpdateResource(options, &ext_processor.Processor{}, recipeControllerConfig.Engine, recipeControllerConfig.ResourceClient, recipeControllerConfig.ConfigLoader) + }, + AsyncOperationTimeout: ext_ctrl.AsyncCreateOrUpdateExtenderTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Delete: builder.Operation[datamodel.Extender]{ + AsyncJobController: func(options asyncctrl.Options) (asyncctrl.Controller, error) { + return pr_ctrl.NewDeleteResource(options, &ext_processor.Processor{}, recipeControllerConfig.Engine, recipeControllerConfig.ConfigLoader) + }, + AsyncOperationTimeout: ext_ctrl.AsyncDeleteExtenderTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + Custom: map[string]builder.Operation[datamodel.Extender]{ + "listsecrets": { + APIController: ext_ctrl.NewListSecretsExtender, + }, + }, + }) + + // Optional + ns.SetAvailableOperations(operationList) + + return ns +} diff --git a/pkg/corerp/setup/setup_test.go b/pkg/corerp/setup/setup_test.go new file mode 100644 index 0000000000..f6817359e0 --- /dev/null +++ b/pkg/corerp/setup/setup_test.go @@ -0,0 +1,253 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package setup + +import ( + "context" + "net/http" + "testing" + + "github.com/go-chi/chi/v5" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/builder" + apictrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/recipes/controllerconfig" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" + + app_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/applications" + ctr_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/containers" + env_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/environments" + gtwy_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/gateways" + hrt_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/httproutes" + secret_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/secretstores" + vol_ctrl "github.com/radius-project/radius/pkg/corerp/frontend/controller/volumes" +) + +var handlerTests = []rpctest.HandlerTestSpec{ + { + OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.core/applications", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.core/applications", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: app_ctrl.ResourceTypeName, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.core/applications/app0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.core/containers", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.core/containers", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: ctr_ctrl.ResourceTypeName, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.core/containers/ctr0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.core/environments", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.core/environments", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.core/environments/env0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: env_ctrl.ResourceTypeName, Method: "ACTIONGETMETADATA"}, + Path: "/resourcegroups/testrg/providers/applications.core/environments/env0/getmetadata", + Method: http.MethodPost, + }, { + OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.core/gateways", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.core/gateways", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: gtwy_ctrl.ResourceTypeName, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.core/gateways/gateway0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.core/httproutes", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.core/httproutes", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: hrt_ctrl.ResourceTypeName, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.core/httproutes/hrt0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.core/secretstores", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.core/secretstores", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: secret_ctrl.ResourceTypeName, Method: "ACTIONLISTSECRETS"}, + Path: "/resourcegroups/testrg/providers/applications.core/secretstores/secret0/listsecrets", + Method: http.MethodPost, + }, { + OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationPlaneScopeList}, + Path: "/providers/applications.core/volumes", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.core/volumes", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: vol_ctrl.ResourceTypeName, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.core/volumes/volume0", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: "Applications.Core/operationStatuses", Method: v1.OperationGet}, + Path: "/providers/applications.core/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Core/operationStatuses", Method: v1.OperationGet}, + Path: "/providers/applications.core/locations/global/operationresults/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, +} + +func TestRouter(t *testing.T) { + mctrl := gomock.NewController(t) + + mockSP := dataprovider.NewMockDataStorageProvider(mctrl) + mockSC := store.NewMockStorageClient(mctrl) + + mockSC.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(&store.Object{}, nil).AnyTimes() + mockSC.EXPECT().Save(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + mockSP.EXPECT().GetStorageClient(gomock.Any(), gomock.Any()).Return(store.StorageClient(mockSC), nil).AnyTimes() + + cfg := &controllerconfig.RecipeControllerConfig{} + ns := SetupNamespace(cfg) + nsBuilder := ns.GenerateBuilder() + + rpctest.AssertRouters(t, handlerTests, "/api.ucp.dev", "/planes/radius/local", func(ctx context.Context) (chi.Router, error) { + r := chi.NewRouter() + validator, err := builder.NewOpenAPIValidator(ctx, "/api.ucp.dev", "applications.core") + require.NoError(t, err) + return r, nsBuilder.ApplyAPIHandlers(ctx, r, apictrl.Options{PathBase: "/api.ucp.dev", DataProvider: mockSP}, validator) + }) +} diff --git a/pkg/daprrp/api/README.md b/pkg/daprrp/api/README.md index 639ddffa04..9aa57fe675 100644 --- a/pkg/daprrp/api/README.md +++ b/pkg/daprrp/api/README.md @@ -44,7 +44,7 @@ The following configuration generates track2 go models and client. ```yaml $(tag) != '' version: 3.*.* -use: "@autorest/go@4.0.0-preview.44" +use: "@autorest/go@4.0.0-preview.55" module-version: 0.0.1 file-prefix: zz_generated_ license-header: "Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information.\nCode generated by Microsoft (R) AutoRest Code Generator.\nChanges may cause incorrect behavior and will be lost if the code is regenerated." diff --git a/pkg/daprrp/api/v20220315privatepreview/datamodel_util.go b/pkg/daprrp/api/v20220315privatepreview/datamodel_util.go index 0ee66e2aeb..fe1e1724b3 100644 --- a/pkg/daprrp/api/v20220315privatepreview/datamodel_util.go +++ b/pkg/daprrp/api/v20220315privatepreview/datamodel_util.go @@ -19,10 +19,10 @@ package v20220315privatepreview import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) func toProvisioningStateDataModel(state *ProvisioningState) v1.ProvisioningState { @@ -72,24 +72,24 @@ func fromProvisioningStateDataModel(state v1.ProvisioningState) *ProvisioningSta return &converted } -func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (linkrp.ResourceProvisioning, error) { +func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (portableresources.ResourceProvisioning, error) { if provisioning == nil { - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil } switch *provisioning { case ResourceProvisioningManual: - return linkrp.ResourceProvisioningManual, nil + return portableresources.ResourceProvisioningManual, nil case ResourceProvisioningRecipe: - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil default: return "", &v1.ErrModelConversion{PropertyName: "$.properties.resourceProvisioning", ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues())} } } -func fromResourceProvisioningDataModel(provisioning linkrp.ResourceProvisioning) *ResourceProvisioning { +func fromResourceProvisioningDataModel(provisioning portableresources.ResourceProvisioning) *ResourceProvisioning { var converted ResourceProvisioning switch provisioning { - case linkrp.ResourceProvisioningManual: + case portableresources.ResourceProvisioningManual: converted = ResourceProvisioningManual default: converted = ResourceProvisioningRecipe @@ -102,22 +102,22 @@ func fromSystemDataModel(s v1.SystemData) *SystemData { return &SystemData{ CreatedBy: to.Ptr(s.CreatedBy), CreatedByType: (*CreatedByType)(to.Ptr(s.CreatedByType)), - CreatedAt: v20220315privatepreview.UnmarshalTimeString(s.CreatedAt), + CreatedAt: v1.UnmarshalTimeString(s.CreatedAt), LastModifiedBy: to.Ptr(s.LastModifiedBy), LastModifiedByType: (*CreatedByType)(to.Ptr(s.LastModifiedByType)), - LastModifiedAt: v20220315privatepreview.UnmarshalTimeString(s.LastModifiedAt), + LastModifiedAt: v1.UnmarshalTimeString(s.LastModifiedAt), } } -func toRecipeDataModel(r *Recipe) linkrp.LinkRecipe { +func toRecipeDataModel(r *Recipe) portableresources.ResourceRecipe { if r == nil { - return linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + return portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, } } - recipe := linkrp.LinkRecipe{} + recipe := portableresources.ResourceRecipe{} if r.Name == nil { - recipe.Name = v20220315privatepreview.DefaultRecipeName + recipe.Name = portableresources.DefaultRecipeName } else { recipe.Name = to.String(r.Name) } @@ -127,27 +127,27 @@ func toRecipeDataModel(r *Recipe) linkrp.LinkRecipe { return recipe } -func fromRecipeDataModel(r linkrp.LinkRecipe) *Recipe { +func fromRecipeDataModel(r portableresources.ResourceRecipe) *Recipe { return &Recipe{ Name: to.Ptr(r.Name), Parameters: r.Parameters, } } -func toResourcesDataModel(r []*ResourceReference) []*linkrp.ResourceReference { +func toResourcesDataModel(r []*ResourceReference) []*portableresources.ResourceReference { if r == nil { return nil } - resources := make([]*linkrp.ResourceReference, len(r)) + resources := make([]*portableresources.ResourceReference, len(r)) for i, resource := range r { - resources[i] = &linkrp.ResourceReference{ + resources[i] = &portableresources.ResourceReference{ ID: to.String(resource.ID), } } return resources } -func fromResourcesDataModel(r []*linkrp.ResourceReference) []*ResourceReference { +func fromResourcesDataModel(r []*portableresources.ResourceReference) []*ResourceReference { if r == nil { return nil } @@ -159,3 +159,23 @@ func fromResourcesDataModel(r []*linkrp.ResourceReference) []*ResourceReference } return resources } + +func toOutputResources(outputResources []rpv1.OutputResource) []*OutputResource { + var outResources []*OutputResource + for _, or := range outputResources { + r := &OutputResource{ + ID: to.Ptr(or.ID.String()), + } + + // We will not serialize the following fields if they are empty or nil. + if or.LocalID != "" { + r.LocalID = to.Ptr(or.LocalID) + } + if or.RadiusManaged != nil { + r.RadiusManaged = or.RadiusManaged + } + + outResources = append(outResources, r) + } + return outResources +} diff --git a/pkg/daprrp/api/v20220315privatepreview/datamodel_util_test.go b/pkg/daprrp/api/v20220315privatepreview/datamodel_util_test.go index 93ee50b243..515e76ec06 100644 --- a/pkg/daprrp/api/v20220315privatepreview/datamodel_util_test.go +++ b/pkg/daprrp/api/v20220315privatepreview/datamodel_util_test.go @@ -20,10 +20,9 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) @@ -117,15 +116,15 @@ func TestFromSystemDataModel(t *testing.T) { func TestToResourcesDataModel(t *testing.T) { testset := []struct { - DMResources []*linkrp.ResourceReference + DMResources []*portableresources.ResourceReference VersionedResources []*ResourceReference }{ { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, + DMResources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, }, { - DMResources: []*linkrp.ResourceReference{}, + DMResources: []*portableresources.ResourceReference{}, VersionedResources: []*ResourceReference{}, }, } @@ -139,15 +138,15 @@ func TestToResourcesDataModel(t *testing.T) { func TestFromResourcesDataModel(t *testing.T) { testset := []struct { - DMResources []*linkrp.ResourceReference + DMResources []*portableresources.ResourceReference VersionedResources []*ResourceReference }{ { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, + DMResources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, }, { - DMResources: []*linkrp.ResourceReference{}, + DMResources: []*portableresources.ResourceReference{}, VersionedResources: []*ResourceReference{}, }, } @@ -162,17 +161,17 @@ func TestFromResourcesDataModel(t *testing.T) { func TestToResourceProvisiongDataModel(t *testing.T) { testset := []struct { versioned ResourceProvisioning - datamodel linkrp.ResourceProvisioning + datamodel portableresources.ResourceProvisioning err error }{ { ResourceProvisioningManual, - linkrp.ResourceProvisioningManual, + portableresources.ResourceProvisioningManual, nil, }, { ResourceProvisioningRecipe, - linkrp.ResourceProvisioningRecipe, + portableresources.ResourceProvisioningRecipe, nil, }, { @@ -199,11 +198,11 @@ func TestToResourceProvisiongDataModel(t *testing.T) { func TestFromResourceProvisiongDataModel(t *testing.T) { testCases := []struct { - datamodel linkrp.ResourceProvisioning + datamodel portableresources.ResourceProvisioning versioned ResourceProvisioning }{ - {linkrp.ResourceProvisioningManual, ResourceProvisioningManual}, - {linkrp.ResourceProvisioningRecipe, ResourceProvisioningRecipe}, + {portableresources.ResourceProvisioningManual, ResourceProvisioningManual}, + {portableresources.ResourceProvisioningRecipe, ResourceProvisioningRecipe}, {"", ResourceProvisioningRecipe}, } @@ -216,12 +215,12 @@ func TestFromResourceProvisiongDataModel(t *testing.T) { func TestToRecipeDataModel(t *testing.T) { testset := []struct { versioned *Recipe - datamodel linkrp.LinkRecipe + datamodel portableresources.ResourceRecipe }{ { nil, - linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, }, }, { @@ -231,7 +230,7 @@ func TestToRecipeDataModel(t *testing.T) { "foo": "bar", }, }, - linkrp.LinkRecipe{ + portableresources.ResourceRecipe{ Name: "test", Parameters: map[string]any{ "foo": "bar", @@ -244,8 +243,8 @@ func TestToRecipeDataModel(t *testing.T) { "foo": "bar", }, }, - linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, Parameters: map[string]any{ "foo": "bar", }, diff --git a/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion.go b/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion.go index f16e6a2857..88b5214b1c 100644 --- a/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion.go +++ b/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion.go @@ -21,11 +21,11 @@ import ( "reflect" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts a versioned DaprPubSubBrokerResource to a version-agnostic DaprPubSubBroker. It returns an error @@ -66,7 +66,7 @@ func (src *DaprPubSubBrokerResource) ConvertTo() (v1.DataModelInterface, error) // the recipe is expected to create the Dapr Component manifest. However, they are required // when resourceProvisioning is set to manual. msgs := []string{} - if converted.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if converted.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { if src.Properties.Recipe != nil && (!reflect.ValueOf(*src.Properties.Recipe).IsZero()) { msgs = append(msgs, "recipe details cannot be specified when resourceProvisioning is set to manual") } @@ -129,11 +129,11 @@ func (dst *DaprPubSubBrokerResource) ConvertFrom(src v1.DataModelInterface) erro ComponentName: to.Ptr(daprPubSub.Properties.ComponentName), ProvisioningState: fromProvisioningStateDataModel(daprPubSub.InternalMetadata.AsyncProvisioningState), Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(daprPubSub.Properties.Status.OutputResources), + OutputResources: toOutputResources(daprPubSub.Properties.Status.OutputResources), }, } - if daprPubSub.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if daprPubSub.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { dst.Properties.Metadata = daprPubSub.Properties.Metadata dst.Properties.Type = to.Ptr(daprPubSub.Properties.Type) dst.Properties.Version = to.Ptr(daprPubSub.Properties.Version) diff --git a/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion_test.go b/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion_test.go index 5842f36ffd..bddbe94961 100644 --- a/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion_test.go +++ b/pkg/daprrp/api/v20220315privatepreview/pubsubbroker_conversion_test.go @@ -20,12 +20,13 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -43,7 +44,7 @@ func TestDaprPubSubBroker_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", Name: "test-dpsb", - Type: linkrp.N_DaprPubSubBrokersResourceType, + Type: portableresources.DaprPubSubBrokersResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -61,11 +62,11 @@ func TestDaprPubSubBroker_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{ "foo": "bar", }, - Resources: []*linkrp.ResourceReference{ + Resources: []*portableresources.ResourceReference{ { ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async", }, @@ -83,7 +84,7 @@ func TestDaprPubSubBroker_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", Name: "test-dpsb", - Type: linkrp.N_DaprPubSubBrokersResourceType, + Type: portableresources.DaprPubSubBrokersResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -101,8 +102,8 @@ func TestDaprPubSubBroker_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Recipe: linkrp.LinkRecipe{ + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, + Recipe: portableresources.ResourceRecipe{ Name: "dpsb-recipe", }, }, @@ -113,10 +114,9 @@ func TestDaprPubSubBroker_ConvertVersionedToDataModel(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) versionedResource := &DaprPubSubBrokerResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) // act @@ -151,10 +151,9 @@ func TestDaprPubSubBroker_ConvertVersionedToDataModel_Invalid(t *testing.T) { for _, test := range testset { t.Run(test.payload, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(test.payload) versionedResource := &DaprStateStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) dm, err := versionedResource.ConvertTo() @@ -193,22 +192,14 @@ func TestDaprPubSubBroker_ConvertDataModelToVersioned(t *testing.T) { Version: to.Ptr("v1"), ComponentName: to.Ptr("test-dpsb"), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb"), Name: to.Ptr("test-dpsb"), - Type: to.Ptr(linkrp.N_DaprPubSubBrokersResourceType), + Type: to.Ptr(portableresources.DaprPubSubBrokersResourceType), }, }, { @@ -225,32 +216,23 @@ func TestDaprPubSubBroker_ConvertDataModelToVersioned(t *testing.T) { ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), ComponentName: to.Ptr("test-dpsb"), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb"), Name: to.Ptr("test-dpsb"), - Type: to.Ptr(linkrp.N_DaprPubSubBrokersResourceType), + Type: to.Ptr(portableresources.DaprPubSubBrokersResourceType), }, }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) resource := &datamodel.DaprPubSubBroker{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &DaprPubSubBrokerResource{} @@ -270,7 +252,7 @@ func TestDaprPubSubBroker_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion.go b/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion.go index 8f7e6d0447..80145f0893 100644 --- a/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion.go +++ b/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion.go @@ -21,11 +21,11 @@ import ( "reflect" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned DaprSecretStore resource to version-agnostic datamodel and returns an error if the @@ -59,7 +59,7 @@ func (src *DaprSecretStoreResource) ConvertTo() (v1.DataModelInterface, error) { } msgs := []string{} - if converted.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if converted.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { if src.Properties.Recipe != nil && (!reflect.ValueOf(*src.Properties.Recipe).IsZero()) { msgs = append(msgs, "recipe details cannot be specified when resourceProvisioning is set to manual") } @@ -123,10 +123,10 @@ func (dst *DaprSecretStoreResource) ConvertFrom(src v1.DataModelInterface) error Metadata: daprSecretStore.Properties.Metadata, ComponentName: to.Ptr(daprSecretStore.Properties.ComponentName), Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(daprSecretStore.Properties.Status.OutputResources), + OutputResources: toOutputResources(daprSecretStore.Properties.Status.OutputResources), }, } - if daprSecretStore.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if daprSecretStore.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { dst.Properties.Metadata = daprSecretStore.Properties.Metadata dst.Properties.Type = to.Ptr(daprSecretStore.Properties.Type) dst.Properties.Version = to.Ptr(daprSecretStore.Properties.Version) diff --git a/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion_test.go b/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion_test.go index 4385af9bfd..8d47ae1e83 100644 --- a/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion_test.go +++ b/pkg/daprrp/api/v20220315privatepreview/secretstore_conversion_test.go @@ -20,12 +20,13 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -43,7 +44,7 @@ func TestDaprSecretStore_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", Name: "test-dss", - Type: linkrp.N_DaprSecretStoresResourceType, + Type: portableresources.DaprSecretStoresResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -61,7 +62,7 @@ func TestDaprSecretStore_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{ "foo": "bar", }, @@ -78,7 +79,7 @@ func TestDaprSecretStore_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", Name: "test-dss", - Type: linkrp.N_DaprSecretStoresResourceType, + Type: portableresources.DaprSecretStoresResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -96,8 +97,8 @@ func TestDaprSecretStore_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Recipe: linkrp.LinkRecipe{ + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, + Recipe: portableresources.ResourceRecipe{ Name: "daprSecretStore", Parameters: map[string]any{ "foo": "bar", @@ -110,10 +111,9 @@ func TestDaprSecretStore_ConvertVersionedToDataModel(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) versionedResource := &DaprSecretStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) // act @@ -150,22 +150,14 @@ func TestDaprSecretStore_ConvertDataModelToVersioned(t *testing.T) { Version: to.Ptr("v1"), ComponentName: to.Ptr("test-dss"), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss"), Name: to.Ptr("test-dss"), - Type: to.Ptr(linkrp.N_DaprSecretStoresResourceType), + Type: to.Ptr(portableresources.DaprSecretStoresResourceType), }, }, { @@ -188,31 +180,22 @@ func TestDaprSecretStore_ConvertDataModelToVersioned(t *testing.T) { Metadata: map[string]any{"foo": "bar"}, ComponentName: to.Ptr("test-dss"), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss"), Name: to.Ptr("test-dss"), - Type: to.Ptr(linkrp.N_DaprSecretStoresResourceType), + Type: to.Ptr(portableresources.DaprSecretStoresResourceType), }, }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) resource := &datamodel.DaprSecretStore{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &DaprSecretStoreResource{} @@ -247,10 +230,9 @@ func TestDaprSecretStore_ConvertVersionedToDataModel_InvalidRequest(t *testing.T } for _, test := range testset { t.Run(test.payload, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(test.payload) versionedResource := &DaprSecretStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) dm, err := versionedResource.ConvertTo() @@ -267,7 +249,7 @@ func TestDaprSecretStore_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/daprrp/api/v20220315privatepreview/statestore_conversion.go b/pkg/daprrp/api/v20220315privatepreview/statestore_conversion.go index 8dfa99cbcc..9f2ef1e3c8 100644 --- a/pkg/daprrp/api/v20220315privatepreview/statestore_conversion.go +++ b/pkg/daprrp/api/v20220315privatepreview/statestore_conversion.go @@ -5,11 +5,11 @@ import ( "reflect" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned DaprStateStore resource to version-agnostic datamodel and returns an error @@ -50,7 +50,7 @@ func (src *DaprStateStoreResource) ConvertTo() (v1.DataModelInterface, error) { // the recipe is expected to create the Dapr Component manifest. However, they are required // when resourceProvisioning is set to manual. msgs := []string{} - if converted.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if converted.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { if src.Properties.Recipe != nil && (!reflect.ValueOf(*src.Properties.Recipe).IsZero()) { msgs = append(msgs, "recipe details cannot be specified when resourceProvisioning is set to manual") } @@ -106,7 +106,7 @@ func (dst *DaprStateStoreResource) ConvertFrom(src v1.DataModelInterface) error dst.Tags = *to.StringMapPtr(daprStateStore.Tags) dst.Properties = &DaprStateStoreProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(daprStateStore.Properties.Status.OutputResources), + OutputResources: toOutputResources(daprStateStore.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(daprStateStore.InternalMetadata.AsyncProvisioningState), Environment: to.Ptr(daprStateStore.Properties.Environment), @@ -116,7 +116,7 @@ func (dst *DaprStateStoreResource) ConvertFrom(src v1.DataModelInterface) error Resources: fromResourcesDataModel(daprStateStore.Properties.Resources), } - if daprStateStore.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if daprStateStore.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { dst.Properties.Type = to.Ptr(daprStateStore.Properties.Type) dst.Properties.Version = to.Ptr(daprStateStore.Properties.Version) dst.Properties.Metadata = daprStateStore.Properties.Metadata diff --git a/pkg/daprrp/api/v20220315privatepreview/statestore_conversion_test.go b/pkg/daprrp/api/v20220315privatepreview/statestore_conversion_test.go index a1249d29f2..5f074e8e01 100644 --- a/pkg/daprrp/api/v20220315privatepreview/statestore_conversion_test.go +++ b/pkg/daprrp/api/v20220315privatepreview/statestore_conversion_test.go @@ -20,12 +20,13 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -37,10 +38,9 @@ func TestDaprStateStore_ConvertVersionedToDataModel(t *testing.T) { for _, payload := range testset { t.Run(payload, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(payload) versionedResource := &DaprStateStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) dm, err := versionedResource.ConvertTo() @@ -53,7 +53,7 @@ func TestDaprStateStore_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/stateStores/stateStore0", Name: "stateStore0", - Type: linkrp.N_DaprStateStoresResourceType, + Type: portableresources.DaprStateStoresResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -74,19 +74,19 @@ func TestDaprStateStore_ConvertVersionedToDataModel(t *testing.T) { }, } if payload == "statestore_values_resource.json" { - expected.Properties.ResourceProvisioning = linkrp.ResourceProvisioningManual + expected.Properties.ResourceProvisioning = portableresources.ResourceProvisioningManual expected.Properties.Type = "state.zookeeper" expected.Properties.Version = "v1" expected.Properties.Metadata = map[string]any{ "foo": "bar", } - expected.Properties.Resources = []*linkrp.ResourceReference{ + expected.Properties.Resources = []*portableresources.ResourceReference{ { ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase", }, } } else if payload == "statestore_recipe_resource.json" { - expected.Properties.ResourceProvisioning = linkrp.ResourceProvisioningRecipe + expected.Properties.ResourceProvisioning = portableresources.ResourceProvisioningRecipe expected.Properties.Recipe.Name = "recipe-test" } @@ -107,10 +107,9 @@ func TestDaprStateStore_ConvertVersionedToDataModel_Invalid(t *testing.T) { for _, test := range testset { t.Run(test.payload, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(test.payload) versionedResource := &DaprStateStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) dm, err := versionedResource.ConvertTo() @@ -130,10 +129,9 @@ func TestDaprStateStore_ConvertDataModelToVersioned(t *testing.T) { for _, payload := range testset { t.Run(payload, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(payload) resource := &datamodel.DaprStateStore{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &DaprStateStoreResource{} @@ -146,7 +144,7 @@ func TestDaprStateStore_ConvertDataModelToVersioned(t *testing.T) { expected := &DaprStateStoreResource{ ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/stateStores/stateStore0"), Name: to.Ptr("stateStore0"), - Type: to.Ptr(linkrp.N_DaprStateStoresResourceType), + Type: to.Ptr(portableresources.DaprStateStoresResourceType), Location: to.Ptr(v1.LocationGlobal), Tags: map[string]*string{ "env": to.Ptr("dev"), @@ -156,15 +154,7 @@ func TestDaprStateStore_ConvertDataModelToVersioned(t *testing.T) { Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), ComponentName: to.Ptr("stateStore0"), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, } @@ -197,7 +187,7 @@ func TestDaprStateStore_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_datamodel.json b/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_datamodel.json index 09f61d2067..74714f0903 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_datamodel.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_datamodel.json @@ -1,44 +1,40 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "tags": { - "env": "dev" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", + "name": "test-dpsb", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "tags": { + "env": "dev" + }, + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "properties": { + "componentName": "test-dpsb", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "resourceProvisioning": "manual", + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" }, - "properties": { - "componentName": "test-dpsb", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "daprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "manual", - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async" - } - ] - } + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async" + } + ] + } } \ No newline at end of file diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_generic_datamodel.json b/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_generic_datamodel.json index a5c114c947..bbd2688472 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_generic_datamodel.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_manual_generic_datamodel.json @@ -1,40 +1,36 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "componentName": "test-dpsb", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "kind": "generic", - "resourceProvisioning": "manual", - "type": "pubsub.kafka", - "version": "v1", - "metadata": { - "foo": "bar" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", + "name": "test-dpsb", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "componentName": "test-dpsb", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "kind": "generic", + "resourceProvisioning": "manual", + "type": "pubsub.kafka", + "version": "v1", + "metadata": { + "foo": "bar" } + } } \ No newline at end of file diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_recipe_datamodel.json b/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_recipe_datamodel.json index 603efe0943..8292bc3900 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_recipe_datamodel.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/pubsubbroker_recipe_datamodel.json @@ -1,37 +1,33 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "tags": { - "env": "dev" - }, - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "properties": { - "componentName": "test-dpsb", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "recipe", - "recipe": { - "name": "dpsb-recipe" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/pubSubBrokers/test-dpsb", + "name": "test-dpsb", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "tags": { + "env": "dev" + }, + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "properties": { + "componentName": "test-dpsb", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "resourceProvisioning": "recipe", + "recipe": { + "name": "dpsb-recipe" } + } } \ No newline at end of file diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_manual_resourcedatamodel.json b/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_manual_resourcedatamodel.json index f97421ee1d..69db9f7141 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_manual_resourcedatamodel.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_manual_resourcedatamodel.json @@ -1,40 +1,36 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", - "name": "test-dss", - "type": "Applications.Dapr/secretStores", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", + "name": "test-dss", + "type": "Applications.Dapr/secretStores", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "componentName": "test-dss", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "kind": "generic", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" }, - "properties": { - "componentName": "test-dss", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprSecretStoreProvider", - "Provider": "kubernetes" - } - } - ] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "kind": "generic", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning":"manual" - } -} + "resourceProvisioning": "manual" + } +} \ No newline at end of file diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resource.json b/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resource.json index eae37b44bd..d478d4161b 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resource.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resource.json @@ -1,28 +1,26 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", - "name": "test-dss", - "type": "Applications.Dapr/secretStores", - "location": "global", - "tags": { - "env": "dev" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", + "name": "test-dss", + "type": "Applications.Dapr/secretStores", + "location": "global", + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Secret", - "Provider": "kubernetes" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "recipe": { - "name": "daprSecretStore", - "parameters":{ - "foo":"bar" - } + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "recipe": { + "name": "daprSecretStore", + "parameters": { + "foo": "bar" } } -} + } +} \ No newline at end of file diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resourcedatamodel.json b/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resourcedatamodel.json index fef3759f91..1758924778 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resourcedatamodel.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/secretstore_recipe_resourcedatamodel.json @@ -1,44 +1,40 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", - "name": "test-dss", - "type": "Applications.Dapr/secretStores", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Dapr/secretStores/test-dss", + "name": "test-dss", + "type": "Applications.Dapr/secretStores", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "componentName": "test-dss", + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" }, - "properties": { - "componentName": "test-dss", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprSecretStoreProvider", - "Provider": "kubernetes" - } - } - ] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "recipe": { - "name": "daprSecretStore", - "parameters":{ - "foo":"bar" - } - } + "recipe": { + "name": "daprSecretStore", + "parameters": { + "foo": "bar" + } } -} + } +} \ No newline at end of file diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_recipe_resourcedatamodel.json b/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_recipe_resourcedatamodel.json index 47b74ae613..98889019fa 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_recipe_resourcedatamodel.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_recipe_resourcedatamodel.json @@ -19,11 +19,7 @@ "status": { "outputResources": [ { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprStateStoreProvider", - "Provider": "kubernetes" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_values_resourcedatamodel.json b/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_values_resourcedatamodel.json index 4e25353eff..fb6009836e 100644 --- a/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_values_resourcedatamodel.json +++ b/pkg/daprrp/api/v20220315privatepreview/testdata/statestore_values_resourcedatamodel.json @@ -19,11 +19,7 @@ "status": { "outputResources": [ { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprStateStoreProvider", - "Provider": "kubernetes" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_client_factory.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_client_factory.go new file mode 100644 index 0000000000..b288e5d860 --- /dev/null +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_client_factory.go @@ -0,0 +1,60 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + rootScope string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + rootScope: rootScope, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPubSubBrokersClient() *PubSubBrokersClient { + subClient, _ := NewPubSubBrokersClient(c.rootScope, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSecretStoresClient() *SecretStoresClient { + subClient, _ := NewSecretStoresClient(c.rootScope, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStateStoresClient() *StateStoresClient { + subClient, _ := NewStateStoresClient(c.rootScope, c.credential, c.options) + return subClient +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_constants.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_constants.go index e80a581e36..b0c3e1f1e9 100644 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_constants.go +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_constants.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -47,6 +46,24 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// IdentitySettingKind - IdentitySettingKind is the kind of supported external identity setting +type IdentitySettingKind string + +const ( + // IdentitySettingKindAzureComWorkload - azure ad workload identity + IdentitySettingKindAzureComWorkload IdentitySettingKind = "azure.com.workload" + // IdentitySettingKindUndefined - undefined identity + IdentitySettingKindUndefined IdentitySettingKind = "undefined" +) + +// PossibleIdentitySettingKindValues returns the possible values for the IdentitySettingKind const type. +func PossibleIdentitySettingKindValues() []IdentitySettingKind { + return []IdentitySettingKind{ + IdentitySettingKindAzureComWorkload, + IdentitySettingKindUndefined, + } +} + // Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" type Origin string @@ -70,12 +87,19 @@ func PossibleOriginValues() []Origin { type ProvisioningState string const ( + // ProvisioningStateAccepted - The resource create request has been accepted ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - The resource is being deleted ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is being provisioned ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is updating ProvisioningStateUpdating ProvisioningState = "Updating" ) @@ -98,7 +122,9 @@ func PossibleProvisioningStateValues() []ProvisioningState { type ResourceProvisioning string const ( + // ResourceProvisioningManual - The resource lifecycle will be managed by the user ResourceProvisioningManual ResourceProvisioning = "manual" + // ResourceProvisioningRecipe - The resource lifecycle will be managed by Radius ResourceProvisioningRecipe ResourceProvisioning = "recipe" ) @@ -110,3 +136,18 @@ func PossibleResourceProvisioningValues() []ResourceProvisioning { } } +// Versions - Supported API versions for the Applications.Dapr resource provider. +type Versions string + +const ( + // VersionsV20220315Privatepreview - 2022-03-15-privatepreview + VersionsV20220315Privatepreview Versions = "2022-03-15-privatepreview" +) + +// PossibleVersionsValues returns the possible values for the Versions const type. +func PossibleVersionsValues() []Versions { + return []Versions{ + VersionsV20220315Privatepreview, + } +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprpubsubbroker_client.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprpubsubbroker_client.go deleted file mode 100644 index c033df708a..0000000000 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprpubsubbroker_client.go +++ /dev/null @@ -1,276 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// DaprPubSubBrokerClient contains the methods for the DaprPubSubBroker group. -// Don't use this type directly, use NewDaprPubSubBrokerClient() instead. -type DaprPubSubBrokerClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewDaprPubSubBrokerClient creates a new instance of DaprPubSubBrokerClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewDaprPubSubBrokerClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DaprPubSubBrokerClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &DaprPubSubBrokerClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprPubSubBrokerName - Dapr PubSubBroker name -// resource - Resource create parameters. -// options - DaprPubSubBrokerClientCreateOrUpdateOptions contains the optional parameters for the DaprPubSubBrokerClient.CreateOrUpdate -// method. -func (client *DaprPubSubBrokerClient) CreateOrUpdate(ctx context.Context, daprPubSubBrokerName string, resource DaprPubSubBrokerResource, options *DaprPubSubBrokerClientCreateOrUpdateOptions) (DaprPubSubBrokerClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, daprPubSubBrokerName, resource, options) - if err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DaprPubSubBrokerClient) createOrUpdateCreateRequest(ctx context.Context, daprPubSubBrokerName string, resource DaprPubSubBrokerResource, options *DaprPubSubBrokerClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{daprPubSubBrokerName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprPubSubBrokerName == "" { - return nil, errors.New("parameter daprPubSubBrokerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprPubSubBrokerName}", url.PathEscape(daprPubSubBrokerName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *DaprPubSubBrokerClient) createOrUpdateHandleResponse(resp *http.Response) (DaprPubSubBrokerClientCreateOrUpdateResponse, error) { - result := DaprPubSubBrokerClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResource); err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// BeginDelete - Deletes an existing DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprPubSubBrokerName - Dapr PubSubBroker name -// options - DaprPubSubBrokerClientBeginDeleteOptions contains the optional parameters for the DaprPubSubBrokerClient.BeginDelete -// method. -func (client *DaprPubSubBrokerClient) BeginDelete(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientBeginDeleteOptions) (*runtime.Poller[DaprPubSubBrokerClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, daprPubSubBrokerName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DaprPubSubBrokerClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[DaprPubSubBrokerClientDeleteResponse](options.ResumeToken, client.pl, nil) - } -} - -// Delete - Deletes an existing DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -func (client *DaprPubSubBrokerClient) deleteOperation(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientBeginDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, daprPubSubBrokerName, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *DaprPubSubBrokerClient) deleteCreateRequest(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{daprPubSubBrokerName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprPubSubBrokerName == "" { - return nil, errors.New("parameter daprPubSubBrokerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprPubSubBrokerName}", url.PathEscape(daprPubSubBrokerName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Retrieves information about a DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprPubSubBrokerName - Dapr PubSubBroker name -// options - DaprPubSubBrokerClientGetOptions contains the optional parameters for the DaprPubSubBrokerClient.Get method. -func (client *DaprPubSubBrokerClient) Get(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientGetOptions) (DaprPubSubBrokerClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, daprPubSubBrokerName, options) - if err != nil { - return DaprPubSubBrokerClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprPubSubBrokerClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprPubSubBrokerClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *DaprPubSubBrokerClient) getCreateRequest(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{daprPubSubBrokerName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprPubSubBrokerName == "" { - return nil, errors.New("parameter daprPubSubBrokerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprPubSubBrokerName}", url.PathEscape(daprPubSubBrokerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *DaprPubSubBrokerClient) getHandleResponse(resp *http.Response) (DaprPubSubBrokerClientGetResponse, error) { - result := DaprPubSubBrokerClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResource); err != nil { - return DaprPubSubBrokerClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all DaprPubSubBrokerResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - DaprPubSubBrokerClientListByRootScopeOptions contains the optional parameters for the DaprPubSubBrokerClient.ListByRootScope -// method. -func (client *DaprPubSubBrokerClient) NewListByRootScopePager(options *DaprPubSubBrokerClientListByRootScopeOptions) (*runtime.Pager[DaprPubSubBrokerClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[DaprPubSubBrokerClientListByRootScopeResponse]{ - More: func(page DaprPubSubBrokerClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DaprPubSubBrokerClientListByRootScopeResponse) (DaprPubSubBrokerClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return DaprPubSubBrokerClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprPubSubBrokerClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprPubSubBrokerClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *DaprPubSubBrokerClient) listByRootScopeCreateRequest(ctx context.Context, options *DaprPubSubBrokerClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *DaprPubSubBrokerClient) listByRootScopeHandleResponse(resp *http.Response) (DaprPubSubBrokerClientListByRootScopeResponse, error) { - result := DaprPubSubBrokerClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResourceListResult); err != nil { - return DaprPubSubBrokerClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprsecretstore_client.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprsecretstore_client.go deleted file mode 100644 index a085337891..0000000000 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprsecretstore_client.go +++ /dev/null @@ -1,272 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// DaprSecretStoreClient contains the methods for the DaprSecretStore group. -// Don't use this type directly, use NewDaprSecretStoreClient() instead. -type DaprSecretStoreClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewDaprSecretStoreClient creates a new instance of DaprSecretStoreClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewDaprSecretStoreClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DaprSecretStoreClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &DaprSecretStoreClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a DaprSecretStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprSecretStoreName - Dapr SecretStore name -// resource - Resource create parameters. -// options - DaprSecretStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprSecretStoreClient.CreateOrUpdate -// method. -func (client *DaprSecretStoreClient) CreateOrUpdate(ctx context.Context, daprSecretStoreName string, resource DaprSecretStoreResource, options *DaprSecretStoreClientCreateOrUpdateOptions) (DaprSecretStoreClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, daprSecretStoreName, resource, options) - if err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DaprSecretStoreClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DaprSecretStoreClient) createOrUpdateCreateRequest(ctx context.Context, daprSecretStoreName string, resource DaprSecretStoreResource, options *DaprSecretStoreClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores/{daprSecretStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprSecretStoreName == "" { - return nil, errors.New("parameter daprSecretStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprSecretStoreName}", url.PathEscape(daprSecretStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *DaprSecretStoreClient) createOrUpdateHandleResponse(resp *http.Response) (DaprSecretStoreClientCreateOrUpdateResponse, error) { - result := DaprSecretStoreClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResource); err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing DaprSecretStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprSecretStoreName - Dapr SecretStore name -// options - DaprSecretStoreClientDeleteOptions contains the optional parameters for the DaprSecretStoreClient.Delete method. -func (client *DaprSecretStoreClient) Delete(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientDeleteOptions) (DaprSecretStoreClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, daprSecretStoreName, options) - if err != nil { - return DaprSecretStoreClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return DaprSecretStoreClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return client.deleteHandleResponse(resp) -} - -// deleteCreateRequest creates the Delete request. -func (client *DaprSecretStoreClient) deleteCreateRequest(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores/{daprSecretStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprSecretStoreName == "" { - return nil, errors.New("parameter daprSecretStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprSecretStoreName}", url.PathEscape(daprSecretStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteHandleResponse handles the Delete response. -func (client *DaprSecretStoreClient) deleteHandleResponse(resp *http.Response) (DaprSecretStoreClientDeleteResponse, error) { - result := DaprSecretStoreClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprSecretStoreClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a DaprSecretStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprSecretStoreName - Dapr SecretStore name -// options - DaprSecretStoreClientGetOptions contains the optional parameters for the DaprSecretStoreClient.Get method. -func (client *DaprSecretStoreClient) Get(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientGetOptions) (DaprSecretStoreClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, daprSecretStoreName, options) - if err != nil { - return DaprSecretStoreClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprSecretStoreClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *DaprSecretStoreClient) getCreateRequest(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores/{daprSecretStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprSecretStoreName == "" { - return nil, errors.New("parameter daprSecretStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprSecretStoreName}", url.PathEscape(daprSecretStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *DaprSecretStoreClient) getHandleResponse(resp *http.Response) (DaprSecretStoreClientGetResponse, error) { - result := DaprSecretStoreClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResource); err != nil { - return DaprSecretStoreClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all DaprSecretStoreResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - DaprSecretStoreClientListByRootScopeOptions contains the optional parameters for the DaprSecretStoreClient.ListByRootScope -// method. -func (client *DaprSecretStoreClient) NewListByRootScopePager(options *DaprSecretStoreClientListByRootScopeOptions) (*runtime.Pager[DaprSecretStoreClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[DaprSecretStoreClientListByRootScopeResponse]{ - More: func(page DaprSecretStoreClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DaprSecretStoreClientListByRootScopeResponse) (DaprSecretStoreClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return DaprSecretStoreClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprSecretStoreClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *DaprSecretStoreClient) listByRootScopeCreateRequest(ctx context.Context, options *DaprSecretStoreClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *DaprSecretStoreClient) listByRootScopeHandleResponse(resp *http.Response) (DaprSecretStoreClientListByRootScopeResponse, error) { - result := DaprSecretStoreClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResourceListResult); err != nil { - return DaprSecretStoreClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprstatestore_client.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprstatestore_client.go deleted file mode 100644 index 0f813ae1b5..0000000000 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_daprstatestore_client.go +++ /dev/null @@ -1,276 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// DaprStateStoreClient contains the methods for the DaprStateStore group. -// Don't use this type directly, use NewDaprStateStoreClient() instead. -type DaprStateStoreClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewDaprStateStoreClient creates a new instance of DaprStateStoreClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewDaprStateStoreClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DaprStateStoreClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &DaprStateStoreClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprStateStoreName - Dapr StateStore name -// resource - Resource create parameters. -// options - DaprStateStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprStateStoreClient.CreateOrUpdate -// method. -func (client *DaprStateStoreClient) CreateOrUpdate(ctx context.Context, daprStateStoreName string, resource DaprStateStoreResource, options *DaprStateStoreClientCreateOrUpdateOptions) (DaprStateStoreClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, daprStateStoreName, resource, options) - if err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DaprStateStoreClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DaprStateStoreClient) createOrUpdateCreateRequest(ctx context.Context, daprStateStoreName string, resource DaprStateStoreResource, options *DaprStateStoreClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores/{daprStateStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprStateStoreName == "" { - return nil, errors.New("parameter daprStateStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprStateStoreName}", url.PathEscape(daprStateStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *DaprStateStoreClient) createOrUpdateHandleResponse(resp *http.Response) (DaprStateStoreClientCreateOrUpdateResponse, error) { - result := DaprStateStoreClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResource); err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// BeginDelete - Deletes an existing DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprStateStoreName - Dapr StateStore name -// options - DaprStateStoreClientBeginDeleteOptions contains the optional parameters for the DaprStateStoreClient.BeginDelete -// method. -func (client *DaprStateStoreClient) BeginDelete(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientBeginDeleteOptions) (*runtime.Poller[DaprStateStoreClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, daprStateStoreName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DaprStateStoreClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[DaprStateStoreClientDeleteResponse](options.ResumeToken, client.pl, nil) - } -} - -// Delete - Deletes an existing DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -func (client *DaprStateStoreClient) deleteOperation(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientBeginDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, daprStateStoreName, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *DaprStateStoreClient) deleteCreateRequest(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores/{daprStateStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprStateStoreName == "" { - return nil, errors.New("parameter daprStateStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprStateStoreName}", url.PathEscape(daprStateStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Retrieves information about a DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprStateStoreName - Dapr StateStore name -// options - DaprStateStoreClientGetOptions contains the optional parameters for the DaprStateStoreClient.Get method. -func (client *DaprStateStoreClient) Get(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientGetOptions) (DaprStateStoreClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, daprStateStoreName, options) - if err != nil { - return DaprStateStoreClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprStateStoreClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprStateStoreClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *DaprStateStoreClient) getCreateRequest(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores/{daprStateStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprStateStoreName == "" { - return nil, errors.New("parameter daprStateStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprStateStoreName}", url.PathEscape(daprStateStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *DaprStateStoreClient) getHandleResponse(resp *http.Response) (DaprStateStoreClientGetResponse, error) { - result := DaprStateStoreClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResource); err != nil { - return DaprStateStoreClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all DaprStateStoreResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - DaprStateStoreClientListByRootScopeOptions contains the optional parameters for the DaprStateStoreClient.ListByRootScope -// method. -func (client *DaprStateStoreClient) NewListByRootScopePager(options *DaprStateStoreClientListByRootScopeOptions) (*runtime.Pager[DaprStateStoreClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[DaprStateStoreClientListByRootScopeResponse]{ - More: func(page DaprStateStoreClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DaprStateStoreClientListByRootScopeResponse) (DaprStateStoreClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return DaprStateStoreClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprStateStoreClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprStateStoreClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *DaprStateStoreClient) listByRootScopeCreateRequest(ctx context.Context, options *DaprStateStoreClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *DaprStateStoreClient) listByRootScopeHandleResponse(resp *http.Response) (DaprStateStoreClientListByRootScopeResponse, error) { - result := DaprStateStoreClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResourceListResult); err != nil { - return DaprStateStoreClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_interfaces.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_interfaces.go new file mode 100644 index 0000000000..104e8355bd --- /dev/null +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_interfaces.go @@ -0,0 +1,18 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +// EnvironmentComputeClassification provides polymorphic access to related types. +// Call the interface's GetEnvironmentCompute() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EnvironmentCompute, *KubernetesCompute +type EnvironmentComputeClassification interface { + // GetEnvironmentCompute returns the EnvironmentCompute content of the underlying type. + GetEnvironmentCompute() *EnvironmentCompute +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_models.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_models.go index c98d66b222..0ccb1a0477 100644 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_models.go +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_models.go @@ -2,481 +2,561 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview import "time" -// BasicDaprResourceProperties - Basic properties of a Dapr component object. -type BasicDaprResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` - - // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to -// use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// BasicResourceProperties - Basic properties of a Radius resource. -type BasicResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// DaprPubSubBrokerClientBeginDeleteOptions contains the optional parameters for the DaprPubSubBrokerClient.BeginDelete method. -type DaprPubSubBrokerClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DaprPubSubBrokerClientCreateOrUpdateOptions contains the optional parameters for the DaprPubSubBrokerClient.CreateOrUpdate -// method. -type DaprPubSubBrokerClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// DaprPubSubBrokerClientGetOptions contains the optional parameters for the DaprPubSubBrokerClient.Get method. -type DaprPubSubBrokerClientGetOptions struct { - // placeholder for future optional parameters -} - -// DaprPubSubBrokerClientListByRootScopeOptions contains the optional parameters for the DaprPubSubBrokerClient.ListByRootScope -// method. -type DaprPubSubBrokerClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - // DaprPubSubBrokerProperties - Dapr PubSubBroker portable resource properties type DaprPubSubBrokerProperties struct { // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` + Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string - // Metadata for the Dapr PubSubBroker resource. This should match the values specified in Dapr component spec - Metadata map[string]interface{} `json:"metadata,omitempty"` + // The metadata for Dapr resource which must match the values specified in Dapr component spec + Metadata map[string]any - // The recipe used to automatically deploy underlying infrastructure for the Dapr PubSubBroker portable resource - Recipe *Recipe `json:"recipe,omitempty"` + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning *ResourceProvisioning - // A collection of references to resources associated with the Dapr PubSubBroker - Resources []*ResourceReference `json:"resources,omitempty"` + // A collection of references to resources associated with the pubSubBroker + Resources []*ResourceReference - // Dapr PubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format. - Type *string `json:"type,omitempty"` + // Dapr component type which must matches the format used by Dapr Kubernetes configuration format + Type *string // Dapr component version - Version *string `json:"version,omitempty"` + Version *string // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to // use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` + ComponentName *string - // READ-ONLY; Provisioning state of the Dapr PubSubBroker portable resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + Status *ResourceStatus } // DaprPubSubBrokerResource - Dapr PubSubBroker portable resource type DaprPubSubBrokerResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *DaprPubSubBrokerProperties `json:"properties,omitempty"` + Properties *DaprPubSubBrokerProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // DaprPubSubBrokerResourceListResult - The response of a DaprPubSubBrokerResource list operation. type DaprPubSubBrokerResourceListResult struct { // REQUIRED; The DaprPubSubBrokerResource items on this page - Value []*DaprPubSubBrokerResource `json:"value,omitempty"` + Value []*DaprPubSubBrokerResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// DaprSecretStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprSecretStoreClient.CreateOrUpdate -// method. -type DaprSecretStoreClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} +// DaprPubSubBrokerResourceUpdate - The type used for update operations of the DaprPubSubBrokerResource. +type DaprPubSubBrokerResourceUpdate struct { + // The updatable properties of the DaprPubSubBrokerResource. + Properties *DaprPubSubBrokerResourceUpdateProperties -// DaprSecretStoreClientDeleteOptions contains the optional parameters for the DaprSecretStoreClient.Delete method. -type DaprSecretStoreClientDeleteOptions struct { - // placeholder for future optional parameters + // Resource tags. + Tags map[string]*string } -// DaprSecretStoreClientGetOptions contains the optional parameters for the DaprSecretStoreClient.Get method. -type DaprSecretStoreClientGetOptions struct { - // placeholder for future optional parameters -} +// DaprPubSubBrokerResourceUpdateProperties - The updatable properties of the DaprPubSubBrokerResource. +type DaprPubSubBrokerResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string + + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string + + // The metadata for Dapr resource which must match the values specified in Dapr component spec + Metadata map[string]any + + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning -// DaprSecretStoreClientListByRootScopeOptions contains the optional parameters for the DaprSecretStoreClient.ListByRootScope -// method. -type DaprSecretStoreClientListByRootScopeOptions struct { - // placeholder for future optional parameters + // A collection of references to resources associated with the pubSubBroker + Resources []*ResourceReference + + // Dapr component type which must matches the format used by Dapr Kubernetes configuration format + Type *string + + // Dapr component version + Version *string } // DaprSecretStoreProperties - Dapr SecretStore portable resource properties type DaprSecretStoreProperties struct { // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` + Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string - // Metadata for the Dapr SecretStore resource. This should match the values specified in Dapr component spec - Metadata map[string]interface{} `json:"metadata,omitempty"` + // The metadata for Dapr resource which must match the values specified in Dapr component spec + Metadata map[string]any - // The recipe used to automatically deploy underlying infrastructure for the Dapr SecretStore portable resource - Recipe *Recipe `json:"recipe,omitempty"` + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning *ResourceProvisioning - // Dapr SecretStore type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/ - Type *string `json:"type,omitempty"` + // Dapr component type which must matches the format used by Dapr Kubernetes configuration format + Type *string // Dapr component version - Version *string `json:"version,omitempty"` + Version *string // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to // use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` + ComponentName *string - // READ-ONLY; Provisioning state of the dapr secret store portable resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + Status *ResourceStatus } // DaprSecretStoreResource - Dapr SecretStore portable resource type DaprSecretStoreResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *DaprSecretStoreProperties `json:"properties,omitempty"` + Properties *DaprSecretStoreProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // DaprSecretStoreResourceListResult - The response of a DaprSecretStoreResource list operation. type DaprSecretStoreResourceListResult struct { // REQUIRED; The DaprSecretStoreResource items on this page - Value []*DaprSecretStoreResource `json:"value,omitempty"` + Value []*DaprSecretStoreResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// DaprStateStoreClientBeginDeleteOptions contains the optional parameters for the DaprStateStoreClient.BeginDelete method. -type DaprStateStoreClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} +// DaprSecretStoreResourceUpdate - The type used for update operations of the DaprSecretStoreResource. +type DaprSecretStoreResourceUpdate struct { + // The updatable properties of the DaprSecretStoreResource. + Properties *DaprSecretStoreResourceUpdateProperties -// DaprStateStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprStateStoreClient.CreateOrUpdate -// method. -type DaprStateStoreClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters + // Resource tags. + Tags map[string]*string } -// DaprStateStoreClientGetOptions contains the optional parameters for the DaprStateStoreClient.Get method. -type DaprStateStoreClientGetOptions struct { - // placeholder for future optional parameters -} +// DaprSecretStoreResourceUpdateProperties - The updatable properties of the DaprSecretStoreResource. +type DaprSecretStoreResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string + + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string + + // The metadata for Dapr resource which must match the values specified in Dapr component spec + Metadata map[string]any + + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning + + // Dapr component type which must matches the format used by Dapr Kubernetes configuration format + Type *string -// DaprStateStoreClientListByRootScopeOptions contains the optional parameters for the DaprStateStoreClient.ListByRootScope -// method. -type DaprStateStoreClientListByRootScopeOptions struct { - // placeholder for future optional parameters + // Dapr component version + Version *string } // DaprStateStoreProperties - Dapr StateStore portable resource properties type DaprStateStoreProperties struct { // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` + Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string - // Metadata for the Dapr StateStore resource. This should match the values specified in Dapr component spec - Metadata map[string]interface{} `json:"metadata,omitempty"` + // The metadata for Dapr resource which must match the values specified in Dapr component spec + Metadata map[string]any - // The recipe used to automatically deploy underlying infrastructure for the Dapr StateStore portable resource - Recipe *Recipe `json:"recipe,omitempty"` + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning *ResourceProvisioning - // A collection of references to resources associated with the Dapr StateStore - Resources []*ResourceReference `json:"resources,omitempty"` + // A collection of references to resources associated with the state store + Resources []*ResourceReference - // Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format. - Type *string `json:"type,omitempty"` + // Dapr component type which must matches the format used by Dapr Kubernetes configuration format + Type *string // Dapr component version - Version *string `json:"version,omitempty"` + Version *string // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to // use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` + ComponentName *string - // READ-ONLY; Provisioning state of the DaprStateStore portable resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + Status *ResourceStatus } // DaprStateStoreResource - Dapr StateStore portable resource type DaprStateStoreResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *DaprStateStoreProperties `json:"properties,omitempty"` + Properties *DaprStateStoreProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // DaprStateStoreResourceListResult - The response of a DaprStateStoreResource list operation. type DaprStateStoreResourceListResult struct { // REQUIRED; The DaprStateStoreResource items on this page - Value []*DaprStateStoreResource `json:"value,omitempty"` + Value []*DaprStateStoreResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } +// DaprStateStoreResourceUpdate - The type used for update operations of the DaprStateStoreResource. +type DaprStateStoreResourceUpdate struct { + // The updatable properties of the DaprStateStoreResource. + Properties *DaprStateStoreResourceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// DaprStateStoreResourceUpdateProperties - The updatable properties of the DaprStateStoreResource. +type DaprStateStoreResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string + + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string + + // The metadata for Dapr resource which must match the values specified in Dapr component spec + Metadata map[string]any + + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning + + // A collection of references to resources associated with the state store + Resources []*ResourceReference + + // Dapr component type which must matches the format used by Dapr Kubernetes configuration format + Type *string + + // Dapr component version + Version *string +} + +// EnvironmentCompute - Represents backing compute resource +type EnvironmentCompute struct { + // REQUIRED; Discriminator property for EnvironmentCompute. + Kind *string + + // Configuration for supported external identity providers + Identity *IdentitySettings + + // The resource id of the compute resource for application environment. + ResourceID *string +} + +// GetEnvironmentCompute implements the EnvironmentComputeClassification interface for type EnvironmentCompute. +func (e *EnvironmentCompute) GetEnvironmentCompute() *EnvironmentCompute { return e } + // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + Info map[string]any // READ-ONLY; The additional info type. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ErrorDetail - The error detail. type ErrorDetail struct { // READ-ONLY; The error additional info. - AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + AdditionalInfo []*ErrorAdditionalInfo // READ-ONLY; The error code. - Code *string `json:"code,omitempty" azure:"ro"` + Code *string // READ-ONLY; The error details. - Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + Details []*ErrorDetail // READ-ONLY; The error message. - Message *string `json:"message,omitempty" azure:"ro"` + Message *string // READ-ONLY; The error target. - Target *string `json:"target,omitempty" azure:"ro"` + Target *string } // ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. // (This also follows the OData error response format.). type ErrorResponse struct { // The error object. - Error *ErrorDetail `json:"error,omitempty"` + Error *ErrorDetail +} + +// IdentitySettings is the external identity setting. +type IdentitySettings struct { + // REQUIRED; kind of identity setting + Kind *IdentitySettingKind + + // The URI for your compute platform's OIDC issuer + OidcIssuer *string + + // The resource ID of the provisioned identity + Resource *string +} + +// KubernetesCompute - The Kubernetes compute configuration +type KubernetesCompute struct { + // REQUIRED; Discriminator property for EnvironmentCompute. + Kind *string + + // REQUIRED; The namespace to use for the environment. + Namespace *string + + // Configuration for supported external identity providers + Identity *IdentitySettings + + // The resource id of the compute resource for application environment. + ResourceID *string +} + +// GetEnvironmentCompute implements the EnvironmentComputeClassification interface for type KubernetesCompute. +func (k *KubernetesCompute) GetEnvironmentCompute() *EnvironmentCompute { + return &EnvironmentCompute{ + Identity: k.Identity, + Kind: k.Kind, + ResourceID: k.ResourceID, + } } // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. - Display *OperationDisplay `json:"display,omitempty"` + Display *OperationDisplay // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + ActionType *ActionType // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane // operations. - IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + IsDataAction *bool // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", // "Microsoft.Compute/virtualMachines/capture/action" - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" - Origin *Origin `json:"origin,omitempty" azure:"ro"` + Origin *Origin } // OperationDisplay - Localized display information for this particular operation. type OperationDisplay struct { // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. - Description *string `json:"description,omitempty" azure:"ro"` + Description *string // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual // Machine", "Restart Virtual Machine". - Operation *string `json:"operation,omitempty" azure:"ro"` + Operation *string // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft // Compute". - Provider *string `json:"provider,omitempty" azure:"ro"` + Provider *string // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job // Schedule Collections". - Resource *string `json:"resource,omitempty" azure:"ro"` + Resource *string } // OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to // get the next set of results. type OperationListResult struct { // READ-ONLY; URL to get the next set of operation list results (if there are any). - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of operations supported by the resource provider - Value []*Operation `json:"value,omitempty" azure:"ro"` + Value []*Operation } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters +// OutputResource - Properties of an output resource. +type OutputResource struct { + // The UCP resource ID of the underlying resource. + ID *string + + // The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency +// relationship. LocalIDs do not have any particular format or meaning beyond +// being compared to determine dependency relationships. + LocalID *string + + // Determines whether Radius manages the lifecycle of the underlying resource. + RadiusManaged *bool } // Recipe - The recipe used to automatically deploy underlying infrastructure for a portable resource type Recipe struct { // REQUIRED; The name of the recipe within the environment to use - Name *string `json:"name,omitempty"` + Name *string // Key/value parameters to pass into the recipe at deployment - Parameters map[string]interface{} `json:"parameters,omitempty"` + Parameters map[string]any +} + +// RecipeUpdate - The recipe used to automatically deploy underlying infrastructure for a portable resource +type RecipeUpdate struct { + // The name of the recipe within the environment to use + Name *string + + // Key/value parameters to pass into the recipe at deployment + Parameters map[string]any } // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ResourceReference - Describes a reference to an existing resource type ResourceReference struct { // REQUIRED; Resource id of an existing resource - ID *string `json:"id,omitempty"` + ID *string } // ResourceStatus - Status of a resource. type ResourceStatus struct { + // The compute resource associated with the resource. + Compute EnvironmentComputeClassification + // Properties of an output resource - OutputResources []map[string]interface{} `json:"outputResources,omitempty"` + OutputResources []*OutputResource } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAt *time.Time // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` + CreatedBy *string // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAt *time.Time // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedBy *string // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *CreatedByType } // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' // and a 'location' type TrackedResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_models_serde.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_models_serde.go index 5f5f674f81..47bba80983 100644 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_models_serde.go +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_models_serde.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -15,83 +14,9 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type BasicDaprResourceProperties. -func (b BasicDaprResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "componentName", b.ComponentName) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicDaprResourceProperties. -func (b *BasicDaprResourceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "componentName": - err = unpopulate(val, "ComponentName", &b.ComponentName) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type BasicResourceProperties. -func (b BasicResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicResourceProperties. -func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerProperties. func (d DaprPubSubBrokerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "application", d.Application) populate(objectMap, "componentName", d.ComponentName) populate(objectMap, "environment", d.Environment) @@ -117,37 +42,37 @@ func (d *DaprPubSubBrokerProperties) UnmarshalJSON(data []byte) error { switch key { case "application": err = unpopulate(val, "Application", &d.Application) - delete(rawMsg, key) + delete(rawMsg, key) case "componentName": err = unpopulate(val, "ComponentName", &d.ComponentName) - delete(rawMsg, key) + delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &d.Environment) - delete(rawMsg, key) + delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &d.Metadata) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "recipe": err = unpopulate(val, "Recipe", &d.Recipe) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProvisioning": err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) - delete(rawMsg, key) + delete(rawMsg, key) case "resources": err = unpopulate(val, "Resources", &d.Resources) - delete(rawMsg, key) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &d.Status) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) + delete(rawMsg, key) case "version": err = unpopulate(val, "Version", &d.Version) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -158,7 +83,7 @@ func (d *DaprPubSubBrokerProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerResource. func (d DaprPubSubBrokerResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "location", d.Location) populate(objectMap, "name", d.Name) @@ -180,25 +105,25 @@ func (d *DaprPubSubBrokerResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &d.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &d.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -209,7 +134,7 @@ func (d *DaprPubSubBrokerResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerResourceListResult. func (d DaprPubSubBrokerResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -226,10 +151,96 @@ func (d *DaprPubSubBrokerResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &d.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerResourceUpdate. +func (d DaprPubSubBrokerResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DaprPubSubBrokerResourceUpdate. +func (d *DaprPubSubBrokerResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerResourceUpdateProperties. +func (d DaprPubSubBrokerResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", d.Application) + populate(objectMap, "environment", d.Environment) + populate(objectMap, "metadata", d.Metadata) + populate(objectMap, "recipe", d.Recipe) + populate(objectMap, "resourceProvisioning", d.ResourceProvisioning) + populate(objectMap, "resources", d.Resources) + populate(objectMap, "type", d.Type) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DaprPubSubBrokerResourceUpdateProperties. +func (d *DaprPubSubBrokerResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &d.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &d.Environment) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &d.Metadata) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &d.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &d.Resources) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -240,7 +251,7 @@ func (d *DaprPubSubBrokerResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreProperties. func (d DaprSecretStoreProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "application", d.Application) populate(objectMap, "componentName", d.ComponentName) populate(objectMap, "environment", d.Environment) @@ -265,34 +276,34 @@ func (d *DaprSecretStoreProperties) UnmarshalJSON(data []byte) error { switch key { case "application": err = unpopulate(val, "Application", &d.Application) - delete(rawMsg, key) + delete(rawMsg, key) case "componentName": err = unpopulate(val, "ComponentName", &d.ComponentName) - delete(rawMsg, key) + delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &d.Environment) - delete(rawMsg, key) + delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &d.Metadata) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "recipe": err = unpopulate(val, "Recipe", &d.Recipe) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProvisioning": err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) - delete(rawMsg, key) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &d.Status) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) + delete(rawMsg, key) case "version": err = unpopulate(val, "Version", &d.Version) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -303,7 +314,7 @@ func (d *DaprSecretStoreProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreResource. func (d DaprSecretStoreResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "location", d.Location) populate(objectMap, "name", d.Name) @@ -325,25 +336,25 @@ func (d *DaprSecretStoreResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &d.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &d.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -354,7 +365,7 @@ func (d *DaprSecretStoreResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreResourceListResult. func (d DaprSecretStoreResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -371,10 +382,92 @@ func (d *DaprSecretStoreResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &d.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreResourceUpdate. +func (d DaprSecretStoreResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DaprSecretStoreResourceUpdate. +func (d *DaprSecretStoreResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreResourceUpdateProperties. +func (d DaprSecretStoreResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", d.Application) + populate(objectMap, "environment", d.Environment) + populate(objectMap, "metadata", d.Metadata) + populate(objectMap, "recipe", d.Recipe) + populate(objectMap, "resourceProvisioning", d.ResourceProvisioning) + populate(objectMap, "type", d.Type) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DaprSecretStoreResourceUpdateProperties. +func (d *DaprSecretStoreResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &d.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &d.Environment) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &d.Metadata) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &d.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -385,7 +478,7 @@ func (d *DaprSecretStoreResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprStateStoreProperties. func (d DaprStateStoreProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "application", d.Application) populate(objectMap, "componentName", d.ComponentName) populate(objectMap, "environment", d.Environment) @@ -411,37 +504,37 @@ func (d *DaprStateStoreProperties) UnmarshalJSON(data []byte) error { switch key { case "application": err = unpopulate(val, "Application", &d.Application) - delete(rawMsg, key) + delete(rawMsg, key) case "componentName": err = unpopulate(val, "ComponentName", &d.ComponentName) - delete(rawMsg, key) + delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &d.Environment) - delete(rawMsg, key) + delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &d.Metadata) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "recipe": err = unpopulate(val, "Recipe", &d.Recipe) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProvisioning": err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) - delete(rawMsg, key) + delete(rawMsg, key) case "resources": err = unpopulate(val, "Resources", &d.Resources) - delete(rawMsg, key) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &d.Status) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) + delete(rawMsg, key) case "version": err = unpopulate(val, "Version", &d.Version) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -452,7 +545,7 @@ func (d *DaprStateStoreProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprStateStoreResource. func (d DaprStateStoreResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "location", d.Location) populate(objectMap, "name", d.Name) @@ -474,25 +567,25 @@ func (d *DaprStateStoreResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &d.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &d.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -503,7 +596,7 @@ func (d *DaprStateStoreResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DaprStateStoreResourceListResult. func (d DaprStateStoreResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -520,10 +613,96 @@ func (d *DaprStateStoreResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &d.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DaprStateStoreResourceUpdate. +func (d DaprStateStoreResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DaprStateStoreResourceUpdate. +func (d *DaprStateStoreResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DaprStateStoreResourceUpdateProperties. +func (d DaprStateStoreResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", d.Application) + populate(objectMap, "environment", d.Environment) + populate(objectMap, "metadata", d.Metadata) + populate(objectMap, "recipe", d.Recipe) + populate(objectMap, "resourceProvisioning", d.ResourceProvisioning) + populate(objectMap, "resources", d.Resources) + populate(objectMap, "type", d.Type) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DaprStateStoreResourceUpdateProperties. +func (d *DaprStateStoreResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &d.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &d.Environment) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &d.Metadata) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &d.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &d.Resources) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -532,9 +711,44 @@ func (d *DaprStateStoreResourceListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type EnvironmentCompute. +func (e EnvironmentCompute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", e.Identity) + objectMap["kind"] = e.Kind + populate(objectMap, "resourceId", e.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentCompute. +func (e *EnvironmentCompute) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &e.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -551,10 +765,10 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { switch key { case "info": err = unpopulate(val, "Info", &e.Info) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -565,7 +779,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -585,19 +799,19 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { switch key { case "additionalInfo": err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) - delete(rawMsg, key) + delete(rawMsg, key) case "code": err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) + delete(rawMsg, key) case "details": err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) + delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) + delete(rawMsg, key) case "target": err = unpopulate(val, "Target", &e.Target) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -608,7 +822,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -624,7 +838,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { switch key { case "error": err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -633,9 +847,83 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type IdentitySettings. +func (i IdentitySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "oidcIssuer", i.OidcIssuer) + populate(objectMap, "resource", i.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentitySettings. +func (i *IdentitySettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "oidcIssuer": + err = unpopulate(val, "OidcIssuer", &i.OidcIssuer) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &i.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesCompute. +func (k KubernetesCompute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", k.Identity) + objectMap["kind"] = "kubernetes" + populate(objectMap, "namespace", k.Namespace) + populate(objectMap, "resourceId", k.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesCompute. +func (k *KubernetesCompute) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &k.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &k.Kind) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &k.Namespace) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &k.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) @@ -655,19 +943,19 @@ func (o *Operation) UnmarshalJSON(data []byte) error { switch key { case "actionType": err = unpopulate(val, "ActionType", &o.ActionType) - delete(rawMsg, key) + delete(rawMsg, key) case "display": err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) + delete(rawMsg, key) case "isDataAction": err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "origin": err = unpopulate(val, "Origin", &o.Origin) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -678,7 +966,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -697,16 +985,16 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { switch key { case "description": err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) + delete(rawMsg, key) case "operation": err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) + delete(rawMsg, key) case "provider": err = unpopulate(val, "Provider", &o.Provider) - delete(rawMsg, key) + delete(rawMsg, key) case "resource": err = unpopulate(val, "Resource", &o.Resource) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -717,7 +1005,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -734,10 +1022,45 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &o.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OutputResource. +func (o OutputResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "localId", o.LocalID) + populate(objectMap, "radiusManaged", o.RadiusManaged) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OutputResource. +func (o *OutputResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "localId": + err = unpopulate(val, "LocalID", &o.LocalID) + delete(rawMsg, key) + case "radiusManaged": + err = unpopulate(val, "RadiusManaged", &o.RadiusManaged) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -748,7 +1071,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Recipe. func (r Recipe) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", r.Name) populate(objectMap, "parameters", r.Parameters) return json.Marshal(objectMap) @@ -765,10 +1088,41 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { switch key { case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecipeUpdate. +func (r RecipeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "parameters", r.Parameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeUpdate. +func (r *RecipeUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) case "parameters": err = unpopulate(val, "Parameters", &r.Parameters) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -779,7 +1133,7 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "systemData", r.SystemData) @@ -798,16 +1152,16 @@ func (r *Resource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -818,7 +1172,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceReference. func (r ResourceReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) return json.Marshal(objectMap) } @@ -834,7 +1188,7 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -845,7 +1199,8 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceStatus. func (r ResourceStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) + populate(objectMap, "compute", r.Compute) populate(objectMap, "outputResources", r.OutputResources) return json.Marshal(objectMap) } @@ -859,9 +1214,12 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "compute": + r.Compute, err = unmarshalEnvironmentComputeClassification(val) + delete(rawMsg, key) case "outputResources": err = unpopulate(val, "OutputResources", &r.OutputResources) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -872,7 +1230,7 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -893,22 +1251,22 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { switch key { case "createdAt": err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "createdByType": err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedAt": err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedByType": err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -919,7 +1277,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -940,22 +1298,22 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &t.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -964,7 +1322,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -974,7 +1332,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_operations_client.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_operations_client.go index 0a3d4f6185..e31434b814 100644 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_operations_client.go +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_operations_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -12,8 +11,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,35 +19,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, -pl: pl, + internal: cl, } return client, nil } // NewListPager - List the operations for the provider +// // Generated from API version 2022-03-15-privatepreview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) (*runtime.Pager[OperationsClientListResponse]) { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -67,7 +56,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -82,7 +71,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Applications.Dapr/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_options.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_options.go new file mode 100644 index 0000000000..0cdf9f2458 --- /dev/null +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_options.go @@ -0,0 +1,102 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PubSubBrokersClientBeginCreateOrUpdateOptions contains the optional parameters for the PubSubBrokersClient.BeginCreateOrUpdate +// method. +type PubSubBrokersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PubSubBrokersClientBeginDeleteOptions contains the optional parameters for the PubSubBrokersClient.BeginDelete method. +type PubSubBrokersClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PubSubBrokersClientBeginUpdateOptions contains the optional parameters for the PubSubBrokersClient.BeginUpdate method. +type PubSubBrokersClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PubSubBrokersClientGetOptions contains the optional parameters for the PubSubBrokersClient.Get method. +type PubSubBrokersClientGetOptions struct { + // placeholder for future optional parameters +} + +// PubSubBrokersClientListByScopeOptions contains the optional parameters for the PubSubBrokersClient.NewListByScopePager +// method. +type PubSubBrokersClientListByScopeOptions struct { + // placeholder for future optional parameters +} + +// SecretStoresClientBeginCreateOrUpdateOptions contains the optional parameters for the SecretStoresClient.BeginCreateOrUpdate +// method. +type SecretStoresClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SecretStoresClientBeginDeleteOptions contains the optional parameters for the SecretStoresClient.BeginDelete method. +type SecretStoresClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SecretStoresClientBeginUpdateOptions contains the optional parameters for the SecretStoresClient.BeginUpdate method. +type SecretStoresClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SecretStoresClientGetOptions contains the optional parameters for the SecretStoresClient.Get method. +type SecretStoresClientGetOptions struct { + // placeholder for future optional parameters +} + +// SecretStoresClientListByScopeOptions contains the optional parameters for the SecretStoresClient.NewListByScopePager method. +type SecretStoresClientListByScopeOptions struct { + // placeholder for future optional parameters +} + +// StateStoresClientBeginCreateOrUpdateOptions contains the optional parameters for the StateStoresClient.BeginCreateOrUpdate +// method. +type StateStoresClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StateStoresClientBeginDeleteOptions contains the optional parameters for the StateStoresClient.BeginDelete method. +type StateStoresClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StateStoresClientBeginUpdateOptions contains the optional parameters for the StateStoresClient.BeginUpdate method. +type StateStoresClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StateStoresClientGetOptions contains the optional parameters for the StateStoresClient.Get method. +type StateStoresClientGetOptions struct { + // placeholder for future optional parameters +} + +// StateStoresClientListByScopeOptions contains the optional parameters for the StateStoresClient.NewListByScopePager method. +type StateStoresClientListByScopeOptions struct { + // placeholder for future optional parameters +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go new file mode 100644 index 0000000000..83f13ff53e --- /dev/null +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go @@ -0,0 +1,32 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import "encoding/json" + +func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (EnvironmentComputeClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b EnvironmentComputeClassification + switch m["kind"] { + case "kubernetes": + b = &KubernetesCompute{} + default: + b = &EnvironmentCompute{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_pubsubbrokers_client.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_pubsubbrokers_client.go new file mode 100644 index 0000000000..8ce667a260 --- /dev/null +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_pubsubbrokers_client.go @@ -0,0 +1,349 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PubSubBrokersClient contains the methods for the PubSubBrokers group. +// Don't use this type directly, use NewPubSubBrokersClient() instead. +type PubSubBrokersClient struct { + internal *arm.Client + rootScope string +} + +// NewPubSubBrokersClient creates a new instance of PubSubBrokersClient with the specified values. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPubSubBrokersClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PubSubBrokersClient, error) { + cl, err := arm.NewClient(moduleName+".PubSubBrokersClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PubSubBrokersClient{ + rootScope: rootScope, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a DaprPubSubBrokerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - pubSubBrokerName - PubSubBroker name +// - resource - Resource create parameters. +// - options - PubSubBrokersClientBeginCreateOrUpdateOptions contains the optional parameters for the PubSubBrokersClient.BeginCreateOrUpdate +// method. +func (client *PubSubBrokersClient) BeginCreateOrUpdate(ctx context.Context, pubSubBrokerName string, resource DaprPubSubBrokerResource, options *PubSubBrokersClientBeginCreateOrUpdateOptions) (*runtime.Poller[PubSubBrokersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, pubSubBrokerName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PubSubBrokersClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PubSubBrokersClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a DaprPubSubBrokerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *PubSubBrokersClient) createOrUpdate(ctx context.Context, pubSubBrokerName string, resource DaprPubSubBrokerResource, options *PubSubBrokersClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, pubSubBrokerName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PubSubBrokersClient) createOrUpdateCreateRequest(ctx context.Context, pubSubBrokerName string, resource DaprPubSubBrokerResource, options *PubSubBrokersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{pubSubBrokerName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if pubSubBrokerName == "" { + return nil, errors.New("parameter pubSubBrokerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pubSubBrokerName}", url.PathEscape(pubSubBrokerName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil +} + +// BeginDelete - Delete a DaprPubSubBrokerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - pubSubBrokerName - PubSubBroker name +// - options - PubSubBrokersClientBeginDeleteOptions contains the optional parameters for the PubSubBrokersClient.BeginDelete +// method. +func (client *PubSubBrokersClient) BeginDelete(ctx context.Context, pubSubBrokerName string, options *PubSubBrokersClientBeginDeleteOptions) (*runtime.Poller[PubSubBrokersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, pubSubBrokerName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PubSubBrokersClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PubSubBrokersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a DaprPubSubBrokerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *PubSubBrokersClient) deleteOperation(ctx context.Context, pubSubBrokerName string, options *PubSubBrokersClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, pubSubBrokerName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PubSubBrokersClient) deleteCreateRequest(ctx context.Context, pubSubBrokerName string, options *PubSubBrokersClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{pubSubBrokerName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if pubSubBrokerName == "" { + return nil, errors.New("parameter pubSubBrokerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pubSubBrokerName}", url.PathEscape(pubSubBrokerName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a DaprPubSubBrokerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - pubSubBrokerName - PubSubBroker name +// - options - PubSubBrokersClientGetOptions contains the optional parameters for the PubSubBrokersClient.Get method. +func (client *PubSubBrokersClient) Get(ctx context.Context, pubSubBrokerName string, options *PubSubBrokersClientGetOptions) (PubSubBrokersClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, pubSubBrokerName, options) + if err != nil { + return PubSubBrokersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PubSubBrokersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PubSubBrokersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PubSubBrokersClient) getCreateRequest(ctx context.Context, pubSubBrokerName string, options *PubSubBrokersClientGetOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{pubSubBrokerName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if pubSubBrokerName == "" { + return nil, errors.New("parameter pubSubBrokerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pubSubBrokerName}", url.PathEscape(pubSubBrokerName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PubSubBrokersClient) getHandleResponse(resp *http.Response) (PubSubBrokersClientGetResponse, error) { + result := PubSubBrokersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResource); err != nil { + return PubSubBrokersClientGetResponse{}, err + } + return result, nil +} + +// NewListByScopePager - List DaprPubSubBrokerResource resources by Scope +// +// Generated from API version 2022-03-15-privatepreview +// - options - PubSubBrokersClientListByScopeOptions contains the optional parameters for the PubSubBrokersClient.NewListByScopePager +// method. +func (client *PubSubBrokersClient) NewListByScopePager(options *PubSubBrokersClientListByScopeOptions) (*runtime.Pager[PubSubBrokersClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[PubSubBrokersClientListByScopeResponse]{ + More: func(page PubSubBrokersClientListByScopeResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PubSubBrokersClientListByScopeResponse) (PubSubBrokersClientListByScopeResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByScopeCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return PubSubBrokersClientListByScopeResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PubSubBrokersClientListByScopeResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PubSubBrokersClientListByScopeResponse{}, runtime.NewResponseError(resp) + } + return client.listByScopeHandleResponse(resp) + }, + }) +} + +// listByScopeCreateRequest creates the ListByScope request. +func (client *PubSubBrokersClient) listByScopeCreateRequest(ctx context.Context, options *PubSubBrokersClientListByScopeOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByScopeHandleResponse handles the ListByScope response. +func (client *PubSubBrokersClient) listByScopeHandleResponse(resp *http.Response) (PubSubBrokersClientListByScopeResponse, error) { + result := PubSubBrokersClientListByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResourceListResult); err != nil { + return PubSubBrokersClientListByScopeResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a DaprPubSubBrokerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - pubSubBrokerName - PubSubBroker name +// - properties - The resource properties to be updated. +// - options - PubSubBrokersClientBeginUpdateOptions contains the optional parameters for the PubSubBrokersClient.BeginUpdate +// method. +func (client *PubSubBrokersClient) BeginUpdate(ctx context.Context, pubSubBrokerName string, properties DaprPubSubBrokerResourceUpdate, options *PubSubBrokersClientBeginUpdateOptions) (*runtime.Poller[PubSubBrokersClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, pubSubBrokerName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PubSubBrokersClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PubSubBrokersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a DaprPubSubBrokerResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *PubSubBrokersClient) update(ctx context.Context, pubSubBrokerName string, properties DaprPubSubBrokerResourceUpdate, options *PubSubBrokersClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, pubSubBrokerName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *PubSubBrokersClient) updateCreateRequest(ctx context.Context, pubSubBrokerName string, properties DaprPubSubBrokerResourceUpdate, options *PubSubBrokersClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{pubSubBrokerName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if pubSubBrokerName == "" { + return nil, errors.New("parameter pubSubBrokerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pubSubBrokerName}", url.PathEscape(pubSubBrokerName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_response_types.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_response_types.go index 7957eeabe4..a2a70b8613 100644 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_response_types.go +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_response_types.go @@ -2,81 +2,101 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview -// DaprPubSubBrokerClientCreateOrUpdateResponse contains the response from method DaprPubSubBrokerClient.CreateOrUpdate. -type DaprPubSubBrokerClientCreateOrUpdateResponse struct { +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// PubSubBrokersClientCreateOrUpdateResponse contains the response from method PubSubBrokersClient.BeginCreateOrUpdate. +type PubSubBrokersClientCreateOrUpdateResponse struct { + // Dapr PubSubBroker portable resource DaprPubSubBrokerResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// DaprPubSubBrokerClientDeleteResponse contains the response from method DaprPubSubBrokerClient.Delete. -type DaprPubSubBrokerClientDeleteResponse struct { +// PubSubBrokersClientDeleteResponse contains the response from method PubSubBrokersClient.BeginDelete. +type PubSubBrokersClientDeleteResponse struct { // placeholder for future response values } -// DaprPubSubBrokerClientGetResponse contains the response from method DaprPubSubBrokerClient.Get. -type DaprPubSubBrokerClientGetResponse struct { +// PubSubBrokersClientGetResponse contains the response from method PubSubBrokersClient.Get. +type PubSubBrokersClientGetResponse struct { + // Dapr PubSubBroker portable resource DaprPubSubBrokerResource } -// DaprPubSubBrokerClientListByRootScopeResponse contains the response from method DaprPubSubBrokerClient.ListByRootScope. -type DaprPubSubBrokerClientListByRootScopeResponse struct { +// PubSubBrokersClientListByScopeResponse contains the response from method PubSubBrokersClient.NewListByScopePager. +type PubSubBrokersClientListByScopeResponse struct { + // The response of a DaprPubSubBrokerResource list operation. DaprPubSubBrokerResourceListResult } -// DaprSecretStoreClientCreateOrUpdateResponse contains the response from method DaprSecretStoreClient.CreateOrUpdate. -type DaprSecretStoreClientCreateOrUpdateResponse struct { +// PubSubBrokersClientUpdateResponse contains the response from method PubSubBrokersClient.BeginUpdate. +type PubSubBrokersClientUpdateResponse struct { + // Dapr PubSubBroker portable resource + DaprPubSubBrokerResource +} + +// SecretStoresClientCreateOrUpdateResponse contains the response from method SecretStoresClient.BeginCreateOrUpdate. +type SecretStoresClientCreateOrUpdateResponse struct { + // Dapr SecretStore portable resource DaprSecretStoreResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// DaprSecretStoreClientDeleteResponse contains the response from method DaprSecretStoreClient.Delete. -type DaprSecretStoreClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 +// SecretStoresClientDeleteResponse contains the response from method SecretStoresClient.BeginDelete. +type SecretStoresClientDeleteResponse struct { + // placeholder for future response values } -// DaprSecretStoreClientGetResponse contains the response from method DaprSecretStoreClient.Get. -type DaprSecretStoreClientGetResponse struct { +// SecretStoresClientGetResponse contains the response from method SecretStoresClient.Get. +type SecretStoresClientGetResponse struct { + // Dapr SecretStore portable resource DaprSecretStoreResource } -// DaprSecretStoreClientListByRootScopeResponse contains the response from method DaprSecretStoreClient.ListByRootScope. -type DaprSecretStoreClientListByRootScopeResponse struct { +// SecretStoresClientListByScopeResponse contains the response from method SecretStoresClient.NewListByScopePager. +type SecretStoresClientListByScopeResponse struct { + // The response of a DaprSecretStoreResource list operation. DaprSecretStoreResourceListResult } -// DaprStateStoreClientCreateOrUpdateResponse contains the response from method DaprStateStoreClient.CreateOrUpdate. -type DaprStateStoreClientCreateOrUpdateResponse struct { +// SecretStoresClientUpdateResponse contains the response from method SecretStoresClient.BeginUpdate. +type SecretStoresClientUpdateResponse struct { + // Dapr SecretStore portable resource + DaprSecretStoreResource +} + +// StateStoresClientCreateOrUpdateResponse contains the response from method StateStoresClient.BeginCreateOrUpdate. +type StateStoresClientCreateOrUpdateResponse struct { + // Dapr StateStore portable resource DaprStateStoreResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// DaprStateStoreClientDeleteResponse contains the response from method DaprStateStoreClient.Delete. -type DaprStateStoreClientDeleteResponse struct { +// StateStoresClientDeleteResponse contains the response from method StateStoresClient.BeginDelete. +type StateStoresClientDeleteResponse struct { // placeholder for future response values } -// DaprStateStoreClientGetResponse contains the response from method DaprStateStoreClient.Get. -type DaprStateStoreClientGetResponse struct { +// StateStoresClientGetResponse contains the response from method StateStoresClient.Get. +type StateStoresClientGetResponse struct { + // Dapr StateStore portable resource DaprStateStoreResource } -// DaprStateStoreClientListByRootScopeResponse contains the response from method DaprStateStoreClient.ListByRootScope. -type DaprStateStoreClientListByRootScopeResponse struct { +// StateStoresClientListByScopeResponse contains the response from method StateStoresClient.NewListByScopePager. +type StateStoresClientListByScopeResponse struct { + // The response of a DaprStateStoreResource list operation. DaprStateStoreResourceListResult } -// OperationsClientListResponse contains the response from method OperationsClient.List. -type OperationsClientListResponse struct { - OperationListResult +// StateStoresClientUpdateResponse contains the response from method StateStoresClient.BeginUpdate. +type StateStoresClientUpdateResponse struct { + // Dapr StateStore portable resource + DaprStateStoreResource } diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_secretstores_client.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_secretstores_client.go new file mode 100644 index 0000000000..5e3692b242 --- /dev/null +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_secretstores_client.go @@ -0,0 +1,349 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// SecretStoresClient contains the methods for the SecretStores group. +// Don't use this type directly, use NewSecretStoresClient() instead. +type SecretStoresClient struct { + internal *arm.Client + rootScope string +} + +// NewSecretStoresClient creates a new instance of SecretStoresClient with the specified values. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSecretStoresClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecretStoresClient, error) { + cl, err := arm.NewClient(moduleName+".SecretStoresClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SecretStoresClient{ + rootScope: rootScope, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a DaprSecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - secretStoreName - SecretStore name +// - resource - Resource create parameters. +// - options - SecretStoresClientBeginCreateOrUpdateOptions contains the optional parameters for the SecretStoresClient.BeginCreateOrUpdate +// method. +func (client *SecretStoresClient) BeginCreateOrUpdate(ctx context.Context, secretStoreName string, resource DaprSecretStoreResource, options *SecretStoresClientBeginCreateOrUpdateOptions) (*runtime.Poller[SecretStoresClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, secretStoreName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecretStoresClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SecretStoresClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a DaprSecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *SecretStoresClient) createOrUpdate(ctx context.Context, secretStoreName string, resource DaprSecretStoreResource, options *SecretStoresClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, secretStoreName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SecretStoresClient) createOrUpdateCreateRequest(ctx context.Context, secretStoreName string, resource DaprSecretStoreResource, options *SecretStoresClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores/{secretStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if secretStoreName == "" { + return nil, errors.New("parameter secretStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{secretStoreName}", url.PathEscape(secretStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil +} + +// BeginDelete - Delete a DaprSecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - secretStoreName - SecretStore name +// - options - SecretStoresClientBeginDeleteOptions contains the optional parameters for the SecretStoresClient.BeginDelete +// method. +func (client *SecretStoresClient) BeginDelete(ctx context.Context, secretStoreName string, options *SecretStoresClientBeginDeleteOptions) (*runtime.Poller[SecretStoresClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, secretStoreName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecretStoresClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SecretStoresClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a DaprSecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *SecretStoresClient) deleteOperation(ctx context.Context, secretStoreName string, options *SecretStoresClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, secretStoreName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SecretStoresClient) deleteCreateRequest(ctx context.Context, secretStoreName string, options *SecretStoresClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores/{secretStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if secretStoreName == "" { + return nil, errors.New("parameter secretStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{secretStoreName}", url.PathEscape(secretStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a DaprSecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - secretStoreName - SecretStore name +// - options - SecretStoresClientGetOptions contains the optional parameters for the SecretStoresClient.Get method. +func (client *SecretStoresClient) Get(ctx context.Context, secretStoreName string, options *SecretStoresClientGetOptions) (SecretStoresClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, secretStoreName, options) + if err != nil { + return SecretStoresClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SecretStoresClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SecretStoresClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SecretStoresClient) getCreateRequest(ctx context.Context, secretStoreName string, options *SecretStoresClientGetOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores/{secretStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if secretStoreName == "" { + return nil, errors.New("parameter secretStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{secretStoreName}", url.PathEscape(secretStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SecretStoresClient) getHandleResponse(resp *http.Response) (SecretStoresClientGetResponse, error) { + result := SecretStoresClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResource); err != nil { + return SecretStoresClientGetResponse{}, err + } + return result, nil +} + +// NewListByScopePager - List DaprSecretStoreResource resources by Scope +// +// Generated from API version 2022-03-15-privatepreview +// - options - SecretStoresClientListByScopeOptions contains the optional parameters for the SecretStoresClient.NewListByScopePager +// method. +func (client *SecretStoresClient) NewListByScopePager(options *SecretStoresClientListByScopeOptions) (*runtime.Pager[SecretStoresClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[SecretStoresClientListByScopeResponse]{ + More: func(page SecretStoresClientListByScopeResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SecretStoresClientListByScopeResponse) (SecretStoresClientListByScopeResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByScopeCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SecretStoresClientListByScopeResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SecretStoresClientListByScopeResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SecretStoresClientListByScopeResponse{}, runtime.NewResponseError(resp) + } + return client.listByScopeHandleResponse(resp) + }, + }) +} + +// listByScopeCreateRequest creates the ListByScope request. +func (client *SecretStoresClient) listByScopeCreateRequest(ctx context.Context, options *SecretStoresClientListByScopeOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByScopeHandleResponse handles the ListByScope response. +func (client *SecretStoresClient) listByScopeHandleResponse(resp *http.Response) (SecretStoresClientListByScopeResponse, error) { + result := SecretStoresClientListByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResourceListResult); err != nil { + return SecretStoresClientListByScopeResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a DaprSecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - secretStoreName - SecretStore name +// - properties - The resource properties to be updated. +// - options - SecretStoresClientBeginUpdateOptions contains the optional parameters for the SecretStoresClient.BeginUpdate +// method. +func (client *SecretStoresClient) BeginUpdate(ctx context.Context, secretStoreName string, properties DaprSecretStoreResourceUpdate, options *SecretStoresClientBeginUpdateOptions) (*runtime.Poller[SecretStoresClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, secretStoreName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SecretStoresClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SecretStoresClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a DaprSecretStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *SecretStoresClient) update(ctx context.Context, secretStoreName string, properties DaprSecretStoreResourceUpdate, options *SecretStoresClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, secretStoreName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *SecretStoresClient) updateCreateRequest(ctx context.Context, secretStoreName string, properties DaprSecretStoreResourceUpdate, options *SecretStoresClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/secretStores/{secretStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if secretStoreName == "" { + return nil, errors.New("parameter secretStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{secretStoreName}", url.PathEscape(secretStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_statestores_client.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_statestores_client.go new file mode 100644 index 0000000000..3e46684413 --- /dev/null +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_statestores_client.go @@ -0,0 +1,347 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// StateStoresClient contains the methods for the StateStores group. +// Don't use this type directly, use NewStateStoresClient() instead. +type StateStoresClient struct { + internal *arm.Client + rootScope string +} + +// NewStateStoresClient creates a new instance of StateStoresClient with the specified values. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewStateStoresClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StateStoresClient, error) { + cl, err := arm.NewClient(moduleName+".StateStoresClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &StateStoresClient{ + rootScope: rootScope, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a DaprStateStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - stateStoreName - StateStore name +// - resource - Resource create parameters. +// - options - StateStoresClientBeginCreateOrUpdateOptions contains the optional parameters for the StateStoresClient.BeginCreateOrUpdate +// method. +func (client *StateStoresClient) BeginCreateOrUpdate(ctx context.Context, stateStoreName string, resource DaprStateStoreResource, options *StateStoresClientBeginCreateOrUpdateOptions) (*runtime.Poller[StateStoresClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, stateStoreName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StateStoresClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[StateStoresClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a DaprStateStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *StateStoresClient) createOrUpdate(ctx context.Context, stateStoreName string, resource DaprStateStoreResource, options *StateStoresClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, stateStoreName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *StateStoresClient) createOrUpdateCreateRequest(ctx context.Context, stateStoreName string, resource DaprStateStoreResource, options *StateStoresClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores/{stateStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if stateStoreName == "" { + return nil, errors.New("parameter stateStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{stateStoreName}", url.PathEscape(stateStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil +} + +// BeginDelete - Delete a DaprStateStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - stateStoreName - StateStore name +// - options - StateStoresClientBeginDeleteOptions contains the optional parameters for the StateStoresClient.BeginDelete method. +func (client *StateStoresClient) BeginDelete(ctx context.Context, stateStoreName string, options *StateStoresClientBeginDeleteOptions) (*runtime.Poller[StateStoresClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, stateStoreName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StateStoresClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[StateStoresClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Delete a DaprStateStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *StateStoresClient) deleteOperation(ctx context.Context, stateStoreName string, options *StateStoresClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, stateStoreName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *StateStoresClient) deleteCreateRequest(ctx context.Context, stateStoreName string, options *StateStoresClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores/{stateStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if stateStoreName == "" { + return nil, errors.New("parameter stateStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{stateStoreName}", url.PathEscape(stateStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a DaprStateStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - stateStoreName - StateStore name +// - options - StateStoresClientGetOptions contains the optional parameters for the StateStoresClient.Get method. +func (client *StateStoresClient) Get(ctx context.Context, stateStoreName string, options *StateStoresClientGetOptions) (StateStoresClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, stateStoreName, options) + if err != nil { + return StateStoresClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return StateStoresClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return StateStoresClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *StateStoresClient) getCreateRequest(ctx context.Context, stateStoreName string, options *StateStoresClientGetOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores/{stateStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if stateStoreName == "" { + return nil, errors.New("parameter stateStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{stateStoreName}", url.PathEscape(stateStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *StateStoresClient) getHandleResponse(resp *http.Response) (StateStoresClientGetResponse, error) { + result := StateStoresClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResource); err != nil { + return StateStoresClientGetResponse{}, err + } + return result, nil +} + +// NewListByScopePager - List DaprStateStoreResource resources by Scope +// +// Generated from API version 2022-03-15-privatepreview +// - options - StateStoresClientListByScopeOptions contains the optional parameters for the StateStoresClient.NewListByScopePager +// method. +func (client *StateStoresClient) NewListByScopePager(options *StateStoresClientListByScopeOptions) (*runtime.Pager[StateStoresClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[StateStoresClientListByScopeResponse]{ + More: func(page StateStoresClientListByScopeResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StateStoresClientListByScopeResponse) (StateStoresClientListByScopeResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByScopeCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return StateStoresClientListByScopeResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return StateStoresClientListByScopeResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StateStoresClientListByScopeResponse{}, runtime.NewResponseError(resp) + } + return client.listByScopeHandleResponse(resp) + }, + }) +} + +// listByScopeCreateRequest creates the ListByScope request. +func (client *StateStoresClient) listByScopeCreateRequest(ctx context.Context, options *StateStoresClientListByScopeOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByScopeHandleResponse handles the ListByScope response. +func (client *StateStoresClient) listByScopeHandleResponse(resp *http.Response) (StateStoresClientListByScopeResponse, error) { + result := StateStoresClientListByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResourceListResult); err != nil { + return StateStoresClientListByScopeResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a DaprStateStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - stateStoreName - StateStore name +// - properties - The resource properties to be updated. +// - options - StateStoresClientBeginUpdateOptions contains the optional parameters for the StateStoresClient.BeginUpdate method. +func (client *StateStoresClient) BeginUpdate(ctx context.Context, stateStoreName string, properties DaprStateStoreResourceUpdate, options *StateStoresClientBeginUpdateOptions) (*runtime.Poller[StateStoresClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, stateStoreName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[StateStoresClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[StateStoresClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a DaprStateStoreResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *StateStoresClient) update(ctx context.Context, stateStoreName string, properties DaprStateStoreResourceUpdate, options *StateStoresClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, stateStoreName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *StateStoresClient) updateCreateRequest(ctx context.Context, stateStoreName string, properties DaprStateStoreResourceUpdate, options *StateStoresClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Dapr/stateStores/{stateStoreName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if stateStoreName == "" { + return nil, errors.New("parameter stateStoreName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{stateStoreName}", url.PathEscape(stateStoreName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/daprrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go b/pkg/daprrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go index cea28fe8b6..30ea6fa1d0 100644 --- a/pkg/daprrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go +++ b/pkg/daprrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -66,7 +65,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/pkg/daprrp/datamodel/converter/pubsubbroker_converter.go b/pkg/daprrp/datamodel/converter/pubsubbroker_converter.go index 1aef1098ad..7f7dbff24c 100644 --- a/pkg/daprrp/datamodel/converter/pubsubbroker_converter.go +++ b/pkg/daprrp/datamodel/converter/pubsubbroker_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/daprrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/daprrp/datamodel" ) // PubSubBrokerDataModelToVersioned converts a version-agnostic datamodel.DaprPubSubBroker to a versioned model based on the version diff --git a/pkg/daprrp/datamodel/converter/pubsubbroker_converter_test.go b/pkg/daprrp/datamodel/converter/pubsubbroker_converter_test.go index 95de84f28e..b5d1750ec0 100644 --- a/pkg/daprrp/datamodel/converter/pubsubbroker_converter_test.go +++ b/pkg/daprrp/datamodel/converter/pubsubbroker_converter_test.go @@ -21,11 +21,12 @@ import ( "testing" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - linkrp_util "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -67,15 +68,7 @@ func TestPubSubBrokerDataModelToVersioned(t *testing.T) { Version: to.Ptr("v1"), ComponentName: to.Ptr("test-dpsb"), ProvisioningState: to.Ptr(v20220315privatepreview.ProvisioningStateAccepted), - Status: &v20220315privatepreview.ResourceStatus{ - OutputResources: []map[string]any{ - { - "LocalID": "Deployment", - "Provider": "kubernetes", - "Identity": nil, - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&v20220315privatepreview.ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), @@ -113,15 +106,7 @@ func TestPubSubBrokerDataModelToVersioned(t *testing.T) { Version: to.Ptr("v1"), ComponentName: to.Ptr("test-dpsb"), ProvisioningState: to.Ptr(v20220315privatepreview.ProvisioningStateAccepted), - Status: &v20220315privatepreview.ResourceStatus{ - OutputResources: []map[string]any{ - { - "LocalID": "Deployment", - "Provider": "kubernetes", - "Identity": nil, - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&v20220315privatepreview.ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), @@ -151,10 +136,10 @@ func TestPubSubBrokerDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.DaprPubSubBroker{} - _ = json.Unmarshal(c, dm) + err = json.Unmarshal(c, dm) + require.NoError(t, err) am, err := PubSubBrokerDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { @@ -209,8 +194,7 @@ func TestDaprPubSubBrokerDataModelFromVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.versionedModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.versionedModelFile) dm, err := PubSubBrokerDataModelFromVersioned(c, tc.apiVersion) if tc.err != nil { require.Equal(t, tc.err, err) diff --git a/pkg/daprrp/datamodel/converter/secretstore_converter.go b/pkg/daprrp/datamodel/converter/secretstore_converter.go index e7fc12ca7c..5c56cb6eb2 100644 --- a/pkg/daprrp/datamodel/converter/secretstore_converter.go +++ b/pkg/daprrp/datamodel/converter/secretstore_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/daprrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/daprrp/datamodel" ) // SecretStoreDataModelToVersioned converts a version-agnostic datamodel.DaprSecretStore to a versioned model based on the version diff --git a/pkg/daprrp/datamodel/converter/secretstore_converter_test.go b/pkg/daprrp/datamodel/converter/secretstore_converter_test.go index 55c8661acc..8adc548111 100644 --- a/pkg/daprrp/datamodel/converter/secretstore_converter_test.go +++ b/pkg/daprrp/datamodel/converter/secretstore_converter_test.go @@ -21,10 +21,10 @@ import ( "errors" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - linkrp_util "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -52,10 +52,10 @@ func TestDaprSecretStoreDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.DaprSecretStore{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := SecretStoreDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -97,8 +97,7 @@ func TestDaprSecretStoreDataModelFromVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.versionedModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.versionedModelFile) dm, err := SecretStoreDataModelFromVersioned(c, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) diff --git a/pkg/daprrp/datamodel/converter/statestore_converter.go b/pkg/daprrp/datamodel/converter/statestore_converter.go index 6cdb595596..c73e7b2eee 100644 --- a/pkg/daprrp/datamodel/converter/statestore_converter.go +++ b/pkg/daprrp/datamodel/converter/statestore_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/daprrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/daprrp/datamodel" ) // StateStoreDataModelToVersioned converts a version-agnostic datamodel.DaprStateStore to a versioned model interface based on the diff --git a/pkg/daprrp/datamodel/converter/statestore_converter_test.go b/pkg/daprrp/datamodel/converter/statestore_converter_test.go index a3d7c08bff..9be6856103 100644 --- a/pkg/daprrp/datamodel/converter/statestore_converter_test.go +++ b/pkg/daprrp/datamodel/converter/statestore_converter_test.go @@ -20,10 +20,10 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - linkrp_util "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -57,10 +57,10 @@ func TestDaprStateStoreDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.DaprStateStore{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := StateStoreDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -107,8 +107,7 @@ func TestDaprStateStoreDataModelFromVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.versionedModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.versionedModelFile) dm, err := StateStoreDataModelFromVersioned(c, tc.apiVersion) if tc.err != nil { require.Equal(t, tc.err, err) diff --git a/pkg/daprrp/datamodel/daprpubsubbroker.go b/pkg/daprrp/datamodel/daprpubsubbroker.go index 1b505605b1..35367d6331 100644 --- a/pkg/daprrp/datamodel/daprpubsubbroker.go +++ b/pkg/daprrp/datamodel/daprpubsubbroker.go @@ -17,10 +17,10 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // DaprPubSubBroker represents Dapr PubSubBroker portable resource. @@ -30,14 +30,12 @@ type DaprPubSubBroker struct { // Properties is the properties of the resource. Properties DaprPubSubBrokerProperties `json:"properties"` - // LinkMetadata represents internal DataModel properties common to all portable resource types. - linkrp_dm.LinkMetadata + // ResourceMetadata represents internal DataModel properties common to all portable resource types. + pr_dm.PortableResourceMetadata } -// ApplyDeploymentOutput applies the properties changes based on the deployment output. It updates the -// OutputResources of the DaprPubSubBroker resource with the output resources from a DeploymentOutput object. +// ApplyDeploymentOutput updates the DaprPubSubBroker resource with the DeploymentOutput values. func (r *DaprPubSubBroker) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources return nil } @@ -53,12 +51,12 @@ func (r *DaprPubSubBroker) ResourceMetadata() *rpv1.BasicResourceProperties { // ResourceTypeName returns a string representing the resource type. func (daprPubSub *DaprPubSubBroker) ResourceTypeName() string { - return linkrp.N_DaprPubSubBrokersResourceType + return portableresources.DaprPubSubBrokersResourceType } // Recipe returns the recipe information of the resource. Returns nil if recipe execution is disabled. -func (r *DaprPubSubBroker) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (r *DaprPubSubBroker) Recipe() *portableresources.ResourceRecipe { + if r.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &r.Properties.Recipe @@ -70,16 +68,16 @@ type DaprPubSubBrokerProperties struct { rpv1.BasicDaprResourceProperties // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` // Metadata of the Dapr Pub/Sub Broker resource. Metadata map[string]any `json:"metadata,omitempty"` // The recipe used to automatically deploy underlying infrastructure for the Dapr Pub/Sub Broker resource. - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` // List of the resource IDs that support the Dapr Pub/Sub Broker resource. - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` + Resources []*portableresources.ResourceReference `json:"resources,omitempty"` // Type of the Dapr Pub/Sub Broker resource. Type string `json:"type,omitempty"` diff --git a/pkg/daprrp/datamodel/daprsecretstore.go b/pkg/daprrp/datamodel/daprsecretstore.go index 7cdb09569e..d6bdad5e5e 100644 --- a/pkg/daprrp/datamodel/daprsecretstore.go +++ b/pkg/daprrp/datamodel/daprsecretstore.go @@ -17,10 +17,10 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // DaprSecretStore represents Dapr SecretStore portable resource. @@ -30,13 +30,12 @@ type DaprSecretStore struct { // Properties is the properties of the resource. Properties DaprSecretStoreProperties `json:"properties"` - // LinkMetadata represents internal DataModel properties common to all portable resource types. - linkrp_dm.LinkMetadata + // ResourceMetadata represents internal DataModel properties common to all portable resource types. + pr_dm.PortableResourceMetadata } -// ApplyDeploymentOutput updates the status of the secret store with the output resources from a deployment. +// ApplyDeploymentOutput updates the DaprSecretStore resource with the DeploymentOutput values. func (r *DaprSecretStore) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources return nil } @@ -52,24 +51,24 @@ func (r *DaprSecretStore) ResourceMetadata() *rpv1.BasicResourceProperties { // ResourceTypeName returns the resource type of the DaprSecretStore resource. func (daprSecretStore *DaprSecretStore) ResourceTypeName() string { - return linkrp.N_DaprSecretStoresResourceType + return portableresources.DaprSecretStoresResourceType } // DaprSecretStoreProperties represents the properties of DaprSecretStore resource. type DaprSecretStoreProperties struct { rpv1.BasicResourceProperties rpv1.BasicDaprResourceProperties - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Metadata map[string]any `json:"metadata,omitempty"` - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + Type string `json:"type,omitempty"` + Version string `json:"version,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` } // Recipe returns the Recipe from the DaprSecretStore Properties if ResourceProvisioning is not set to Manual, // otherwise it returns nil. -func (daprSecretStore *DaprSecretStore) Recipe() *linkrp.LinkRecipe { - if daprSecretStore.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (daprSecretStore *DaprSecretStore) Recipe() *portableresources.ResourceRecipe { + if daprSecretStore.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &daprSecretStore.Properties.Recipe diff --git a/pkg/daprrp/datamodel/daprstatestore.go b/pkg/daprrp/datamodel/daprstatestore.go index b143dd092e..fde21de75c 100644 --- a/pkg/daprrp/datamodel/daprstatestore.go +++ b/pkg/daprrp/datamodel/daprstatestore.go @@ -17,11 +17,10 @@ limitations under the License. package datamodel import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/renderers" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // DaprStateStore represents DaprStateStore portable resource. @@ -31,18 +30,12 @@ type DaprStateStore struct { // Properties is the properties of the resource. Properties DaprStateStoreProperties `json:"properties"` - // LinkMetadata represents internal DataModel properties common to all portable types. - linkrp_dm.LinkMetadata + // PortableResourceMetadata represents internal DataModel properties common to all portable types. + pr_dm.PortableResourceMetadata } // ApplyDeploymentOutput updates the DaprStateStore resource with the DeploymentOutput values. func (r *DaprStateStore) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - r.ComputedValues = do.ComputedValues - r.SecretValues = do.SecretValues - if cn, ok := do.ComputedValues[renderers.ComponentNameKey].(string); ok { - r.Properties.ComponentName = cn - } return nil } @@ -58,12 +51,12 @@ func (r *DaprStateStore) ResourceMetadata() *rpv1.BasicResourceProperties { // ResourceTypeName returns the resource type of the DaprStateStore resource. func (daprStateStore *DaprStateStore) ResourceTypeName() string { - return linkrp.N_DaprStateStoresResourceType + return portableresources.DaprStateStoresResourceType } // Recipe returns the recipe information of the resource. It returns nil if the ResourceProvisioning is set to manual. -func (r *DaprStateStore) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (r *DaprStateStore) Recipe() *portableresources.ResourceRecipe { + if r.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &r.Properties.Recipe @@ -74,10 +67,10 @@ type DaprStateStoreProperties struct { rpv1.BasicResourceProperties rpv1.BasicDaprResourceProperties // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - Metadata map[string]any `json:"metadata,omitempty"` - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` + Resources []*portableresources.ResourceReference `json:"resources,omitempty"` + Type string `json:"type,omitempty"` + Version string `json:"version,omitempty"` } diff --git a/pkg/daprrp/datamodel/daprstatestore_test.go b/pkg/daprrp/datamodel/daprstatestore_test.go deleted file mode 100644 index 9f39803ca1..0000000000 --- a/pkg/daprrp/datamodel/daprstatestore_test.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "testing" - - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestDaprStateStore_ApplyDeploymentOutput(t *testing.T) { - tests := []struct { - name string - dss *DaprStateStore - do *rpv1.DeploymentOutput - wantErr bool - }{ - { - name: "with component name", - dss: &DaprStateStore{}, - do: &rpv1.DeploymentOutput{ - DeployedOutputResources: []rpv1.OutputResource{ - { - LocalID: rpv1.LocalIDDaprStateStoreAzureStorage, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Data: resourcemodel.ARMIdentity{}, - }, - RadiusManaged: to.Ptr(true), - Dependencies: []rpv1.Dependency{ - { - LocalID: "", - }, - }, - }, - }, - ComputedValues: map[string]any{ - renderers.ComponentNameKey: "dapr-state-store-test", - }, - }, - wantErr: false, - }, - { - name: "without component name", - dss: &DaprStateStore{}, - do: &rpv1.DeploymentOutput{ - DeployedOutputResources: []rpv1.OutputResource{ - { - LocalID: rpv1.LocalIDDaprStateStoreAzureStorage, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Data: resourcemodel.ARMIdentity{}, - }, - RadiusManaged: to.Ptr(true), - Dependencies: []rpv1.Dependency{ - { - LocalID: "", - }, - }, - }, - }, - ComputedValues: map[string]any{}, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := tt.dss.ApplyDeploymentOutput(*tt.do); (err != nil) != tt.wantErr { - t.Errorf("DaprStateStore.ApplyDeploymentOutput() error = %v, wantErr %v", err, tt.wantErr) - } - - if !tt.wantErr { - require.EqualValues(t, tt.do.DeployedOutputResources, tt.dss.Properties.Status.OutputResources) - require.EqualValues(t, tt.do.ComputedValues, tt.dss.ComputedValues) - require.EqualValues(t, tt.do.SecretValues, tt.dss.SecretValues) - require.Condition(t, func() bool { - if tt.do.ComputedValues[renderers.ComponentNameKey] != nil { - return tt.dss.Properties.ComponentName == tt.do.ComputedValues[renderers.ComponentNameKey] - } - return tt.dss.Properties.ComponentName == "" - }, "component name should be equal") - } - }) - } -} diff --git a/pkg/daprrp/frontend/controller/types.go b/pkg/daprrp/frontend/controller/types.go new file mode 100644 index 0000000000..838d6b66b9 --- /dev/null +++ b/pkg/daprrp/frontend/controller/types.go @@ -0,0 +1,38 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controller + +import ( + "time" +) + +var ( + // AsyncCreateOrUpdateDaprStateStoreTimeout is the timeout for async create or update dapr state store + AsyncCreateOrUpdateDaprStateStoreTimeout = time.Duration(60) * time.Minute + // AsyncDeleteDaprStateStoreTimeout is the timeout for async delete dapr state store + AsyncDeleteDaprStateStoreTimeout = time.Duration(30) * time.Minute + + // AsyncCreateOrUpdateDaprSecretStoreTimeout is the timeout for async create or update dapr secret store + AsyncCreateOrUpdateDaprSecretStoreTimeout = time.Duration(60) * time.Minute + // AsyncDeleteDaprSecretStoreTimeout is the timeout for async delete dapr secret store + AsyncDeleteDaprSecretStoreTimeout = time.Duration(30) * time.Minute + + // AsyncCreateOrUpdateDaprPubSubBrokerTimeout is the timeout for async create or update dapr pub sub broker + AsyncCreateOrUpdateDaprPubSubBrokerTimeout = time.Duration(60) * time.Minute + // AsyncDeleteDaprPubSubBrokerTimeout is the timeout for async delete dapr pub sub broker + AsyncDeleteDaprPubSubBrokerTimeout = time.Duration(30) * time.Minute +) diff --git a/pkg/daprrp/processors/pubsubbrokers/processor.go b/pkg/daprrp/processors/pubsubbrokers/processor.go index aec3307224..a095416ca9 100644 --- a/pkg/daprrp/processors/pubsubbrokers/processor.go +++ b/pkg/daprrp/processors/pubsubbrokers/processor.go @@ -19,18 +19,19 @@ package pubsubbrokers import ( "context" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/handlers" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/handlers" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers/dapr" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime_client "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -52,7 +53,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprPubSubB return err } - if resource.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { + if resource.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { // If the resource is being provisioned by recipe then we expect the recipe to create the Dapr Component // in Kubernetes. At this point we're done so we can just return. return nil @@ -76,7 +77,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprPubSubB resource.Properties.ComponentName, applicationID.Name(), resource.Name, - linkrp.N_DaprPubSubBrokersResourceType) + portableresources.DaprPubSubBrokersResourceType) if err != nil { return err } @@ -86,7 +87,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprPubSubB return &processors.ResourceError{Inner: err} } - err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, linkrp.N_DaprPubSubBrokersResourceType) + err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, portableresources.DaprPubSubBrokersResourceType) if err != nil { return &processors.ValidationError{Message: err.Error()} } @@ -96,9 +97,43 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprPubSubB return &processors.ResourceError{Inner: err} } - deployed := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) + deployed := rpv1.NewKubernetesOutputResource("Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) deployed.RadiusManaged = to.Ptr(true) resource.Properties.Status.OutputResources = append(resource.Properties.Status.OutputResources, deployed) return nil } + +// Delete implements the processors.Processor interface for DaprPubSubBroker resources. If the resource is being +// provisioned manually, it deletes the Dapr component in Kubernetes. +func (p *Processor) Delete(ctx context.Context, resource *datamodel.DaprPubSubBroker, options processors.Options) error { + if resource.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { + // If the resource was provisioned by recipe then we expect the recipe engine to delete the Dapr Component + // in Kubernetes. At this point we're done so we can just return. + return nil + } + + applicationID, err := resources.ParseResource(resource.Properties.Application) + if err != nil { + return err // This should already be validated by this point. + } + + component := unstructured.Unstructured{ + Object: map[string]any{ + "apiVersion": dapr.DaprAPIVersion, + "kind": dapr.DaprKind, + "metadata": map[string]any{ + "namespace": options.RuntimeConfiguration.Kubernetes.Namespace, + "name": kubernetes.NormalizeDaprResourceName(resource.Properties.ComponentName), + "labels": kubernetes.MakeDescriptiveDaprLabels(applicationID.Name(), resource.Name, portableresources.DaprPubSubBrokersResourceType), + }, + }, + } + + err = p.Client.Delete(ctx, &component) + if err != nil { + return &processors.ResourceError{Inner: err} + } + + return nil +} diff --git a/pkg/daprrp/processors/pubsubbrokers/processor_test.go b/pkg/daprrp/processors/pubsubbrokers/processor_test.go index bf33587aed..c4397b46c4 100644 --- a/pkg/daprrp/processors/pubsubbrokers/processor_test.go +++ b/pkg/daprrp/processors/pubsubbrokers/processor_test.go @@ -20,17 +20,16 @@ import ( "context" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/k8sutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers/dapr" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -135,11 +134,11 @@ func Test_Process(t *testing.T) { BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ ComponentName: componentName, }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{ "config": "extrasecure", }, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: externalResourceID1}}, Type: "pubsub.redis", Version: "v1", }, @@ -167,12 +166,12 @@ func Test_Process(t *testing.T) { generated := &unstructured.Unstructured{ Object: map[string]any{ - "apiVersion": "dapr.io/v1alpha1", - "kind": "Component", + "apiVersion": dapr.DaprAPIVersion, + "kind": dapr.DaprKind, "metadata": map[string]any{ "namespace": "test-namespace", "name": "test-dapr-pubsub-broker", - "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", linkrp.N_DaprPubSubBrokersResourceType), + "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", portableresources.DaprPubSubBrokersResourceType), "resourceVersion": "1", }, "spec": map[string]any{ @@ -188,9 +187,8 @@ func Test_Process(t *testing.T) { }, } - component := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) + component := rpv1.NewKubernetesOutputResource("Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) component.RadiusManaged = to.Ptr(true) - component.Resource = generated expectedOutputResources = append(expectedOutputResources, component) require.NoError(t, err) @@ -292,7 +290,7 @@ func Test_Process(t *testing.T) { "test-dapr-pubsub-broker", "test-app", "some-other-other-name", - linkrp.N_DaprPubSubBrokersResourceType) + portableresources.DaprPubSubBrokersResourceType) require.NoError(t, err) processor := Processor{ @@ -311,9 +309,9 @@ func Test_Process(t *testing.T) { BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ ComponentName: componentName, }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{"config": "extrasecure"}, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: externalResourceID1}}, Type: "pubsub.redis", Version: "v1", }, diff --git a/pkg/daprrp/processors/secretstores/processor.go b/pkg/daprrp/processors/secretstores/processor.go index 1eff1a6a28..7153006db2 100644 --- a/pkg/daprrp/processors/secretstores/processor.go +++ b/pkg/daprrp/processors/secretstores/processor.go @@ -19,18 +19,19 @@ package secretstores import ( "context" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/handlers" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/handlers" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers/dapr" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime_client "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -50,7 +51,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprSecretS return err } - if resource.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { + if resource.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { // If the resource is being provisioned by recipe then we expect the recipe to create the Dapr Component // in Kubernetes. At this point we're done so we can just return. return nil @@ -73,7 +74,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprSecretS resource.Properties.ComponentName, applicationID.Name(), resource.Name, - linkrp.N_DaprSecretStoresResourceType) + portableresources.DaprSecretStoresResourceType) if err != nil { return err } @@ -83,7 +84,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprSecretS return &processors.ResourceError{Inner: err} } - err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, linkrp.N_DaprSecretStoresResourceType) + err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, portableresources.DaprSecretStoresResourceType) if err != nil { return &processors.ValidationError{Message: err.Error()} } @@ -93,9 +94,43 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprSecretS return &processors.ResourceError{Inner: err} } - deployed := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) + deployed := rpv1.NewKubernetesOutputResource("Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) deployed.RadiusManaged = to.Ptr(true) resource.Properties.Status.OutputResources = append(resource.Properties.Status.OutputResources, deployed) return nil } + +// Delete implements the processors.Processor interface for DaprSecretStore resources. If the resource is being +// provisioned manually, it deletes the Dapr component in Kubernetes. +func (p *Processor) Delete(ctx context.Context, resource *datamodel.DaprSecretStore, options processors.Options) error { + if resource.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { + // If the resource was provisioned by recipe then we expect the recipe engine to delete the Dapr Component + // in Kubernetes. At this point we're done so we can just return. + return nil + } + + applicationID, err := resources.ParseResource(resource.Properties.Application) + if err != nil { + return err // This should already be validated by this point. + } + + component := unstructured.Unstructured{ + Object: map[string]any{ + "apiVersion": dapr.DaprAPIVersion, + "kind": dapr.DaprKind, + "metadata": map[string]any{ + "namespace": options.RuntimeConfiguration.Kubernetes.Namespace, + "name": kubernetes.NormalizeDaprResourceName(resource.Properties.ComponentName), + "labels": kubernetes.MakeDescriptiveDaprLabels(applicationID.Name(), resource.Name, portableresources.DaprSecretStoresResourceType), + }, + }, + } + + err = p.Client.Delete(ctx, &component) + if err != nil { + return &processors.ResourceError{Inner: err} + } + + return nil +} diff --git a/pkg/daprrp/processors/secretstores/processor_test.go b/pkg/daprrp/processors/secretstores/processor_test.go index 3842ca4f93..e5eedf30c5 100644 --- a/pkg/daprrp/processors/secretstores/processor_test.go +++ b/pkg/daprrp/processors/secretstores/processor_test.go @@ -20,17 +20,16 @@ import ( "context" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/k8sutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers/dapr" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -125,7 +124,7 @@ func Test_Process(t *testing.T) { BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ ComponentName: componentName, }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{"config": "extrasecure"}, Type: "secretstores.kubernetes", Version: "v1", @@ -151,12 +150,12 @@ func Test_Process(t *testing.T) { expectedSecrets := map[string]rpv1.SecretValueReference{} generated := &unstructured.Unstructured{ Object: map[string]any{ - "apiVersion": "dapr.io/v1alpha1", - "kind": "Component", + "apiVersion": dapr.DaprAPIVersion, + "kind": dapr.DaprKind, "metadata": map[string]any{ "namespace": "test-namespace", "name": "test-component", - "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", linkrp.N_DaprSecretStoresResourceType), + "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", portableresources.DaprSecretStoresResourceType), "resourceVersion": "1", }, "spec": map[string]any{ @@ -172,9 +171,8 @@ func Test_Process(t *testing.T) { }, } - component := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) + component := rpv1.NewKubernetesOutputResource("Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) component.RadiusManaged = to.Ptr(true) - component.Resource = generated expectedOutputResources := []rpv1.OutputResource{component} require.NoError(t, err) @@ -266,7 +264,7 @@ func Test_Process(t *testing.T) { "test-component", "test-app", "some-other-other-name", - linkrp.N_DaprSecretStoresResourceType) + portableresources.DaprSecretStoresResourceType) require.NoError(t, err) processor := Processor{ @@ -285,7 +283,7 @@ func Test_Process(t *testing.T) { BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ ComponentName: componentName, }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{"config": "extrasecure"}, Type: "secretstores.kubernetes", Version: "v1", diff --git a/pkg/daprrp/processors/statestores/processor.go b/pkg/daprrp/processors/statestores/processor.go index 38646fb3e5..5275e92864 100644 --- a/pkg/daprrp/processors/statestores/processor.go +++ b/pkg/daprrp/processors/statestores/processor.go @@ -19,18 +19,19 @@ package statestores import ( "context" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/handlers" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/handlers" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers/dapr" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime_client "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -52,7 +53,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprStateSt return err } - if resource.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { + if resource.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { // If the resource is being provisioned by recipe then we expect the recipe to create the Dapr Component // in Kubernetes. At this point we're done so we can just return. return nil @@ -76,7 +77,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprStateSt resource.Properties.ComponentName, applicationID.Name(), resource.Name, - linkrp.DaprStateStoresResourceType) + portableresources.DaprStateStoresResourceType) if err != nil { return err } @@ -86,7 +87,7 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprStateSt return &processors.ResourceError{Inner: err} } - err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, linkrp.DaprStateStoresResourceType) + err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, portableresources.DaprStateStoresResourceType) if err != nil { return &processors.ValidationError{Message: err.Error()} } @@ -96,9 +97,43 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprStateSt return &processors.ResourceError{Inner: err} } - deployed := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) + deployed := rpv1.NewKubernetesOutputResource("Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) deployed.RadiusManaged = to.Ptr(true) resource.Properties.Status.OutputResources = append(resource.Properties.Status.OutputResources, deployed) return nil } + +// Delete implements the processors.Processor interface for DaprStateStore resources. If the resource is being +// provisioned manually, it deletes the Dapr component in Kubernetes. +func (p *Processor) Delete(ctx context.Context, resource *datamodel.DaprStateStore, options processors.Options) error { + if resource.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { + // If the resource was provisioned by recipe then we expect the recipe engine to delete the Dapr Component + // in Kubernetes. At this point we're done so we can just return. + return nil + } + + applicationID, err := resources.ParseResource(resource.Properties.Application) + if err != nil { + return err // This should already be validated by this point. + } + + component := unstructured.Unstructured{ + Object: map[string]any{ + "apiVersion": dapr.DaprAPIVersion, + "kind": dapr.DaprKind, + "metadata": map[string]any{ + "namespace": options.RuntimeConfiguration.Kubernetes.Namespace, + "name": kubernetes.NormalizeDaprResourceName(resource.Properties.ComponentName), + "labels": kubernetes.MakeDescriptiveDaprLabels(applicationID.Name(), resource.Name, portableresources.DaprStateStoresResourceType), + }, + }, + } + + err = p.Client.Delete(ctx, &component) + if err != nil { + return &processors.ResourceError{Inner: err} + } + + return nil +} diff --git a/pkg/daprrp/processors/statestores/processor_test.go b/pkg/daprrp/processors/statestores/processor_test.go index 571fa9d0a9..ddb228d04f 100644 --- a/pkg/daprrp/processors/statestores/processor_test.go +++ b/pkg/daprrp/processors/statestores/processor_test.go @@ -20,17 +20,16 @@ import ( "context" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/k8sutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers/dapr" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -129,9 +128,9 @@ func Test_Process(t *testing.T) { BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ ComponentName: componentName, }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{"config": "extrasecure"}, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: externalResourceID1}}, Type: "state.redis", Version: "v1", }, @@ -159,12 +158,12 @@ func Test_Process(t *testing.T) { generated := &unstructured.Unstructured{ Object: map[string]any{ - "apiVersion": "dapr.io/v1alpha1", - "kind": "Component", + "apiVersion": dapr.DaprAPIVersion, + "kind": dapr.DaprKind, "metadata": map[string]any{ "namespace": "test-namespace", "name": "test-component", - "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", linkrp.DaprStateStoresResourceType), + "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", portableresources.DaprStateStoresResourceType), "resourceVersion": "1", }, "spec": map[string]any{ @@ -180,9 +179,8 @@ func Test_Process(t *testing.T) { }, } - component := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) + component := rpv1.NewKubernetesOutputResource("Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) component.RadiusManaged = to.Ptr(true) - component.Resource = generated expectedOutputResources = append(expectedOutputResources, component) require.NoError(t, err) @@ -280,7 +278,7 @@ func Test_Process(t *testing.T) { "test-component", "test-app", "some-other-other-name", - linkrp.DaprStateStoresResourceType) + portableresources.DaprStateStoresResourceType) require.NoError(t, err) processor := Processor{ @@ -299,9 +297,9 @@ func Test_Process(t *testing.T) { BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ ComponentName: componentName, }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Metadata: map[string]any{"config": "extrasecure"}, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: externalResourceID1}}, Type: "state.redis", Version: "v1", }, diff --git a/pkg/datastoresrp/api/README.md b/pkg/datastoresrp/api/README.md index 04cc3c2468..6d33e0b779 100644 --- a/pkg/datastoresrp/api/README.md +++ b/pkg/datastoresrp/api/README.md @@ -44,7 +44,7 @@ The following configuration generates track2 go models and client. ```yaml $(tag) != '' version: 3.*.* -use: "@autorest/go@4.0.0-preview.44" +use: "@autorest/go@4.0.0-preview.55" module-version: 0.0.1 file-prefix: zz_generated_ license-header: "Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information.\nCode generated by Microsoft (R) AutoRest Code Generator.\nChanges may cause incorrect behavior and will be lost if the code is regenerated." diff --git a/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util.go b/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util.go index b9b7b29790..64cd7d4158 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util.go @@ -19,10 +19,10 @@ package v20220315privatepreview import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) func toProvisioningStateDataModel(state *ProvisioningState) v1.ProvisioningState { @@ -72,24 +72,24 @@ func fromProvisioningStateDataModel(state v1.ProvisioningState) *ProvisioningSta return &converted } -func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (linkrp.ResourceProvisioning, error) { +func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (portableresources.ResourceProvisioning, error) { if provisioning == nil { - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil } switch *provisioning { case ResourceProvisioningManual: - return linkrp.ResourceProvisioningManual, nil + return portableresources.ResourceProvisioningManual, nil case ResourceProvisioningRecipe: - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil default: return "", &v1.ErrModelConversion{PropertyName: "$.properties.resourceProvisioning", ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues())} } } -func fromResourceProvisioningDataModel(provisioning linkrp.ResourceProvisioning) *ResourceProvisioning { +func fromResourceProvisioningDataModel(provisioning portableresources.ResourceProvisioning) *ResourceProvisioning { var converted ResourceProvisioning switch provisioning { - case linkrp.ResourceProvisioningManual: + case portableresources.ResourceProvisioningManual: converted = ResourceProvisioningManual default: converted = ResourceProvisioningRecipe @@ -98,15 +98,15 @@ func fromResourceProvisioningDataModel(provisioning linkrp.ResourceProvisioning) return &converted } -func toRecipeDataModel(r *Recipe) linkrp.LinkRecipe { +func toRecipeDataModel(r *Recipe) portableresources.ResourceRecipe { if r == nil { - return linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + return portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, } } - recipe := linkrp.LinkRecipe{} + recipe := portableresources.ResourceRecipe{} if r.Name == nil { - recipe.Name = v20220315privatepreview.DefaultRecipeName + recipe.Name = portableresources.DefaultRecipeName } else { recipe.Name = to.String(r.Name) } @@ -116,27 +116,27 @@ func toRecipeDataModel(r *Recipe) linkrp.LinkRecipe { return recipe } -func fromRecipeDataModel(r linkrp.LinkRecipe) *Recipe { +func fromRecipeDataModel(r portableresources.ResourceRecipe) *Recipe { return &Recipe{ Name: to.Ptr(r.Name), Parameters: r.Parameters, } } -func toResourcesDataModel(r []*ResourceReference) []*linkrp.ResourceReference { +func toResourcesDataModel(r []*ResourceReference) []*portableresources.ResourceReference { if r == nil { return nil } - resources := make([]*linkrp.ResourceReference, len(r)) + resources := make([]*portableresources.ResourceReference, len(r)) for i, resource := range r { - resources[i] = &linkrp.ResourceReference{ + resources[i] = &portableresources.ResourceReference{ ID: to.String(resource.ID), } } return resources } -func fromResourcesDataModel(r []*linkrp.ResourceReference) []*ResourceReference { +func fromResourcesDataModel(r []*portableresources.ResourceReference) []*ResourceReference { if r == nil { return nil } @@ -153,9 +153,29 @@ func fromSystemDataModel(s v1.SystemData) *SystemData { return &SystemData{ CreatedBy: to.Ptr(s.CreatedBy), CreatedByType: (*CreatedByType)(to.Ptr(s.CreatedByType)), - CreatedAt: v20220315privatepreview.UnmarshalTimeString(s.CreatedAt), + CreatedAt: v1.UnmarshalTimeString(s.CreatedAt), LastModifiedBy: to.Ptr(s.LastModifiedBy), LastModifiedByType: (*CreatedByType)(to.Ptr(s.LastModifiedByType)), - LastModifiedAt: v20220315privatepreview.UnmarshalTimeString(s.LastModifiedAt), + LastModifiedAt: v1.UnmarshalTimeString(s.LastModifiedAt), } } + +func toOutputResources(outputResources []rpv1.OutputResource) []*OutputResource { + var outResources []*OutputResource + for _, or := range outputResources { + r := &OutputResource{ + ID: to.Ptr(or.ID.String()), + } + + // We will not serialize the following fields if they are empty or nil. + if or.LocalID != "" { + r.LocalID = to.Ptr(or.LocalID) + } + if or.RadiusManaged != nil { + r.RadiusManaged = or.RadiusManaged + } + + outResources = append(outResources, r) + } + return outResources +} diff --git a/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util_test.go b/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util_test.go index 955b94b808..1162b6aeb2 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util_test.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/datamodel_util_test.go @@ -20,10 +20,9 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) @@ -117,15 +116,15 @@ func TestFromSystemDataModel(t *testing.T) { func TestToResourcesDataModel(t *testing.T) { testset := []struct { - DMResources []*linkrp.ResourceReference + DMResources []*portableresources.ResourceReference VersionedResources []*ResourceReference }{ { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, + DMResources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, }, { - DMResources: []*linkrp.ResourceReference{}, + DMResources: []*portableresources.ResourceReference{}, VersionedResources: []*ResourceReference{}, }, } @@ -139,15 +138,15 @@ func TestToResourcesDataModel(t *testing.T) { func TestFromResourcesDataModel(t *testing.T) { testset := []struct { - DMResources []*linkrp.ResourceReference + DMResources []*portableresources.ResourceReference VersionedResources []*ResourceReference }{ { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, + DMResources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, }, { - DMResources: []*linkrp.ResourceReference{}, + DMResources: []*portableresources.ResourceReference{}, VersionedResources: []*ResourceReference{}, }, } @@ -162,17 +161,17 @@ func TestFromResourcesDataModel(t *testing.T) { func TestToResourceProvisiongDataModel(t *testing.T) { testset := []struct { versioned ResourceProvisioning - datamodel linkrp.ResourceProvisioning + datamodel portableresources.ResourceProvisioning err error }{ { ResourceProvisioningManual, - linkrp.ResourceProvisioningManual, + portableresources.ResourceProvisioningManual, nil, }, { ResourceProvisioningRecipe, - linkrp.ResourceProvisioningRecipe, + portableresources.ResourceProvisioningRecipe, nil, }, { @@ -199,11 +198,11 @@ func TestToResourceProvisiongDataModel(t *testing.T) { func TestFromResourceProvisiongDataModel(t *testing.T) { testCases := []struct { - datamodel linkrp.ResourceProvisioning + datamodel portableresources.ResourceProvisioning versioned ResourceProvisioning }{ - {linkrp.ResourceProvisioningManual, ResourceProvisioningManual}, - {linkrp.ResourceProvisioningRecipe, ResourceProvisioningRecipe}, + {portableresources.ResourceProvisioningManual, ResourceProvisioningManual}, + {portableresources.ResourceProvisioningRecipe, ResourceProvisioningRecipe}, {"", ResourceProvisioningRecipe}, } @@ -215,12 +214,12 @@ func TestFromResourceProvisiongDataModel(t *testing.T) { func TestToRecipeDataModel(t *testing.T) { testset := []struct { versioned *Recipe - datamodel linkrp.LinkRecipe + datamodel portableresources.ResourceRecipe }{ { nil, - linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, }, }, { @@ -230,7 +229,7 @@ func TestToRecipeDataModel(t *testing.T) { "foo": "bar", }, }, - linkrp.LinkRecipe{ + portableresources.ResourceRecipe{ Name: "test", Parameters: map[string]any{ "foo": "bar", @@ -243,8 +242,8 @@ func TestToRecipeDataModel(t *testing.T) { "foo": "bar", }, }, - linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, Parameters: map[string]any{ "foo": "bar", }, @@ -259,18 +258,18 @@ func TestToRecipeDataModel(t *testing.T) { func TestFromRecipeDataModel(t *testing.T) { testset := []struct { - DMResources []linkrp.LinkRecipe + DMResources []portableresources.ResourceRecipe VersionedResources []*Recipe }{ { - DMResources: []linkrp.LinkRecipe{{ - Name: v20220315privatepreview.DefaultRecipeName, + DMResources: []portableresources.ResourceRecipe{{ + Name: portableresources.DefaultRecipeName, Parameters: map[string]any{ "foo": "bar", }, }}, VersionedResources: []*Recipe{{ - Name: to.Ptr(v20220315privatepreview.DefaultRecipeName), + Name: to.Ptr(portableresources.DefaultRecipeName), Parameters: map[string]any{ "foo": "bar", }, diff --git a/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion.go b/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion.go index 7e794eee3f..c958300c12 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion.go @@ -17,11 +17,11 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned Mongo database resource to version-agnostic datamodel and returns it, @@ -67,7 +67,7 @@ func (src *MongoDatabaseResource) ConvertTo() (v1.DataModelInterface, error) { Password: to.String(v.Secrets.Password), } } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { + if converted.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { converted.Properties.Recipe = toRecipeDataModel(v.Recipe) } @@ -98,7 +98,7 @@ func (dst *MongoDatabaseResource) ConvertFrom(src v1.DataModelInterface) error { Port: to.Ptr(mongo.Properties.Port), Database: to.Ptr(mongo.Properties.Database), Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(mongo.Properties.Status.OutputResources), + OutputResources: toOutputResources(mongo.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(mongo.InternalMetadata.AsyncProvisioningState), Environment: to.Ptr(mongo.Properties.Environment), diff --git a/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion_test.go b/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion_test.go index aab3478dcf..a0dd6af485 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion_test.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/mongodatabase_conversion_test.go @@ -20,12 +20,13 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -44,7 +45,7 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", Name: "mongo0", - Type: linkrp.N_MongoDatabasesResourceType, + Type: portableresources.MongoDatabasesResourceType, Tags: map[string]string{}, }, InternalMetadata: v1.InternalMetadata{ @@ -59,11 +60,11 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Host: "testAccount.mongo.cosmos.azure.com", Port: 10255, Database: "test-database", - Resources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"}}, + Resources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"}}, }, }, }, @@ -75,7 +76,7 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", Name: "mongo0", - Type: linkrp.N_MongoDatabasesResourceType, + Type: portableresources.MongoDatabasesResourceType, Tags: map[string]string{}, }, InternalMetadata: v1.InternalMetadata{ @@ -90,10 +91,10 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, Host: "testAccount.mongo.cosmos.azure.com", Port: 10255, - Recipe: linkrp.LinkRecipe{Name: "cosmosdb", Parameters: map[string]interface{}{"foo": "bar"}}, + Recipe: portableresources.ResourceRecipe{Name: "cosmosdb", Parameters: map[string]interface{}{"foo": "bar"}}, }, }, }, @@ -106,7 +107,7 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", Name: "mongo0", - Type: linkrp.N_MongoDatabasesResourceType, + Type: portableresources.MongoDatabasesResourceType, Tags: map[string]string{}, }, InternalMetadata: v1.InternalMetadata{ @@ -121,10 +122,10 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, Host: "mynewhost.com", Port: 10256, - Recipe: linkrp.LinkRecipe{Name: v20220315privatepreview.DefaultRecipeName, Parameters: nil}, + Recipe: portableresources.ResourceRecipe{Name: portableresources.DefaultRecipeName, Parameters: nil}, }, }, }, @@ -136,7 +137,7 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", Name: "mongo0", - Type: linkrp.N_MongoDatabasesResourceType, + Type: portableresources.MongoDatabasesResourceType, Tags: map[string]string{}, }, InternalMetadata: v1.InternalMetadata{ @@ -151,7 +152,7 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Host: "testAccount.mongo.cosmos.azure.com", Port: 10255, Database: "test-database", @@ -167,10 +168,9 @@ func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { for _, tc := range testset { // arrange t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) versionedResource := &MongoDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) // act @@ -204,10 +204,9 @@ func TestMongoDatabase_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) } for _, test := range testset { t.Run(test.payload, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(test.payload) versionedResource := &MongoDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) dm, err := versionedResource.ConvertTo() @@ -240,22 +239,14 @@ func TestMongoDatabase_ConvertDataModelToVersioned(t *testing.T) { ProvisioningState: to.Ptr(ProvisioningStateAccepted), Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, Username: to.Ptr("testUser"), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "AzureCosmosAccount", - "Provider": "azure", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0"), Name: to.Ptr("mongo0"), - Type: to.Ptr(linkrp.N_MongoDatabasesResourceType), + Type: to.Ptr(portableresources.MongoDatabasesResourceType), }, }, { @@ -283,7 +274,7 @@ func TestMongoDatabase_ConvertDataModelToVersioned(t *testing.T) { }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0"), Name: to.Ptr("mongo0"), - Type: to.Ptr(linkrp.N_MongoDatabasesResourceType), + Type: to.Ptr(portableresources.MongoDatabasesResourceType), }, }, { @@ -311,16 +302,15 @@ func TestMongoDatabase_ConvertDataModelToVersioned(t *testing.T) { }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0"), Name: to.Ptr("mongo0"), - Type: to.Ptr(linkrp.N_MongoDatabasesResourceType), + Type: to.Ptr(portableresources.MongoDatabasesResourceType), }, }, } for _, tc := range testset { t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) resource := &datamodel.MongoDatabase{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &MongoDatabaseResource{} @@ -340,7 +330,7 @@ func TestMongoDatabase_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } @@ -353,10 +343,9 @@ func TestMongoDatabase_ConvertFromValidation(t *testing.T) { func TestMongoDatabaseSecrets_ConvertVersionedToDataModel(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/mongodatabasesecrets.json") - require.NoError(t, err) + rawPayload := testutil.ReadFixture("mongodatabasesecrets.json") versioned := &MongoDatabaseSecrets{} - err = json.Unmarshal(rawPayload, versioned) + err := json.Unmarshal(rawPayload, versioned) require.NoError(t, err) // act @@ -371,10 +360,9 @@ func TestMongoDatabaseSecrets_ConvertVersionedToDataModel(t *testing.T) { func TestMongoDatabaseSecrets_ConvertDataModelToVersioned(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/mongodatabasesecretsdatamodel.json") - require.NoError(t, err) + rawPayload := testutil.ReadFixture("mongodatabasesecretsdatamodel.json") secrets := &datamodel.MongoDatabaseSecrets{} - err = json.Unmarshal(rawPayload, secrets) + err := json.Unmarshal(rawPayload, secrets) require.NoError(t, err) // act @@ -392,7 +380,7 @@ func TestMongoDatabaseSecrets_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion.go b/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion.go index 4765fb06bf..ad62edf69a 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion.go @@ -17,11 +17,11 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned Redis cache resource to version-agnostic datamodel @@ -55,7 +55,7 @@ func (src *RedisCacheResource) ConvertTo() (v1.DataModelInterface, error) { if err != nil { return nil, err } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { + if converted.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { converted.Properties.Recipe = toRecipeDataModel(v.Recipe) } converted.Properties.Resources = toResourcesDataModel(v.Resources) @@ -100,7 +100,7 @@ func (dst *RedisCacheResource) ConvertFrom(src v1.DataModelInterface) error { TLS: to.Ptr(redis.Properties.TLS), Username: to.Ptr(redis.Properties.Username), Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(redis.Properties.Status.OutputResources), + OutputResources: toOutputResources(redis.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(redis.InternalMetadata.AsyncProvisioningState), Environment: to.Ptr(redis.Properties.Environment), diff --git a/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion_test.go b/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion_test.go index a70f7272cd..cbf576231c 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion_test.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/rediscache_conversion_test.go @@ -21,13 +21,14 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) @@ -50,12 +51,12 @@ func TestRedisCache_ConvertVersionedToDataModel(t *testing.T) { BaseResource: createBaseResource(), Properties: datamodel.RedisCacheProperties{ BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, Host: "", Port: 0, TLS: false, Username: "", - Recipe: linkrp.LinkRecipe{Name: "default"}, + Recipe: portableresources.ResourceRecipe{Name: "default"}, }, }, }, @@ -66,12 +67,12 @@ func TestRedisCache_ConvertVersionedToDataModel(t *testing.T) { BaseResource: createBaseResource(), Properties: datamodel.RedisCacheProperties{ BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, Host: "", Port: 0, TLS: false, Username: "", - Recipe: linkrp.LinkRecipe{Name: "redis-test"}, + Recipe: portableresources.ResourceRecipe{Name: "redis-test"}, }, }, }, @@ -82,12 +83,12 @@ func TestRedisCache_ConvertVersionedToDataModel(t *testing.T) { BaseResource: createBaseResource(), Properties: datamodel.RedisCacheProperties{ BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, Host: "myrediscache.redis.cache.windows.net", Port: 10255, TLS: false, Username: "", - Recipe: linkrp.LinkRecipe{Name: "redis-test", Parameters: map[string]any{"port": float64(6081)}}, + Recipe: portableresources.ResourceRecipe{Name: "redis-test", Parameters: map[string]any{"port": float64(6081)}}, }, }, }, @@ -98,12 +99,12 @@ func TestRedisCache_ConvertVersionedToDataModel(t *testing.T) { BaseResource: createBaseResource(), Properties: datamodel.RedisCacheProperties{ BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Host: "myrediscache.redis.cache.windows.net", Port: 10255, TLS: true, Username: "admin", - Resources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}}, + Resources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}}, Secrets: datamodel.RedisCacheSecrets{ Password: "testPassword", ConnectionString: "test-connection-string", @@ -119,7 +120,7 @@ func TestRedisCache_ConvertVersionedToDataModel(t *testing.T) { BaseResource: createBaseResource(), Properties: datamodel.RedisCacheProperties{ BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Host: "myrediscache.redis.cache.windows.net", Port: 10255, TLS: false, @@ -132,10 +133,9 @@ func TestRedisCache_ConvertVersionedToDataModel(t *testing.T) { for _, tc := range testset { // arrange t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) versionedResource := &RedisCacheResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) // act @@ -171,22 +171,14 @@ func TestRedisCache_ConvertDataModelToVersioned(t *testing.T) { Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, Username: to.Ptr(""), TLS: to.Ptr(false), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr(RedisID), Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.N_RedisCachesResourceType), + Type: to.Ptr(portableresources.RedisCachesResourceType), }, }, { @@ -204,22 +196,14 @@ func TestRedisCache_ConvertDataModelToVersioned(t *testing.T) { Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, Username: to.Ptr(""), TLS: to.Ptr(false), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr(RedisID), Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.N_RedisCachesResourceType), + Type: to.Ptr(portableresources.RedisCachesResourceType), }, }, { @@ -237,22 +221,14 @@ func TestRedisCache_ConvertDataModelToVersioned(t *testing.T) { Recipe: &Recipe{Name: to.Ptr("redis-test"), Parameters: map[string]any{"port": float64(6081)}}, Username: to.Ptr(""), TLS: to.Ptr(false), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr(RedisID), Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.N_RedisCachesResourceType), + Type: to.Ptr(portableresources.RedisCachesResourceType), }, }, { @@ -283,17 +259,16 @@ func TestRedisCache_ConvertDataModelToVersioned(t *testing.T) { }, ID: to.Ptr(RedisID), Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.N_RedisCachesResourceType), + Type: to.Ptr(portableresources.RedisCachesResourceType), }, }, } for _, tc := range testset1 { t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) resource := &datamodel.RedisCache{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &RedisCacheResource{} @@ -312,10 +287,9 @@ func TestRedisCache_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) { testset := []string{"rediscacheresource-invalid.json", "rediscacheresource-invalid2.json"} for _, payload := range testset { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(payload) versionedResource := &RedisCacheResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) if payload == "rediscacheresource-invalid.json" { expectedErr := v1.ErrModelConversion{PropertyName: "$.properties.resourceProvisioning", ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues())} @@ -335,7 +309,7 @@ func TestRedisCache_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } @@ -348,10 +322,9 @@ func TestRedisCache_ConvertFromValidation(t *testing.T) { func TestRedisCacheSecrets_ConvertVersionedToDataModel(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/rediscachesecrets.json") - require.NoError(t, err) + rawPayload := testutil.ReadFixture("/rediscachesecrets.json") versioned := &RedisCacheSecrets{} - err = json.Unmarshal(rawPayload, versioned) + err := json.Unmarshal(rawPayload, versioned) require.NoError(t, err) // act @@ -367,10 +340,9 @@ func TestRedisCacheSecrets_ConvertVersionedToDataModel(t *testing.T) { func TestRedisCacheSecrets_ConvertDataModelToVersioned(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/rediscachesecretsdatamodel.json") - require.NoError(t, err) + rawPayload := testutil.ReadFixture("rediscachesecretsdatamodel.json") secrets := &datamodel.RedisCacheSecrets{} - err = json.Unmarshal(rawPayload, secrets) + err := json.Unmarshal(rawPayload, secrets) require.NoError(t, err) // act @@ -389,7 +361,7 @@ func TestRedisCacheSecrets_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } @@ -405,7 +377,7 @@ func createBaseResource() v1.BaseResource { TrackedResource: v1.TrackedResource{ ID: RedisID, Name: "redis0", - Type: linkrp.N_RedisCachesResourceType, + Type: portableresources.RedisCachesResourceType, Tags: map[string]string{}, }, InternalMetadata: v1.InternalMetadata{ diff --git a/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion.go b/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion.go index 704d4ad419..d25dd22ae9 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion.go @@ -17,11 +17,11 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts from the versioned SqlDatabase resource to version-agnostic datamodel @@ -56,7 +56,7 @@ func (src *SQLDatabaseResource) ConvertTo() (v1.DataModelInterface, error) { if err != nil { return nil, err } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { + if converted.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { converted.Properties.Recipe = toRecipeDataModel(properties.Recipe) } converted.Properties.Resources = toResourcesDataModel(properties.Resources) @@ -98,14 +98,14 @@ func (dst *SQLDatabaseResource) ConvertFrom(src v1.DataModelInterface) error { Server: to.Ptr(sql.Properties.Server), Port: to.Ptr(sql.Properties.Port), Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(sql.Properties.Status.OutputResources), + OutputResources: toOutputResources(sql.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(sql.InternalMetadata.AsyncProvisioningState), Environment: to.Ptr(sql.Properties.Environment), Application: to.Ptr(sql.Properties.Application), Username: to.Ptr(sql.Properties.Username), } - if sql.Properties.ResourceProvisioning == linkrp.ResourceProvisioningRecipe { + if sql.Properties.ResourceProvisioning == portableresources.ResourceProvisioningRecipe { dst.Properties.Recipe = fromRecipeDataModel(sql.Properties.Recipe) } return nil diff --git a/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion_test.go b/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion_test.go index 1ccf9582a9..ef60a87d85 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion_test.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/sqldatabase_conversion_test.go @@ -20,12 +20,13 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_shared "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -43,7 +44,7 @@ func TestSqlDatabase_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", Name: "sql0", - Type: linkrp.N_SqlDatabasesResourceType, + Type: portableresources.SqlDatabasesResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -61,8 +62,8 @@ func TestSqlDatabase_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Resources: []*linkrp.ResourceReference{ + ResourceProvisioning: portableresources.ResourceProvisioningManual, + Resources: []*portableresources.ResourceReference{ { ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase", }, @@ -86,7 +87,7 @@ func TestSqlDatabase_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", Name: "sql0", - Type: linkrp.N_SqlDatabasesResourceType, + Type: portableresources.SqlDatabasesResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -104,8 +105,8 @@ func TestSqlDatabase_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Recipe: linkrp.LinkRecipe{ + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, + Recipe: portableresources.ResourceRecipe{ Name: "sql-test", Parameters: map[string]any{ "foo": "bar", @@ -118,10 +119,9 @@ func TestSqlDatabase_ConvertVersionedToDataModel(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { // arrange - rawPayload, err := linkrp_shared.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) versionedResource := &SQLDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) // act @@ -161,22 +161,14 @@ func TestSqlDatabase_ConvertDataModelToVersioned(t *testing.T) { Port: to.Ptr(int32(1433)), Username: to.Ptr("testUser"), ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0"), Name: to.Ptr("sql0"), - Type: to.Ptr(linkrp.N_SqlDatabasesResourceType), + Type: to.Ptr(portableresources.SqlDatabasesResourceType), }, }, { @@ -199,31 +191,22 @@ func TestSqlDatabase_ConvertDataModelToVersioned(t *testing.T) { }, }, ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0"), Name: to.Ptr("sql0"), - Type: to.Ptr(linkrp.N_SqlDatabasesResourceType), + Type: to.Ptr(portableresources.SqlDatabasesResourceType), }, }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := linkrp_shared.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) resource := &datamodel.SqlDatabase{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &SQLDatabaseResource{} @@ -258,10 +241,9 @@ func TestSqlDatabase_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) { for _, test := range testset { t.Run(test.payload, func(t *testing.T) { - rawPayload, err := linkrp_shared.LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(test.payload) versionedResource := &SQLDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) dm, err := versionedResource.ConvertTo() @@ -278,7 +260,7 @@ func TestSqlDatabase_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&linkrp_shared.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } @@ -291,10 +273,9 @@ func TestSqlDatabase_ConvertFromValidation(t *testing.T) { func TestSqlDatabaseSecrets_ConvertDataModelToVersioned(t *testing.T) { // arrange - rawPayload, err := linkrp_shared.LoadTestData("./testdata/sqldatabase_secrets_datamodel.json") - require.NoError(t, err) + rawPayload := testutil.ReadFixture("sqldatabase_secrets_datamodel.json") secrets := &datamodel.SqlDatabaseSecrets{} - err = json.Unmarshal(rawPayload, secrets) + err := json.Unmarshal(rawPayload, secrets) require.NoError(t, err) // act @@ -312,7 +293,7 @@ func TestSqlDatabaseSecrets_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&linkrp_shared.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresource.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresource.json index f2e83b6793..3a4c0fc9b6 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresource.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresource.json @@ -1,27 +1,25 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.cosmosdb.mongo", - "Provider": "azure" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount.mongo.cosmos.azure.com", - "port": 10255, - "database": "test-database", - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount.mongo.cosmos.azure.com", + "port": 10255, + "database": "test-database", + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "test-connection-string" } -} + } +} \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json index 6bfa17a4c6..c62c159bee 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json @@ -1,38 +1,36 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "AzureCosmosAccount", - "ResourceType": { - "Type": "azure.cosmosdb.mongo", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "test-database", - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "test-database", + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "test-connection-string" } -} + } +} \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresource_manual.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresource_manual.json index 31b4baa9f9..dbb371cddd 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresource_manual.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresource_manual.json @@ -1,33 +1,31 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resources": [ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "username": "admin", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string", - "url": "test-url" - }, - "tls": true, - "resourceProvisioning": "manual" - } -} + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 10255, + "username": "admin", + "secrets": { + "password": "testPassword", + "connectionString": "test-connection-string", + "url": "test-url" + }, + "tls": true, + "resourceProvisioning": "manual" + } +} \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual.json index 9db7b6f062..4fa666fab3 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual.json @@ -1,32 +1,30 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "resourceProvisioning": "manual" - } -} + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "host": "myrediscache.redis.cache.windows.net", + "port": 10255, + "resourceProvisioning": "manual" + } +} \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_default.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_default.json index 3ecacb6114..9eaa162121 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_default.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_default.json @@ -1,29 +1,27 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication" - } -} + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication" + } +} \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_params.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_params.json index 31bfe7573a..3028bfe106 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_params.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_params.json @@ -1,35 +1,33 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "recipe": { - "name": "redis-test", - "parameters": { - "port": 6081 - } + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "recipe": { + "name": "redis-test", + "parameters": { + "port": 6081 + } } -} + } +} \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json index bba0676b7a..d1789e2177 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json @@ -1,36 +1,34 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.sql.database", - "Provider": "azure" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning":"manual", - "resources": [ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server":"testAccount1.sql.cosmos.azure.com", - "port":1433, - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "port": 1433, + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "test-connection-string" } + } } \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json index 25d6535630..a74ffd9733 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json @@ -1,40 +1,38 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.sql.database", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "resources":[ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning":"manual", - "username": "testUser", - "port":1433 - } + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "manual", + "username": "testUser", + "port": 1433 + } } \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json b/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json index 0fbd273d06..e9a341e8ef 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json +++ b/pkg/datastoresrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json @@ -1,41 +1,39 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "tags": { - "env": "dev" + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "recipe": { + "name": "sql-test", + "parameters": { + "foo": "bar" + } }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.sql.database", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "recipe": { - "name": "sql-test", - "parameters":{ - "foo":"bar" - } - }, - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning":"recipe", - "username":"testUser", - "port":1433 - } + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "recipe", + "username": "testUser", + "port": 1433 + } } \ No newline at end of file diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_client_factory.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_client_factory.go new file mode 100644 index 0000000000..0ee75d4bda --- /dev/null +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_client_factory.go @@ -0,0 +1,60 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + rootScope string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + rootScope: rootScope, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewMongoDatabasesClient() *MongoDatabasesClient { + subClient, _ := NewMongoDatabasesClient(c.rootScope, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRedisCachesClient() *RedisCachesClient { + subClient, _ := NewRedisCachesClient(c.rootScope, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLDatabasesClient() *SQLDatabasesClient { + subClient, _ := NewSQLDatabasesClient(c.rootScope, c.credential, c.options) + return subClient +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_constants.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_constants.go index e80a581e36..68682f4151 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_constants.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_constants.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -47,6 +46,24 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// IdentitySettingKind - IdentitySettingKind is the kind of supported external identity setting +type IdentitySettingKind string + +const ( + // IdentitySettingKindAzureComWorkload - azure ad workload identity + IdentitySettingKindAzureComWorkload IdentitySettingKind = "azure.com.workload" + // IdentitySettingKindUndefined - undefined identity + IdentitySettingKindUndefined IdentitySettingKind = "undefined" +) + +// PossibleIdentitySettingKindValues returns the possible values for the IdentitySettingKind const type. +func PossibleIdentitySettingKindValues() []IdentitySettingKind { + return []IdentitySettingKind{ + IdentitySettingKindAzureComWorkload, + IdentitySettingKindUndefined, + } +} + // Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" type Origin string @@ -70,12 +87,19 @@ func PossibleOriginValues() []Origin { type ProvisioningState string const ( + // ProvisioningStateAccepted - The resource create request has been accepted ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - The resource is being deleted ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is being provisioned ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is updating ProvisioningStateUpdating ProvisioningState = "Updating" ) @@ -98,7 +122,9 @@ func PossibleProvisioningStateValues() []ProvisioningState { type ResourceProvisioning string const ( + // ResourceProvisioningManual - The resource lifecycle will be managed by the user ResourceProvisioningManual ResourceProvisioning = "manual" + // ResourceProvisioningRecipe - The resource lifecycle will be managed by Radius ResourceProvisioningRecipe ResourceProvisioning = "recipe" ) @@ -110,3 +136,18 @@ func PossibleResourceProvisioningValues() []ResourceProvisioning { } } +// Versions - Supported API versions for the Applications.Databases resource provider. +type Versions string + +const ( + // VersionsV20220315Privatepreview - 2022-03-15-privatepreview + VersionsV20220315Privatepreview Versions = "2022-03-15-privatepreview" +) + +// PossibleVersionsValues returns the possible values for the Versions const type. +func PossibleVersionsValues() []Versions { + return []Versions{ + VersionsV20220315Privatepreview, + } +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_interfaces.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_interfaces.go new file mode 100644 index 0000000000..104e8355bd --- /dev/null +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_interfaces.go @@ -0,0 +1,18 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +// EnvironmentComputeClassification provides polymorphic access to related types. +// Call the interface's GetEnvironmentCompute() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EnvironmentCompute, *KubernetesCompute +type EnvironmentComputeClassification interface { + // GetEnvironmentCompute returns the EnvironmentCompute content of the underlying type. + GetEnvironmentCompute() *EnvironmentCompute +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models.go index cf56b6c0b5..4efff8b902 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models.go @@ -2,560 +2,651 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview import "time" -// BasicDaprResourceProperties - Basic properties of a Dapr component object. -type BasicDaprResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` +// EnvironmentCompute - Represents backing compute resource +type EnvironmentCompute struct { + // REQUIRED; Discriminator property for EnvironmentCompute. + Kind *string - // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to -// use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` + // Configuration for supported external identity providers + Identity *IdentitySettings - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + // The resource id of the compute resource for application environment. + ResourceID *string } -// BasicResourceProperties - Basic properties of a Radius resource. -type BasicResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} +// GetEnvironmentCompute implements the EnvironmentComputeClassification interface for type EnvironmentCompute. +func (e *EnvironmentCompute) GetEnvironmentCompute() *EnvironmentCompute { return e } // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + Info map[string]any // READ-ONLY; The additional info type. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ErrorDetail - The error detail. type ErrorDetail struct { // READ-ONLY; The error additional info. - AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + AdditionalInfo []*ErrorAdditionalInfo // READ-ONLY; The error code. - Code *string `json:"code,omitempty" azure:"ro"` + Code *string // READ-ONLY; The error details. - Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + Details []*ErrorDetail // READ-ONLY; The error message. - Message *string `json:"message,omitempty" azure:"ro"` + Message *string // READ-ONLY; The error target. - Target *string `json:"target,omitempty" azure:"ro"` + Target *string } // ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. // (This also follows the OData error response format.). type ErrorResponse struct { // The error object. - Error *ErrorDetail `json:"error,omitempty"` + Error *ErrorDetail +} + +// IdentitySettings is the external identity setting. +type IdentitySettings struct { + // REQUIRED; kind of identity setting + Kind *IdentitySettingKind + + // The URI for your compute platform's OIDC issuer + OidcIssuer *string + + // The resource ID of the provisioned identity + Resource *string } -// MongoDatabaseListSecretsResult - The secret values for the given Mongo database resource +// KubernetesCompute - The Kubernetes compute configuration +type KubernetesCompute struct { + // REQUIRED; Discriminator property for EnvironmentCompute. + Kind *string + + // REQUIRED; The namespace to use for the environment. + Namespace *string + + // Configuration for supported external identity providers + Identity *IdentitySettings + + // The resource id of the compute resource for application environment. + ResourceID *string +} + +// GetEnvironmentCompute implements the EnvironmentComputeClassification interface for type KubernetesCompute. +func (k *KubernetesCompute) GetEnvironmentCompute() *EnvironmentCompute { + return &EnvironmentCompute{ + Identity: k.Identity, + Kind: k.Kind, + ResourceID: k.ResourceID, + } +} + +// MongoDatabaseListSecretsResult - The secret values for the given MongoDatabase resource type MongoDatabaseListSecretsResult struct { // Connection string used to connect to the target Mongo database - ConnectionString *string `json:"connectionString,omitempty"` + ConnectionString *string // Password to use when connecting to the target Mongo database - Password *string `json:"password,omitempty"` + Password *string } -// MongoDatabaseProperties - Mongo database portable resource properties +// MongoDatabaseProperties - MongoDatabase portable resource properties type MongoDatabaseProperties struct { // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` + Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string // Database name of the target Mongo database - Database *string `json:"database,omitempty"` + Database *string // Host name of the target Mongo database - Host *string `json:"host,omitempty"` + Host *string // Port value of the target Mongo database - Port *int32 `json:"port,omitempty"` + Port *int32 - // The recipe used to automatically deploy underlying infrastructure for the Mongo database portable resource - Recipe *Recipe `json:"recipe,omitempty"` + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning *ResourceProvisioning - // List of the resource IDs that support the Mongo database resource - Resources []*ResourceReference `json:"resources,omitempty"` + // List of the resource IDs that support the MongoDB resource + Resources []*ResourceReference // Secret values provided for the resource - Secrets *MongoDatabaseSecrets `json:"secrets,omitempty"` + Secrets *MongoDatabaseSecrets // Username to use when connecting to the target Mongo database - Username *string `json:"username,omitempty"` + Username *string - // READ-ONLY; Provisioning state of the Mongo database portable resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + Status *ResourceStatus } -// MongoDatabaseResource - Mongo database portable resource +// MongoDatabaseResource - MongoDatabase portable resource type MongoDatabaseResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *MongoDatabaseProperties `json:"properties,omitempty"` + Properties *MongoDatabaseProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // MongoDatabaseResourceListResult - The response of a MongoDatabaseResource list operation. type MongoDatabaseResourceListResult struct { // REQUIRED; The MongoDatabaseResource items on this page - Value []*MongoDatabaseResource `json:"value,omitempty"` + Value []*MongoDatabaseResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// MongoDatabaseSecrets - The secret values for the given Mongo database resource -type MongoDatabaseSecrets struct { - // Connection string used to connect to the target Mongo database - ConnectionString *string `json:"connectionString,omitempty"` +// MongoDatabaseResourceUpdate - The type used for update operations of the MongoDatabaseResource. +type MongoDatabaseResourceUpdate struct { + // The updatable properties of the MongoDatabaseResource. + Properties *MongoDatabaseResourceUpdateProperties - // Password to use when connecting to the target Mongo database - Password *string `json:"password,omitempty"` + // Resource tags. + Tags map[string]*string } -// MongoDatabasesClientBeginDeleteOptions contains the optional parameters for the MongoDatabasesClient.BeginDelete method. -type MongoDatabasesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} +// MongoDatabaseResourceUpdateProperties - The updatable properties of the MongoDatabaseResource. +type MongoDatabaseResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string -// MongoDatabasesClientCreateOrUpdateOptions contains the optional parameters for the MongoDatabasesClient.CreateOrUpdate -// method. -type MongoDatabasesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} + // Database name of the target Mongo database + Database *string -// MongoDatabasesClientGetOptions contains the optional parameters for the MongoDatabasesClient.Get method. -type MongoDatabasesClientGetOptions struct { - // placeholder for future optional parameters -} + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string + + // Host name of the target Mongo database + Host *string + + // Port value of the target Mongo database + Port *int32 + + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning + + // List of the resource IDs that support the MongoDB resource + Resources []*ResourceReference -// MongoDatabasesClientListByRootScopeOptions contains the optional parameters for the MongoDatabasesClient.ListByRootScope -// method. -type MongoDatabasesClientListByRootScopeOptions struct { - // placeholder for future optional parameters + // Secret values provided for the resource + Secrets *MongoDatabaseSecrets + + // Username to use when connecting to the target Mongo database + Username *string } -// MongoDatabasesClientListSecretsOptions contains the optional parameters for the MongoDatabasesClient.ListSecrets method. -type MongoDatabasesClientListSecretsOptions struct { - // placeholder for future optional parameters +// MongoDatabaseSecrets - The secret values for the given MongoDatabase resource +type MongoDatabaseSecrets struct { + // Connection string used to connect to the target Mongo database + ConnectionString *string + + // Password to use when connecting to the target Mongo database + Password *string } // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. - Display *OperationDisplay `json:"display,omitempty"` + Display *OperationDisplay // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + ActionType *ActionType // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane // operations. - IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + IsDataAction *bool // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", // "Microsoft.Compute/virtualMachines/capture/action" - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" - Origin *Origin `json:"origin,omitempty" azure:"ro"` + Origin *Origin } // OperationDisplay - Localized display information for this particular operation. type OperationDisplay struct { // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. - Description *string `json:"description,omitempty" azure:"ro"` + Description *string // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual // Machine", "Restart Virtual Machine". - Operation *string `json:"operation,omitempty" azure:"ro"` + Operation *string // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft // Compute". - Provider *string `json:"provider,omitempty" azure:"ro"` + Provider *string // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job // Schedule Collections". - Resource *string `json:"resource,omitempty" azure:"ro"` + Resource *string } // OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to // get the next set of results. type OperationListResult struct { // READ-ONLY; URL to get the next set of operation list results (if there are any). - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of operations supported by the resource provider - Value []*Operation `json:"value,omitempty" azure:"ro"` + Value []*Operation } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters +// OutputResource - Properties of an output resource. +type OutputResource struct { + // The UCP resource ID of the underlying resource. + ID *string + + // The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency +// relationship. LocalIDs do not have any particular format or meaning beyond +// being compared to determine dependency relationships. + LocalID *string + + // Determines whether Radius manages the lifecycle of the underlying resource. + RadiusManaged *bool } // Recipe - The recipe used to automatically deploy underlying infrastructure for a portable resource type Recipe struct { // REQUIRED; The name of the recipe within the environment to use - Name *string `json:"name,omitempty"` + Name *string + + // Key/value parameters to pass into the recipe at deployment + Parameters map[string]any +} + +// RecipeUpdate - The recipe used to automatically deploy underlying infrastructure for a portable resource +type RecipeUpdate struct { + // The name of the recipe within the environment to use + Name *string // Key/value parameters to pass into the recipe at deployment - Parameters map[string]interface{} `json:"parameters,omitempty"` + Parameters map[string]any } -// RedisCacheListSecretsResult - The secret values for the given Redis cache resource +// RedisCacheListSecretsResult - The secret values for the given RedisCache resource type RedisCacheListSecretsResult struct { // The connection string used to connect to the Redis cache - ConnectionString *string `json:"connectionString,omitempty"` + ConnectionString *string // The password for this Redis cache instance - Password *string `json:"password,omitempty"` + Password *string // The URL used to connect to the Redis cache - URL *string `json:"url,omitempty"` + URL *string } -// RedisCacheProperties - Redis cache portable resource properties +// RedisCacheProperties - RedisCache portable resource properties type RedisCacheProperties struct { // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` + Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string // The host name of the target Redis cache - Host *string `json:"host,omitempty"` + Host *string // The port value of the target Redis cache - Port *int32 `json:"port,omitempty"` + Port *int32 - // The recipe used to automatically deploy underlying infrastructure for the Redis cache portable resource - Recipe *Recipe `json:"recipe,omitempty"` + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning *ResourceProvisioning // List of the resource IDs that support the Redis resource - Resources []*ResourceReference `json:"resources,omitempty"` + Resources []*ResourceReference // Secrets provided by resource - Secrets *RedisCacheSecrets `json:"secrets,omitempty"` + Secrets *RedisCacheSecrets // Specifies whether to enable SSL connections to the Redis cache - TLS *bool `json:"tls,omitempty"` + TLS *bool // The username for Redis cache - Username *string `json:"username,omitempty"` + Username *string - // READ-ONLY; Provisioning state of the redis cache portable at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + Status *ResourceStatus } -// RedisCacheResource - Redis cache portable resource +// RedisCacheResource - RedisCache portable resource type RedisCacheResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *RedisCacheProperties `json:"properties,omitempty"` + Properties *RedisCacheProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // RedisCacheResourceListResult - The response of a RedisCacheResource list operation. type RedisCacheResourceListResult struct { // REQUIRED; The RedisCacheResource items on this page - Value []*RedisCacheResource `json:"value,omitempty"` + Value []*RedisCacheResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// RedisCacheSecrets - The secret values for the given Redis cache resource -type RedisCacheSecrets struct { - // The connection string used to connect to the Redis cache - ConnectionString *string `json:"connectionString,omitempty"` - - // The password for this Redis cache instance - Password *string `json:"password,omitempty"` +// RedisCacheResourceUpdate - The type used for update operations of the RedisCacheResource. +type RedisCacheResourceUpdate struct { + // The updatable properties of the RedisCacheResource. + Properties *RedisCacheResourceUpdateProperties - // The URL used to connect to the Redis cache - URL *string `json:"url,omitempty"` + // Resource tags. + Tags map[string]*string } -// RedisCachesClientCreateOrUpdateOptions contains the optional parameters for the RedisCachesClient.CreateOrUpdate method. -type RedisCachesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} +// RedisCacheResourceUpdateProperties - The updatable properties of the RedisCacheResource. +type RedisCacheResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string -// RedisCachesClientDeleteOptions contains the optional parameters for the RedisCachesClient.Delete method. -type RedisCachesClientDeleteOptions struct { - // placeholder for future optional parameters -} + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string -// RedisCachesClientGetOptions contains the optional parameters for the RedisCachesClient.Get method. -type RedisCachesClientGetOptions struct { - // placeholder for future optional parameters -} + // The host name of the target Redis cache + Host *string + + // The port value of the target Redis cache + Port *int32 + + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning + + // List of the resource IDs that support the Redis resource + Resources []*ResourceReference + + // Secrets provided by resource + Secrets *RedisCacheSecrets + + // Specifies whether to enable SSL connections to the Redis cache + TLS *bool -// RedisCachesClientListByRootScopeOptions contains the optional parameters for the RedisCachesClient.ListByRootScope method. -type RedisCachesClientListByRootScopeOptions struct { - // placeholder for future optional parameters + // The username for Redis cache + Username *string } -// RedisCachesClientListSecretsOptions contains the optional parameters for the RedisCachesClient.ListSecrets method. -type RedisCachesClientListSecretsOptions struct { - // placeholder for future optional parameters +// RedisCacheSecrets - The secret values for the given RedisCache resource +type RedisCacheSecrets struct { + // The connection string used to connect to the Redis cache + ConnectionString *string + + // The password for this Redis cache instance + Password *string + + // The URL used to connect to the Redis cache + URL *string } // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ResourceReference - Describes a reference to an existing resource type ResourceReference struct { // REQUIRED; Resource id of an existing resource - ID *string `json:"id,omitempty"` + ID *string } // ResourceStatus - Status of a resource. type ResourceStatus struct { + // The compute resource associated with the resource. + Compute EnvironmentComputeClassification + // Properties of an output resource - OutputResources []map[string]interface{} `json:"outputResources,omitempty"` + OutputResources []*OutputResource } -// SQLDatabaseListSecretsResult - The secret values for the given SQL database resource +// SQLDatabaseListSecretsResult - The secret values for the given SqlDatabase resource type SQLDatabaseListSecretsResult struct { - // Connection string used to connect to the target SQL database - ConnectionString *string `json:"connectionString,omitempty"` + // Connection string used to connect to the target Sql database + ConnectionString *string - // Password to use when connecting to the target SQL database - Password *string `json:"password,omitempty"` + // Password to use when connecting to the target Sql database + Password *string } -// SQLDatabaseProperties - Sql database properties +// SQLDatabaseProperties - SqlDatabase properties type SQLDatabaseProperties struct { // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` + Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string - // The name of the SQL database. - Database *string `json:"database,omitempty"` + // The name of the Sql database. + Database *string - // Port value of the target SQL database - Port *int32 `json:"port,omitempty"` + // Port value of the target Sql database + Port *int32 - // The recipe used to automatically deploy underlying infrastructure for the SQL database portable resource - Recipe *Recipe `json:"recipe,omitempty"` + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning *ResourceProvisioning - // List of the resource IDs that support the SQL database resource - Resources []*ResourceReference `json:"resources,omitempty"` + // List of the resource IDs that support the SqlDatabase resource + Resources []*ResourceReference // Secret values provided for the resource - Secrets *SQLDatabaseSecrets `json:"secrets,omitempty"` + Secrets *SQLDatabaseSecrets - // The fully qualified domain name of the target SQL database. - Server *string `json:"server,omitempty"` + // The fully qualified domain name of the Sql database. + Server *string - // Username to use when connecting to the target SQL database - Username *string `json:"username,omitempty"` + // Username to use when connecting to the target Sql database + Username *string - // READ-ONLY; Provisioning state of the SQL database portable resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + Status *ResourceStatus } -// SQLDatabaseResource - Sql database portable resource +// SQLDatabaseResource - SqlDatabase portable resource type SQLDatabaseResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *SQLDatabaseProperties `json:"properties,omitempty"` + Properties *SQLDatabaseProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // SQLDatabaseResourceListResult - The response of a SqlDatabaseResource list operation. type SQLDatabaseResourceListResult struct { // REQUIRED; The SqlDatabaseResource items on this page - Value []*SQLDatabaseResource `json:"value,omitempty"` + Value []*SQLDatabaseResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// SQLDatabaseSecrets - The secret values for the given SQL database resource -type SQLDatabaseSecrets struct { - // Connection string used to connect to the target SQL database - ConnectionString *string `json:"connectionString,omitempty"` +// SQLDatabaseResourceUpdate - The type used for update operations of the SqlDatabaseResource. +type SQLDatabaseResourceUpdate struct { + // The updatable properties of the SqlDatabaseResource. + Properties *SQLDatabaseResourceUpdateProperties - // Password to use when connecting to the target SQL database - Password *string `json:"password,omitempty"` + // Resource tags. + Tags map[string]*string } -// SQLDatabasesClientCreateOrUpdateOptions contains the optional parameters for the SQLDatabasesClient.CreateOrUpdate method. -type SQLDatabasesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} +// SQLDatabaseResourceUpdateProperties - The updatable properties of the SqlDatabaseResource. +type SQLDatabaseResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string -// SQLDatabasesClientDeleteOptions contains the optional parameters for the SQLDatabasesClient.Delete method. -type SQLDatabasesClientDeleteOptions struct { - // placeholder for future optional parameters -} + // The name of the Sql database. + Database *string -// SQLDatabasesClientGetOptions contains the optional parameters for the SQLDatabasesClient.Get method. -type SQLDatabasesClientGetOptions struct { - // placeholder for future optional parameters -} + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string + + // Port value of the target Sql database + Port *int32 + + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning + + // List of the resource IDs that support the SqlDatabase resource + Resources []*ResourceReference -// SQLDatabasesClientListByRootScopeOptions contains the optional parameters for the SQLDatabasesClient.ListByRootScope method. -type SQLDatabasesClientListByRootScopeOptions struct { - // placeholder for future optional parameters + // Secret values provided for the resource + Secrets *SQLDatabaseSecrets + + // The fully qualified domain name of the Sql database. + Server *string + + // Username to use when connecting to the target Sql database + Username *string } -// SQLDatabasesClientListSecretsOptions contains the optional parameters for the SQLDatabasesClient.ListSecrets method. -type SQLDatabasesClientListSecretsOptions struct { - // placeholder for future optional parameters +// SQLDatabaseSecrets - The secret values for the given SqlDatabase resource +type SQLDatabaseSecrets struct { + // Connection string used to connect to the target Sql database + ConnectionString *string + + // Password to use when connecting to the target Sql database + Password *string } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAt *time.Time // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` + CreatedBy *string // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAt *time.Time // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedBy *string // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *CreatedByType } // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' // and a 'location' type TrackedResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models_serde.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models_serde.go index c6b3c18269..1d92cf1ddd 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models_serde.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_models_serde.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -15,75 +14,36 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type BasicDaprResourceProperties. -func (b BasicDaprResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "componentName", b.ComponentName) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) +// MarshalJSON implements the json.Marshaller interface for type EnvironmentCompute. +func (e EnvironmentCompute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", e.Identity) + objectMap["kind"] = e.Kind + populate(objectMap, "resourceId", e.ResourceID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicDaprResourceProperties. -func (b *BasicDaprResourceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentCompute. +func (e *EnvironmentCompute) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "componentName": - err = unpopulate(val, "ComponentName", &b.ComponentName) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type BasicResourceProperties. -func (b BasicResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicResourceProperties. -func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &e.ResourceID) + delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil @@ -91,7 +51,7 @@ func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -108,10 +68,10 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { switch key { case "info": err = unpopulate(val, "Info", &e.Info) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -122,7 +82,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -142,19 +102,19 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { switch key { case "additionalInfo": err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) - delete(rawMsg, key) + delete(rawMsg, key) case "code": err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) + delete(rawMsg, key) case "details": err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) + delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) + delete(rawMsg, key) case "target": err = unpopulate(val, "Target", &e.Target) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -165,7 +125,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -181,7 +141,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { switch key { case "error": err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -190,9 +150,83 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type IdentitySettings. +func (i IdentitySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "oidcIssuer", i.OidcIssuer) + populate(objectMap, "resource", i.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentitySettings. +func (i *IdentitySettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "oidcIssuer": + err = unpopulate(val, "OidcIssuer", &i.OidcIssuer) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &i.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesCompute. +func (k KubernetesCompute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", k.Identity) + objectMap["kind"] = "kubernetes" + populate(objectMap, "namespace", k.Namespace) + populate(objectMap, "resourceId", k.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesCompute. +func (k *KubernetesCompute) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &k.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &k.Kind) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &k.Namespace) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &k.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type MongoDatabaseListSecretsResult. func (m MongoDatabaseListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionString", m.ConnectionString) populate(objectMap, "password", m.Password) return json.Marshal(objectMap) @@ -209,10 +243,10 @@ func (m *MongoDatabaseListSecretsResult) UnmarshalJSON(data []byte) error { switch key { case "connectionString": err = unpopulate(val, "ConnectionString", &m.ConnectionString) - delete(rawMsg, key) + delete(rawMsg, key) case "password": err = unpopulate(val, "Password", &m.Password) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) @@ -223,7 +257,7 @@ func (m *MongoDatabaseListSecretsResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MongoDatabaseProperties. func (m MongoDatabaseProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "application", m.Application) populate(objectMap, "database", m.Database) populate(objectMap, "environment", m.Environment) @@ -250,40 +284,40 @@ func (m *MongoDatabaseProperties) UnmarshalJSON(data []byte) error { switch key { case "application": err = unpopulate(val, "Application", &m.Application) - delete(rawMsg, key) + delete(rawMsg, key) case "database": err = unpopulate(val, "Database", &m.Database) - delete(rawMsg, key) + delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &m.Environment) - delete(rawMsg, key) + delete(rawMsg, key) case "host": err = unpopulate(val, "Host", &m.Host) - delete(rawMsg, key) + delete(rawMsg, key) case "port": err = unpopulate(val, "Port", &m.Port) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "recipe": err = unpopulate(val, "Recipe", &m.Recipe) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProvisioning": err = unpopulate(val, "ResourceProvisioning", &m.ResourceProvisioning) - delete(rawMsg, key) + delete(rawMsg, key) case "resources": err = unpopulate(val, "Resources", &m.Resources) - delete(rawMsg, key) + delete(rawMsg, key) case "secrets": err = unpopulate(val, "Secrets", &m.Secrets) - delete(rawMsg, key) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &m.Status) - delete(rawMsg, key) + delete(rawMsg, key) case "username": err = unpopulate(val, "Username", &m.Username) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) @@ -294,7 +328,7 @@ func (m *MongoDatabaseProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MongoDatabaseResource. func (m MongoDatabaseResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "location", m.Location) populate(objectMap, "name", m.Name) @@ -316,25 +350,25 @@ func (m *MongoDatabaseResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &m.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &m.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &m.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &m.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &m.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &m.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &m.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) @@ -345,7 +379,7 @@ func (m *MongoDatabaseResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MongoDatabaseResourceListResult. func (m MongoDatabaseResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -362,10 +396,104 @@ func (m *MongoDatabaseResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &m.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &m.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MongoDatabaseResourceUpdate. +func (m MongoDatabaseResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "tags", m.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDatabaseResourceUpdate. +func (m *MongoDatabaseResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MongoDatabaseResourceUpdateProperties. +func (m MongoDatabaseResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", m.Application) + populate(objectMap, "database", m.Database) + populate(objectMap, "environment", m.Environment) + populate(objectMap, "host", m.Host) + populate(objectMap, "port", m.Port) + populate(objectMap, "recipe", m.Recipe) + populate(objectMap, "resourceProvisioning", m.ResourceProvisioning) + populate(objectMap, "resources", m.Resources) + populate(objectMap, "secrets", m.Secrets) + populate(objectMap, "username", m.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDatabaseResourceUpdateProperties. +func (m *MongoDatabaseResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &m.Application) + delete(rawMsg, key) + case "database": + err = unpopulate(val, "Database", &m.Database) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &m.Environment) + delete(rawMsg, key) + case "host": + err = unpopulate(val, "Host", &m.Host) + delete(rawMsg, key) + case "port": + err = unpopulate(val, "Port", &m.Port) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &m.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &m.ResourceProvisioning) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &m.Resources) + delete(rawMsg, key) + case "secrets": + err = unpopulate(val, "Secrets", &m.Secrets) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &m.Username) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) @@ -376,7 +504,7 @@ func (m *MongoDatabaseResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MongoDatabaseSecrets. func (m MongoDatabaseSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionString", m.ConnectionString) populate(objectMap, "password", m.Password) return json.Marshal(objectMap) @@ -393,10 +521,10 @@ func (m *MongoDatabaseSecrets) UnmarshalJSON(data []byte) error { switch key { case "connectionString": err = unpopulate(val, "ConnectionString", &m.ConnectionString) - delete(rawMsg, key) + delete(rawMsg, key) case "password": err = unpopulate(val, "Password", &m.Password) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) @@ -407,7 +535,7 @@ func (m *MongoDatabaseSecrets) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) @@ -427,19 +555,19 @@ func (o *Operation) UnmarshalJSON(data []byte) error { switch key { case "actionType": err = unpopulate(val, "ActionType", &o.ActionType) - delete(rawMsg, key) + delete(rawMsg, key) case "display": err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) + delete(rawMsg, key) case "isDataAction": err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "origin": err = unpopulate(val, "Origin", &o.Origin) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -450,7 +578,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -469,16 +597,16 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { switch key { case "description": err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) + delete(rawMsg, key) case "operation": err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) + delete(rawMsg, key) case "provider": err = unpopulate(val, "Provider", &o.Provider) - delete(rawMsg, key) + delete(rawMsg, key) case "resource": err = unpopulate(val, "Resource", &o.Resource) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -489,7 +617,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -506,10 +634,45 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &o.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OutputResource. +func (o OutputResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "localId", o.LocalID) + populate(objectMap, "radiusManaged", o.RadiusManaged) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OutputResource. +func (o *OutputResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "localId": + err = unpopulate(val, "LocalID", &o.LocalID) + delete(rawMsg, key) + case "radiusManaged": + err = unpopulate(val, "RadiusManaged", &o.RadiusManaged) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -520,7 +683,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Recipe. func (r Recipe) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", r.Name) populate(objectMap, "parameters", r.Parameters) return json.Marshal(objectMap) @@ -537,10 +700,41 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { switch key { case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecipeUpdate. +func (r RecipeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "parameters", r.Parameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeUpdate. +func (r *RecipeUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) case "parameters": err = unpopulate(val, "Parameters", &r.Parameters) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -551,7 +745,7 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RedisCacheListSecretsResult. func (r RedisCacheListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionString", r.ConnectionString) populate(objectMap, "password", r.Password) populate(objectMap, "url", r.URL) @@ -569,13 +763,13 @@ func (r *RedisCacheListSecretsResult) UnmarshalJSON(data []byte) error { switch key { case "connectionString": err = unpopulate(val, "ConnectionString", &r.ConnectionString) - delete(rawMsg, key) + delete(rawMsg, key) case "password": err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) + delete(rawMsg, key) case "url": err = unpopulate(val, "URL", &r.URL) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -586,7 +780,7 @@ func (r *RedisCacheListSecretsResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RedisCacheProperties. func (r RedisCacheProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "application", r.Application) populate(objectMap, "environment", r.Environment) populate(objectMap, "host", r.Host) @@ -613,40 +807,40 @@ func (r *RedisCacheProperties) UnmarshalJSON(data []byte) error { switch key { case "application": err = unpopulate(val, "Application", &r.Application) - delete(rawMsg, key) + delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &r.Environment) - delete(rawMsg, key) + delete(rawMsg, key) case "host": err = unpopulate(val, "Host", &r.Host) - delete(rawMsg, key) + delete(rawMsg, key) case "port": err = unpopulate(val, "Port", &r.Port) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "recipe": err = unpopulate(val, "Recipe", &r.Recipe) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProvisioning": err = unpopulate(val, "ResourceProvisioning", &r.ResourceProvisioning) - delete(rawMsg, key) + delete(rawMsg, key) case "resources": err = unpopulate(val, "Resources", &r.Resources) - delete(rawMsg, key) + delete(rawMsg, key) case "secrets": err = unpopulate(val, "Secrets", &r.Secrets) - delete(rawMsg, key) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &r.Status) - delete(rawMsg, key) + delete(rawMsg, key) case "tls": err = unpopulate(val, "TLS", &r.TLS) - delete(rawMsg, key) + delete(rawMsg, key) case "username": err = unpopulate(val, "Username", &r.Username) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -657,7 +851,7 @@ func (r *RedisCacheProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RedisCacheResource. func (r RedisCacheResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "location", r.Location) populate(objectMap, "name", r.Name) @@ -679,25 +873,25 @@ func (r *RedisCacheResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &r.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &r.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &r.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -708,7 +902,7 @@ func (r *RedisCacheResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RedisCacheResourceListResult. func (r RedisCacheResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -725,10 +919,104 @@ func (r *RedisCacheResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &r.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &r.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RedisCacheResourceUpdate. +func (r RedisCacheResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RedisCacheResourceUpdate. +func (r *RedisCacheResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RedisCacheResourceUpdateProperties. +func (r RedisCacheResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", r.Application) + populate(objectMap, "environment", r.Environment) + populate(objectMap, "host", r.Host) + populate(objectMap, "port", r.Port) + populate(objectMap, "recipe", r.Recipe) + populate(objectMap, "resourceProvisioning", r.ResourceProvisioning) + populate(objectMap, "resources", r.Resources) + populate(objectMap, "secrets", r.Secrets) + populate(objectMap, "tls", r.TLS) + populate(objectMap, "username", r.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RedisCacheResourceUpdateProperties. +func (r *RedisCacheResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &r.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &r.Environment) + delete(rawMsg, key) + case "host": + err = unpopulate(val, "Host", &r.Host) + delete(rawMsg, key) + case "port": + err = unpopulate(val, "Port", &r.Port) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &r.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &r.ResourceProvisioning) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &r.Resources) + delete(rawMsg, key) + case "secrets": + err = unpopulate(val, "Secrets", &r.Secrets) + delete(rawMsg, key) + case "tls": + err = unpopulate(val, "TLS", &r.TLS) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &r.Username) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -739,7 +1027,7 @@ func (r *RedisCacheResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RedisCacheSecrets. func (r RedisCacheSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionString", r.ConnectionString) populate(objectMap, "password", r.Password) populate(objectMap, "url", r.URL) @@ -757,13 +1045,13 @@ func (r *RedisCacheSecrets) UnmarshalJSON(data []byte) error { switch key { case "connectionString": err = unpopulate(val, "ConnectionString", &r.ConnectionString) - delete(rawMsg, key) + delete(rawMsg, key) case "password": err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) + delete(rawMsg, key) case "url": err = unpopulate(val, "URL", &r.URL) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -774,7 +1062,7 @@ func (r *RedisCacheSecrets) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "systemData", r.SystemData) @@ -793,16 +1081,16 @@ func (r *Resource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -813,7 +1101,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceReference. func (r ResourceReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) return json.Marshal(objectMap) } @@ -829,7 +1117,7 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -840,7 +1128,8 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceStatus. func (r ResourceStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) + populate(objectMap, "compute", r.Compute) populate(objectMap, "outputResources", r.OutputResources) return json.Marshal(objectMap) } @@ -854,9 +1143,12 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "compute": + r.Compute, err = unmarshalEnvironmentComputeClassification(val) + delete(rawMsg, key) case "outputResources": err = unpopulate(val, "OutputResources", &r.OutputResources) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -867,7 +1159,7 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SQLDatabaseListSecretsResult. func (s SQLDatabaseListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionString", s.ConnectionString) populate(objectMap, "password", s.Password) return json.Marshal(objectMap) @@ -884,10 +1176,10 @@ func (s *SQLDatabaseListSecretsResult) UnmarshalJSON(data []byte) error { switch key { case "connectionString": err = unpopulate(val, "ConnectionString", &s.ConnectionString) - delete(rawMsg, key) + delete(rawMsg, key) case "password": err = unpopulate(val, "Password", &s.Password) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -898,7 +1190,7 @@ func (s *SQLDatabaseListSecretsResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SQLDatabaseProperties. func (s SQLDatabaseProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "application", s.Application) populate(objectMap, "database", s.Database) populate(objectMap, "environment", s.Environment) @@ -925,40 +1217,40 @@ func (s *SQLDatabaseProperties) UnmarshalJSON(data []byte) error { switch key { case "application": err = unpopulate(val, "Application", &s.Application) - delete(rawMsg, key) + delete(rawMsg, key) case "database": err = unpopulate(val, "Database", &s.Database) - delete(rawMsg, key) + delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &s.Environment) - delete(rawMsg, key) + delete(rawMsg, key) case "port": err = unpopulate(val, "Port", &s.Port) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "recipe": err = unpopulate(val, "Recipe", &s.Recipe) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProvisioning": err = unpopulate(val, "ResourceProvisioning", &s.ResourceProvisioning) - delete(rawMsg, key) + delete(rawMsg, key) case "resources": err = unpopulate(val, "Resources", &s.Resources) - delete(rawMsg, key) + delete(rawMsg, key) case "secrets": err = unpopulate(val, "Secrets", &s.Secrets) - delete(rawMsg, key) + delete(rawMsg, key) case "server": err = unpopulate(val, "Server", &s.Server) - delete(rawMsg, key) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &s.Status) - delete(rawMsg, key) + delete(rawMsg, key) case "username": err = unpopulate(val, "Username", &s.Username) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -969,7 +1261,7 @@ func (s *SQLDatabaseProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SQLDatabaseResource. func (s SQLDatabaseResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "location", s.Location) populate(objectMap, "name", s.Name) @@ -991,25 +1283,25 @@ func (s *SQLDatabaseResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &s.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &s.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &s.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &s.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &s.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &s.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &s.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -1020,7 +1312,7 @@ func (s *SQLDatabaseResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SQLDatabaseResourceListResult. func (s SQLDatabaseResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -1037,10 +1329,104 @@ func (s *SQLDatabaseResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &s.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &s.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SQLDatabaseResourceUpdate. +func (s SQLDatabaseResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SQLDatabaseResourceUpdate. +func (s *SQLDatabaseResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SQLDatabaseResourceUpdateProperties. +func (s SQLDatabaseResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", s.Application) + populate(objectMap, "database", s.Database) + populate(objectMap, "environment", s.Environment) + populate(objectMap, "port", s.Port) + populate(objectMap, "recipe", s.Recipe) + populate(objectMap, "resourceProvisioning", s.ResourceProvisioning) + populate(objectMap, "resources", s.Resources) + populate(objectMap, "secrets", s.Secrets) + populate(objectMap, "server", s.Server) + populate(objectMap, "username", s.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SQLDatabaseResourceUpdateProperties. +func (s *SQLDatabaseResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &s.Application) + delete(rawMsg, key) + case "database": + err = unpopulate(val, "Database", &s.Database) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &s.Environment) + delete(rawMsg, key) + case "port": + err = unpopulate(val, "Port", &s.Port) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &s.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &s.ResourceProvisioning) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &s.Resources) + delete(rawMsg, key) + case "secrets": + err = unpopulate(val, "Secrets", &s.Secrets) + delete(rawMsg, key) + case "server": + err = unpopulate(val, "Server", &s.Server) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &s.Username) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -1051,7 +1437,7 @@ func (s *SQLDatabaseResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SQLDatabaseSecrets. func (s SQLDatabaseSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "connectionString", s.ConnectionString) populate(objectMap, "password", s.Password) return json.Marshal(objectMap) @@ -1068,10 +1454,10 @@ func (s *SQLDatabaseSecrets) UnmarshalJSON(data []byte) error { switch key { case "connectionString": err = unpopulate(val, "ConnectionString", &s.ConnectionString) - delete(rawMsg, key) + delete(rawMsg, key) case "password": err = unpopulate(val, "Password", &s.Password) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -1082,7 +1468,7 @@ func (s *SQLDatabaseSecrets) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -1103,22 +1489,22 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { switch key { case "createdAt": err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "createdByType": err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedAt": err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedByType": err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -1129,7 +1515,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -1150,22 +1536,22 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &t.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -1174,7 +1560,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -1184,7 +1570,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_mongodatabases_client.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_mongodatabases_client.go index 6a53129292..41037e6aca 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_mongodatabases_client.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_mongodatabases_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -13,79 +12,91 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) // MongoDatabasesClient contains the methods for the MongoDatabases group. // Don't use this type directly, use NewMongoDatabasesClient() instead. type MongoDatabasesClient struct { - host string + internal *arm.Client rootScope string - pl runtime.Pipeline } // NewMongoDatabasesClient creates a new instance of MongoDatabasesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMongoDatabasesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MongoDatabasesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MongoDatabasesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MongoDatabasesClient{ rootScope: rootScope, - host: ep, -pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or updates a MongoDatabaseResource +// BeginCreateOrUpdate - Create a MongoDatabaseResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - mongoDatabaseName - The name of the MongoDatabase portable resource resource +// - resource - Resource create parameters. +// - options - MongoDatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the MongoDatabasesClient.BeginCreateOrUpdate +// method. +func (client *MongoDatabasesClient) BeginCreateOrUpdate(ctx context.Context, mongoDatabaseName string, resource MongoDatabaseResource, options *MongoDatabasesClientBeginCreateOrUpdateOptions) (*runtime.Poller[MongoDatabasesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, mongoDatabaseName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MongoDatabasesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[MongoDatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a MongoDatabaseResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the Mongo database portable resource -// resource - Resource create parameters. -// options - MongoDatabasesClientCreateOrUpdateOptions contains the optional parameters for the MongoDatabasesClient.CreateOrUpdate -// method. -func (client *MongoDatabasesClient) CreateOrUpdate(ctx context.Context, mongoDatabaseName string, resource MongoDatabaseResource, options *MongoDatabasesClientCreateOrUpdateOptions) (MongoDatabasesClientCreateOrUpdateResponse, error) { +func (client *MongoDatabasesClient) createOrUpdate(ctx context.Context, mongoDatabaseName string, resource MongoDatabaseResource, options *MongoDatabasesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, mongoDatabaseName, resource, options) if err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return MongoDatabasesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.createOrUpdateHandleResponse(resp) + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *MongoDatabasesClient) createOrUpdateCreateRequest(ctx context.Context, mongoDatabaseName string, resource MongoDatabaseResource, options *MongoDatabasesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *MongoDatabasesClient) createOrUpdateCreateRequest(ctx context.Context, mongoDatabaseName string, resource MongoDatabaseResource, options *MongoDatabasesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/mongoDatabases/{mongoDatabaseName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if mongoDatabaseName == "" { return nil, errors.New("parameter mongoDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -93,62 +104,53 @@ func (client *MongoDatabasesClient) createOrUpdateCreateRequest(ctx context.Cont reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err } - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *MongoDatabasesClient) createOrUpdateHandleResponse(resp *http.Response) (MongoDatabasesClientCreateOrUpdateResponse, error) { - result := MongoDatabasesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.MongoDatabaseResource); err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err - } - return result, nil + return req, nil } -// BeginDelete - Deletes an existing MongoDatabaseResource +// BeginDelete - Delete a MongoDatabaseResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the Mongo database portable resource -// options - MongoDatabasesClientBeginDeleteOptions contains the optional parameters for the MongoDatabasesClient.BeginDelete -// method. +// - mongoDatabaseName - The name of the MongoDatabase portable resource resource +// - options - MongoDatabasesClientBeginDeleteOptions contains the optional parameters for the MongoDatabasesClient.BeginDelete +// method. func (client *MongoDatabasesClient) BeginDelete(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientBeginDeleteOptions) (*runtime.Poller[MongoDatabasesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, mongoDatabaseName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MongoDatabasesClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MongoDatabasesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MongoDatabasesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MongoDatabasesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } -// Delete - Deletes an existing MongoDatabaseResource +// Delete - Delete a MongoDatabaseResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview func (client *MongoDatabasesClient) deleteOperation(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, mongoDatabaseName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -159,7 +161,7 @@ func (client *MongoDatabasesClient) deleteCreateRequest(ctx context.Context, mon return nil, errors.New("parameter mongoDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -170,24 +172,28 @@ func (client *MongoDatabasesClient) deleteCreateRequest(ctx context.Context, mon return req, nil } -// Get - Retrieves information about a MongoDatabaseResource +// Get - Get a MongoDatabaseResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the Mongo database portable resource -// options - MongoDatabasesClientGetOptions contains the optional parameters for the MongoDatabasesClient.Get method. +// - mongoDatabaseName - The name of the MongoDatabase portable resource resource +// - options - MongoDatabasesClientGetOptions contains the optional parameters for the MongoDatabasesClient.Get method. func (client *MongoDatabasesClient) Get(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientGetOptions) (MongoDatabasesClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, mongoDatabaseName, options) if err != nil { return MongoDatabasesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MongoDatabasesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MongoDatabasesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MongoDatabasesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -198,7 +204,7 @@ func (client *MongoDatabasesClient) getCreateRequest(ctx context.Context, mongoD return nil, errors.New("parameter mongoDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -218,43 +224,44 @@ func (client *MongoDatabasesClient) getHandleResponse(resp *http.Response) (Mong return result, nil } -// NewListByRootScopePager - Lists information about all MongoDatabaseResources in the given root scope +// NewListByScopePager - List MongoDatabaseResource resources by Scope +// // Generated from API version 2022-03-15-privatepreview -// options - MongoDatabasesClientListByRootScopeOptions contains the optional parameters for the MongoDatabasesClient.ListByRootScope -// method. -func (client *MongoDatabasesClient) NewListByRootScopePager(options *MongoDatabasesClientListByRootScopeOptions) (*runtime.Pager[MongoDatabasesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[MongoDatabasesClientListByRootScopeResponse]{ - More: func(page MongoDatabasesClientListByRootScopeResponse) bool { +// - options - MongoDatabasesClientListByScopeOptions contains the optional parameters for the MongoDatabasesClient.NewListByScopePager +// method. +func (client *MongoDatabasesClient) NewListByScopePager(options *MongoDatabasesClientListByScopeOptions) (*runtime.Pager[MongoDatabasesClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[MongoDatabasesClientListByScopeResponse]{ + More: func(page MongoDatabasesClientListByScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *MongoDatabasesClientListByRootScopeResponse) (MongoDatabasesClientListByRootScopeResponse, error) { + Fetcher: func(ctx context.Context, page *MongoDatabasesClientListByScopeResponse) (MongoDatabasesClientListByScopeResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) + req, err = client.listByScopeCreateRequest(ctx, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return MongoDatabasesClientListByRootScopeResponse{}, err + return MongoDatabasesClientListByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return MongoDatabasesClientListByRootScopeResponse{}, err + return MongoDatabasesClientListByScopeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return MongoDatabasesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) + return MongoDatabasesClientListByScopeResponse{}, runtime.NewResponseError(resp) } - return client.listByRootScopeHandleResponse(resp) + return client.listByScopeHandleResponse(resp) }, }) } -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *MongoDatabasesClient) listByRootScopeCreateRequest(ctx context.Context, options *MongoDatabasesClientListByRootScopeOptions) (*policy.Request, error) { +// listByScopeCreateRequest creates the ListByScope request. +func (client *MongoDatabasesClient) listByScopeCreateRequest(ctx context.Context, options *MongoDatabasesClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/mongoDatabases" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -265,45 +272,50 @@ func (client *MongoDatabasesClient) listByRootScopeCreateRequest(ctx context.Con return req, nil } -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *MongoDatabasesClient) listByRootScopeHandleResponse(resp *http.Response) (MongoDatabasesClientListByRootScopeResponse, error) { - result := MongoDatabasesClientListByRootScopeResponse{} +// listByScopeHandleResponse handles the ListByScope response. +func (client *MongoDatabasesClient) listByScopeHandleResponse(resp *http.Response) (MongoDatabasesClientListByScopeResponse, error) { + result := MongoDatabasesClientListByScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.MongoDatabaseResourceListResult); err != nil { - return MongoDatabasesClientListByRootScopeResponse{}, err + return MongoDatabasesClientListByScopeResponse{}, err } return result, nil } -// ListSecrets - Lists secrets values for the specified Mongo database resource +// ListSecrets - Lists secrets values for the specified MongoDatabases resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the Mongo database portable resource -// options - MongoDatabasesClientListSecretsOptions contains the optional parameters for the MongoDatabasesClient.ListSecrets -// method. -func (client *MongoDatabasesClient) ListSecrets(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientListSecretsOptions) (MongoDatabasesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, mongoDatabaseName, options) +// - mongoDatabaseName - The name of the MongoDatabase portable resource resource +// - body - The content of the action request +// - options - MongoDatabasesClientListSecretsOptions contains the optional parameters for the MongoDatabasesClient.ListSecrets +// method. +func (client *MongoDatabasesClient) ListSecrets(ctx context.Context, mongoDatabaseName string, body map[string]any, options *MongoDatabasesClientListSecretsOptions) (MongoDatabasesClientListSecretsResponse, error) { + var err error + req, err := client.listSecretsCreateRequest(ctx, mongoDatabaseName, body, options) if err != nil { return MongoDatabasesClientListSecretsResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MongoDatabasesClientListSecretsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MongoDatabasesClientListSecretsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MongoDatabasesClientListSecretsResponse{}, err } - return client.listSecretsHandleResponse(resp) + resp, err := client.listSecretsHandleResponse(httpResp) + return resp, err } // listSecretsCreateRequest creates the ListSecrets request. -func (client *MongoDatabasesClient) listSecretsCreateRequest(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientListSecretsOptions) (*policy.Request, error) { +func (client *MongoDatabasesClient) listSecretsCreateRequest(ctx context.Context, mongoDatabaseName string, body map[string]any, options *MongoDatabasesClientListSecretsOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/mongoDatabases/{mongoDatabaseName}/listSecrets" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if mongoDatabaseName == "" { return nil, errors.New("parameter mongoDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -311,6 +323,9 @@ func (client *MongoDatabasesClient) listSecretsCreateRequest(ctx context.Context reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err +} return req, nil } @@ -323,3 +338,69 @@ func (client *MongoDatabasesClient) listSecretsHandleResponse(resp *http.Respons return result, nil } +// BeginUpdate - Update a MongoDatabaseResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - mongoDatabaseName - The name of the MongoDatabase portable resource resource +// - properties - The resource properties to be updated. +// - options - MongoDatabasesClientBeginUpdateOptions contains the optional parameters for the MongoDatabasesClient.BeginUpdate +// method. +func (client *MongoDatabasesClient) BeginUpdate(ctx context.Context, mongoDatabaseName string, properties MongoDatabaseResourceUpdate, options *MongoDatabasesClientBeginUpdateOptions) (*runtime.Poller[MongoDatabasesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, mongoDatabaseName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MongoDatabasesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[MongoDatabasesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a MongoDatabaseResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *MongoDatabasesClient) update(ctx context.Context, mongoDatabaseName string, properties MongoDatabaseResourceUpdate, options *MongoDatabasesClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, mongoDatabaseName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *MongoDatabasesClient) updateCreateRequest(ctx context.Context, mongoDatabaseName string, properties MongoDatabaseResourceUpdate, options *MongoDatabasesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Datastores/mongoDatabases/{mongoDatabaseName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if mongoDatabaseName == "" { + return nil, errors.New("parameter mongoDatabaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_operations_client.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_operations_client.go index 12faffca8c..fb8362f3a5 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_operations_client.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_operations_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -12,8 +11,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,35 +19,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, -pl: pl, + internal: cl, } return client, nil } // NewListPager - List the operations for the provider +// // Generated from API version 2022-03-15-privatepreview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) (*runtime.Pager[OperationsClientListResponse]) { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -67,7 +56,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -82,7 +71,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Applications.Datastores/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_options.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_options.go new file mode 100644 index 0000000000..e7dcc2d24f --- /dev/null +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_options.go @@ -0,0 +1,117 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +// MongoDatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the MongoDatabasesClient.BeginCreateOrUpdate +// method. +type MongoDatabasesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MongoDatabasesClientBeginDeleteOptions contains the optional parameters for the MongoDatabasesClient.BeginDelete method. +type MongoDatabasesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MongoDatabasesClientBeginUpdateOptions contains the optional parameters for the MongoDatabasesClient.BeginUpdate method. +type MongoDatabasesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MongoDatabasesClientGetOptions contains the optional parameters for the MongoDatabasesClient.Get method. +type MongoDatabasesClientGetOptions struct { + // placeholder for future optional parameters +} + +// MongoDatabasesClientListByScopeOptions contains the optional parameters for the MongoDatabasesClient.NewListByScopePager +// method. +type MongoDatabasesClientListByScopeOptions struct { + // placeholder for future optional parameters +} + +// MongoDatabasesClientListSecretsOptions contains the optional parameters for the MongoDatabasesClient.ListSecrets method. +type MongoDatabasesClientListSecretsOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// RedisCachesClientBeginCreateOrUpdateOptions contains the optional parameters for the RedisCachesClient.BeginCreateOrUpdate +// method. +type RedisCachesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RedisCachesClientBeginDeleteOptions contains the optional parameters for the RedisCachesClient.BeginDelete method. +type RedisCachesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RedisCachesClientBeginUpdateOptions contains the optional parameters for the RedisCachesClient.BeginUpdate method. +type RedisCachesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RedisCachesClientGetOptions contains the optional parameters for the RedisCachesClient.Get method. +type RedisCachesClientGetOptions struct { + // placeholder for future optional parameters +} + +// RedisCachesClientListByScopeOptions contains the optional parameters for the RedisCachesClient.NewListByScopePager method. +type RedisCachesClientListByScopeOptions struct { + // placeholder for future optional parameters +} + +// RedisCachesClientListSecretsOptions contains the optional parameters for the RedisCachesClient.ListSecrets method. +type RedisCachesClientListSecretsOptions struct { + // placeholder for future optional parameters +} + +// SQLDatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the SQLDatabasesClient.BeginCreateOrUpdate +// method. +type SQLDatabasesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SQLDatabasesClientBeginDeleteOptions contains the optional parameters for the SQLDatabasesClient.BeginDelete method. +type SQLDatabasesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SQLDatabasesClientBeginUpdateOptions contains the optional parameters for the SQLDatabasesClient.BeginUpdate method. +type SQLDatabasesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SQLDatabasesClientGetOptions contains the optional parameters for the SQLDatabasesClient.Get method. +type SQLDatabasesClientGetOptions struct { + // placeholder for future optional parameters +} + +// SQLDatabasesClientListByScopeOptions contains the optional parameters for the SQLDatabasesClient.NewListByScopePager method. +type SQLDatabasesClientListByScopeOptions struct { + // placeholder for future optional parameters +} + +// SQLDatabasesClientListSecretsOptions contains the optional parameters for the SQLDatabasesClient.ListSecrets method. +type SQLDatabasesClientListSecretsOptions struct { + // placeholder for future optional parameters +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go new file mode 100644 index 0000000000..83f13ff53e --- /dev/null +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go @@ -0,0 +1,32 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import "encoding/json" + +func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (EnvironmentComputeClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b EnvironmentComputeClassification + switch m["kind"] { + case "kubernetes": + b = &KubernetesCompute{} + default: + b = &EnvironmentCompute{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_rediscaches_client.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_rediscaches_client.go index b275958abf..5966046dea 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_rediscaches_client.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_rediscaches_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -13,79 +12,91 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) // RedisCachesClient contains the methods for the RedisCaches group. // Don't use this type directly, use NewRedisCachesClient() instead. type RedisCachesClient struct { - host string + internal *arm.Client rootScope string - pl runtime.Pipeline } // NewRedisCachesClient creates a new instance of RedisCachesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRedisCachesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RedisCachesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RedisCachesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RedisCachesClient{ rootScope: rootScope, - host: ep, -pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or updates a RedisCacheResource +// BeginCreateOrUpdate - Create a RedisCacheResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - redisCacheName - The name of the RedisCache portable resource resource +// - resource - Resource create parameters. +// - options - RedisCachesClientBeginCreateOrUpdateOptions contains the optional parameters for the RedisCachesClient.BeginCreateOrUpdate +// method. +func (client *RedisCachesClient) BeginCreateOrUpdate(ctx context.Context, redisCacheName string, resource RedisCacheResource, options *RedisCachesClientBeginCreateOrUpdateOptions) (*runtime.Poller[RedisCachesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, redisCacheName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RedisCachesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[RedisCachesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a RedisCacheResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the Redis cache portable resource -// resource - Resource create parameters. -// options - RedisCachesClientCreateOrUpdateOptions contains the optional parameters for the RedisCachesClient.CreateOrUpdate -// method. -func (client *RedisCachesClient) CreateOrUpdate(ctx context.Context, redisCacheName string, resource RedisCacheResource, options *RedisCachesClientCreateOrUpdateOptions) (RedisCachesClientCreateOrUpdateResponse, error) { +func (client *RedisCachesClient) createOrUpdate(ctx context.Context, redisCacheName string, resource RedisCacheResource, options *RedisCachesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, redisCacheName, resource, options) if err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return RedisCachesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.createOrUpdateHandleResponse(resp) + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *RedisCachesClient) createOrUpdateCreateRequest(ctx context.Context, redisCacheName string, resource RedisCacheResource, options *RedisCachesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *RedisCachesClient) createOrUpdateCreateRequest(ctx context.Context, redisCacheName string, resource RedisCacheResource, options *RedisCachesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/redisCaches/{redisCacheName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if redisCacheName == "" { return nil, errors.New("parameter redisCacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -93,55 +104,63 @@ func (client *RedisCachesClient) createOrUpdateCreateRequest(ctx context.Context reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *RedisCachesClient) createOrUpdateHandleResponse(resp *http.Response) (RedisCachesClientCreateOrUpdateResponse, error) { - result := RedisCachesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) +// BeginDelete - Delete a RedisCacheResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - redisCacheName - The name of the RedisCache portable resource resource +// - options - RedisCachesClientBeginDeleteOptions contains the optional parameters for the RedisCachesClient.BeginDelete method. +func (client *RedisCachesClient) BeginDelete(ctx context.Context, redisCacheName string, options *RedisCachesClientBeginDeleteOptions) (*runtime.Poller[RedisCachesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, redisCacheName, options) if err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err + return nil, err } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.RedisCacheResource); err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RedisCachesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[RedisCachesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Deletes an existing RedisCacheResource +// Delete - Delete a RedisCacheResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the Redis cache portable resource -// options - RedisCachesClientDeleteOptions contains the optional parameters for the RedisCachesClient.Delete method. -func (client *RedisCachesClient) Delete(ctx context.Context, redisCacheName string, options *RedisCachesClientDeleteOptions) (RedisCachesClientDeleteResponse, error) { +func (client *RedisCachesClient) deleteOperation(ctx context.Context, redisCacheName string, options *RedisCachesClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, redisCacheName, options) if err != nil { - return RedisCachesClientDeleteResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RedisCachesClientDeleteResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return RedisCachesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.deleteHandleResponse(resp) + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *RedisCachesClient) deleteCreateRequest(ctx context.Context, redisCacheName string, options *RedisCachesClientDeleteOptions) (*policy.Request, error) { +func (client *RedisCachesClient) deleteCreateRequest(ctx context.Context, redisCacheName string, options *RedisCachesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/redisCaches/{redisCacheName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if redisCacheName == "" { return nil, errors.New("parameter redisCacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -152,38 +171,28 @@ func (client *RedisCachesClient) deleteCreateRequest(ctx context.Context, redisC return req, nil } -// deleteHandleResponse handles the Delete response. -func (client *RedisCachesClient) deleteHandleResponse(resp *http.Response) (RedisCachesClientDeleteResponse, error) { - result := RedisCachesClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return RedisCachesClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a RedisCacheResource +// Get - Get a RedisCacheResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the Redis cache portable resource -// options - RedisCachesClientGetOptions contains the optional parameters for the RedisCachesClient.Get method. +// - redisCacheName - The name of the RedisCache portable resource resource +// - options - RedisCachesClientGetOptions contains the optional parameters for the RedisCachesClient.Get method. func (client *RedisCachesClient) Get(ctx context.Context, redisCacheName string, options *RedisCachesClientGetOptions) (RedisCachesClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, redisCacheName, options) if err != nil { return RedisCachesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RedisCachesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RedisCachesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RedisCachesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -194,7 +203,7 @@ func (client *RedisCachesClient) getCreateRequest(ctx context.Context, redisCach return nil, errors.New("parameter redisCacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -214,43 +223,44 @@ func (client *RedisCachesClient) getHandleResponse(resp *http.Response) (RedisCa return result, nil } -// NewListByRootScopePager - Lists information about all RedisCacheResources in the given root scope +// NewListByScopePager - List RedisCacheResource resources by Scope +// // Generated from API version 2022-03-15-privatepreview -// options - RedisCachesClientListByRootScopeOptions contains the optional parameters for the RedisCachesClient.ListByRootScope -// method. -func (client *RedisCachesClient) NewListByRootScopePager(options *RedisCachesClientListByRootScopeOptions) (*runtime.Pager[RedisCachesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[RedisCachesClientListByRootScopeResponse]{ - More: func(page RedisCachesClientListByRootScopeResponse) bool { +// - options - RedisCachesClientListByScopeOptions contains the optional parameters for the RedisCachesClient.NewListByScopePager +// method. +func (client *RedisCachesClient) NewListByScopePager(options *RedisCachesClientListByScopeOptions) (*runtime.Pager[RedisCachesClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[RedisCachesClientListByScopeResponse]{ + More: func(page RedisCachesClientListByScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *RedisCachesClientListByRootScopeResponse) (RedisCachesClientListByRootScopeResponse, error) { + Fetcher: func(ctx context.Context, page *RedisCachesClientListByScopeResponse) (RedisCachesClientListByScopeResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) + req, err = client.listByScopeCreateRequest(ctx, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return RedisCachesClientListByRootScopeResponse{}, err + return RedisCachesClientListByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return RedisCachesClientListByRootScopeResponse{}, err + return RedisCachesClientListByScopeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return RedisCachesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) + return RedisCachesClientListByScopeResponse{}, runtime.NewResponseError(resp) } - return client.listByRootScopeHandleResponse(resp) + return client.listByScopeHandleResponse(resp) }, }) } -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *RedisCachesClient) listByRootScopeCreateRequest(ctx context.Context, options *RedisCachesClientListByRootScopeOptions) (*policy.Request, error) { +// listByScopeCreateRequest creates the ListByScope request. +func (client *RedisCachesClient) listByScopeCreateRequest(ctx context.Context, options *RedisCachesClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/redisCaches" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -261,44 +271,49 @@ func (client *RedisCachesClient) listByRootScopeCreateRequest(ctx context.Contex return req, nil } -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *RedisCachesClient) listByRootScopeHandleResponse(resp *http.Response) (RedisCachesClientListByRootScopeResponse, error) { - result := RedisCachesClientListByRootScopeResponse{} +// listByScopeHandleResponse handles the ListByScope response. +func (client *RedisCachesClient) listByScopeHandleResponse(resp *http.Response) (RedisCachesClientListByScopeResponse, error) { + result := RedisCachesClientListByScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.RedisCacheResourceListResult); err != nil { - return RedisCachesClientListByRootScopeResponse{}, err + return RedisCachesClientListByScopeResponse{}, err } return result, nil } -// ListSecrets - Lists secrets values for the specified Redis cache resource +// ListSecrets - Lists secrets values for the specified RedisCache resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the Redis cache portable resource -// options - RedisCachesClientListSecretsOptions contains the optional parameters for the RedisCachesClient.ListSecrets method. -func (client *RedisCachesClient) ListSecrets(ctx context.Context, redisCacheName string, options *RedisCachesClientListSecretsOptions) (RedisCachesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, redisCacheName, options) +// - redisCacheName - The name of the RedisCache portable resource resource +// - body - The content of the action request +// - options - RedisCachesClientListSecretsOptions contains the optional parameters for the RedisCachesClient.ListSecrets method. +func (client *RedisCachesClient) ListSecrets(ctx context.Context, redisCacheName string, body map[string]any, options *RedisCachesClientListSecretsOptions) (RedisCachesClientListSecretsResponse, error) { + var err error + req, err := client.listSecretsCreateRequest(ctx, redisCacheName, body, options) if err != nil { return RedisCachesClientListSecretsResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RedisCachesClientListSecretsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RedisCachesClientListSecretsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RedisCachesClientListSecretsResponse{}, err } - return client.listSecretsHandleResponse(resp) + resp, err := client.listSecretsHandleResponse(httpResp) + return resp, err } // listSecretsCreateRequest creates the ListSecrets request. -func (client *RedisCachesClient) listSecretsCreateRequest(ctx context.Context, redisCacheName string, options *RedisCachesClientListSecretsOptions) (*policy.Request, error) { +func (client *RedisCachesClient) listSecretsCreateRequest(ctx context.Context, redisCacheName string, body map[string]any, options *RedisCachesClientListSecretsOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/redisCaches/{redisCacheName}/listSecrets" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if redisCacheName == "" { return nil, errors.New("parameter redisCacheName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -306,6 +321,9 @@ func (client *RedisCachesClient) listSecretsCreateRequest(ctx context.Context, r reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err +} return req, nil } @@ -318,3 +336,68 @@ func (client *RedisCachesClient) listSecretsHandleResponse(resp *http.Response) return result, nil } +// BeginUpdate - Update a RedisCacheResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - redisCacheName - The name of the RedisCache portable resource resource +// - properties - The resource properties to be updated. +// - options - RedisCachesClientBeginUpdateOptions contains the optional parameters for the RedisCachesClient.BeginUpdate method. +func (client *RedisCachesClient) BeginUpdate(ctx context.Context, redisCacheName string, properties RedisCacheResourceUpdate, options *RedisCachesClientBeginUpdateOptions) (*runtime.Poller[RedisCachesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, redisCacheName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RedisCachesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[RedisCachesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a RedisCacheResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *RedisCachesClient) update(ctx context.Context, redisCacheName string, properties RedisCacheResourceUpdate, options *RedisCachesClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, redisCacheName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *RedisCachesClient) updateCreateRequest(ctx context.Context, redisCacheName string, properties RedisCacheResourceUpdate, options *RedisCachesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Datastores/redisCaches/{redisCacheName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if redisCacheName == "" { + return nil, errors.New("parameter redisCacheName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_response_types.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_response_types.go index 4f6f944e57..6f319c8a24 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_response_types.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_response_types.go @@ -2,97 +2,119 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview -// MongoDatabasesClientCreateOrUpdateResponse contains the response from method MongoDatabasesClient.CreateOrUpdate. +// MongoDatabasesClientCreateOrUpdateResponse contains the response from method MongoDatabasesClient.BeginCreateOrUpdate. type MongoDatabasesClientCreateOrUpdateResponse struct { + // MongoDatabase portable resource MongoDatabaseResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// MongoDatabasesClientDeleteResponse contains the response from method MongoDatabasesClient.Delete. +// MongoDatabasesClientDeleteResponse contains the response from method MongoDatabasesClient.BeginDelete. type MongoDatabasesClientDeleteResponse struct { // placeholder for future response values } // MongoDatabasesClientGetResponse contains the response from method MongoDatabasesClient.Get. type MongoDatabasesClientGetResponse struct { + // MongoDatabase portable resource MongoDatabaseResource } -// MongoDatabasesClientListByRootScopeResponse contains the response from method MongoDatabasesClient.ListByRootScope. -type MongoDatabasesClientListByRootScopeResponse struct { +// MongoDatabasesClientListByScopeResponse contains the response from method MongoDatabasesClient.NewListByScopePager. +type MongoDatabasesClientListByScopeResponse struct { + // The response of a MongoDatabaseResource list operation. MongoDatabaseResourceListResult } // MongoDatabasesClientListSecretsResponse contains the response from method MongoDatabasesClient.ListSecrets. type MongoDatabasesClientListSecretsResponse struct { + // The secret values for the given MongoDatabase resource MongoDatabaseListSecretsResult } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// MongoDatabasesClientUpdateResponse contains the response from method MongoDatabasesClient.BeginUpdate. +type MongoDatabasesClientUpdateResponse struct { + // MongoDatabase portable resource + MongoDatabaseResource +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. OperationListResult } -// RedisCachesClientCreateOrUpdateResponse contains the response from method RedisCachesClient.CreateOrUpdate. +// RedisCachesClientCreateOrUpdateResponse contains the response from method RedisCachesClient.BeginCreateOrUpdate. type RedisCachesClientCreateOrUpdateResponse struct { + // RedisCache portable resource RedisCacheResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// RedisCachesClientDeleteResponse contains the response from method RedisCachesClient.Delete. +// RedisCachesClientDeleteResponse contains the response from method RedisCachesClient.BeginDelete. type RedisCachesClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 + // placeholder for future response values } // RedisCachesClientGetResponse contains the response from method RedisCachesClient.Get. type RedisCachesClientGetResponse struct { + // RedisCache portable resource RedisCacheResource } -// RedisCachesClientListByRootScopeResponse contains the response from method RedisCachesClient.ListByRootScope. -type RedisCachesClientListByRootScopeResponse struct { +// RedisCachesClientListByScopeResponse contains the response from method RedisCachesClient.NewListByScopePager. +type RedisCachesClientListByScopeResponse struct { + // The response of a RedisCacheResource list operation. RedisCacheResourceListResult } // RedisCachesClientListSecretsResponse contains the response from method RedisCachesClient.ListSecrets. type RedisCachesClientListSecretsResponse struct { + // The secret values for the given RedisCache resource RedisCacheListSecretsResult } -// SQLDatabasesClientCreateOrUpdateResponse contains the response from method SQLDatabasesClient.CreateOrUpdate. +// RedisCachesClientUpdateResponse contains the response from method RedisCachesClient.BeginUpdate. +type RedisCachesClientUpdateResponse struct { + // RedisCache portable resource + RedisCacheResource +} + +// SQLDatabasesClientCreateOrUpdateResponse contains the response from method SQLDatabasesClient.BeginCreateOrUpdate. type SQLDatabasesClientCreateOrUpdateResponse struct { + // SqlDatabase portable resource SQLDatabaseResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// SQLDatabasesClientDeleteResponse contains the response from method SQLDatabasesClient.Delete. +// SQLDatabasesClientDeleteResponse contains the response from method SQLDatabasesClient.BeginDelete. type SQLDatabasesClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 + // placeholder for future response values } // SQLDatabasesClientGetResponse contains the response from method SQLDatabasesClient.Get. type SQLDatabasesClientGetResponse struct { + // SqlDatabase portable resource SQLDatabaseResource } -// SQLDatabasesClientListByRootScopeResponse contains the response from method SQLDatabasesClient.ListByRootScope. -type SQLDatabasesClientListByRootScopeResponse struct { +// SQLDatabasesClientListByScopeResponse contains the response from method SQLDatabasesClient.NewListByScopePager. +type SQLDatabasesClientListByScopeResponse struct { + // The response of a SqlDatabaseResource list operation. SQLDatabaseResourceListResult } // SQLDatabasesClientListSecretsResponse contains the response from method SQLDatabasesClient.ListSecrets. type SQLDatabasesClientListSecretsResponse struct { + // The secret values for the given SqlDatabase resource SQLDatabaseListSecretsResult } +// SQLDatabasesClientUpdateResponse contains the response from method SQLDatabasesClient.BeginUpdate. +type SQLDatabasesClientUpdateResponse struct { + // SqlDatabase portable resource + SQLDatabaseResource +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_sqldatabases_client.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_sqldatabases_client.go index 706be5dd05..4dd5e60343 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_sqldatabases_client.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_sqldatabases_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -13,79 +12,91 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) // SQLDatabasesClient contains the methods for the SQLDatabases group. // Don't use this type directly, use NewSQLDatabasesClient() instead. type SQLDatabasesClient struct { - host string + internal *arm.Client rootScope string - pl runtime.Pipeline } // NewSQLDatabasesClient creates a new instance of SQLDatabasesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSQLDatabasesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLDatabasesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SQLDatabasesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLDatabasesClient{ rootScope: rootScope, - host: ep, -pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or updates a SqlDatabaseResource +// BeginCreateOrUpdate - Create a SqlDatabaseResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - sqlDatabaseName - The name of the SqlDatabase portable resource resource +// - resource - Resource create parameters. +// - options - SQLDatabasesClientBeginCreateOrUpdateOptions contains the optional parameters for the SQLDatabasesClient.BeginCreateOrUpdate +// method. +func (client *SQLDatabasesClient) BeginCreateOrUpdate(ctx context.Context, sqlDatabaseName string, resource SQLDatabaseResource, options *SQLDatabasesClientBeginCreateOrUpdateOptions) (*runtime.Poller[SQLDatabasesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, sqlDatabaseName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLDatabasesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SQLDatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a SqlDatabaseResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SQL database portable resource -// resource - Resource create parameters. -// options - SQLDatabasesClientCreateOrUpdateOptions contains the optional parameters for the SQLDatabasesClient.CreateOrUpdate -// method. -func (client *SQLDatabasesClient) CreateOrUpdate(ctx context.Context, sqlDatabaseName string, resource SQLDatabaseResource, options *SQLDatabasesClientCreateOrUpdateOptions) (SQLDatabasesClientCreateOrUpdateResponse, error) { +func (client *SQLDatabasesClient) createOrUpdate(ctx context.Context, sqlDatabaseName string, resource SQLDatabaseResource, options *SQLDatabasesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, sqlDatabaseName, resource, options) if err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return SQLDatabasesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.createOrUpdateHandleResponse(resp) + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *SQLDatabasesClient) createOrUpdateCreateRequest(ctx context.Context, sqlDatabaseName string, resource SQLDatabaseResource, options *SQLDatabasesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *SQLDatabasesClient) createOrUpdateCreateRequest(ctx context.Context, sqlDatabaseName string, resource SQLDatabaseResource, options *SQLDatabasesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if sqlDatabaseName == "" { return nil, errors.New("parameter sqlDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -93,55 +104,64 @@ func (client *SQLDatabasesClient) createOrUpdateCreateRequest(ctx context.Contex reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *SQLDatabasesClient) createOrUpdateHandleResponse(resp *http.Response) (SQLDatabasesClientCreateOrUpdateResponse, error) { - result := SQLDatabasesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) +// BeginDelete - Delete a SqlDatabaseResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - sqlDatabaseName - The name of the SqlDatabase portable resource resource +// - options - SQLDatabasesClientBeginDeleteOptions contains the optional parameters for the SQLDatabasesClient.BeginDelete +// method. +func (client *SQLDatabasesClient) BeginDelete(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientBeginDeleteOptions) (*runtime.Poller[SQLDatabasesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, sqlDatabaseName, options) if err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err + return nil, err } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.SQLDatabaseResource); err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLDatabasesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SQLDatabasesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Deletes an existing SqlDatabaseResource +// Delete - Delete a SqlDatabaseResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SQL database portable resource -// options - SQLDatabasesClientDeleteOptions contains the optional parameters for the SQLDatabasesClient.Delete method. -func (client *SQLDatabasesClient) Delete(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientDeleteOptions) (SQLDatabasesClientDeleteResponse, error) { +func (client *SQLDatabasesClient) deleteOperation(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, sqlDatabaseName, options) if err != nil { - return SQLDatabasesClientDeleteResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return SQLDatabasesClientDeleteResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return SQLDatabasesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.deleteHandleResponse(resp) + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *SQLDatabasesClient) deleteCreateRequest(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientDeleteOptions) (*policy.Request, error) { +func (client *SQLDatabasesClient) deleteCreateRequest(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if sqlDatabaseName == "" { return nil, errors.New("parameter sqlDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -152,38 +172,28 @@ func (client *SQLDatabasesClient) deleteCreateRequest(ctx context.Context, sqlDa return req, nil } -// deleteHandleResponse handles the Delete response. -func (client *SQLDatabasesClient) deleteHandleResponse(resp *http.Response) (SQLDatabasesClientDeleteResponse, error) { - result := SQLDatabasesClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return SQLDatabasesClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a SqlDatabaseResource +// Get - Get a SqlDatabaseResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SQL database portable resource -// options - SQLDatabasesClientGetOptions contains the optional parameters for the SQLDatabasesClient.Get method. +// - sqlDatabaseName - The name of the SqlDatabase portable resource resource +// - options - SQLDatabasesClientGetOptions contains the optional parameters for the SQLDatabasesClient.Get method. func (client *SQLDatabasesClient) Get(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientGetOptions) (SQLDatabasesClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, sqlDatabaseName, options) if err != nil { return SQLDatabasesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLDatabasesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SQLDatabasesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SQLDatabasesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -194,7 +204,7 @@ func (client *SQLDatabasesClient) getCreateRequest(ctx context.Context, sqlDatab return nil, errors.New("parameter sqlDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -214,43 +224,44 @@ func (client *SQLDatabasesClient) getHandleResponse(resp *http.Response) (SQLDat return result, nil } -// NewListByRootScopePager - Lists information about all SqlDatabaseResources in the given root scope +// NewListByScopePager - List SqlDatabaseResource resources by Scope +// // Generated from API version 2022-03-15-privatepreview -// options - SQLDatabasesClientListByRootScopeOptions contains the optional parameters for the SQLDatabasesClient.ListByRootScope -// method. -func (client *SQLDatabasesClient) NewListByRootScopePager(options *SQLDatabasesClientListByRootScopeOptions) (*runtime.Pager[SQLDatabasesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[SQLDatabasesClientListByRootScopeResponse]{ - More: func(page SQLDatabasesClientListByRootScopeResponse) bool { +// - options - SQLDatabasesClientListByScopeOptions contains the optional parameters for the SQLDatabasesClient.NewListByScopePager +// method. +func (client *SQLDatabasesClient) NewListByScopePager(options *SQLDatabasesClientListByScopeOptions) (*runtime.Pager[SQLDatabasesClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[SQLDatabasesClientListByScopeResponse]{ + More: func(page SQLDatabasesClientListByScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *SQLDatabasesClientListByRootScopeResponse) (SQLDatabasesClientListByRootScopeResponse, error) { + Fetcher: func(ctx context.Context, page *SQLDatabasesClientListByScopeResponse) (SQLDatabasesClientListByScopeResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) + req, err = client.listByScopeCreateRequest(ctx, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return SQLDatabasesClientListByRootScopeResponse{}, err + return SQLDatabasesClientListByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return SQLDatabasesClientListByRootScopeResponse{}, err + return SQLDatabasesClientListByScopeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return SQLDatabasesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) + return SQLDatabasesClientListByScopeResponse{}, runtime.NewResponseError(resp) } - return client.listByRootScopeHandleResponse(resp) + return client.listByScopeHandleResponse(resp) }, }) } -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *SQLDatabasesClient) listByRootScopeCreateRequest(ctx context.Context, options *SQLDatabasesClientListByRootScopeOptions) (*policy.Request, error) { +// listByScopeCreateRequest creates the ListByScope request. +func (client *SQLDatabasesClient) listByScopeCreateRequest(ctx context.Context, options *SQLDatabasesClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/sqlDatabases" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -261,45 +272,50 @@ func (client *SQLDatabasesClient) listByRootScopeCreateRequest(ctx context.Conte return req, nil } -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *SQLDatabasesClient) listByRootScopeHandleResponse(resp *http.Response) (SQLDatabasesClientListByRootScopeResponse, error) { - result := SQLDatabasesClientListByRootScopeResponse{} +// listByScopeHandleResponse handles the ListByScope response. +func (client *SQLDatabasesClient) listByScopeHandleResponse(resp *http.Response) (SQLDatabasesClientListByScopeResponse, error) { + result := SQLDatabasesClientListByScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.SQLDatabaseResourceListResult); err != nil { - return SQLDatabasesClientListByRootScopeResponse{}, err + return SQLDatabasesClientListByScopeResponse{}, err } return result, nil } -// ListSecrets - Lists secrets values for the specified SQL database resource +// ListSecrets - Lists secrets values for the specified SqlDatabase resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SQL database portable resource -// options - SQLDatabasesClientListSecretsOptions contains the optional parameters for the SQLDatabasesClient.ListSecrets -// method. -func (client *SQLDatabasesClient) ListSecrets(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientListSecretsOptions) (SQLDatabasesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, sqlDatabaseName, options) +// - sqlDatabaseName - The name of the SqlDatabase portable resource resource +// - body - The content of the action request +// - options - SQLDatabasesClientListSecretsOptions contains the optional parameters for the SQLDatabasesClient.ListSecrets +// method. +func (client *SQLDatabasesClient) ListSecrets(ctx context.Context, sqlDatabaseName string, body map[string]any, options *SQLDatabasesClientListSecretsOptions) (SQLDatabasesClientListSecretsResponse, error) { + var err error + req, err := client.listSecretsCreateRequest(ctx, sqlDatabaseName, body, options) if err != nil { return SQLDatabasesClientListSecretsResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLDatabasesClientListSecretsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SQLDatabasesClientListSecretsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SQLDatabasesClientListSecretsResponse{}, err } - return client.listSecretsHandleResponse(resp) + resp, err := client.listSecretsHandleResponse(httpResp) + return resp, err } // listSecretsCreateRequest creates the ListSecrets request. -func (client *SQLDatabasesClient) listSecretsCreateRequest(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientListSecretsOptions) (*policy.Request, error) { +func (client *SQLDatabasesClient) listSecretsCreateRequest(ctx context.Context, sqlDatabaseName string, body map[string]any, options *SQLDatabasesClientListSecretsOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}/listSecrets" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if sqlDatabaseName == "" { return nil, errors.New("parameter sqlDatabaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,6 +323,9 @@ func (client *SQLDatabasesClient) listSecretsCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err +} return req, nil } @@ -319,3 +338,69 @@ func (client *SQLDatabasesClient) listSecretsHandleResponse(resp *http.Response) return result, nil } +// BeginUpdate - Update a SqlDatabaseResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - sqlDatabaseName - The name of the SqlDatabase portable resource resource +// - properties - The resource properties to be updated. +// - options - SQLDatabasesClientBeginUpdateOptions contains the optional parameters for the SQLDatabasesClient.BeginUpdate +// method. +func (client *SQLDatabasesClient) BeginUpdate(ctx context.Context, sqlDatabaseName string, properties SQLDatabaseResourceUpdate, options *SQLDatabasesClientBeginUpdateOptions) (*runtime.Poller[SQLDatabasesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, sqlDatabaseName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLDatabasesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[SQLDatabasesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a SqlDatabaseResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *SQLDatabasesClient) update(ctx context.Context, sqlDatabaseName string, properties SQLDatabaseResourceUpdate, options *SQLDatabasesClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, sqlDatabaseName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *SQLDatabasesClient) updateCreateRequest(ctx context.Context, sqlDatabaseName string, properties SQLDatabaseResourceUpdate, options *SQLDatabasesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if sqlDatabaseName == "" { + return nil, errors.New("parameter sqlDatabaseName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go index cea28fe8b6..30ea6fa1d0 100644 --- a/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go +++ b/pkg/datastoresrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -66,7 +65,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/pkg/datastoresrp/datamodel/converter/mongodatabase_converter.go b/pkg/datastoresrp/datamodel/converter/mongodatabase_converter.go index d8889f2afc..9097162347 100644 --- a/pkg/datastoresrp/datamodel/converter/mongodatabase_converter.go +++ b/pkg/datastoresrp/datamodel/converter/mongodatabase_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" ) // MongoDatabaseDataModelToVersioned converts a Mongo database data model to a versioned model interface based on the diff --git a/pkg/datastoresrp/datamodel/converter/mongodatabase_converter_test.go b/pkg/datastoresrp/datamodel/converter/mongodatabase_converter_test.go index 2145261f7e..9dd0e8ea2e 100644 --- a/pkg/datastoresrp/datamodel/converter/mongodatabase_converter_test.go +++ b/pkg/datastoresrp/datamodel/converter/mongodatabase_converter_test.go @@ -21,10 +21,10 @@ import ( "errors" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - linkrp_util "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -52,10 +52,10 @@ func TestMongoDatabaseDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.MongoDatabase{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := MongoDatabaseDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -96,8 +96,7 @@ func TestMongoDatabaseDataModelFromVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.versionedModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.versionedModelFile) dm, err := MongoDatabaseDataModelFromVersioned(c, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -132,10 +131,10 @@ func TestMongoDatabaseSecretsDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.MongoDatabaseSecrets{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := MongoDatabaseSecretsDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) diff --git a/pkg/datastoresrp/datamodel/converter/rediscache_converter.go b/pkg/datastoresrp/datamodel/converter/rediscache_converter.go index bf895a8c91..4acecd0076 100644 --- a/pkg/datastoresrp/datamodel/converter/rediscache_converter.go +++ b/pkg/datastoresrp/datamodel/converter/rediscache_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" ) // RedisCacheDataModelToVersioned converts a Redis cache data model to a versioned model interface and returns an error if diff --git a/pkg/datastoresrp/datamodel/converter/rediscache_converter_test.go b/pkg/datastoresrp/datamodel/converter/rediscache_converter_test.go index 04f1ae5e26..61d5f58d5a 100644 --- a/pkg/datastoresrp/datamodel/converter/rediscache_converter_test.go +++ b/pkg/datastoresrp/datamodel/converter/rediscache_converter_test.go @@ -21,10 +21,10 @@ import ( "errors" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - linkrp_util "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -52,10 +52,10 @@ func TestRedisCacheDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.RedisCache{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := RedisCacheDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -97,8 +97,7 @@ func TestRedisCacheDataModelFromVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.versionedModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.versionedModelFile) dm, err := RedisCacheDataModelFromVersioned(c, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -133,10 +132,10 @@ func TestRedisCacheSecretsDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.RedisCacheSecrets{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := RedisCacheSecretsDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) diff --git a/pkg/datastoresrp/datamodel/converter/sqldatabase_converter.go b/pkg/datastoresrp/datamodel/converter/sqldatabase_converter.go index d976be4bf3..7be7ab51f6 100644 --- a/pkg/datastoresrp/datamodel/converter/sqldatabase_converter.go +++ b/pkg/datastoresrp/datamodel/converter/sqldatabase_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" ) // SqlDatabaseDataModelToVersioned converts a SqlDatabase data model to a VersionedModelInterface based on the specified diff --git a/pkg/datastoresrp/datamodel/converter/sqldatabase_converter_test.go b/pkg/datastoresrp/datamodel/converter/sqldatabase_converter_test.go index 5af1583337..b67707974f 100644 --- a/pkg/datastoresrp/datamodel/converter/sqldatabase_converter_test.go +++ b/pkg/datastoresrp/datamodel/converter/sqldatabase_converter_test.go @@ -21,10 +21,10 @@ import ( "errors" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - linkrp_util "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -52,10 +52,10 @@ func TestSqlDatabaseDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.SqlDatabase{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := SqlDatabaseDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -102,8 +102,7 @@ func TestSqlDatabaseDataModelFromVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.versionedModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.versionedModelFile) dm, err := SqlDatabaseDataModelFromVersioned(c, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -144,10 +143,10 @@ func TestSqlDatabaseSecretsDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.SqlDatabaseSecrets{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := SqlDatabaseSecretsDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) diff --git a/pkg/datastoresrp/datamodel/mongodatabase.go b/pkg/datastoresrp/datamodel/mongodatabase.go index 26bfc39252..322996f187 100644 --- a/pkg/datastoresrp/datamodel/mongodatabase.go +++ b/pkg/datastoresrp/datamodel/mongodatabase.go @@ -20,19 +20,18 @@ import ( "fmt" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/renderers" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // MongoDatabase represents Mongo database portable resource. type MongoDatabase struct { v1.BaseResource - // LinkMetadata represents internal DataModel properties common to all portable resources. - linkrp_dm.LinkMetadata + // PortableResourceMetadata represents internal DataModel properties common to all portable resources. + pr_dm.PortableResourceMetadata // Properties is the properties of the resource. Properties MongoDatabaseProperties `json:"properties"` @@ -50,11 +49,11 @@ type MongoDatabaseProperties struct { // Database name of the target Mongo database Database string `json:"database,omitempty"` // The recipe used to automatically deploy underlying infrastructure for the Mongo database link - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` // List of the resource IDs that support the Mongo database resource - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` + Resources []*portableresources.ResourceReference `json:"resources,omitempty"` // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` // Username of the Mongo database Username string `json:"username,omitempty"` } @@ -73,7 +72,7 @@ func (mongoSecrets MongoDatabaseSecrets) IsEmpty() bool { // VerifyInputs checks if the manual resource provisioning fields are set and returns an error if any of them are missing. func (mongodb *MongoDatabase) VerifyInputs() error { msgs := []string{} - if mongodb.Properties.ResourceProvisioning != "" && mongodb.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if mongodb.Properties.ResourceProvisioning != "" && mongodb.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { if mongodb.Properties.Host == "" { msgs = append(msgs, "host must be specified when resourceProvisioning is set to manual") } @@ -103,13 +102,6 @@ func (mongodb *MongoDatabase) VerifyInputs() error { // ApplyDeploymentOutput updates the Mongo database instance's database property, output resources, computed values // and secret values with the given DeploymentOutput. func (r *MongoDatabase) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - r.ComputedValues = do.ComputedValues - r.SecretValues = do.SecretValues - if database, ok := do.ComputedValues[renderers.DatabaseNameValue].(string); ok { - r.Properties.Database = database - } - return nil } @@ -123,10 +115,10 @@ func (r *MongoDatabase) ResourceMetadata() *rpv1.BasicResourceProperties { return &r.Properties.BasicResourceProperties } -// Recipe returns the LinkRecipe associated with the Mongo database instance, or nil if the +// Recipe returns the ResourceRecipe associated with the Mongo database instance, or nil if the // ResourceProvisioning is set to Manual. -func (r *MongoDatabase) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (r *MongoDatabase) Recipe() *portableresources.ResourceRecipe { + if r.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &r.Properties.Recipe @@ -134,10 +126,10 @@ func (r *MongoDatabase) Recipe() *linkrp.LinkRecipe { // ResourceTypeName returns the resource type for Mongo database resource. func (mongoSecrets *MongoDatabaseSecrets) ResourceTypeName() string { - return linkrp.N_MongoDatabasesResourceType + return portableresources.MongoDatabasesResourceType } // ResourceTypeName returns the resource type for Mongo database resource. func (mongo *MongoDatabase) ResourceTypeName() string { - return linkrp.N_MongoDatabasesResourceType + return portableresources.MongoDatabasesResourceType } diff --git a/pkg/datastoresrp/datamodel/rediscache.go b/pkg/datastoresrp/datamodel/rediscache.go index b1bd9e87b4..67790d7d06 100644 --- a/pkg/datastoresrp/datamodel/rediscache.go +++ b/pkg/datastoresrp/datamodel/rediscache.go @@ -17,16 +17,13 @@ limitations under the License. package datamodel import ( - "errors" "fmt" - "strconv" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/renderers" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // RedisCache represents Redis cache portable resource. @@ -36,40 +33,13 @@ type RedisCache struct { // Properties is the properties of the resource. Properties RedisCacheProperties `json:"properties"` - // LinkMetadata represents internal DataModel properties common to all link types. - linkrp_dm.LinkMetadata + // PortableResourceMetadata represents internal DataModel properties common to all resource types. + pr_dm.PortableResourceMetadata } // ApplyDeploymentOutput sets the Status, ComputedValues, SecretValues, Host, Port and Username properties of the // Redis cache instance based on the DeploymentOutput object. func (r *RedisCache) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - r.ComputedValues = do.ComputedValues - r.SecretValues = do.SecretValues - if host, ok := do.ComputedValues[renderers.Host].(string); ok { - r.Properties.Host = host - } - if port, ok := do.ComputedValues[renderers.Port]; ok { - if port != nil { - switch p := port.(type) { - case float64: - r.Properties.Port = int32(p) - case int32: - r.Properties.Port = p - case string: - converted, err := strconv.Atoi(p) - if err != nil { - return err - } - r.Properties.Port = int32(converted) - default: - return errors.New("unhandled type for the property port") - } - } - } - if username, ok := do.ComputedValues[renderers.UsernameStringValue].(string); ok { - r.Properties.Username = username - } return nil } @@ -85,13 +55,13 @@ func (r *RedisCache) ResourceMetadata() *rpv1.BasicResourceProperties { // ResourceTypeName returns the resource type of Redis cache resource. func (redis *RedisCache) ResourceTypeName() string { - return linkrp.N_RedisCachesResourceType + return portableresources.RedisCachesResourceType } -// Recipe returns the LinkRecipe from the Redis cache Properties if ResourceProvisioning is not set to Manual, +// Recipe returns the ResourceRecipe from the Redis cache Properties if ResourceProvisioning is not set to Manual, // otherwise it returns nil. -func (redis *RedisCache) Recipe() *linkrp.LinkRecipe { - if redis.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (redis *RedisCache) Recipe() *portableresources.ResourceRecipe { + if redis.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &redis.Properties.Recipe @@ -106,7 +76,7 @@ func (redisSecrets *RedisCacheSecrets) IsEmpty() bool { // and returns an error if not. func (redisCache *RedisCache) VerifyInputs() error { msgs := []string{} - if redisCache.Properties.ResourceProvisioning != "" && redisCache.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if redisCache.Properties.ResourceProvisioning != "" && redisCache.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { if redisCache.Properties.Host == "" { msgs = append(msgs, "host must be specified when resourceProvisioning is set to manual") } @@ -145,16 +115,16 @@ type RedisCacheProperties struct { TLS bool `json:"tls,omitempty"` // The recipe used to automatically deploy underlying infrastructure for the Redis caches link - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` // Secrets provided by resource Secrets RedisCacheSecrets `json:"secrets,omitempty"` // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` // List of the resource IDs that support the Redis resource - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` + Resources []*portableresources.ResourceReference `json:"resources,omitempty"` } // Secrets values consisting of secrets provided for the resource @@ -166,5 +136,5 @@ type RedisCacheSecrets struct { // ResourceTypeName returns the resource type of RedisCache resource. func (redis RedisCacheSecrets) ResourceTypeName() string { - return linkrp.N_RedisCachesResourceType + return portableresources.RedisCachesResourceType } diff --git a/pkg/datastoresrp/datamodel/sqldatabase.go b/pkg/datastoresrp/datamodel/sqldatabase.go index 273053020a..3cfad887af 100644 --- a/pkg/datastoresrp/datamodel/sqldatabase.go +++ b/pkg/datastoresrp/datamodel/sqldatabase.go @@ -20,16 +20,16 @@ import ( "fmt" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) -// Recipe returns the LinkRecipe associated with the SQL database instance if the ResourceProvisioning is not +// Recipe returns the ResourceRecipe associated with the SQL database instance if the ResourceProvisioning is not // set to Manual, otherwise it returns nil. -func (sql *SqlDatabase) Recipe() *linkrp.LinkRecipe { - if sql.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (sql *SqlDatabase) Recipe() *portableresources.ResourceRecipe { + if sql.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &sql.Properties.Recipe @@ -42,14 +42,13 @@ type SqlDatabase struct { // Properties is the properties of the resource. Properties SqlDatabaseProperties `json:"properties"` - // LinkMetadata represents internal DataModel properties common to all portable resources. - linkrp_dm.LinkMetadata + // ResourceMetadata represents internal DataModel properties common to all portable resources. + pr_dm.PortableResourceMetadata } // ApplyDeploymentOutput updates the output resources of a SQL database resource with the output resources of a DeploymentOutput // object and returns no error. func (r *SqlDatabase) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources return nil } @@ -65,14 +64,14 @@ func (r *SqlDatabase) ResourceMetadata() *rpv1.BasicResourceProperties { // ResourceTypeName returns the resource type of the SQL database resource. func (sql *SqlDatabase) ResourceTypeName() string { - return linkrp.N_SqlDatabasesResourceType + return portableresources.SqlDatabasesResourceType } // SqlDatabaseProperties represents the properties of SQL database resource. type SqlDatabaseProperties struct { rpv1.BasicResourceProperties // The recipe used to automatically deploy underlying infrastructure for the SQL database resource - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` // Database name of the target SQL database resource Database string `json:"database,omitempty"` // The fully qualified domain name of the SQL database resource @@ -80,9 +79,9 @@ type SqlDatabaseProperties struct { // Port value of the target SQL database resource Port int32 `json:"port,omitempty"` // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` // List of the resource IDs that support the SQL database resource - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` + Resources []*portableresources.ResourceReference `json:"resources,omitempty"` // Username of the SQL database resource Username string `json:"username,omitempty"` // Secrets values provided for the resource @@ -102,7 +101,7 @@ type SqlDatabaseSecrets struct { // if any of the required fields are not set. func (sql *SqlDatabase) VerifyInputs() error { msgs := []string{} - if sql.Properties.ResourceProvisioning != "" && sql.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if sql.Properties.ResourceProvisioning != "" && sql.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { if sql.Properties.Server == "" { msgs = append(msgs, "server must be specified when resourceProvisioning is set to manual") } @@ -136,5 +135,5 @@ func (sqlSecrets SqlDatabaseSecrets) IsEmpty() bool { // ResourceTypeName returns the resource type of the SQL database resource. func (sqlSecrets *SqlDatabaseSecrets) ResourceTypeName() string { - return linkrp.N_SqlDatabasesResourceType + return portableresources.SqlDatabasesResourceType } diff --git a/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase.go b/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase.go index 7a178721e6..133cf19afd 100644 --- a/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase.go +++ b/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase.go @@ -20,12 +20,12 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel/converter" - "github.com/project-radius/radius/pkg/linkrp/renderers" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel/converter" + "github.com/radius-project/radius/pkg/portableresources/renderers" ) var _ ctrl.Controller = (*ListSecretsMongoDatabase)(nil) diff --git a/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase_test.go b/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase_test.go index 8ef273e6f5..0c4b368a47 100644 --- a/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase_test.go +++ b/pkg/datastoresrp/frontend/controller/mongodatabases/listsecretsmongodatabase_test.go @@ -24,12 +24,12 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources/renderers" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/datastoresrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_datamodel.json b/pkg/datastoresrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_datamodel.json index 2976a38d65..7e20688f62 100644 --- a/pkg/datastoresrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_datamodel.json +++ b/pkg/datastoresrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_datamodel.json @@ -15,12 +15,7 @@ "status": { "outputResources": [ { - "LocalID": "AzureCosmosAccount", - "Dependencies": null, - "ResourceType": { - "type": "azure.cosmosdb.account", - "provider": "azure" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/datastoresrp/frontend/controller/mongodatabases/types.go b/pkg/datastoresrp/frontend/controller/mongodatabases/types.go deleted file mode 100644 index c9833d3940..0000000000 --- a/pkg/datastoresrp/frontend/controller/mongodatabases/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mongodatabases - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/datastoresrp/frontend/controller/mongodatabases/v20220315privatepreview_test.go b/pkg/datastoresrp/frontend/controller/mongodatabases/v20220315privatepreview_test.go index 11dab84f74..9ff527de65 100644 --- a/pkg/datastoresrp/frontend/controller/mongodatabases/v20220315privatepreview_test.go +++ b/pkg/datastoresrp/frontend/controller/mongodatabases/v20220315privatepreview_test.go @@ -19,9 +19,9 @@ package mongodatabases import ( "encoding/json" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/test/testutil" ) const testHeaderfile = "20220315privatepreview_requestheaders.json" diff --git a/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache.go b/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache.go index 945eb1c88f..1fc78c14aa 100644 --- a/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache.go +++ b/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache.go @@ -21,13 +21,13 @@ import ( "errors" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/datamodel/converter" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel/converter" + "github.com/radius-project/radius/pkg/portableresources/renderers" + "github.com/radius-project/radius/pkg/ucp/store" ) var _ ctrl.Controller = (*ListSecretsRedisCache)(nil) @@ -53,7 +53,7 @@ func (ctrl *ListSecretsRedisCache) Run(ctx context.Context, w http.ResponseWrite sCtx := v1.ARMRequestContextFromContext(ctx) // Request route for listsecrets has name of the operation as suffix which should be removed to get the resource id. - // route id format: subscriptions//resourceGroups//providers/Applications.Link/redisCaches//listsecrets + // route id format: subscriptions//resourceGroups//providers/Applications.Datastores/redisCaches//listsecrets parsedResourceID := sCtx.ResourceID.Truncate() resource, _, err := ctrl.GetResource(ctx, parsedResourceID) if err != nil { diff --git a/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache_test.go b/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache_test.go index 059846c048..3f9d314d6a 100644 --- a/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache_test.go +++ b/pkg/datastoresrp/frontend/controller/rediscaches/listsecretsrediscache_test.go @@ -24,12 +24,12 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources/renderers" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/datastoresrp/frontend/controller/rediscaches/testdata/20220315privatepreview_datamodel.json b/pkg/datastoresrp/frontend/controller/rediscaches/testdata/20220315privatepreview_datamodel.json index 33574645b7..4e2949b3cb 100644 --- a/pkg/datastoresrp/frontend/controller/rediscaches/testdata/20220315privatepreview_datamodel.json +++ b/pkg/datastoresrp/frontend/controller/rediscaches/testdata/20220315privatepreview_datamodel.json @@ -15,12 +15,7 @@ "status": { "outputResources": [ { - "LocalID": "AzureRedis", - "Dependencies": null, - "ResourceType": { - "type": "azure.redis", - "provider": "azure" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/datastoresrp/frontend/controller/rediscaches/types.go b/pkg/datastoresrp/frontend/controller/rediscaches/types.go deleted file mode 100644 index 17e9f7961a..0000000000 --- a/pkg/datastoresrp/frontend/controller/rediscaches/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rediscaches - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/datastoresrp/frontend/controller/rediscaches/v20220315privatepreview_test.go b/pkg/datastoresrp/frontend/controller/rediscaches/v20220315privatepreview_test.go index d8b33f53b7..124b46fe60 100644 --- a/pkg/datastoresrp/frontend/controller/rediscaches/v20220315privatepreview_test.go +++ b/pkg/datastoresrp/frontend/controller/rediscaches/v20220315privatepreview_test.go @@ -19,9 +19,9 @@ package rediscaches import ( "encoding/json" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/test/testutil" ) const testHeaderfile = "20220315privatepreview_requestheaders.json" diff --git a/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase.go b/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase.go index 30c058c139..ef3c8c5a44 100644 --- a/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase.go +++ b/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase.go @@ -20,12 +20,12 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel/converter" - "github.com/project-radius/radius/pkg/linkrp/renderers" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel/converter" + "github.com/radius-project/radius/pkg/portableresources/renderers" ) var _ ctrl.Controller = (*ListSecretsSqlDatabase)(nil) diff --git a/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase_test.go b/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase_test.go index 6288854458..083255677d 100644 --- a/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase_test.go +++ b/pkg/datastoresrp/frontend/controller/sqldatabases/listsecretssqldatabase_test.go @@ -24,11 +24,11 @@ import ( "net/http/httptest" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" diff --git a/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_datamodel.json b/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_datamodel.json index 267af46be9..c2bb9d2355 100644 --- a/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_datamodel.json +++ b/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_datamodel.json @@ -15,12 +15,7 @@ "status": { "outputResources": [ { - "LocalID": "AzureSqlServer", - "Dependencies": null, - "ResourceType": { - "type": "azure.sql", - "provider": "azure" - } + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } ] }, diff --git a/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_output.json b/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_output.json index 37067d5bad..acc7a87520 100644 --- a/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_output.json +++ b/pkg/datastoresrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_output.json @@ -1,37 +1,37 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.datastores/sqldatabases/sql0", - "location": "West US", - "name": "sql0", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "AzureSqlServer", - "Provider": "azure", - "Identity": null - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "provisioningState": "Succeeded", - "resourceProvisioning": "manual", - "port": 1433, - "username": "testUser" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.datastores/sqldatabases/sql0", + "location": "West US", + "name": "sql0", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "tags": {}, - "type": "applications.datastores/sqldatabases" + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "provisioningState": "Succeeded", + "resourceProvisioning": "manual", + "port": 1433, + "username": "testUser" + }, + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "tags": {}, + "type": "applications.datastores/sqldatabases" } \ No newline at end of file diff --git a/pkg/datastoresrp/frontend/controller/sqldatabases/types.go b/pkg/datastoresrp/frontend/controller/sqldatabases/types.go deleted file mode 100644 index 1e801ba341..0000000000 --- a/pkg/datastoresrp/frontend/controller/sqldatabases/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package sqldatabases - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/datastoresrp/frontend/controller/sqldatabases/v20220315privatepreview_test.go b/pkg/datastoresrp/frontend/controller/sqldatabases/v20220315privatepreview_test.go index cca9fd06c0..117c18a161 100644 --- a/pkg/datastoresrp/frontend/controller/sqldatabases/v20220315privatepreview_test.go +++ b/pkg/datastoresrp/frontend/controller/sqldatabases/v20220315privatepreview_test.go @@ -19,9 +19,9 @@ package sqldatabases import ( "encoding/json" - "github.com/project-radius/radius/pkg/datastoresrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/datastoresrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/test/testutil" ) const testHeaderfile = "20220315privatepreview_requestheaders.json" diff --git a/pkg/datastoresrp/frontend/controller/types.go b/pkg/datastoresrp/frontend/controller/types.go index 9219bb1530..224063485a 100644 --- a/pkg/datastoresrp/frontend/controller/types.go +++ b/pkg/datastoresrp/frontend/controller/types.go @@ -20,7 +20,10 @@ import ( "time" ) -var ( +const ( + // User defined operation names + OperationListSecret = "LISTSECRETS" + // AsyncCreateOrUpdateMongoDatabaseTimeout is the timeout for async create or update Mongo database AsyncCreateOrUpdateMongoDatabaseTimeout = time.Duration(10) * time.Minute // AsyncDeleteMongoDatabaseTimeout is the timeout for async delete Mongo database @@ -35,4 +38,9 @@ var ( AsyncCreateOrUpdateDaprStateStoreTimeout = time.Duration(60) * time.Minute // AsyncDeleteDaprStateStoreTimeout is the timeout for async delete Dapr state store AsyncDeleteDaprStateStoreTimeout = time.Duration(30) * time.Minute + + // AsyncCreateOrUpdateSqlTimeout is the timeout for async create or update sql database + AsyncCreateOrUpdateSqlDatabaseTimeout = time.Duration(10) * time.Minute + // AsyncDeleteSqlDatabaseTimeout is the timeout for async delete sql database + AsyncDeleteSqlDatabaseTimeout = time.Duration(15) * time.Minute ) diff --git a/pkg/datastoresrp/processors/mongodatabases/processor.go b/pkg/datastoresrp/processors/mongodatabases/processor.go index 8f80c2ae22..3b54fbd52b 100644 --- a/pkg/datastoresrp/processors/mongodatabases/processor.go +++ b/pkg/datastoresrp/processors/mongodatabases/processor.go @@ -20,9 +20,9 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers" ) // Processor is a processor for MongoDB resources. @@ -52,6 +52,11 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.MongoDataba return nil } +// Delete implements the processors.Processor interface for MongoDatabase resources. +func (p *Processor) Delete(ctx context.Context, resource *datamodel.MongoDatabase, options processors.Options) error { + return nil +} + func (p *Processor) computeConnectionString(resource *datamodel.MongoDatabase) string { connectionString := "mongodb://" diff --git a/pkg/datastoresrp/processors/mongodatabases/processor_test.go b/pkg/datastoresrp/processors/mongodatabases/processor_test.go index 3f0aad542b..dc1525d642 100644 --- a/pkg/datastoresrp/processors/mongodatabases/processor_test.go +++ b/pkg/datastoresrp/processors/mongodatabases/processor_test.go @@ -20,11 +20,11 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" "github.com/stretchr/testify/require" ) @@ -96,7 +96,7 @@ func Test_Process(t *testing.T) { t.Run("success - manual", func(t *testing.T) { resource := &datamodel.MongoDatabase{ Properties: datamodel.MongoDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureMongoResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: azureMongoResourceID1}}, Host: host, Port: port, Database: database, @@ -132,7 +132,7 @@ func Test_Process(t *testing.T) { }, } - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ + expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*portableresources.ResourceReference{ { ID: azureMongoResourceID1, }, @@ -147,7 +147,7 @@ func Test_Process(t *testing.T) { t.Run("success - recipe with value overrides", func(t *testing.T) { resource := &datamodel.MongoDatabase{ Properties: datamodel.MongoDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureMongoResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: azureMongoResourceID1}}, Host: host, Port: port, Database: database, @@ -208,7 +208,7 @@ func Test_Process(t *testing.T) { require.NoError(t, err) expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ + resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*portableresources.ResourceReference{ { ID: azureMongoResourceID1, }, diff --git a/pkg/datastoresrp/processors/rediscaches/processor.go b/pkg/datastoresrp/processors/rediscaches/processor.go index d3ed1765a9..94f43bfdfb 100644 --- a/pkg/datastoresrp/processors/rediscaches/processor.go +++ b/pkg/datastoresrp/processors/rediscaches/processor.go @@ -20,9 +20,9 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers" ) const ( @@ -65,6 +65,11 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.RedisCache, return nil } +// Delete implements the processors.Processor interface for RedisCache resources. +func (p *Processor) Delete(ctx context.Context, resource *datamodel.RedisCache, options processors.Options) error { + return nil +} + func (p *Processor) computeSSL(resource *datamodel.RedisCache) bool { return resource.Properties.Port == RedisSSLPort } diff --git a/pkg/datastoresrp/processors/rediscaches/processor_test.go b/pkg/datastoresrp/processors/rediscaches/processor_test.go index 212011bb56..47c92c156c 100644 --- a/pkg/datastoresrp/processors/rediscaches/processor_test.go +++ b/pkg/datastoresrp/processors/rediscaches/processor_test.go @@ -20,11 +20,11 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" "github.com/stretchr/testify/require" ) @@ -101,7 +101,7 @@ func Test_Process(t *testing.T) { t.Run("success - manual", func(t *testing.T) { resource := &datamodel.RedisCache{ Properties: datamodel.RedisCacheProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureRedisResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: azureRedisResourceID1}}, Host: host, Port: RedisSSLPort, Username: username, @@ -141,7 +141,7 @@ func Test_Process(t *testing.T) { }, } - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ + expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*portableresources.ResourceReference{ { ID: azureRedisResourceID1, }, @@ -156,7 +156,7 @@ func Test_Process(t *testing.T) { t.Run("success - recipe with value overrides", func(t *testing.T) { resource := &datamodel.RedisCache{ Properties: datamodel.RedisCacheProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureRedisResourceID1}}, + Resources: []*portableresources.ResourceReference{{ID: azureRedisResourceID1}}, Host: host, Port: RedisNonSSLPort, Username: username, @@ -221,7 +221,7 @@ func Test_Process(t *testing.T) { require.NoError(t, err) expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ + resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*portableresources.ResourceReference{ { ID: azureRedisResourceID1, }, diff --git a/pkg/datastoresrp/processors/sqldatabases/processor.go b/pkg/datastoresrp/processors/sqldatabases/processor.go index 5bfb1f587b..cd5e8768e4 100644 --- a/pkg/datastoresrp/processors/sqldatabases/processor.go +++ b/pkg/datastoresrp/processors/sqldatabases/processor.go @@ -9,9 +9,9 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers" ) // Processor is a processor for SQL database resources. @@ -41,6 +41,11 @@ func (p *Processor) Process(ctx context.Context, resource *datamodel.SqlDatabase return nil } +// Delete implements the processors.Processor interface for SQLDatabase resources. +func (p *Processor) Delete(ctx context.Context, resource *datamodel.SqlDatabase, options processors.Options) error { + return nil +} + func (p *Processor) computeConnectionString(resource *datamodel.SqlDatabase) string { var username, password string if resource.Properties.Username != "" { diff --git a/pkg/datastoresrp/processors/sqldatabases/processor_test.go b/pkg/datastoresrp/processors/sqldatabases/processor_test.go index 33e47d3c0b..0337ee4ec7 100644 --- a/pkg/datastoresrp/processors/sqldatabases/processor_test.go +++ b/pkg/datastoresrp/processors/sqldatabases/processor_test.go @@ -9,11 +9,11 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" "github.com/stretchr/testify/require" ) @@ -83,7 +83,7 @@ func Test_Process(t *testing.T) { t.Run("success - manual", func(t *testing.T) { resource := &datamodel.SqlDatabase{ Properties: datamodel.SqlDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureSqlResourceID}}, + Resources: []*portableresources.ResourceReference{{ID: azureSqlResourceID}}, Database: database, Server: server, Port: port, @@ -119,7 +119,7 @@ func Test_Process(t *testing.T) { }, } - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ + expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*portableresources.ResourceReference{ { ID: azureSqlResourceID, }, @@ -134,7 +134,7 @@ func Test_Process(t *testing.T) { t.Run("success - recipe with value overrides", func(t *testing.T) { resource := &datamodel.SqlDatabase{ Properties: datamodel.SqlDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureSqlResourceID}}, + Resources: []*portableresources.ResourceReference{{ID: azureSqlResourceID}}, Database: database, Server: server, Port: port, @@ -194,7 +194,7 @@ func Test_Process(t *testing.T) { require.NoError(t, err) expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ + resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*portableresources.ResourceReference{ { ID: azureSqlResourceID, }, diff --git a/pkg/kubernetes/object.go b/pkg/kubernetes/object.go index 462927d3e2..54bd6c2e2d 100644 --- a/pkg/kubernetes/object.go +++ b/pkg/kubernetes/object.go @@ -21,8 +21,8 @@ import ( "hash/fnv" "strings" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1" appsv1 "k8s.io/api/apps/v1" @@ -34,11 +34,11 @@ import ( // associated OutputResource object. func FindDeployment(resources []rpv1.OutputResource) (*appsv1.Deployment, rpv1.OutputResource) { for _, r := range resources { - if r.ResourceType.Type != resourcekinds.Deployment { + if r.GetResourceType().Type != resources_kubernetes.ResourceTypeDeployment { continue } - deployment, ok := r.Resource.(*appsv1.Deployment) + deployment, ok := r.CreateResource.Data.(*appsv1.Deployment) if !ok { continue } @@ -53,11 +53,11 @@ func FindDeployment(resources []rpv1.OutputResource) (*appsv1.Deployment, rpv1.O // OutputResource object it was found in. func FindService(resources []rpv1.OutputResource) (*corev1.Service, rpv1.OutputResource) { for _, r := range resources { - if r.ResourceType.Type != resourcekinds.Service { + if r.GetResourceType().Type != resources_kubernetes.ResourceTypeService { continue } - service, ok := r.Resource.(*corev1.Service) + service, ok := r.CreateResource.Data.(*corev1.Service) if !ok { continue } @@ -72,11 +72,12 @@ func FindService(resources []rpv1.OutputResource) (*corev1.Service, rpv1.OutputR // corresponding OutputResource object. func FindSecret(resources []rpv1.OutputResource) (*corev1.Secret, rpv1.OutputResource) { for _, r := range resources { - if r.ResourceType.Type != resourcekinds.Secret { + resourceType := r.GetResourceType() + if resourceType.Type != resources_kubernetes.ResourceTypeSecret { continue } - secret, ok := r.Resource.(*corev1.Secret) + secret, ok := r.CreateResource.Data.(*corev1.Secret) if !ok { continue } @@ -87,49 +88,48 @@ func FindSecret(resources []rpv1.OutputResource) (*corev1.Secret, rpv1.OutputRes return nil, rpv1.OutputResource{} } -// FindHttpRouteByLocalID searches through a slice of OutputResources to find a HTTPProxy resource -// with the given localID. -func FindHttpRouteByLocalID(resources []rpv1.OutputResource, localID string) (*contourv1.HTTPProxy, rpv1.OutputResource) { +// FindContourHTTPProxyByLocalID searches through a slice of OutputResources to find a HTTPProxy resource. +func FindContourHTTPProxy(resources []rpv1.OutputResource) (*contourv1.HTTPProxy, rpv1.OutputResource) { for _, r := range resources { - if r.ResourceType.Type != resourcekinds.KubernetesHTTPRoute || r.LocalID != localID { + if r.GetResourceType().Type != resources_kubernetes.ResourceTypeContourHTTPProxy { continue } - httpRoute, ok := r.Resource.(*contourv1.HTTPProxy) + httpProxy, ok := r.CreateResource.Data.(*contourv1.HTTPProxy) if !ok { continue } // If VirtualHost exists, then this is a root HTTPProxy (gateway) - if httpRoute.Spec.VirtualHost != nil { + if httpProxy.Spec.VirtualHost == nil { continue } - return httpRoute, r + return httpProxy, r } return nil, rpv1.OutputResource{} } -// FindGateway iterates through a slice of OutputResources and returns the first HTTPProxy resource found with a -// VirtualHost set. -func FindGateway(resources []rpv1.OutputResource) (*contourv1.HTTPProxy, rpv1.OutputResource) { +// FindContourHTTPProxyByLocalID searches through a slice of OutputResources to find a HTTPProxy resource +// with the given localID. +func FindContourHTTPProxyByLocalID(resources []rpv1.OutputResource, localID string) (*contourv1.HTTPProxy, rpv1.OutputResource) { for _, r := range resources { - if r.ResourceType.Type != resourcekinds.Gateway { + if r.GetResourceType().Type != resources_kubernetes.ResourceTypeContourHTTPProxy || r.LocalID != localID { continue } - gateway, ok := r.Resource.(*contourv1.HTTPProxy) + httpRoute, ok := r.CreateResource.Data.(*contourv1.HTTPProxy) if !ok { continue } // If VirtualHost exists, then this is a root HTTPProxy (gateway) - if gateway.Spec.VirtualHost == nil { + if httpRoute.Spec.VirtualHost != nil { continue } - return gateway, r + return httpRoute, r } return nil, rpv1.OutputResource{} diff --git a/pkg/kubeutil/client.go b/pkg/kubeutil/client.go index 9b83219ff3..593a9269c5 100644 --- a/pkg/kubeutil/client.go +++ b/pkg/kubeutil/client.go @@ -21,12 +21,62 @@ import ( apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/client-go/discovery" + "k8s.io/client-go/dynamic" + "k8s.io/client-go/kubernetes" clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" csidriver "sigs.k8s.io/secrets-store-csi-driver/apis/v1alpha1" ) +// Clients is a collection of Kubernetes clients. +type Clients struct { + // RuntimeClient is the Kubernetes controller runtime client. + RuntimeClient runtimeclient.Client + + // ClientSet is the Kubernetes client-go strongly-typed client. + ClientSet *kubernetes.Clientset + + // DiscoveryClient is the Kubernetes client-go discovery client. + DiscoveryClient *discovery.DiscoveryClient + + // DynamicClient is the Kubernetes client-go dynamic client. + DynamicClient dynamic.Interface +} + +// NewClients creates a new Kubernetes client set and controller runtime client using the given config. +func NewClients(config *rest.Config) (*Clients, error) { + c := &Clients{} + + var err error + c.RuntimeClient, err = NewRuntimeClient(config) + if err != nil { + return nil, err + } + + c.ClientSet, err = kubernetes.NewForConfig(config) + if err != nil { + return nil, err + } + + c.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(config) + if err != nil { + return nil, err + } + + // Use legacy discovery client to avoid the issue of the staled GroupVersion discovery(api.ucp.dev/v1alpha3). + // TODO: Disable UseLegacyDiscovery once https://github.com/radius-project/radius/issues/5974 is resolved. + c.DiscoveryClient.UseLegacyDiscovery = true + + c.DynamicClient, err = dynamic.NewForConfig(config) + if err != nil { + return nil, err + } + + return c, nil +} + // NewRuntimeClient creates a new runtime client using the given config and adds the // required resource schemes to the client. func NewRuntimeClient(config *rest.Config) (runtimeclient.Client, error) { diff --git a/pkg/kubeutil/manifest.go b/pkg/kubeutil/manifest.go new file mode 100644 index 0000000000..73991e348a --- /dev/null +++ b/pkg/kubeutil/manifest.go @@ -0,0 +1,83 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kubeutil + +import ( + "bytes" + "io" + + "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/yaml" + clientscheme "k8s.io/client-go/kubernetes/scheme" +) + +// ObjectManifest is a map of runtime.Object slice where the key is GroupVersionKind for the resource. +type ObjectManifest map[schema.GroupVersionKind][]runtime.Object + +// Get returns a runtime.Object slice for the given key. +func (m ObjectManifest) Get(gvk schema.GroupVersionKind) []runtime.Object { + obj, ok := m[gvk] + if ok { + return obj + } else { + return []runtime.Object{} + } +} + +// GetFirst returns the first runtime.Object for the given key. +func (m ObjectManifest) GetFirst(gvk schema.GroupVersionKind) runtime.Object { + obj, ok := m[gvk] + if ok { + return obj[0] + } else { + return nil + } +} + +// ParseManifest parses the given manifest and returns a map of runtime.Object slice where +// the key is GroupVersionKind for the resource. +// It returns an error if the given manifest is invalid. +func ParseManifest(data []byte) (ObjectManifest, error) { + decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(data), 4096) + deser := clientscheme.Codecs.UniversalDeserializer() + + objects := ObjectManifest{} + for { + ext := runtime.RawExtension{} + if err := decoder.Decode(&ext); err != nil { + if err == io.EOF { + break + } + return nil, err + } + + obj, _, err := deser.Decode([]byte(ext.Raw), nil, nil) + if err != nil { + return nil, err + } + + key := obj.GetObjectKind().GroupVersionKind() + if v, ok := objects[key]; ok { + objects[key] = append(v, obj) + } else { + objects[key] = []runtime.Object{obj} + } + } + + return objects, nil +} diff --git a/pkg/kubeutil/manifest_test.go b/pkg/kubeutil/manifest_test.go new file mode 100644 index 0000000000..c4137005fc --- /dev/null +++ b/pkg/kubeutil/manifest_test.go @@ -0,0 +1,178 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kubeutil + +import ( + "testing" + + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const validManifest = ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + namespace: app-scoped + labels: + app: nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: my-service +spec: + selector: + app.kubernetes.io/name: MyApp + ports: + - protocol: TCP + port: 80 + targetPort: 9376 +` + +const validManifestWithSecrets = ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + namespace: app-scoped + labels: + app: nginx +spec: + replicas: 3 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Secret +metadata: + name: secret-admin +type: Opaque +stringData: + username: admin + password: password +--- +apiVersion: v1 +kind: Secret +metadata: + name: secret-user +type: Opaque +stringData: + username: user + password: password +` + +const invalidManifest = ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + namespace: app-scoped + labels: + app: nginx +spec: + replicas: 3 + sele +` + +func TestParseManifest(t *testing.T) { + manifestTests := []struct { + name string + manifest string + types map[schema.GroupVersionKind]int + errString string + }{ + { + name: "valid manifest with deployments and services", + manifest: validManifest, + types: map[schema.GroupVersionKind]int{ + appsv1.SchemeGroupVersion.WithKind("Deployment"): 1, + corev1.SchemeGroupVersion.WithKind("Service"): 1, + }, + errString: "", + }, + { + name: "valid manifest with deployments and secrets", + manifest: validManifestWithSecrets, + types: map[schema.GroupVersionKind]int{ + appsv1.SchemeGroupVersion.WithKind("Deployment"): 1, + corev1.SchemeGroupVersion.WithKind("Secret"): 2, + }, + errString: "", + }, + { + name: "invalid manifest", + manifest: invalidManifest, + errString: "error converting YAML to JSON: yaml: line 12: could not find expected ':'", + }, + } + + for _, tc := range manifestTests { + t.Run(tc.name, func(t *testing.T) { + objects, err := ParseManifest([]byte(tc.manifest)) + if tc.errString != "" { + require.Error(t, err) + require.Contains(t, err.Error(), tc.errString) + return + } + + require.NoError(t, err) + for k := range objects { + require.Equal(t, tc.types[k], len(objects[k])) + } + }) + } +} + +func TestObjectManifest(t *testing.T) { + base, err := ParseManifest([]byte(validManifestWithSecrets)) + + require.NoError(t, err) + require.Len(t, base.Get(appsv1.SchemeGroupVersion.WithKind("Deployment")), 1) + require.Len(t, base.Get(corev1.SchemeGroupVersion.WithKind("ConfigMap")), 0) + require.Equal(t, base.GetFirst(appsv1.SchemeGroupVersion.WithKind("Deployment")).GetObjectKind().GroupVersionKind().Kind, "Deployment") + require.Nil(t, base.GetFirst(corev1.SchemeGroupVersion.WithKind("ConfigMap"))) +} diff --git a/pkg/kubeutil/namespace.go b/pkg/kubeutil/namespace.go index ff0015457b..3059411bbc 100644 --- a/pkg/kubeutil/namespace.go +++ b/pkg/kubeutil/namespace.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/kubernetes" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime_client "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/pkg/kubeutil/namespace_test.go b/pkg/kubeutil/namespace_test.go index 6b8fe1cfdc..f8f591af88 100644 --- a/pkg/kubeutil/namespace_test.go +++ b/pkg/kubeutil/namespace_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/project-radius/radius/test/k8sutil" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/require" "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/linkrp/api/README.md b/pkg/linkrp/api/README.md deleted file mode 100644 index 2dcfada3ef..0000000000 --- a/pkg/linkrp/api/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# API models - -This directory includes API version specific models from open api specs. The models in this directory is used for serializing/deserializing request and response. [datamodels](../datamodel/) has the converters to convert between version specific models and datamodels. datamodels will be used for internal controller and datastorage. - -## Generate new models -### Prerequisites -1. Install [NodeJS](https://nodejs.org/) -2. Install [AutoRest](http://aka.ms/autorest) -``` -npm install -g autorest -``` - -### Add new api-version - -1. Add api version tags and openapi file below in this README.md -2. Run autorest. -```bash -autorest README.md --tag=link-2022-03-15-privatepreview -``` -3. Create or modify the corresponding datamodels in [datamodel](../datamodel/) -4. Add the converter between versioned model and datamodel in [converter](../datamodel/converter/) - ---- - -## Configuration - -The following are the settings for this using this API with AutoRest. - -### Input OpenAPI specificiations - -#### Tag: link-2022-03-15-privatepreview - -These settings apply only when `--tag=link-2022-03-15-privatepreview` is specified on the command line. - -```yaml $(tag) == 'link-2022-03-15-privatepreview' -input-file: - - ../../../swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/openapi.json - - ../../../swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/extenders.json -modelerfour: - treat-type-object-as-anything: false -``` -### Common - -The following configuration generates track2 go models and client. - -```yaml $(tag) != '' -version: 3.*.* -use: "@autorest/go@4.0.0-preview.44" -module-version: 0.0.1 -file-prefix: zz_generated_ -license-header: "Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information.\nCode generated by Microsoft (R) AutoRest Code Generator.\nChanges may cause incorrect behavior and will be lost if the code is regenerated." -azure-arm: true -``` - -### Output - -#### Tag: link-2022-03-15-privatepreview - -These settings apply only when `--tag=link-2022-03-15-privatepreview` is specified on the command line. - -```yaml $(tag) == 'link-2022-03-15-privatepreview' -output-folder: ./v20220315privatepreview -``` \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/daprpubsubbroker_conversion.go b/pkg/linkrp/api/v20220315privatepreview/daprpubsubbroker_conversion.go deleted file mode 100644 index 78541bdadd..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/daprpubsubbroker_conversion.go +++ /dev/null @@ -1,151 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "fmt" - "reflect" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned DaprPubSubBroker resource to version-agnostic datamodel, validating the input -// and returning an error if any of the validation checks fail. -func (src *DaprPubSubBrokerResource) ConvertTo() (v1.DataModelInterface, error) { - daprPubSubproperties := datamodel.DaprPubSubBrokerProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - } - - trackedResource := v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - } - internalMetadata := v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - } - converted := &datamodel.DaprPubSubBroker{} - converted.TrackedResource = trackedResource - converted.InternalMetadata = internalMetadata - converted.Properties = daprPubSubproperties - - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(src.Properties.ResourceProvisioning) - if err != nil { - return nil, err - } - - converted.Properties.Resources = toResourcesDataModel(src.Properties.Resources) - - // Note: The metadata, type, and version fields cannot be specified when using recipes since - // the recipe is expected to create the Dapr Component manifest. However, they are required - // when resourceProvisioning is set to manual. - msgs := []string{} - if converted.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - if src.Properties.Recipe != nil && (!reflect.ValueOf(*src.Properties.Recipe).IsZero()) { - msgs = append(msgs, "recipe details cannot be specified when resourceProvisioning is set to manual") - } - if src.Properties.Metadata == nil || len(src.Properties.Metadata) == 0 { - msgs = append(msgs, "metadata must be specified when resourceProvisioning is set to manual") - } - if src.Properties.Type == nil || *src.Properties.Type == "" { - msgs = append(msgs, "type must be specified when resourceProvisioning is set to manual") - } - if src.Properties.Version == nil || *src.Properties.Version == "" { - msgs = append(msgs, "version must be specified when resourceProvisioning is set to manual") - } - - converted.Properties.Metadata = src.Properties.Metadata - converted.Properties.Type = to.String(src.Properties.Type) - converted.Properties.Version = to.String(src.Properties.Version) - } else { - if src.Properties.Metadata != nil && (!reflect.ValueOf(src.Properties.Metadata).IsZero()) { - msgs = append(msgs, "metadata cannot be specified when resourceProvisioning is set to recipe (default)") - } - if src.Properties.Type != nil && (!reflect.ValueOf(*src.Properties.Type).IsZero()) { - msgs = append(msgs, "type cannot be specified when resourceProvisioning is set to recipe (default)") - } - if src.Properties.Version != nil && (!reflect.ValueOf(*src.Properties.Version).IsZero()) { - msgs = append(msgs, "version cannot be specified when resourceProvisioning is set to recipe (default)") - } - - converted.Properties.Recipe = toRecipeDataModel(src.Properties.Recipe) - } - - if len(msgs) == 1 { - return nil, &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: msgs[0], - } - } else if len(msgs) > 1 { - return nil, &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: fmt.Sprintf("multiple errors were found:\n\t%v", strings.Join(msgs, "\n\t")), - } - } - - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned DaprPubSubBroker resource. -// If the DataModelInterface is not of the correct type, an error is returned. -func (dst *DaprPubSubBrokerResource) ConvertFrom(src v1.DataModelInterface) error { - daprPubSub, ok := src.(*datamodel.DaprPubSubBroker) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(daprPubSub.ID) - dst.Name = to.Ptr(daprPubSub.Name) - dst.Type = to.Ptr(daprPubSub.Type) - dst.SystemData = fromSystemDataModel(daprPubSub.SystemData) - dst.Location = to.Ptr(daprPubSub.Location) - dst.Tags = *to.StringMapPtr(daprPubSub.Tags) - - dst.Properties = &DaprPubSubBrokerProperties{ - Environment: to.Ptr(daprPubSub.Properties.Environment), - Application: to.Ptr(daprPubSub.Properties.Application), - ResourceProvisioning: fromResourceProvisioningDataModel(daprPubSub.Properties.ResourceProvisioning), - Resources: fromResourcesDataModel(daprPubSub.Properties.Resources), - ComponentName: to.Ptr(daprPubSub.Properties.ComponentName), - ProvisioningState: fromProvisioningStateDataModel(daprPubSub.InternalMetadata.AsyncProvisioningState), - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(daprPubSub.Properties.Status.OutputResources), - }, - } - - if daprPubSub.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - dst.Properties.Metadata = daprPubSub.Properties.Metadata - dst.Properties.Type = to.Ptr(daprPubSub.Properties.Type) - dst.Properties.Version = to.Ptr(daprPubSub.Properties.Version) - } else { - dst.Properties.Recipe = fromRecipeDataModel(daprPubSub.Properties.Recipe) - } - - return nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/daprpubsubbroker_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/daprpubsubbroker_conversion_test.go deleted file mode 100644 index 56a5fc83ae..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/daprpubsubbroker_conversion_test.go +++ /dev/null @@ -1,281 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestDaprPubSubBroker_ConvertVersionedToDataModel(t *testing.T) { - testCases := []struct { - desc string - file string - expected *datamodel.DaprPubSubBroker - }{ - { - desc: "Manual provisioning of a DaprPubSubBroker", - file: "daprpubsubbroker/daprpubsubbroker_manual_resource.json", - expected: &datamodel.DaprPubSubBroker{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - Name: "test-dpsb", - Type: linkrp.DaprPubSubBrokersResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.DaprPubSubBrokerProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{ - "foo": "bar", - }, - Resources: []*linkrp.ResourceReference{ - { - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async", - }, - }, - Type: "pubsub.azure.servicebus", - Version: "v1", - }, - }, - }, - { - desc: "Provisioning by a Recipe of a DaprPubSubBroker", - file: "daprpubsubbroker/daprpubsubbroker_recipe_resource.json", - expected: &datamodel.DaprPubSubBroker{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - Name: "test-dpsb", - Type: linkrp.DaprPubSubBrokersResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.DaprPubSubBrokerProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Recipe: linkrp.LinkRecipe{ - Name: "dpsb-recipe", - }, - }, - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - versionedResource := &DaprPubSubBrokerResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - // act - dm, err := versionedResource.ConvertTo() - - // assert - require.NoError(t, err) - convertedResource := dm.(*datamodel.DaprPubSubBroker) - - require.Equal(t, tc.expected, convertedResource) - }) - } -} - -func TestDaprPubSubBroker_ConvertVersionedToDataModel_Invalid(t *testing.T) { - testset := []struct { - payload string - errType error - message string - }{ - { - "daprpubsubbroker/daprpubsubbroker_invalidmanual_resource.json", - &v1.ErrClientRP{}, - "code BadRequest: err multiple errors were found:\n\trecipe details cannot be specified when resourceProvisioning is set to manual\n\tmetadata must be specified when resourceProvisioning is set to manual\n\ttype must be specified when resourceProvisioning is set to manual\n\tversion must be specified when resourceProvisioning is set to manual", - }, - { - "daprpubsubbroker/daprpubsubbroker_invalidrecipe_resource.json", - &v1.ErrClientRP{}, - "code BadRequest: err multiple errors were found:\n\tmetadata cannot be specified when resourceProvisioning is set to recipe (default)\n\ttype cannot be specified when resourceProvisioning is set to recipe (default)\n\tversion cannot be specified when resourceProvisioning is set to recipe (default)", - }, - } - - for _, test := range testset { - t.Run(test.payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) - versionedResource := &DaprStateStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - dm, err := versionedResource.ConvertTo() - require.Error(t, err) - require.Nil(t, dm) - require.IsType(t, test.errType, err) - require.Equal(t, test.message, err.Error()) - }) - } -} - -func TestDaprPubSubBroker_ConvertDataModelToVersioned(t *testing.T) { - testCases := []struct { - desc string - file string - expected *DaprPubSubBrokerResource - }{ - { - desc: "Convert manually provisioned DaprPubSubBroker datamodel to versioned resource", - file: "daprpubsubbroker/daprpubsubbroker_manual_datamodel.json", - expected: &DaprPubSubBrokerResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &DaprPubSubBrokerProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - Metadata: map[string]any{ - "foo": "bar", - }, - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - Resources: []*ResourceReference{ - { - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async"), - }, - }, - Type: to.Ptr("pubsub.azure.servicebus"), - Version: to.Ptr("v1"), - ComponentName: to.Ptr("test-dpsb"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb"), - Name: to.Ptr("test-dpsb"), - Type: to.Ptr(linkrp.DaprPubSubBrokersResourceType), - }, - }, - { - desc: "Convert DaprPubSubBroker datamodel provisioned by a recipe to versioned resource", - file: "daprpubsubbroker/daprpubsubbroker_recipe_datamodel.json", - expected: &DaprPubSubBrokerResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &DaprPubSubBrokerProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - Recipe: &Recipe{ - Name: to.Ptr("dpsb-recipe"), - }, - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - ComponentName: to.Ptr("test-dpsb"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb"), - Name: to.Ptr("test-dpsb"), - Type: to.Ptr(linkrp.DaprPubSubBrokersResourceType), - }, - }, - } - - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - resource := &datamodel.DaprPubSubBroker{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &DaprPubSubBrokerResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - require.Equal(t, tc.expected, versionedResource) - }) - } -} - -func TestDaprPubSubBroker_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &DaprPubSubBrokerResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/daprsecretstore_conversion.go b/pkg/linkrp/api/v20220315privatepreview/daprsecretstore_conversion.go deleted file mode 100644 index 18d9b898e7..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/daprsecretstore_conversion.go +++ /dev/null @@ -1,141 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "fmt" - "reflect" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned DaprSecretStore resource to version-agnostic datamodel and returns an error if the -// resourceProvisioning is set to manual and the required fields are not specified. -func (src *DaprSecretStoreResource) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.DaprSecretStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - }, - InternalMetadata: v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - }, - }, - Properties: datamodel.DaprSecretStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - }, - } - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(src.Properties.ResourceProvisioning) - if err != nil { - return nil, err - } - - msgs := []string{} - if converted.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - if src.Properties.Recipe != nil && (!reflect.ValueOf(*src.Properties.Recipe).IsZero()) { - msgs = append(msgs, "recipe details cannot be specified when resourceProvisioning is set to manual") - } - if src.Properties.Metadata == nil || len(src.Properties.Metadata) == 0 { - msgs = append(msgs, "metadata must be specified when resourceProvisioning is set to manual") - } - if src.Properties.Type == nil || *src.Properties.Type == "" { - msgs = append(msgs, "type must be specified when resourceProvisioning is set to manual") - } - if src.Properties.Version == nil || *src.Properties.Version == "" { - msgs = append(msgs, "version must be specified when resourceProvisioning is set to manual") - } - - converted.Properties.Metadata = src.Properties.Metadata - converted.Properties.Type = to.String(src.Properties.Type) - converted.Properties.Version = to.String(src.Properties.Version) - } else { - if src.Properties.Metadata != nil && (!reflect.ValueOf(src.Properties.Metadata).IsZero()) { - msgs = append(msgs, "metadata cannot be specified when resourceProvisioning is set to recipe (default)") - } - if src.Properties.Type != nil && (!reflect.ValueOf(*src.Properties.Type).IsZero()) { - msgs = append(msgs, "type cannot be specified when resourceProvisioning is set to recipe (default)") - } - if src.Properties.Version != nil && (!reflect.ValueOf(*src.Properties.Version).IsZero()) { - msgs = append(msgs, "version cannot be specified when resourceProvisioning is set to recipe (default)") - } - - converted.Properties.Recipe = toRecipeDataModel(src.Properties.Recipe) - } - if len(msgs) == 1 { - return nil, &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: msgs[0], - } - } else if len(msgs) > 1 { - return nil, &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: fmt.Sprintf("multiple errors were found:\n\t%v", strings.Join(msgs, "\n\t")), - } - } - - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned DaprSecretStore resource. -func (dst *DaprSecretStoreResource) ConvertFrom(src v1.DataModelInterface) error { - daprSecretStore, ok := src.(*datamodel.DaprSecretStore) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(daprSecretStore.ID) - dst.Name = to.Ptr(daprSecretStore.Name) - dst.Type = to.Ptr(daprSecretStore.Type) - dst.SystemData = fromSystemDataModel(daprSecretStore.SystemData) - dst.Location = to.Ptr(daprSecretStore.Location) - dst.Tags = *to.StringMapPtr(daprSecretStore.Tags) - dst.Properties = &DaprSecretStoreProperties{ - ResourceProvisioning: fromResourceProvisioningDataModel(daprSecretStore.Properties.ResourceProvisioning), - ProvisioningState: fromProvisioningStateDataModel(daprSecretStore.InternalMetadata.AsyncProvisioningState), - Environment: to.Ptr(daprSecretStore.Properties.Environment), - Application: to.Ptr(daprSecretStore.Properties.Application), - Type: to.Ptr(daprSecretStore.Properties.Type), - Version: to.Ptr(daprSecretStore.Properties.Version), - Metadata: daprSecretStore.Properties.Metadata, - ComponentName: to.Ptr(daprSecretStore.Properties.ComponentName), - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(daprSecretStore.Properties.Status.OutputResources), - }, - } - if daprSecretStore.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - dst.Properties.Metadata = daprSecretStore.Properties.Metadata - dst.Properties.Type = to.Ptr(daprSecretStore.Properties.Type) - dst.Properties.Version = to.Ptr(daprSecretStore.Properties.Version) - } else { - dst.Properties.Recipe = fromRecipeDataModel(daprSecretStore.Properties.Recipe) - } - return nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/daprsecretstore_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/daprsecretstore_conversion_test.go deleted file mode 100644 index 85f44d36a0..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/daprsecretstore_conversion_test.go +++ /dev/null @@ -1,279 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - - "github.com/stretchr/testify/require" -) - -func TestDaprSecretStore_ConvertVersionedToDataModel(t *testing.T) { - testCases := []struct { - desc string - file string - expected *datamodel.DaprSecretStore - }{ - { - desc: "daprsecretstore manual resource", - file: "daprsecretstore_manual_resource.json", - expected: &datamodel.DaprSecretStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss", - Name: "test-dss", - Type: linkrp.DaprSecretStoresResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.DaprSecretStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{ - "foo": "bar", - }, - Type: "secretstores.hashicorp.vault", - Version: "v1", - }, - }, - }, - { - desc: "daprsecretstore recipe resource", - file: "daprsecretstore_recipe_resource.json", - expected: &datamodel.DaprSecretStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss", - Name: "test-dss", - Type: linkrp.DaprSecretStoresResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.DaprSecretStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Recipe: linkrp.LinkRecipe{ - Name: "daprSecretStore", - Parameters: map[string]any{ - "foo": "bar", - }, - }, - }, - }, - }, - } - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - versionedResource := &DaprSecretStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - // act - dm, err := versionedResource.ConvertTo() - - // assert - require.NoError(t, err) - convertedResource := dm.(*datamodel.DaprSecretStore) - - require.Equal(t, tc.expected, convertedResource) - }) - } -} - -func TestDaprSecretStore_ConvertDataModelToVersioned(t *testing.T) { - testCases := []struct { - desc string - file string - expected *DaprSecretStoreResource - }{ - { - desc: "daprsecretstore manual resource data model", - file: "daprsecretstore_manual_resourcedatamodel.json", - expected: &DaprSecretStoreResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &DaprSecretStoreProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - Metadata: map[string]any{ - "foo": "bar", - }, - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - Type: to.Ptr("secretstores.hashicorp.vault"), - Version: to.Ptr("v1"), - ComponentName: to.Ptr("test-dss"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss"), - Name: to.Ptr("test-dss"), - Type: to.Ptr(linkrp.DaprSecretStoresResourceType), - }, - }, - { - desc: "daprsecretstore recipe resource data model", - file: "daprsecretstore_recipe_resourcedatamodel.json", - expected: &DaprSecretStoreResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &DaprSecretStoreProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - Recipe: &Recipe{ - Name: to.Ptr("daprSecretStore"), - Parameters: map[string]any{ - "foo": "bar", - }, - }, - Type: to.Ptr("secretstores.hashicorp.vault"), - Version: to.Ptr("v1"), - Metadata: map[string]any{"foo": "bar"}, - ComponentName: to.Ptr("test-dss"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss"), - Name: to.Ptr("test-dss"), - Type: to.Ptr(linkrp.DaprSecretStoresResourceType), - }, - }, - } - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - resource := &datamodel.DaprSecretStore{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &DaprSecretStoreResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - require.Equal(t, tc.expected, versionedResource) - }) - } - -} - -func TestDaprSecretStore_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) { - testset := []struct { - payload string - errType error - message string - }{ - { - "daprsecretstore_invalidvalues_resource.json", - &v1.ErrClientRP{}, - "code BadRequest: err multiple errors were found:\n\trecipe details cannot be specified when resourceProvisioning is set to manual\n\tmetadata must be specified when resourceProvisioning is set to manual\n\ttype must be specified when resourceProvisioning is set to manual\n\tversion must be specified when resourceProvisioning is set to manual", - }, - { - "daprsecretstore_invalidrecipe_resource.json", - &v1.ErrClientRP{}, - "code BadRequest: err multiple errors were found:\n\tmetadata cannot be specified when resourceProvisioning is set to recipe (default)\n\ttype cannot be specified when resourceProvisioning is set to recipe (default)\n\tversion cannot be specified when resourceProvisioning is set to recipe (default)", - }, - } - for _, test := range testset { - t.Run(test.payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) - versionedResource := &DaprSecretStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - dm, err := versionedResource.ConvertTo() - require.Error(t, err) - require.Nil(t, dm) - require.IsType(t, test.errType, err) - require.Equal(t, test.message, err.Error()) - }) - } -} - -func TestDaprSecretStore_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &DaprSecretStoreResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/daprstatestore_conversion.go b/pkg/linkrp/api/v20220315privatepreview/daprstatestore_conversion.go deleted file mode 100644 index c7ab73b3c6..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/daprstatestore_conversion.go +++ /dev/null @@ -1,134 +0,0 @@ -package v20220315privatepreview - -import ( - "fmt" - "reflect" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned DaprStateStore resource to version-agnostic datamodel and returns an error -// if the resourceProvisioning is set to manual and the required fields are not specified. -func (src *DaprStateStoreResource) ConvertTo() (v1.DataModelInterface, error) { - daprStateStoreProperties := datamodel.DaprStateStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - } - - trackedResource := v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - } - internalMetadata := v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - } - converted := &datamodel.DaprStateStore{} - converted.TrackedResource = trackedResource - converted.InternalMetadata = internalMetadata - converted.Properties = daprStateStoreProperties - - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(src.Properties.ResourceProvisioning) - if err != nil { - return nil, err - } - - converted.Properties.Resources = toResourcesDataModel(src.Properties.Resources) - - // Note: The metadata, type, and version fields cannot be specified when using recipes since - // the recipe is expected to create the Dapr Component manifest. However, they are required - // when resourceProvisioning is set to manual. - msgs := []string{} - if converted.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - if src.Properties.Recipe != nil && (!reflect.ValueOf(*src.Properties.Recipe).IsZero()) { - msgs = append(msgs, "recipe details cannot be specified when resourceProvisioning is set to manual") - } - if src.Properties.Metadata == nil || len(src.Properties.Metadata) == 0 { - msgs = append(msgs, "metadata must be specified when resourceProvisioning is set to manual") - } - if src.Properties.Type == nil || *src.Properties.Type == "" { - msgs = append(msgs, "type must be specified when resourceProvisioning is set to manual") - } - if src.Properties.Version == nil || *src.Properties.Version == "" { - msgs = append(msgs, "version must be specified when resourceProvisioning is set to manual") - } - - converted.Properties.Metadata = src.Properties.Metadata - converted.Properties.Type = to.String(src.Properties.Type) - converted.Properties.Version = to.String(src.Properties.Version) - } else { - if src.Properties.Metadata != nil && (!reflect.ValueOf(src.Properties.Metadata).IsZero()) { - msgs = append(msgs, "metadata cannot be specified when resourceProvisioning is set to recipe (default)") - } - if src.Properties.Type != nil && (!reflect.ValueOf(*src.Properties.Type).IsZero()) { - msgs = append(msgs, "type cannot be specified when resourceProvisioning is set to recipe (default)") - } - if src.Properties.Version != nil && (!reflect.ValueOf(*src.Properties.Version).IsZero()) { - msgs = append(msgs, "version cannot be specified when resourceProvisioning is set to recipe (default)") - } - - converted.Properties.Recipe = toRecipeDataModel(src.Properties.Recipe) - } - - if len(msgs) == 1 { - return nil, &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: msgs[0], - } - } else if len(msgs) > 1 { - return nil, &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: fmt.Sprintf("multiple errors were found:\n\t%v", strings.Join(msgs, "\n\t")), - } - } - - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned DaprStateStore resource and returns an error if the -// conversion fails. -func (dst *DaprStateStoreResource) ConvertFrom(src v1.DataModelInterface) error { - daprStateStore, ok := src.(*datamodel.DaprStateStore) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(daprStateStore.ID) - dst.Name = to.Ptr(daprStateStore.Name) - dst.Type = to.Ptr(daprStateStore.Type) - dst.SystemData = fromSystemDataModel(daprStateStore.SystemData) - dst.Location = to.Ptr(daprStateStore.Location) - dst.Tags = *to.StringMapPtr(daprStateStore.Tags) - dst.Properties = &DaprStateStoreProperties{ - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(daprStateStore.Properties.Status.OutputResources), - }, - ProvisioningState: fromProvisioningStateDataModel(daprStateStore.InternalMetadata.AsyncProvisioningState), - Environment: to.Ptr(daprStateStore.Properties.Environment), - Application: to.Ptr(daprStateStore.Properties.Application), - ComponentName: to.Ptr(daprStateStore.Properties.ComponentName), - ResourceProvisioning: fromResourceProvisioningDataModel(daprStateStore.Properties.ResourceProvisioning), - Resources: fromResourcesDataModel(daprStateStore.Properties.Resources), - } - - if daprStateStore.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - dst.Properties.Type = to.Ptr(daprStateStore.Properties.Type) - dst.Properties.Version = to.Ptr(daprStateStore.Properties.Version) - dst.Properties.Metadata = daprStateStore.Properties.Metadata - } else { - dst.Properties.Recipe = fromRecipeDataModel(daprStateStore.Properties.Recipe) - } - - return nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/daprstatestore_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/daprstatestore_conversion_test.go deleted file mode 100644 index d545baca3e..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/daprstatestore_conversion_test.go +++ /dev/null @@ -1,208 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestDaprStateStore_ConvertVersionedToDataModel(t *testing.T) { - testset := []string{ - "daprstatestore_values_resource.json", - "daprstatestore_recipe_resource.json", - } - - for _, payload := range testset { - t.Run(payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + payload) - require.NoError(t, err) - versionedResource := &DaprStateStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - dm, err := versionedResource.ConvertTo() - - require.NoError(t, err) - convertedResource := dm.(*datamodel.DaprStateStore) - - expected := &datamodel.DaprStateStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0", - Name: "daprStateStore0", - Type: linkrp.DaprStateStoresResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.DaprStateStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - }, - } - if payload == "daprstatestore_values_resource.json" { - expected.Properties.ResourceProvisioning = linkrp.ResourceProvisioningManual - expected.Properties.Type = "state.zookeeper" - expected.Properties.Version = "v1" - expected.Properties.Metadata = map[string]any{ - "foo": "bar", - } - expected.Properties.Resources = []*linkrp.ResourceReference{ - { - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase", - }, - } - } else if payload == "daprstatestore_recipe_resource.json" { - expected.Properties.ResourceProvisioning = linkrp.ResourceProvisioningRecipe - expected.Properties.Recipe.Name = "recipe-test" - } - - require.Equal(t, expected, convertedResource) - }) - } -} - -func TestDaprStateStore_ConvertVersionedToDataModel_Invalid(t *testing.T) { - testset := []struct { - payload string - errType error - message string - }{ - {"daprstatestore_invalidvalues_resource.json", &v1.ErrClientRP{}, "code BadRequest: err multiple errors were found:\n\trecipe details cannot be specified when resourceProvisioning is set to manual\n\tmetadata must be specified when resourceProvisioning is set to manual\n\ttype must be specified when resourceProvisioning is set to manual\n\tversion must be specified when resourceProvisioning is set to manual"}, - {"daprstatestore_invalidrecipe_resource.json", &v1.ErrClientRP{}, "code BadRequest: err multiple errors were found:\n\tmetadata cannot be specified when resourceProvisioning is set to recipe (default)\n\ttype cannot be specified when resourceProvisioning is set to recipe (default)\n\tversion cannot be specified when resourceProvisioning is set to recipe (default)"}, - } - - for _, test := range testset { - t.Run(test.payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) - versionedResource := &DaprStateStoreResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - dm, err := versionedResource.ConvertTo() - require.Error(t, err) - require.Nil(t, dm) - require.IsType(t, test.errType, err) - require.Equal(t, test.message, err.Error()) - }) - } -} - -func TestDaprStateStore_ConvertDataModelToVersioned(t *testing.T) { - testset := []string{ - "daprstatestore_values_resourcedatamodel.json", - "daprstatestore_recipe_resourcedatamodel.json", - } - - for _, payload := range testset { - t.Run(payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + payload) - require.NoError(t, err) - resource := &datamodel.DaprStateStore{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &DaprStateStoreResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - expected := &DaprStateStoreResource{ - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0"), - Name: to.Ptr("daprStateStore0"), - Type: to.Ptr(linkrp.DaprStateStoresResourceType), - Location: to.Ptr(v1.LocationGlobal), - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - Properties: &DaprStateStoreProperties{ - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), - ComponentName: to.Ptr("daprStateStore0"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "kubernetes", - }, - }, - }, - }, - } - - if payload == "daprstatestore_values_resourcedatamodel.json" { - expected.Properties.ResourceProvisioning = to.Ptr(ResourceProvisioningManual) - expected.Properties.Type = to.Ptr("state.zookeeper") - expected.Properties.Version = to.Ptr("v1") - expected.Properties.Metadata = map[string]any{ - "foo": "bar", - } - expected.Properties.Resources = []*ResourceReference{ - { - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase"), - }, - } - } else if payload == "daprstatestore_recipe_resourcedatamodel.json" { - expected.Properties.ResourceProvisioning = to.Ptr(ResourceProvisioningRecipe) - expected.Properties.Recipe = &Recipe{ - Name: to.Ptr("recipe-test"), - } - } - - require.Equal(t, expected, versionedResource) - }) - } -} - -func TestDaprStateStore_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &DaprStateStoreResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/datamodel_util.go b/pkg/linkrp/api/v20220315privatepreview/datamodel_util.go deleted file mode 100644 index 6f77b73d4e..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/datamodel_util.go +++ /dev/null @@ -1,163 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "fmt" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/to" -) - -// DefaultRecipeName represents the default recipe name. -const DefaultRecipeName = "default" - -func toProvisioningStateDataModel(state *ProvisioningState) v1.ProvisioningState { - if state == nil { - return v1.ProvisioningStateAccepted - } - - switch *state { - case ProvisioningStateUpdating: - return v1.ProvisioningStateUpdating - case ProvisioningStateDeleting: - return v1.ProvisioningStateDeleting - case ProvisioningStateAccepted: - return v1.ProvisioningStateAccepted - case ProvisioningStateSucceeded: - return v1.ProvisioningStateSucceeded - case ProvisioningStateFailed: - return v1.ProvisioningStateFailed - case ProvisioningStateCanceled: - return v1.ProvisioningStateCanceled - case ProvisioningStateProvisioning: - return v1.ProvisioningStateProvisioning - default: - return v1.ProvisioningStateAccepted - } -} - -func fromProvisioningStateDataModel(state v1.ProvisioningState) *ProvisioningState { - var converted ProvisioningState - switch state { - case v1.ProvisioningStateUpdating: - converted = ProvisioningStateUpdating - case v1.ProvisioningStateDeleting: - converted = ProvisioningStateDeleting - case v1.ProvisioningStateAccepted: - converted = ProvisioningStateAccepted - case v1.ProvisioningStateSucceeded: - converted = ProvisioningStateSucceeded - case v1.ProvisioningStateFailed: - converted = ProvisioningStateFailed - case v1.ProvisioningStateCanceled: - converted = ProvisioningStateCanceled - default: - converted = ProvisioningStateAccepted - } - - return &converted -} - -func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (linkrp.ResourceProvisioning, error) { - if provisioning == nil { - return linkrp.ResourceProvisioningRecipe, nil - } - switch *provisioning { - case ResourceProvisioningManual: - return linkrp.ResourceProvisioningManual, nil - case ResourceProvisioningRecipe: - return linkrp.ResourceProvisioningRecipe, nil - default: - return "", &v1.ErrModelConversion{PropertyName: "$.properties.resourceProvisioning", ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues())} - } -} - -func fromResourceProvisioningDataModel(provisioning linkrp.ResourceProvisioning) *ResourceProvisioning { - var converted ResourceProvisioning - switch provisioning { - case linkrp.ResourceProvisioningManual: - converted = ResourceProvisioningManual - default: - converted = ResourceProvisioningRecipe - } - - return &converted -} - -func fromSystemDataModel(s v1.SystemData) *SystemData { - return &SystemData{ - CreatedBy: to.Ptr(s.CreatedBy), - CreatedByType: (*CreatedByType)(to.Ptr(s.CreatedByType)), - CreatedAt: UnmarshalTimeString(s.CreatedAt), - LastModifiedBy: to.Ptr(s.LastModifiedBy), - LastModifiedByType: (*CreatedByType)(to.Ptr(s.LastModifiedByType)), - LastModifiedAt: UnmarshalTimeString(s.LastModifiedAt), - } -} - -func toRecipeDataModel(r *Recipe) linkrp.LinkRecipe { - if r == nil { - return linkrp.LinkRecipe{ - Name: DefaultRecipeName, - } - } - recipe := linkrp.LinkRecipe{} - if r.Name == nil { - recipe.Name = DefaultRecipeName - } else { - recipe.Name = to.String(r.Name) - } - if r.Parameters != nil { - recipe.Parameters = r.Parameters - } - return recipe -} - -func fromRecipeDataModel(r linkrp.LinkRecipe) *Recipe { - return &Recipe{ - Name: to.Ptr(r.Name), - Parameters: r.Parameters, - } -} - -func toResourcesDataModel(r []*ResourceReference) []*linkrp.ResourceReference { - if r == nil { - return nil - } - resources := make([]*linkrp.ResourceReference, len(r)) - for i, resource := range r { - resources[i] = &linkrp.ResourceReference{ - ID: to.String(resource.ID), - } - } - return resources -} - -func fromResourcesDataModel(r []*linkrp.ResourceReference) []*ResourceReference { - if r == nil { - return nil - } - resources := make([]*ResourceReference, len(r)) - for i, resource := range r { - resources[i] = &ResourceReference{ - ID: to.Ptr(resource.ID), - } - } - return resources -} diff --git a/pkg/linkrp/api/v20220315privatepreview/datamodel_util_test.go b/pkg/linkrp/api/v20220315privatepreview/datamodel_util_test.go deleted file mode 100644 index 77e5188b50..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/datamodel_util_test.go +++ /dev/null @@ -1,272 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "fmt" - "testing" - "time" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/to" - - "github.com/stretchr/testify/require" -) - -func TestToProvisioningStateDataModel(t *testing.T) { - stateTests := []struct { - versioned ProvisioningState - datamodel v1.ProvisioningState - }{ - {ProvisioningStateUpdating, v1.ProvisioningStateUpdating}, - {ProvisioningStateDeleting, v1.ProvisioningStateDeleting}, - {ProvisioningStateAccepted, v1.ProvisioningStateAccepted}, - {ProvisioningStateSucceeded, v1.ProvisioningStateSucceeded}, - {ProvisioningStateFailed, v1.ProvisioningStateFailed}, - {ProvisioningStateCanceled, v1.ProvisioningStateCanceled}, - {"", v1.ProvisioningStateAccepted}, - } - - for _, tt := range stateTests { - sc := toProvisioningStateDataModel(&tt.versioned) - require.Equal(t, tt.datamodel, sc) - } -} - -func TestFromProvisioningStateDataModel(t *testing.T) { - testCases := []struct { - datamodel v1.ProvisioningState - versioned ProvisioningState - }{ - {v1.ProvisioningStateUpdating, ProvisioningStateUpdating}, - {v1.ProvisioningStateDeleting, ProvisioningStateDeleting}, - {v1.ProvisioningStateAccepted, ProvisioningStateAccepted}, - {v1.ProvisioningStateSucceeded, ProvisioningStateSucceeded}, - {v1.ProvisioningStateFailed, ProvisioningStateFailed}, - {v1.ProvisioningStateCanceled, ProvisioningStateCanceled}, - {"", ProvisioningStateAccepted}, - } - - for _, testCase := range testCases { - sc := fromProvisioningStateDataModel(testCase.datamodel) - require.Equal(t, testCase.versioned, *sc) - } -} - -func TestUnmarshalTimeString(t *testing.T) { - parsedTime := UnmarshalTimeString("2021-09-24T19:09:00.000000Z") - require.NotNil(t, parsedTime) - - require.Equal(t, 2021, parsedTime.Year()) - require.Equal(t, time.Month(9), parsedTime.Month()) - require.Equal(t, 24, parsedTime.Day()) - - parsedTime = UnmarshalTimeString("") - require.NotNil(t, parsedTime) - require.Equal(t, 1, parsedTime.Year()) -} - -func TestFromSystemDataModel(t *testing.T) { - systemDataTests := []v1.SystemData{ - { - CreatedBy: "", - CreatedByType: "", - CreatedAt: "", - LastModifiedBy: "", - LastModifiedByType: "", - LastModifiedAt: "", - }, { - CreatedBy: "fakeid@live.com", - CreatedByType: "", - CreatedAt: "2021-09-24T19:09:00Z", - LastModifiedBy: "fakeid@live.com", - LastModifiedByType: "", - LastModifiedAt: "2021-09-25T19:09:00Z", - }, { - CreatedBy: "fakeid@live.com", - CreatedByType: "User", - CreatedAt: "2021-09-24T19:09:00Z", - LastModifiedBy: "fakeid@live.com", - LastModifiedByType: "User", - LastModifiedAt: "2021-09-25T19:09:00Z", - }, - } - - for _, tt := range systemDataTests { - versioned := fromSystemDataModel(tt) - require.Equal(t, tt.CreatedBy, string(*versioned.CreatedBy)) - require.Equal(t, tt.CreatedByType, string(*versioned.CreatedByType)) - c, err := versioned.CreatedAt.MarshalText() - require.NoError(t, err) - if tt.CreatedAt == "" { - tt.CreatedAt = "0001-01-01T00:00:00Z" - } - require.Equal(t, tt.CreatedAt, string(c)) - - require.Equal(t, tt.LastModifiedBy, string(*versioned.LastModifiedBy)) - require.Equal(t, tt.LastModifiedByType, string(*versioned.LastModifiedByType)) - c, err = versioned.LastModifiedAt.MarshalText() - require.NoError(t, err) - if tt.LastModifiedAt == "" { - tt.LastModifiedAt = "0001-01-01T00:00:00Z" - } - require.Equal(t, tt.LastModifiedAt, string(c)) - } -} - -func TestToResourcesDataModel(t *testing.T) { - testset := []struct { - DMResources []*linkrp.ResourceReference - VersionedResources []*ResourceReference - }{ - { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, - VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, - }, - { - DMResources: []*linkrp.ResourceReference{}, - VersionedResources: []*ResourceReference{}, - }, - } - - for _, tt := range testset { - dm := toResourcesDataModel(tt.VersionedResources) - require.Equal(t, tt.DMResources, dm) - - } -} - -func TestFromResourcesDataModel(t *testing.T) { - testset := []struct { - DMResources []*linkrp.ResourceReference - VersionedResources []*ResourceReference - }{ - { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, - VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, - }, - { - DMResources: []*linkrp.ResourceReference{}, - VersionedResources: []*ResourceReference{}, - }, - } - - for _, tt := range testset { - versioned := fromResourcesDataModel(tt.DMResources) - require.Equal(t, tt.VersionedResources, versioned) - - } -} - -func TestToResourceProvisiongDataModel(t *testing.T) { - testset := []struct { - versioned ResourceProvisioning - datamodel linkrp.ResourceProvisioning - err error - }{ - { - ResourceProvisioningManual, - linkrp.ResourceProvisioningManual, - nil, - }, - { - ResourceProvisioningRecipe, - linkrp.ResourceProvisioningRecipe, - nil, - }, - { - "", - "", - &v1.ErrModelConversion{ - PropertyName: "$.properties.resourceProvisioning", - ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues()), - }, - }, - } - for _, tt := range testset { - sc, err := toResourceProvisiongDataModel(&tt.versioned) - - if tt.err != nil { - require.EqualError(t, err, tt.err.Error()) - continue - } - - require.NoError(t, err) - require.Equal(t, tt.datamodel, sc) - } -} - -func TestFromResourceProvisiongDataModel(t *testing.T) { - testCases := []struct { - datamodel linkrp.ResourceProvisioning - versioned ResourceProvisioning - }{ - {linkrp.ResourceProvisioningManual, ResourceProvisioningManual}, - {linkrp.ResourceProvisioningRecipe, ResourceProvisioningRecipe}, - {"", ResourceProvisioningRecipe}, - } - - for _, testCase := range testCases { - sc := fromResourceProvisioningDataModel(testCase.datamodel) - require.Equal(t, testCase.versioned, *sc) - } -} -func TestToRecipeDataModel(t *testing.T) { - testset := []struct { - versioned *Recipe - datamodel linkrp.LinkRecipe - }{ - { - nil, - linkrp.LinkRecipe{ - Name: DefaultRecipeName, - }, - }, - { - &Recipe{ - Name: to.Ptr("test"), - Parameters: map[string]any{ - "foo": "bar", - }, - }, - linkrp.LinkRecipe{ - Name: "test", - Parameters: map[string]any{ - "foo": "bar", - }, - }, - }, - { - &Recipe{ - Parameters: map[string]any{ - "foo": "bar", - }, - }, - linkrp.LinkRecipe{ - Name: DefaultRecipeName, - Parameters: map[string]any{ - "foo": "bar", - }, - }, - }, - } - for _, testCase := range testset { - sc := toRecipeDataModel(testCase.versioned) - require.Equal(t, testCase.datamodel, sc) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/extender_conversion.go b/pkg/linkrp/api/v20220315privatepreview/extender_conversion.go deleted file mode 100644 index 6538ae151a..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/extender_conversion.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned Extender resource to version-agnostic datamodel and returns it, or an error if the -// conversion fails. -func (src *ExtenderResource) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.Extender{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - }, - InternalMetadata: v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - }, - }, - Properties: datamodel.ExtenderProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - AdditionalProperties: src.Properties.AdditionalProperties, - Secrets: src.Properties.Secrets, - Recipe: toRecipeDataModel(src.Properties.Recipe), - }, - } - - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(src.Properties.ResourceProvisioning) - if err != nil { - return nil, err - } - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned Extender resource and returns an error if the conversion fails. -func (dst *ExtenderResource) ConvertFrom(src v1.DataModelInterface) error { - extender, ok := src.(*datamodel.Extender) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(extender.ID) - dst.Name = to.Ptr(extender.Name) - dst.Type = to.Ptr(extender.Type) - dst.SystemData = fromSystemDataModel(extender.SystemData) - dst.Location = to.Ptr(extender.Location) - dst.Tags = *to.StringMapPtr(extender.Tags) - dst.Properties = &ExtenderProperties{ - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(extender.Properties.Status.OutputResources), - }, - ProvisioningState: fromProvisioningStateDataModel(extender.InternalMetadata.AsyncProvisioningState), - Environment: to.Ptr(extender.Properties.Environment), - Application: to.Ptr(extender.Properties.Application), - AdditionalProperties: extender.Properties.AdditionalProperties, - Recipe: fromRecipeDataModel(extender.Properties.Recipe), - ResourceProvisioning: fromResourceProvisioningDataModel(extender.Properties.ResourceProvisioning), - // Secrets are omitted. - } - return nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/extender_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/extender_conversion_test.go deleted file mode 100644 index da64004d16..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/extender_conversion_test.go +++ /dev/null @@ -1,268 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestExtender_ConvertVersionedToDataModel(t *testing.T) { - testset := []struct { - desc string - file string - expected *datamodel.Extender - }{ - { - desc: "extender resource provisioning manual", - file: "extender_manual.json", - expected: &datamodel.Extender{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - Name: "extender0", - Type: linkrp.ExtendersResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.ExtenderProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Secrets: map[string]any{"accountSid": "sid", "authToken": "token"}, - Recipe: linkrp.LinkRecipe{Name: "default"}, - }, - }, - }, - { - desc: "extender resource provisioning manual (no secrets)", - file: "extender_manual_nosecrets.json", - expected: &datamodel.Extender{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - Name: "extender0", - Type: linkrp.ExtendersResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.ExtenderProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Recipe: linkrp.LinkRecipe{Name: "default"}, - }, - }, - }, - { - desc: "extender resource recipe", - file: "extender_recipe.json", - expected: &datamodel.Extender{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - Name: "extender0", - Type: linkrp.ExtendersResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.ExtenderProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Recipe: linkrp.LinkRecipe{Name: "test-recipe"}, - }, - }, - }, - } - - for _, payload := range testset { - // arrange - rawPayload, err := LoadTestData("./testdata/" + payload.file) - require.NoError(t, err) - versionedResource := &ExtenderResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - // act - dm, err := versionedResource.ConvertTo() - - // assert - require.NoError(t, err) - convertedResource := dm.(*datamodel.Extender) - - require.Equal(t, payload.expected, convertedResource) - } -} - -func TestExtender_ConvertDataModelToVersioned(t *testing.T) { - testset := []struct { - desc string - file string - expected *ExtenderResource - }{ - { - desc: "extender resource provisioning manual datamodel", - file: "extenderdatamodel_manual.json", - expected: &ExtenderResource{ - Location: to.Ptr(""), - Properties: &ExtenderProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, - AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "ExtenderProvider", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0"), - Name: to.Ptr("extender0"), - Type: to.Ptr(linkrp.ExtendersResourceType), - }, - }, - { - desc: "extender resource provisioning manual datamodel (no secrets)", - file: "extenderdatamodel_manual_nosecrets.json", - expected: &ExtenderResource{ - Location: to.Ptr(""), - Properties: &ExtenderProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, - AdditionalProperties: map[string]any{"fromNumber": "222-222-2222"}, - Status: &ResourceStatus{}, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0"), - Name: to.Ptr("extender0"), - Type: to.Ptr(linkrp.ExtendersResourceType), - }, - }, - { - desc: "extender resource recipe datamodel", - file: "extenderdatamodel_recipe.json", - expected: &ExtenderResource{ - Location: to.Ptr(""), - Properties: &ExtenderProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr("test-recipe"), Parameters: nil}, - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "ExtenderProvider", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0"), - Name: to.Ptr("extender0"), - Type: to.Ptr(linkrp.ExtendersResourceType), - }, - }, - } - - for _, tc := range testset { - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - resource := &datamodel.Extender{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &ExtenderResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - require.Equal(t, tc.expected, versionedResource) - }) - } -} - -func TestExtender_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &ExtenderResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/mongodatabase_conversion.go b/pkg/linkrp/api/v20220315privatepreview/mongodatabase_conversion.go deleted file mode 100644 index 494ad3d7ad..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/mongodatabase_conversion.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned MongoDatabase resource to version-agnostic datamodel and returns it, -// returning an error if any of the inputs are invalid. -func (src *MongoDatabaseResource) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.MongoDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - }, - InternalMetadata: v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - }, - }, - Properties: datamodel.MongoDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - }, - } - v := src.Properties - - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(v.ResourceProvisioning) - if err != nil { - return nil, err - } - - converted.Properties.Resources = toResourcesDataModel(v.Resources) - converted.Properties.Host = to.String(v.Host) - converted.Properties.Port = to.Int32(v.Port) - converted.Properties.Database = to.String(v.Database) - converted.Properties.Username = to.String(v.Username) - if v.Secrets != nil { - converted.Properties.Secrets = datamodel.MongoDatabaseSecrets{ - ConnectionString: to.String(v.Secrets.ConnectionString), - Password: to.String(v.Secrets.Password), - } - } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { - converted.Properties.Recipe = toRecipeDataModel(v.Recipe) - } - - if err = converted.VerifyInputs(); err != nil { - return nil, err - } - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned MongoDatabase resource. It returns an error if the -// DataModelInterface is not a MongoDatabase. -func (dst *MongoDatabaseResource) ConvertFrom(src v1.DataModelInterface) error { - mongo, ok := src.(*datamodel.MongoDatabase) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(mongo.ID) - dst.Name = to.Ptr(mongo.Name) - dst.Type = to.Ptr(mongo.Type) - dst.SystemData = fromSystemDataModel(mongo.SystemData) - dst.Location = to.Ptr(mongo.Location) - dst.Tags = *to.StringMapPtr(mongo.Tags) - - dst.Properties = &MongoDatabaseProperties{ - Resources: fromResourcesDataModel(mongo.Properties.Resources), - Host: to.Ptr(mongo.Properties.Host), - Port: to.Ptr(mongo.Properties.Port), - Database: to.Ptr(mongo.Properties.Database), - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(mongo.Properties.Status.OutputResources), - }, - ProvisioningState: fromProvisioningStateDataModel(mongo.InternalMetadata.AsyncProvisioningState), - Environment: to.Ptr(mongo.Properties.Environment), - Application: to.Ptr(mongo.Properties.Application), - Recipe: fromRecipeDataModel(mongo.Properties.Recipe), - ResourceProvisioning: fromResourceProvisioningDataModel(mongo.Properties.ResourceProvisioning), - Username: to.Ptr(mongo.Properties.Username), - } - - return nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned MongoDatabaseSecrets instance and returns an error if -// the conversion fails. -func (dst *MongoDatabaseSecrets) ConvertFrom(src v1.DataModelInterface) error { - mongoSecrets, ok := src.(*datamodel.MongoDatabaseSecrets) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ConnectionString = to.Ptr(mongoSecrets.ConnectionString) - dst.Password = to.Ptr(mongoSecrets.Password) - - return nil -} - -// ConvertTo converts from the versioned MongoDatabaseSecrets instance to version-agnostic datamodel. -func (src *MongoDatabaseSecrets) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.MongoDatabaseSecrets{ - ConnectionString: to.String(src.ConnectionString), - Password: to.String(src.Password), - } - return converted, nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/mongodatabase_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/mongodatabase_conversion_test.go deleted file mode 100644 index 434d02eaf8..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/mongodatabase_conversion_test.go +++ /dev/null @@ -1,402 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestMongoDatabase_ConvertVersionedToDataModel(t *testing.T) { - testset := []struct { - file string - desc string - expected *datamodel.MongoDatabase - }{ - { - // Opt-out with resources - file: "mongodatabaseresource2.json", - desc: "mongodb resource provisioning manual (with resources)", - expected: &datamodel.MongoDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - Name: "mongo0", - Type: linkrp.MongoDatabasesResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.MongoDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Host: "testAccount.mongo.cosmos.azure.com", - Port: 10255, - Database: "test-database", - Resources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"}}, - }, - }, - }, - { - desc: "mongodb resource named recipe", - file: "mongodatabaseresource_recipe.json", - expected: &datamodel.MongoDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - Name: "mongo0", - Type: linkrp.MongoDatabasesResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.MongoDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Host: "testAccount.mongo.cosmos.azure.com", - Port: 10255, - Recipe: linkrp.LinkRecipe{Name: "cosmosdb", Parameters: map[string]interface{}{"foo": "bar"}}, - }, - }, - }, - { - desc: "mongodb resource default recipe with overriden values", - file: "mongodatabaseresource_recipe2.json", - expected: &datamodel.MongoDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - Name: "mongo0", - Type: linkrp.MongoDatabasesResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.MongoDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Host: "mynewhost.com", - Port: 10256, - Recipe: linkrp.LinkRecipe{Name: DefaultRecipeName, Parameters: nil}, - }, - }, - }, - { - desc: "mongodb resource provisioning manual (without resources)", - file: "mongodatabaseresource.json", - expected: &datamodel.MongoDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - Name: "mongo0", - Type: linkrp.MongoDatabasesResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.MongoDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Host: "testAccount.mongo.cosmos.azure.com", - Port: 10255, - Database: "test-database", - Username: "testUser", - Secrets: datamodel.MongoDatabaseSecrets{ - Password: "testPassword", - ConnectionString: "test-connection-string", - }, - }, - }, - }, - } - for _, tc := range testset { - // arrange - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - versionedResource := &MongoDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - // act - dm, err := versionedResource.ConvertTo() - - // assert - require.NoError(t, err) - convertedResource := dm.(*datamodel.MongoDatabase) - - require.Equal(t, tc.expected, convertedResource) - }) - } -} - -func TestMongoDatabase_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) { - testset := []struct { - payload string - errType error - message string - }{ - { - payload: "mongodatabaseresource-invalidresprovisioning.json", - errType: &v1.ErrModelConversion{}, - message: "$.properties.resourceProvisioning must be one of [manual recipe].", - }, - { - payload: "mongodatabaseresource-missinginputs.json", - errType: &v1.ErrClientRP{}, - message: "code BadRequest: err multiple errors were found:\n\thost must be specified when resourceProvisioning is set to manual\n\tport must be specified when resourceProvisioning is set to manual\n\tdatabase must be specified when resourceProvisioning is set to manual", - }, - } - for _, test := range testset { - t.Run(test.payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) - versionedResource := &MongoDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - dm, err := versionedResource.ConvertTo() - require.Error(t, err) - require.Nil(t, dm) - require.IsType(t, test.errType, err) - require.Equal(t, test.message, err.Error()) - }) - } -} - -func TestMongoDatabase_ConvertDataModelToVersioned(t *testing.T) { - testset := []struct { - file string - desc string - expected *MongoDatabaseResource - }{ - { - desc: "mongodb resource provisioning manual datamodel (without resources)", - file: "mongodatabaseresourcedatamodel.json", - expected: &MongoDatabaseResource{ - Location: to.Ptr(""), - Properties: &MongoDatabaseProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - Host: to.Ptr("testAccount1.mongo.cosmos.azure.com"), - Port: to.Ptr(int32(10255)), - Database: to.Ptr("test-database"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, - Username: to.Ptr("testUser"), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "AzureCosmosAccount", - "Provider": "azure", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0"), - Name: to.Ptr("mongo0"), - Type: to.Ptr(linkrp.MongoDatabasesResourceType), - }, - }, - { - desc: "mongodb resource provisioning manual datamodel (with resources)", - file: "mongodatabaseresourcedatamodel2.json", - expected: &MongoDatabaseResource{ - Location: to.Ptr(""), - Properties: &MongoDatabaseProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - Host: to.Ptr("testAccount1.mongo.cosmos.azure.com"), - Port: to.Ptr(int32(10255)), - Database: to.Ptr("test-database"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, - Resources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db")}}, - Username: to.Ptr(""), - Status: &ResourceStatus{ - OutputResources: nil, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0"), - Name: to.Ptr("mongo0"), - Type: to.Ptr(linkrp.MongoDatabasesResourceType), - }, - }, - { - // Named recipe - desc: "mongodb named recipe datamodel", - file: "mongodatabaseresourcedatamodel_recipe.json", - expected: &MongoDatabaseResource{ - Location: to.Ptr(""), - Properties: &MongoDatabaseProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication"), - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - Host: to.Ptr("testAccount1.mongo.cosmos.azure.com"), - Port: to.Ptr(int32(10255)), - Database: to.Ptr(""), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr("cosmosdb"), Parameters: map[string]interface{}{"foo": "bar"}}, - Username: to.Ptr(""), - Status: &ResourceStatus{ - OutputResources: nil, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0"), - Name: to.Ptr("mongo0"), - Type: to.Ptr(linkrp.MongoDatabasesResourceType), - }, - }, - } - for _, tc := range testset { - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - resource := &datamodel.MongoDatabase{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &MongoDatabaseResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - require.Equal(t, tc.expected, versionedResource) - }) - } -} - -func TestMongoDatabase_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &MongoDatabaseResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} - -func TestMongoDatabaseSecrets_ConvertVersionedToDataModel(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/mongodatabasesecrets.json") - require.NoError(t, err) - versioned := &MongoDatabaseSecrets{} - err = json.Unmarshal(rawPayload, versioned) - require.NoError(t, err) - - // act - dm, err := versioned.ConvertTo() - - // assert - require.NoError(t, err) - converted := dm.(*datamodel.MongoDatabaseSecrets) - require.Equal(t, "test-connection-string", converted.ConnectionString) - require.Equal(t, "testPassword", converted.Password) -} - -func TestMongoDatabaseSecrets_ConvertDataModelToVersioned(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/mongodatabasesecretsdatamodel.json") - require.NoError(t, err) - secrets := &datamodel.MongoDatabaseSecrets{} - err = json.Unmarshal(rawPayload, secrets) - require.NoError(t, err) - - // act - versionedResource := &MongoDatabaseSecrets{} - err = versionedResource.ConvertFrom(secrets) - - // assert - require.NoError(t, err) - require.Equal(t, "test-connection-string", secrets.ConnectionString) - require.Equal(t, "testPassword", secrets.Password) -} - -func TestMongoDatabaseSecrets_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &MongoDatabaseSecrets{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/rabbitmq_conversion.go b/pkg/linkrp/api/v20220315privatepreview/rabbitmq_conversion.go deleted file mode 100644 index d3adec9a1d..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/rabbitmq_conversion.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned RabbitMQMessageQueue resource to version-agnostic datamodel -// and returns an error if the inputs are invalid. -func (src *RabbitMQMessageQueueResource) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.RabbitMQMessageQueue{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - }, - InternalMetadata: v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - }, - }, - Properties: datamodel.RabbitMQMessageQueueProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - }, - } - properties := src.Properties - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(properties.ResourceProvisioning) - if err != nil { - return nil, err - } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { - converted.Properties.Recipe = toRecipeDataModel(properties.Recipe) - } - converted.Properties.Resources = toResourcesDataModel(properties.Resources) - converted.Properties.Host = to.String(properties.Host) - converted.Properties.Port = to.Int32(properties.Port) - converted.Properties.Username = to.String(properties.Username) - converted.Properties.Queue = to.String(properties.Queue) - converted.Properties.VHost = to.String(properties.VHost) - converted.Properties.TLS = to.Bool(properties.TLS) - err = converted.VerifyInputs() - if err != nil { - return nil, err - } - - if src.Properties.Secrets != nil { - converted.Properties.Secrets = datamodel.RabbitMQSecrets{ - URI: to.String(src.Properties.Secrets.URI), - Password: to.String(properties.Secrets.Password), - } - } - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned RabbitMQMessageQueue resource, -// and returns an error if the source is not a valid datamodel.RabbitMQMessageQueue. -func (dst *RabbitMQMessageQueueResource) ConvertFrom(src v1.DataModelInterface) error { - rabbitmq, ok := src.(*datamodel.RabbitMQMessageQueue) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(rabbitmq.ID) - dst.Name = to.Ptr(rabbitmq.Name) - dst.Type = to.Ptr(rabbitmq.Type) - dst.SystemData = fromSystemDataModel(rabbitmq.SystemData) - dst.Location = to.Ptr(rabbitmq.Location) - dst.Tags = *to.StringMapPtr(rabbitmq.Tags) - dst.Properties = &RabbitMQMessageQueueProperties{ - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(rabbitmq.Properties.Status.OutputResources), - }, - ProvisioningState: fromProvisioningStateDataModel(rabbitmq.InternalMetadata.AsyncProvisioningState), - Environment: to.Ptr(rabbitmq.Properties.Environment), - Application: to.Ptr(rabbitmq.Properties.Application), - ResourceProvisioning: fromResourceProvisioningDataModel(rabbitmq.Properties.ResourceProvisioning), - Queue: to.Ptr(rabbitmq.Properties.Queue), - Host: to.Ptr(rabbitmq.Properties.Host), - Port: to.Ptr(rabbitmq.Properties.Port), - VHost: to.Ptr(rabbitmq.Properties.VHost), - Username: to.Ptr(rabbitmq.Properties.Username), - Resources: fromResourcesDataModel(rabbitmq.Properties.Resources), - TLS: to.Ptr(rabbitmq.Properties.TLS), - } - if rabbitmq.Properties.ResourceProvisioning == linkrp.ResourceProvisioningRecipe { - dst.Properties.Recipe = fromRecipeDataModel(rabbitmq.Properties.Recipe) - } - return nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned RabbitmqSecrets instance -// and returns an error if the conversion fails. -func (dst *RabbitMQSecrets) ConvertFrom(src v1.DataModelInterface) error { - rabbitMQSecrets, ok := src.(*datamodel.RabbitMQSecrets) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.URI = to.Ptr(rabbitMQSecrets.URI) - dst.Password = to.Ptr(rabbitMQSecrets.Password) - return nil -} - -// ConvertTo converts from the versioned RabbitMQSecrets instance to version-agnostic datamodel. -func (src *RabbitMQSecrets) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.RabbitMQSecrets{ - URI: to.String(src.URI), - Password: to.String(src.Password), - } - return converted, nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/rabbitmq_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/rabbitmq_conversion_test.go deleted file mode 100644 index 58f7c485cb..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/rabbitmq_conversion_test.go +++ /dev/null @@ -1,336 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestRabbitMQMessageQueue_ConvertVersionedToDataModel(t *testing.T) { - testCases := []struct { - desc string - file string - expected *datamodel.RabbitMQMessageQueue - }{ - { - desc: "rabbitmq manual resource", - file: "rabbitmq_manual_resource.json", - expected: &datamodel.RabbitMQMessageQueue{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - Name: "rabbitmq0", - Type: linkrp.RabbitMQMessageQueuesResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.RabbitMQMessageQueueProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Queue: "testQueue", - Host: "test-host", - VHost: "test-vhost", - Port: 5672, - Username: "test-user", - TLS: true, - Secrets: datamodel.RabbitMQSecrets{ - URI: "connection://string", - Password: "password", - }, - }, - }, - }, - { - desc: "rabbitmq recipe resource", - file: "rabbitmq_recipe_resource.json", - expected: &datamodel.RabbitMQMessageQueue{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - Name: "rabbitmq0", - Type: linkrp.RabbitMQMessageQueuesResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.RabbitMQMessageQueueProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - TLS: false, - Recipe: linkrp.LinkRecipe{ - Name: "rabbitmq", - Parameters: map[string]any{ - "foo": "bar", - }, - }, - }, - }, - }, - } - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - versionedResource := &RabbitMQMessageQueueResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - // act - dm, err := versionedResource.ConvertTo() - - // assert - require.NoError(t, err) - convertedResource := dm.(*datamodel.RabbitMQMessageQueue) - - require.Equal(t, tc.expected, convertedResource) - }) - } -} - -func TestRabbitMQMessageQueue_ConvertDataModelToVersioned(t *testing.T) { - testCases := []struct { - desc string - file string - expected *RabbitMQMessageQueueResource - }{ - { - desc: "rabbitmq manual data model", - file: "rabbitmq_manual_datamodel.json", - expected: &RabbitMQMessageQueueResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &RabbitMQMessageQueueProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Queue: to.Ptr("testQueue"), - Host: to.Ptr("test-host"), - VHost: to.Ptr("test-vhost"), - Port: to.Ptr(int32(5672)), - Username: to.Ptr("test-user"), - TLS: to.Ptr(true), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "rabbitmqProvider", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0"), - Name: to.Ptr("rabbitmq0"), - Type: to.Ptr(linkrp.RabbitMQMessageQueuesResourceType), - }, - }, - { - desc: "rabbitmq recipe data model", - file: "rabbitmq_recipe_datamodel.json", - expected: &RabbitMQMessageQueueResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &RabbitMQMessageQueueProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Queue: to.Ptr("testQueue"), - Host: to.Ptr("test-host"), - VHost: to.Ptr("test-vhost"), - Port: to.Ptr(int32(5672)), - Username: to.Ptr("test-user"), - TLS: to.Ptr(false), - Recipe: &Recipe{ - Name: to.Ptr("rabbitmq"), - Parameters: map[string]any{ - "foo": "bar", - }, - }, - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "rabbitmqProvider", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0"), - Name: to.Ptr("rabbitmq0"), - Type: to.Ptr(linkrp.RabbitMQMessageQueuesResourceType), - }, - }, - } - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - resource := &datamodel.RabbitMQMessageQueue{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &RabbitMQMessageQueueResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - require.Equal(t, tc.expected, versionedResource) - }) - } -} - -func TestRabbitMQMessageQueue_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) { - testset := []struct { - payload string - errType error - message string - }{ - { - "rabbitmq_invalid_properties_resource.json", - &v1.ErrClientRP{}, - "code Bad Request: err queue is required when resourceProvisioning is manual", - }, - { - "rabbitmq_invalid_resourceprovisioning_resource.json", - &v1.ErrModelConversion{}, - "$.properties.resourceProvisioning must be one of [manual recipe].", - }, - } - - for _, test := range testset { - t.Run(test.payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) - versionedResource := &RabbitMQMessageQueueResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - dm, err := versionedResource.ConvertTo() - require.Error(t, err) - require.Nil(t, dm) - require.IsType(t, test.errType, err) - require.Equal(t, test.message, err.Error()) - }) - } -} - -func TestRabbitMQMessageQueue_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &RabbitMQMessageQueueResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} - -func TestRabbitMQSecrets_ConvertVersionedToDataModel(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/rabbitmqsecrets.json") - require.NoError(t, err) - versioned := &RabbitMQSecrets{} - err = json.Unmarshal(rawPayload, versioned) - require.NoError(t, err) - - // act - dm, err := versioned.ConvertTo() - - // assert - require.NoError(t, err) - converted := dm.(*datamodel.RabbitMQSecrets) - require.Equal(t, "test-connection-string", converted.URI) -} - -func TestRabbitMQSecrets_ConvertDataModelToVersioned(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/rabbitmqsecretsdatamodel.json") - require.NoError(t, err) - secrets := &datamodel.RabbitMQSecrets{} - err = json.Unmarshal(rawPayload, secrets) - require.NoError(t, err) - - // act - versionedResource := &RabbitMQSecrets{} - err = versionedResource.ConvertFrom(secrets) - - // assert - require.NoError(t, err) - require.Equal(t, "test-connection-string", secrets.URI) -} - -func TestRabbitMQSecrets_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &RabbitMQSecrets{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/rediscache_conversion.go b/pkg/linkrp/api/v20220315privatepreview/rediscache_conversion.go deleted file mode 100644 index 77126ee4ac..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/rediscache_conversion.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned RedisCache resource to version-agnostic datamodel -// and returns an error if the inputs are invalid. -func (src *RedisCacheResource) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.RedisCache{ - BaseResource: v1.BaseResource{ - InternalMetadata: v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - }, - TrackedResource: v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - }, - }, - Properties: datamodel.RedisCacheProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - }, - } - v := src.Properties - - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(src.Properties.ResourceProvisioning) - if err != nil { - return nil, err - } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { - converted.Properties.Recipe = toRecipeDataModel(v.Recipe) - } - converted.Properties.Resources = toResourcesDataModel(v.Resources) - converted.Properties.Host = to.String(v.Host) - converted.Properties.Port = to.Int32(v.Port) - converted.Properties.TLS = to.Bool(v.TLS) - converted.Properties.Username = to.String(v.Username) - if v.Secrets != nil { - converted.Properties.Secrets = datamodel.RedisCacheSecrets{ - ConnectionString: to.String(v.Secrets.ConnectionString), - Password: to.String(v.Secrets.Password), - URL: to.String(v.Secrets.URL), - } - } - - if err = converted.VerifyInputs(); err != nil { - return nil, err - } - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned RedisCache resource. -func (dst *RedisCacheResource) ConvertFrom(src v1.DataModelInterface) error { - redis, ok := src.(*datamodel.RedisCache) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(redis.ID) - dst.Name = to.Ptr(redis.Name) - dst.Type = to.Ptr(redis.Type) - dst.SystemData = fromSystemDataModel(redis.SystemData) - dst.Location = to.Ptr(redis.Location) - dst.Tags = *to.StringMapPtr(redis.Tags) - - dst.Properties = &RedisCacheProperties{ - Recipe: fromRecipeDataModel(redis.Properties.Recipe), - ResourceProvisioning: fromResourceProvisioningDataModel(redis.Properties.ResourceProvisioning), - Resources: fromResourcesDataModel(redis.Properties.Resources), - Host: to.Ptr(redis.Properties.Host), - Port: to.Ptr(redis.Properties.Port), - TLS: to.Ptr(redis.Properties.TLS), - Username: to.Ptr(redis.Properties.Username), - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(redis.Properties.Status.OutputResources), - }, - ProvisioningState: fromProvisioningStateDataModel(redis.InternalMetadata.AsyncProvisioningState), - Environment: to.Ptr(redis.Properties.Environment), - Application: to.Ptr(redis.Properties.Application), - } - - return nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned RedisCacheSecrets instance -// and returns an error if the conversion fails. -func (dst *RedisCacheSecrets) ConvertFrom(src v1.DataModelInterface) error { - redisSecrets, ok := src.(*datamodel.RedisCacheSecrets) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ConnectionString = to.Ptr(redisSecrets.ConnectionString) - dst.Password = to.Ptr(redisSecrets.Password) - dst.URL = to.Ptr(redisSecrets.URL) - - return nil -} - -// ConvertTo converts from the versioned RedisCacheSecrets instance to version-agnostic datamodel. -func (src *RedisCacheSecrets) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.RedisCacheSecrets{ - ConnectionString: to.String(src.ConnectionString), - Password: to.String(src.Password), - URL: to.String(src.URL), - } - return converted, nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/rediscache_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/rediscache_conversion_test.go deleted file mode 100644 index db75261dab..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/rediscache_conversion_test.go +++ /dev/null @@ -1,425 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "fmt" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/to" - - "github.com/stretchr/testify/require" -) - -const ( - ApplicationID = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication" - EnvironmentID = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0" - RedisID = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0" -) - -func TestRedisCache_ConvertVersionedToDataModel(t *testing.T) { - testset := []struct { - desc string - file string - expected *datamodel.RedisCache - }{ - { - desc: "redis cache with default recipe", - file: "rediscacheresource_defaultrecipe.json", - expected: &datamodel.RedisCache{ - BaseResource: createBaseResource(), - Properties: datamodel.RedisCacheProperties{ - BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Host: "", - Port: 0, - TLS: false, - Username: "", - Recipe: linkrp.LinkRecipe{Name: "default"}, - }, - }, - }, - { - desc: "redis cache with named recipe", - file: "rediscacheresource_recipe_named.json", - expected: &datamodel.RedisCache{ - BaseResource: createBaseResource(), - Properties: datamodel.RedisCacheProperties{ - BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Host: "", - Port: 0, - TLS: false, - Username: "", - Recipe: linkrp.LinkRecipe{Name: "redis-test"}, - }, - }, - }, - { - desc: "redis cache with recipe overridden values", - file: "rediscacheresource_recipe_overridevalues.json", - expected: &datamodel.RedisCache{ - BaseResource: createBaseResource(), - Properties: datamodel.RedisCacheProperties{ - BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Host: "myrediscache.redis.cache.windows.net", - Port: 10255, - TLS: false, - Username: "", - Recipe: linkrp.LinkRecipe{Name: "redis-test", Parameters: map[string]any{"port": float64(6081)}}, - }, - }, - }, - { - desc: "redis cache manual with resources", - file: "rediscacheresource_manual.json", - expected: &datamodel.RedisCache{ - BaseResource: createBaseResource(), - Properties: datamodel.RedisCacheProperties{ - BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Host: "myrediscache.redis.cache.windows.net", - Port: 10255, - TLS: true, - Username: "admin", - Resources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}}, - Secrets: datamodel.RedisCacheSecrets{ - Password: "testPassword", - ConnectionString: "test-connection-string", - URL: "test-url", - }, - }, - }, - }, - { - desc: "redis cache manual without resources", - file: "rediscacheresource_manual_noresources.json", - expected: &datamodel.RedisCache{ - BaseResource: createBaseResource(), - Properties: datamodel.RedisCacheProperties{ - BasicResourceProperties: createBasicResourceProperties(), - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Host: "myrediscache.redis.cache.windows.net", - Port: 10255, - TLS: false, - Username: "", - }, - }, - }, - } - - for _, tc := range testset { - // arrange - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - versionedResource := &RedisCacheResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - // act - dm, err := versionedResource.ConvertTo() - - // assert - require.NoError(t, err) - convertedResource := dm.(*datamodel.RedisCache) - - require.Equal(t, tc.expected, convertedResource) - }) - } -} - -func TestRedisCache_ConvertDataModelToVersioned(t *testing.T) { - testset1 := []struct { - desc string - file string - expected *RedisCacheResource - }{ - { - desc: "redis cache manual with resources", - file: "rediscacheresourcedatamodel_manual.json", - expected: &RedisCacheResource{ - Location: to.Ptr(""), - Properties: &RedisCacheProperties{ - Environment: to.Ptr(EnvironmentID), - Application: to.Ptr(ApplicationID), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - Host: to.Ptr("myrediscache.redis.cache.windows.net"), - Port: to.Ptr(int32(10255)), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, - Username: to.Ptr(""), - TLS: to.Ptr(false), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr(RedisID), - Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.RedisCachesResourceType), - }, - }, - { - desc: "redis cache default recipe", - file: "rediscacheresourcedatamodel_recipe_default.json", - expected: &RedisCacheResource{ - Location: to.Ptr(""), - Properties: &RedisCacheProperties{ - Environment: to.Ptr(EnvironmentID), - Application: to.Ptr(ApplicationID), - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - Host: to.Ptr(""), - Port: to.Ptr(int32(0)), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, - Username: to.Ptr(""), - TLS: to.Ptr(false), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr(RedisID), - Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.RedisCachesResourceType), - }, - }, - { - desc: "redis cache named recipe", - file: "rediscacheresourcedatamodel_recipe_params.json", - expected: &RedisCacheResource{ - Location: to.Ptr(""), - Properties: &RedisCacheProperties{ - Environment: to.Ptr(EnvironmentID), - Application: to.Ptr(ApplicationID), - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - Host: to.Ptr(""), - Port: to.Ptr(int32(0)), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr("redis-test"), Parameters: map[string]any{"port": float64(6081)}}, - Username: to.Ptr(""), - TLS: to.Ptr(false), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr(RedisID), - Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.RedisCachesResourceType), - }, - }, - { - desc: "redis cache manual with resources", - file: "rediscacheresourcedatamodel_manual_resources.json", - expected: &RedisCacheResource{ - Location: to.Ptr(""), - Properties: &RedisCacheProperties{ - Environment: to.Ptr(EnvironmentID), - Application: to.Ptr(ApplicationID), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - Host: to.Ptr("myrediscache.redis.cache.windows.net"), - Port: to.Ptr(int32(10255)), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Recipe: &Recipe{Name: to.Ptr(""), Parameters: nil}, - Username: to.Ptr(""), - TLS: to.Ptr(true), - Status: &ResourceStatus{ - OutputResources: nil, - }, - Resources: []*ResourceReference{ - {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, - {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr(RedisID), - Name: to.Ptr("redis0"), - Type: to.Ptr(linkrp.RedisCachesResourceType), - }, - }, - } - - for _, tc := range testset1 { - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - resource := &datamodel.RedisCache{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &RedisCacheResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - require.Equal(t, tc.expected, versionedResource) - }) - } -} - -func TestRedisCache_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) { - testset := []string{"rediscacheresource-invalid.json", "rediscacheresource-invalid2.json"} - for _, payload := range testset { - // arrange - rawPayload, err := LoadTestData("./testdata/" + payload) - require.NoError(t, err) - versionedResource := &RedisCacheResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - if payload == "rediscacheresource-invalid.json" { - expectedErr := v1.ErrModelConversion{PropertyName: "$.properties.resourceProvisioning", ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues())} - _, err = versionedResource.ConvertTo() - require.Equal(t, &expectedErr, err) - } - if payload == "rediscacheresource-invalid2.json" { - expectedErr := v1.ErrClientRP{Code: "BadRequest", Message: "multiple errors were found:\n\thost must be specified when resourceProvisioning is set to manual\n\tport must be specified when resourceProvisioning is set to manual"} - _, err = versionedResource.ConvertTo() - require.Equal(t, &expectedErr, err) - } - } -} - -func TestRedisCache_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &RedisCacheResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} - -func TestRedisCacheSecrets_ConvertVersionedToDataModel(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/rediscachesecrets.json") - require.NoError(t, err) - versioned := &RedisCacheSecrets{} - err = json.Unmarshal(rawPayload, versioned) - require.NoError(t, err) - - // act - dm, err := versioned.ConvertTo() - - // assert - require.NoError(t, err) - converted := dm.(*datamodel.RedisCacheSecrets) - require.Equal(t, "test-connection-string", converted.ConnectionString) - require.Equal(t, "testPassword", converted.Password) - require.Equal(t, "test-url", converted.URL) -} - -func TestRedisCacheSecrets_ConvertDataModelToVersioned(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/rediscachesecretsdatamodel.json") - require.NoError(t, err) - secrets := &datamodel.RedisCacheSecrets{} - err = json.Unmarshal(rawPayload, secrets) - require.NoError(t, err) - - // act - versionedResource := &RedisCacheSecrets{} - err = versionedResource.ConvertFrom(secrets) - - // assert - require.NoError(t, err) - require.Equal(t, "test-connection-string", secrets.ConnectionString) - require.Equal(t, "testPassword", secrets.Password) - require.Equal(t, "test-url", secrets.URL) -} - -func TestRedisCacheSecrets_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &RedisCacheSecrets{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} - -func createBaseResource() v1.BaseResource { - return v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: RedisID, - Name: "redis0", - Type: linkrp.RedisCachesResourceType, - Tags: map[string]string{}, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - } -} - -func createBasicResourceProperties() rpv1.BasicResourceProperties { - return rpv1.BasicResourceProperties{ - Application: ApplicationID, - Environment: EnvironmentID, - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/sqldatabase_conversion.go b/pkg/linkrp/api/v20220315privatepreview/sqldatabase_conversion.go deleted file mode 100644 index f9a20372f4..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/sqldatabase_conversion.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" -) - -// ConvertTo converts from the versioned SqlDatabase resource to version-agnostic datamodel -// and returns an error if the inputs are invalid. -func (src *SQLDatabaseResource) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.SqlDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: to.String(src.ID), - Name: to.String(src.Name), - Type: to.String(src.Type), - Location: to.String(src.Location), - Tags: to.StringMap(src.Tags), - }, - InternalMetadata: v1.InternalMetadata{ - UpdatedAPIVersion: Version, - AsyncProvisioningState: toProvisioningStateDataModel(src.Properties.ProvisioningState), - }, - }, - Properties: datamodel.SqlDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Environment: to.String(src.Properties.Environment), - Application: to.String(src.Properties.Application), - }, - }, - } - - properties := src.Properties - - var err error - converted.Properties.ResourceProvisioning, err = toResourceProvisiongDataModel(properties.ResourceProvisioning) - if err != nil { - return nil, err - } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { - converted.Properties.Recipe = toRecipeDataModel(properties.Recipe) - } - converted.Properties.Resources = toResourcesDataModel(properties.Resources) - converted.Properties.Database = to.String(properties.Database) - converted.Properties.Server = to.String(properties.Server) - converted.Properties.Port = to.Int32(properties.Port) - converted.Properties.Username = to.String(properties.Username) - if properties.Secrets != nil { - converted.Properties.Secrets = datamodel.SqlDatabaseSecrets{ - ConnectionString: to.String(properties.Secrets.ConnectionString), - Password: to.String(properties.Secrets.Password), - } - } - err = converted.VerifyInputs() - if err != nil { - return nil, err - } - - return converted, nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned SqlDatabase resource. -func (dst *SQLDatabaseResource) ConvertFrom(src v1.DataModelInterface) error { - sql, ok := src.(*datamodel.SqlDatabase) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ID = to.Ptr(sql.ID) - dst.Name = to.Ptr(sql.Name) - dst.Type = to.Ptr(sql.Type) - dst.SystemData = fromSystemDataModel(sql.SystemData) - dst.Location = to.Ptr(sql.Location) - dst.Tags = *to.StringMapPtr(sql.Tags) - dst.Properties = &SQLDatabaseProperties{ - ResourceProvisioning: fromResourceProvisioningDataModel(sql.Properties.ResourceProvisioning), - Resources: fromResourcesDataModel(sql.Properties.Resources), - Database: to.Ptr(sql.Properties.Database), - Server: to.Ptr(sql.Properties.Server), - Port: to.Ptr(sql.Properties.Port), - Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(sql.Properties.Status.OutputResources), - }, - ProvisioningState: fromProvisioningStateDataModel(sql.InternalMetadata.AsyncProvisioningState), - Environment: to.Ptr(sql.Properties.Environment), - Application: to.Ptr(sql.Properties.Application), - Username: to.Ptr(sql.Properties.Username), - } - if sql.Properties.ResourceProvisioning == linkrp.ResourceProvisioningRecipe { - dst.Properties.Recipe = fromRecipeDataModel(sql.Properties.Recipe) - } - return nil -} - -// ConvertFrom converts from version-agnostic datamodel to the versioned SqlDatabaseSecrets instance -// and returns an error if the conversion fails. -func (dst *SQLDatabaseSecrets) ConvertFrom(src v1.DataModelInterface) error { - sqlSecrets, ok := src.(*datamodel.SqlDatabaseSecrets) - if !ok { - return v1.ErrInvalidModelConversion - } - - dst.ConnectionString = to.Ptr(sqlSecrets.ConnectionString) - dst.Password = to.Ptr(sqlSecrets.Password) - - return nil -} - -// ConvertTo converts from the versioned SqlDatabaseSecrets instance to version-agnostic datamodel -// and returns an error if the conversion fails. -func (src *SQLDatabaseSecrets) ConvertTo() (v1.DataModelInterface, error) { - converted := &datamodel.SqlDatabaseSecrets{ - ConnectionString: to.String(src.ConnectionString), - Password: to.String(src.Password), - } - return converted, nil -} diff --git a/pkg/linkrp/api/v20220315privatepreview/sqldatabase_conversion_test.go b/pkg/linkrp/api/v20220315privatepreview/sqldatabase_conversion_test.go deleted file mode 100644 index 2e593834d6..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/sqldatabase_conversion_test.go +++ /dev/null @@ -1,323 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestSqlDatabase_ConvertVersionedToDataModel(t *testing.T) { - testCases := []struct { - desc string - file string - expected *datamodel.SqlDatabase - }{ - { - desc: "sqldatabase manual resource", - file: "sqldatabase_manual_resource.json", - expected: &datamodel.SqlDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - Name: "sql0", - Type: linkrp.SqlDatabasesResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.SqlDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Resources: []*linkrp.ResourceReference{ - { - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase", - }, - }, - Database: "testDatabase", - Server: "testAccount1.sql.cosmos.azure.com", - Port: 1433, - Username: "testUser", - Secrets: datamodel.SqlDatabaseSecrets{ - Password: "testPassword", - ConnectionString: "test-connection-string", - }, - }, - }, - }, - { - desc: "sqldatabase recipe resource", - file: "sqldatabase_recipe_resource.json", - expected: &datamodel.SqlDatabase{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - Name: "sql0", - Type: linkrp.SqlDatabasesResourceType, - Location: v1.LocationGlobal, - Tags: map[string]string{ - "env": "dev", - }, - }, - InternalMetadata: v1.InternalMetadata{ - CreatedAPIVersion: "", - UpdatedAPIVersion: "2022-03-15-privatepreview", - AsyncProvisioningState: v1.ProvisioningStateAccepted, - }, - SystemData: v1.SystemData{}, - }, - Properties: datamodel.SqlDatabaseProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, - Recipe: linkrp.LinkRecipe{ - Name: "sql-test", - Parameters: map[string]any{ - "foo": "bar", - }, - }, - }, - }, - }, - } - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - versionedResource := &SQLDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - // act - dm, err := versionedResource.ConvertTo() - - // assert - require.NoError(t, err) - convertedResource := dm.(*datamodel.SqlDatabase) - - require.Equal(t, tc.expected, convertedResource) - }) - } -} - -func TestSqlDatabase_ConvertDataModelToVersioned(t *testing.T) { - testCases := []struct { - desc string - file string - expected *SQLDatabaseResource - }{ - { - desc: "sqldatabase manual resource datamodel", - file: "sqldatabase_manual_resourcedatamodel.json", - expected: &SQLDatabaseResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &SQLDatabaseProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - ResourceProvisioning: to.Ptr(ResourceProvisioningManual), - Resources: []*ResourceReference{ - { - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase"), - }, - }, - Database: to.Ptr("testDatabase"), - Server: to.Ptr("testAccount1.sql.cosmos.azure.com"), - Port: to.Ptr(int32(1433)), - Username: to.Ptr("testUser"), - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0"), - Name: to.Ptr("sql0"), - Type: to.Ptr(linkrp.SqlDatabasesResourceType), - }, - }, - { - desc: "sqldatabase recipe resource datamodel", - file: "sqldatabase_recipe_resourcedatamodel.json", - expected: &SQLDatabaseResource{ - Location: to.Ptr(v1.LocationGlobal), - Properties: &SQLDatabaseProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - ResourceProvisioning: to.Ptr(ResourceProvisioningRecipe), - Database: to.Ptr("testDatabase"), - Port: to.Ptr(int32(1433)), - Username: to.Ptr("testUser"), - Server: to.Ptr("testAccount1.sql.cosmos.azure.com"), - Recipe: &Recipe{ - Name: to.Ptr("sql-test"), - Parameters: map[string]any{ - "foo": "bar", - }, - }, - ProvisioningState: to.Ptr(ProvisioningStateAccepted), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "azure", - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0"), - Name: to.Ptr("sql0"), - Type: to.Ptr(linkrp.SqlDatabasesResourceType), - }, - }, - } - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) - resource := &datamodel.SqlDatabase{} - err = json.Unmarshal(rawPayload, resource) - require.NoError(t, err) - - versionedResource := &SQLDatabaseResource{} - err = versionedResource.ConvertFrom(resource) - require.NoError(t, err) - - // Skip system data comparison - versionedResource.SystemData = nil - - require.Equal(t, tc.expected, versionedResource) - }) - } -} - -func TestSqlDatabase_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) { - testset := []struct { - payload string - errType error - message string - }{ - { - "sqldatabase_invalid_properties_resource.json", - &v1.ErrClientRP{}, - "code BadRequest: err multiple errors were found:\n\tserver must be specified when resourceProvisioning is set to manual\n\tport must be specified when resourceProvisioning is set to manual\n\tdatabase must be specified when resourceProvisioning is set to manual", - }, - { - "sqldatabase_invalid_resourceprovisioning_resource.json", - &v1.ErrModelConversion{}, - "$.properties.resourceProvisioning must be one of [manual recipe].", - }, - } - - for _, test := range testset { - t.Run(test.payload, func(t *testing.T) { - rawPayload, err := LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) - versionedResource := &SQLDatabaseResource{} - err = json.Unmarshal(rawPayload, versionedResource) - require.NoError(t, err) - - dm, err := versionedResource.ConvertTo() - require.Error(t, err) - require.Nil(t, dm) - require.IsType(t, test.errType, err) - require.Equal(t, test.message, err.Error()) - }) - } -} - -func TestSqlDatabase_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &SQLDatabaseResource{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} - -func TestSqlDatabaseSecrets_ConvertDataModelToVersioned(t *testing.T) { - // arrange - rawPayload, err := LoadTestData("./testdata/sqldatabase_secrets_datamodel.json") - require.NoError(t, err) - secrets := &datamodel.SqlDatabaseSecrets{} - err = json.Unmarshal(rawPayload, secrets) - require.NoError(t, err) - - // act - versionedResource := &SQLDatabaseSecrets{} - err = versionedResource.ConvertFrom(secrets) - - // assert - require.NoError(t, err) - require.Equal(t, "test-connection-string", secrets.ConnectionString) - require.Equal(t, "testPassword", secrets.Password) -} - -func TestSqlDatabaseSecrets_ConvertFromValidation(t *testing.T) { - validationTests := []struct { - src v1.DataModelInterface - err error - }{ - {&FakeResource{}, v1.ErrInvalidModelConversion}, - {nil, v1.ErrInvalidModelConversion}, - } - - for _, tc := range validationTests { - versioned := &SQLDatabaseSecrets{} - err := versioned.ConvertFrom(tc.src) - require.ErrorAs(t, tc.err, &err) - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/test_util.go b/pkg/linkrp/api/v20220315privatepreview/test_util.go deleted file mode 100644 index 673fa925e9..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/test_util.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -import ( - "os" - "time" -) - -// FakeResource is a fake resource type. -type FakeResource struct{} - -// Always returns "FakeResource" as the name. -func (f *FakeResource) ResourceTypeName() string { - return "FakeResource" -} - -// LoadTestData reads the contents of a file and returns it as a byte slice. -// It takes a single argument, testfile, which is the path to the file to be read. -// If the file cannot be read, an error is returned. -func LoadTestData(testfile string) ([]byte, error) { - d, err := os.ReadFile(testfile) - if err != nil { - return nil, err - } - return d, nil -} - -// UnmarshalTimeString unmarshals a string representation of a time in RFC3339 format into a time.Time object. -func UnmarshalTimeString(ts string) *time.Time { - var tt timeRFC3339 - _ = tt.UnmarshalText([]byte(ts)) - return (*time.Time)(&tt) -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidmanual_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidmanual_resource.json deleted file mode 100644 index 776b1af3a3..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidmanual_resource.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "manual", - "recipe": { - "name": "test-recipe" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidrecipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidrecipe_resource.json deleted file mode 100644 index e9a754043c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidrecipe_resource.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_datamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_datamodel.json deleted file mode 100644 index 1a323b317b..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_datamodel.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "tags": { - "env": "dev" - }, - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "properties": { - "componentName": "test-dpsb", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "manual", - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async" - } - ] - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_generic_datamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_generic_datamodel.json deleted file mode 100644 index 2978133059..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_generic_datamodel.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "componentName": "test-dpsb", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "kind": "generic", - "resourceProvisioning": "manual", - "type": "pubsub.kafka", - "version": "v1", - "metadata": { - "foo": "bar" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_resource.json deleted file mode 100644 index e680962f5a..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_resource.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "manual", - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async" - } - ] - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_recipe_datamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_recipe_datamodel.json deleted file mode 100644 index 2254a6a86d..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_recipe_datamodel.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "tags": { - "env": "dev" - }, - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "properties": { - "componentName": "test-dpsb", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "recipe", - "recipe": { - "name": "dpsb-recipe" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_recipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_recipe_resource.json deleted file mode 100644 index 0b237c419c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_recipe_resource.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb", - "name": "test-dpsb", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "recipe", - "recipe": { - "name": "dpsb-recipe" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_invalidrecipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_invalidrecipe_resource.json deleted file mode 100644 index cd90cb7552..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_invalidrecipe_resource.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss", - "name": "test-dss", - "type": "Applications.Link/daprSecretStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "type": "secretstores.kubernetes", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_invalidvalues_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_invalidvalues_resource.json deleted file mode 100644 index 870be1d9f6..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_invalidvalues_resource.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-ss", - "name": "test-dpsb", - "type": "Applications.Link/daprSecretStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning": "manual", - "recipe": { - "name": "test-recipe" - } - } - } \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_manual_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_manual_resource.json deleted file mode 100644 index f5ea3e5216..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_manual_resource.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss", - "name": "test-dss", - "type": "Applications.Link/daprSecretStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "kind": "generic", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning":"manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_manual_resourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_manual_resourcedatamodel.json deleted file mode 100644 index de98137fb2..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_manual_resourcedatamodel.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss", - "name": "test-dss", - "type": "Applications.Link/daprSecretStores", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "componentName": "test-dss", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "kind": "generic", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning":"manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_recipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_recipe_resource.json deleted file mode 100644 index 6984ffbbc9..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_recipe_resource.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss", - "name": "test-dss", - "type": "Applications.Link/daprSecretStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Secret", - "Provider": "kubernetes" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "recipe": { - "name": "daprSecretStore", - "parameters":{ - "foo":"bar" - } - } - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_recipe_resourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_recipe_resourcedatamodel.json deleted file mode 100644 index 948f02d645..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstore_recipe_resourcedatamodel.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/test-dss", - "name": "test-dss", - "type": "Applications.Link/daprSecretStores", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "componentName": "test-dss", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprPubSubProvider", - "Provider": "kubernetes" - } - } - ] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "recipe": { - "name": "daprSecretStore", - "parameters":{ - "foo":"bar" - } - } - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstoreresource-invalid.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstoreresource-invalid.json deleted file mode 100644 index 45d3ed6d00..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprsecretstoreresource-invalid.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprSecretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Link/daprSecretStores", - "properties": { - "resourceProvisioning": "manual", - "version": 1 - - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_invalidrecipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_invalidrecipe_resource.json deleted file mode 100644 index d6facaeef0..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_invalidrecipe_resource.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_invalidvalues_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_invalidvalues_resource.json deleted file mode 100644 index 316bd5d5cf..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_invalidvalues_resource.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "recipe": { - "name": "test-recipe" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_recipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_recipe_resource.json deleted file mode 100644 index b18478ab23..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_recipe_resource.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "recipe", - "recipe": { - "name": "recipe-test" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_recipe_resourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_recipe_resourcedatamodel.json deleted file mode 100644 index c0b4717e6a..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_recipe_resourcedatamodel.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "componentName": "daprStateStore0", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprStateStoreProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "recipe-test" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_values_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_values_resource.json deleted file mode 100644 index 7ae1e25241..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_values_resource.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ] - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_values_resourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_values_resourcedatamodel.json deleted file mode 100644 index 9ea4f01971..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/daprstatestore_values_resourcedatamodel.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "tags": { - "env": "dev" - }, - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "properties": { - "componentName": "daprStateStore0", - "status": { - "outputResources": [ - { - "LocalID": "Deployment", - "ResourceType": { - "Type": "DaprStateStoreProvider", - "Provider": "kubernetes" - } - } - ] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ] - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extender_manual.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extender_manual.json deleted file mode 100644 index e32698c8b1..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extender_manual.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken": "token" - }, - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extender_manual_nosecrets.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extender_manual_nosecrets.json deleted file mode 100644 index 07f4827104..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extender_manual_nosecrets.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extender_recipe.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extender_recipe.json deleted file mode 100644 index a155d3247d..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extender_recipe.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "test-recipe" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_manual.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_manual.json deleted file mode 100644 index eaa1cbc080..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_manual.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "additionalProperties":{ - "fromNumber": "222-222-2222" - }, - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_manual_nosecrets.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_manual_nosecrets.json deleted file mode 100644 index cadcd2af02..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_manual_nosecrets.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "additionalProperties":{ - "fromNumber": "222-222-2222" - }, - "resourceProvisioning": "manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_recipe.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_recipe.json deleted file mode 100644 index e4dcb85310..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderdatamodel_recipe.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "test-recipe" - } - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderresource-invalid.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extenderresource-invalid.json deleted file mode 100644 index c5e0ed066d..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderresource-invalid.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "properties": { - "secrets": 12345 - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderresponseresourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/extenderresponseresourcedatamodel.json deleted file mode 100644 index f793246445..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/extenderresponseresourcedatamodel.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "Extender", - "Provider": "ExtenderProvider" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "additionalProperties":{ - "fromNumber": "222-222-2222" - }, - "resourceProvisioning": "manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-invalid.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-invalid.json deleted file mode 100644 index ecb8ef6a07..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-invalid.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "properties": { - "mode": "resource", - "resource": 12345 - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-invalidresprovisioning.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-invalidresprovisioning.json deleted file mode 100644 index a2e4a81560..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-invalidresprovisioning.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "properties": { - "resourceProvisioning": "invalid" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-missinginputs.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-missinginputs.json deleted file mode 100644 index f1deb9bb6c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource-missinginputs.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "properties": { - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource.json deleted file mode 100644 index 8c7e3204f6..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.cosmosdb.mongo", - "Provider": "azure" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount.mongo.cosmos.azure.com", - "port": 10255, - "database": "test-database", - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" - } - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource2.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource2.json deleted file mode 100644 index 4d3c2cf3b4..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource2.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"}], - "host": "testAccount.mongo.cosmos.azure.com", - "port": 10255, - "database": "test-database" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource_recipe.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource_recipe.json deleted file mode 100644 index df483de374..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource_recipe.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters":{ - "foo":"bar" - } - }, - "resourceProvisioning": "recipe", - "host": "testAccount.mongo.cosmos.azure.com", - "port": 10255 - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource_recipe2.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource_recipe2.json deleted file mode 100644 index 2906269b97..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresource_recipe2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "host": "mynewhost.com", - "port": 10256 - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json deleted file mode 100644 index 7651bf8740..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "AzureCosmosAccount", - "ResourceType": { - "Type": "azure.cosmosdb.mongo", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "test-database", - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" - } - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel2.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel2.json deleted file mode 100644 index 03ef5a6209..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel2.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "resourceProvisioning": "manual", - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"}], - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "test-database" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel_recipe.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel_recipe.json deleted file mode 100644 index be6c334ad1..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel_recipe.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "recipe": { - "name": "cosmosdb", - "parameters":{ - "foo":"bar" - } - }, - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255 - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabasesecrets.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabasesecrets.json deleted file mode 100644 index e3236171ba..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabasesecrets.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "password": "testPassword", - "connectionString": "test-connection-string" -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabasesecretsdatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabasesecretsdatamodel.json deleted file mode 100644 index e3236171ba..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/mongodatabasesecretsdatamodel.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "password": "testPassword", - "connectionString": "test-connection-string" -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_invalid_properties_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_invalid_properties_resource.json deleted file mode 100644 index 15e1210aae..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_invalid_properties_resource.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "properties": { - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_invalid_resourceprovisioning_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_invalid_resourceprovisioning_resource.json deleted file mode 100644 index de3c20e94e..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_invalid_resourceprovisioning_resource.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "properties": { - "resourceProvisioning": "invalid" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json deleted file mode 100644 index 9227c3f226..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "location": "global", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "rabbitmq", - "Provider": "rabbitmqProvider" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "resourceProvisioning":"manual", - "queue": "testQueue", - "host": "test-host", - "vHost": "test-vhost", - "port": 5672, - "username": "test-user", - "tls":true, - "secrets": { - "uri": "connection://string", - "password": "password" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_manual_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_manual_resource.json deleted file mode 100644 index 0c8ba30fe1..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_manual_resource.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "resourceProvisioning":"manual", - "queue": "testQueue", - "host": "test-host", - "vHost": "test-vhost", - "port": 5672, - "username": "test-user", - "tls":true, - "secrets": { - "uri": "connection://string", - "password":"password" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_datamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_datamodel.json deleted file mode 100644 index 40a736d12c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_datamodel.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "location": "global", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "rabbitmq", - "Provider": "rabbitmqProvider" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "resourceProvisioning":"recipe", - "queue": "testQueue", - "host": "test-host", - "port": 5672, - "vHost": "test-vhost", - "username": "test-user", - "tls":false, - "recipe": { - "name": "rabbitmq", - "parameters":{ - "foo":"bar" - } - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_resource.json deleted file mode 100644 index 7cb117fece..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_resource.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "rabbitmq", - "Provider": "rabbitmqProvider" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "tls": false, - "recipe": { - "name": "rabbitmq", - "parameters":{ - "foo":"bar" - } - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqresource-invalid.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqresource-invalid.json deleted file mode 100644 index d25ed39514..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqresource-invalid.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "properties": { - "queue": 12345 - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqsecrets.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqsecrets.json deleted file mode 100644 index e6ce6e7aa7..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqsecrets.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "uri": "test-connection-string", - "password": "test-password" -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqsecretsdatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqsecretsdatamodel.json deleted file mode 100644 index e6ce6e7aa7..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rabbitmqsecretsdatamodel.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "uri": "test-connection-string", - "password": "test-password" -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalid.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalid.json deleted file mode 100644 index 8186e64ecf..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalid.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "resourceProvisioning": "invalid" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalid2.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalid2.json deleted file mode 100644 index b57cc3677a..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalid2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "resourceProvisioning": "manual", - "secrets": { - "password": "password" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalidinput.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalidinput.json deleted file mode 100644 index 05601d25ec..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource-invalidinput.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "host": 12345 - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_defaultrecipe.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_defaultrecipe.json deleted file mode 100644 index 83748d6685..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_defaultrecipe.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_manual.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_manual.json deleted file mode 100644 index 9b09e08079..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_manual.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resources": [ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "username": "admin", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string", - "url": "test-url" - }, - "tls": true, - "resourceProvisioning": "manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_manual_noresources.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_manual_noresources.json deleted file mode 100644 index fb2215a2f3..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_manual_noresources.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_recipe_named.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_recipe_named.json deleted file mode 100644 index 2820edacde..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_recipe_named.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis-test" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_recipe_overridevalues.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_recipe_overridevalues.json deleted file mode 100644 index 66293fd8f0..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresource_recipe_overridevalues.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis-test", - "parameters": { - "port": 6081 - } - }, - "host": "myrediscache.redis.cache.windows.net", - "port": 10255 - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual.json deleted file mode 100644 index fad5ed84ff..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "resourceProvisioning": "manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual_resources.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual_resources.json deleted file mode 100644 index e2720809eb..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_manual_resources.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "resources": [{ - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache" - }, - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1" - }], - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "tls": true, - "resourceProvisioning": "manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_default.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_default.json deleted file mode 100644 index 9858b43ed1..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_default.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_params.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_params.json deleted file mode 100644 index f87553fd7c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscacheresourcedatamodel_recipe_params.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.redis", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "recipe": { - "name": "redis-test", - "parameters": { - "port": 6081 - } - } - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscachesecrets.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscachesecrets.json deleted file mode 100644 index f5cc81d18e..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscachesecrets.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "password": "testPassword", - "connectionString": "test-connection-string", - "url": "test-url" -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscachesecretsdatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/rediscachesecretsdatamodel.json deleted file mode 100644 index f5cc81d18e..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/rediscachesecretsdatamodel.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "password": "testPassword", - "connectionString": "test-connection-string", - "url": "test-url" -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_invalid_properties_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_invalid_properties_resource.json deleted file mode 100644 index 8c3a953cf8..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_invalid_properties_resource.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "properties": { - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_invalid_resourceprovisioning_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_invalid_resourceprovisioning_resource.json deleted file mode 100644 index 66c13e9497..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_invalid_resourceprovisioning_resource.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "properties": { - "resourceProvisioning": "invalid" - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json deleted file mode 100644 index 71fc788985..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.sql.database", - "Provider": "azure" - } - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "resourceProvisioning":"manual", - "resources": [ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server":"testAccount1.sql.cosmos.azure.com", - "port":1433, - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json deleted file mode 100644 index 263b80599b..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.sql.database", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "resources":[ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning":"manual", - "username": "testUser", - "port":1433 - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resource.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resource.json deleted file mode 100644 index f1261e316c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resource.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "tags": { - "env": "dev" - }, - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "recipe": { - "name": "sql-test", - "parameters":{ - "foo":"bar" - } - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json deleted file mode 100644 index f8b5a28c0c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "azure.sql.database", - "Provider": "azure" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "recipe": { - "name": "sql-test", - "parameters":{ - "foo":"bar" - } - }, - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning":"recipe", - "username":"testUser", - "port":1433 - } -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_secrets_datamodel.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_secrets_datamodel.json deleted file mode 100644 index 4f05d5885c..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabase_secrets_datamodel.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "password": "testPassword", - "connectionString": "test-connection-string" -} \ No newline at end of file diff --git a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabaseresource-invalid.json b/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabaseresource-invalid.json deleted file mode 100644 index c4ad92383f..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/testdata/sqldatabaseresource-invalid.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "properties": { - "database": 12345, - "resourceProvisioning":"manual" - } -} diff --git a/pkg/linkrp/api/v20220315privatepreview/version.go b/pkg/linkrp/api/v20220315privatepreview/version.go deleted file mode 100644 index 3a97781966..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/version.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v20220315privatepreview - -// Version represents the api version in this package. -const Version = "2022-03-15-privatepreview" diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_constants.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_constants.go deleted file mode 100644 index 8a415ad733..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_constants.go +++ /dev/null @@ -1,112 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -const ( - moduleName = "v20220315privatepreview" - moduleVersion = "v0.0.1" -) - -// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. -type ActionType string - -const ( - ActionTypeInternal ActionType = "Internal" -) - -// PossibleActionTypeValues returns the possible values for the ActionType const type. -func PossibleActionTypeValues() []ActionType { - return []ActionType{ - ActionTypeInternal, - } -} - -// CreatedByType - The type of identity that created the resource. -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. -func PossibleCreatedByTypeValues() []CreatedByType { - return []CreatedByType{ - CreatedByTypeApplication, - CreatedByTypeKey, - CreatedByTypeManagedIdentity, - CreatedByTypeUser, - } -} - -// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default -// value is "user,system" -type Origin string - -const ( - OriginSystem Origin = "system" - OriginUser Origin = "user" - OriginUserSystem Origin = "user,system" -) - -// PossibleOriginValues returns the possible values for the Origin const type. -func PossibleOriginValues() []Origin { - return []Origin{ - OriginSystem, - OriginUser, - OriginUserSystem, - } -} - -// ProvisioningState - Provisioning state of the link at the time the operation was called -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateProvisioning ProvisioningState = "Provisioning" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" -) - -// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. -func PossibleProvisioningStateValues() []ProvisioningState { - return []ProvisioningState{ - ProvisioningStateAccepted, - ProvisioningStateCanceled, - ProvisioningStateDeleting, - ProvisioningStateFailed, - ProvisioningStateProvisioning, - ProvisioningStateSucceeded, - ProvisioningStateUpdating, - } -} - -// ResourceProvisioning - Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', -// where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user -// manages the resource and provides the values. -type ResourceProvisioning string - -const ( - ResourceProvisioningManual ResourceProvisioning = "manual" - ResourceProvisioningRecipe ResourceProvisioning = "recipe" -) - -// PossibleResourceProvisioningValues returns the possible values for the ResourceProvisioning const type. -func PossibleResourceProvisioningValues() []ResourceProvisioning { - return []ResourceProvisioning{ - ResourceProvisioningManual, - ResourceProvisioningRecipe, - } -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprpubsubbroker_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprpubsubbroker_client.go deleted file mode 100644 index f4be06d752..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprpubsubbroker_client.go +++ /dev/null @@ -1,276 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// DaprPubSubBrokerClient contains the methods for the DaprPubSubBroker group. -// Don't use this type directly, use NewDaprPubSubBrokerClient() instead. -type DaprPubSubBrokerClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewDaprPubSubBrokerClient creates a new instance of DaprPubSubBrokerClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewDaprPubSubBrokerClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DaprPubSubBrokerClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &DaprPubSubBrokerClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprPubSubBrokerName - DaprPubSubBroker name -// resource - Resource create parameters. -// options - DaprPubSubBrokerClientCreateOrUpdateOptions contains the optional parameters for the DaprPubSubBrokerClient.CreateOrUpdate -// method. -func (client *DaprPubSubBrokerClient) CreateOrUpdate(ctx context.Context, daprPubSubBrokerName string, resource DaprPubSubBrokerResource, options *DaprPubSubBrokerClientCreateOrUpdateOptions) (DaprPubSubBrokerClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, daprPubSubBrokerName, resource, options) - if err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DaprPubSubBrokerClient) createOrUpdateCreateRequest(ctx context.Context, daprPubSubBrokerName string, resource DaprPubSubBrokerResource, options *DaprPubSubBrokerClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprPubSubBrokers/{daprPubSubBrokerName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprPubSubBrokerName == "" { - return nil, errors.New("parameter daprPubSubBrokerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprPubSubBrokerName}", url.PathEscape(daprPubSubBrokerName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *DaprPubSubBrokerClient) createOrUpdateHandleResponse(resp *http.Response) (DaprPubSubBrokerClientCreateOrUpdateResponse, error) { - result := DaprPubSubBrokerClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResource); err != nil { - return DaprPubSubBrokerClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// BeginDelete - Deletes an existing DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprPubSubBrokerName - DaprPubSubBroker name -// options - DaprPubSubBrokerClientBeginDeleteOptions contains the optional parameters for the DaprPubSubBrokerClient.BeginDelete -// method. -func (client *DaprPubSubBrokerClient) BeginDelete(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientBeginDeleteOptions) (*runtime.Poller[DaprPubSubBrokerClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, daprPubSubBrokerName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DaprPubSubBrokerClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[DaprPubSubBrokerClientDeleteResponse](options.ResumeToken, client.pl, nil) - } -} - -// Delete - Deletes an existing DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -func (client *DaprPubSubBrokerClient) deleteOperation(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientBeginDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, daprPubSubBrokerName, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *DaprPubSubBrokerClient) deleteCreateRequest(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprPubSubBrokers/{daprPubSubBrokerName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprPubSubBrokerName == "" { - return nil, errors.New("parameter daprPubSubBrokerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprPubSubBrokerName}", url.PathEscape(daprPubSubBrokerName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Retrieves information about a DaprPubSubBrokerResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprPubSubBrokerName - DaprPubSubBroker name -// options - DaprPubSubBrokerClientGetOptions contains the optional parameters for the DaprPubSubBrokerClient.Get method. -func (client *DaprPubSubBrokerClient) Get(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientGetOptions) (DaprPubSubBrokerClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, daprPubSubBrokerName, options) - if err != nil { - return DaprPubSubBrokerClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprPubSubBrokerClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprPubSubBrokerClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *DaprPubSubBrokerClient) getCreateRequest(ctx context.Context, daprPubSubBrokerName string, options *DaprPubSubBrokerClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprPubSubBrokers/{daprPubSubBrokerName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprPubSubBrokerName == "" { - return nil, errors.New("parameter daprPubSubBrokerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprPubSubBrokerName}", url.PathEscape(daprPubSubBrokerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *DaprPubSubBrokerClient) getHandleResponse(resp *http.Response) (DaprPubSubBrokerClientGetResponse, error) { - result := DaprPubSubBrokerClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResource); err != nil { - return DaprPubSubBrokerClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all DaprPubSubBrokerResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - DaprPubSubBrokerClientListByRootScopeOptions contains the optional parameters for the DaprPubSubBrokerClient.ListByRootScope -// method. -func (client *DaprPubSubBrokerClient) NewListByRootScopePager(options *DaprPubSubBrokerClientListByRootScopeOptions) (*runtime.Pager[DaprPubSubBrokerClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[DaprPubSubBrokerClientListByRootScopeResponse]{ - More: func(page DaprPubSubBrokerClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DaprPubSubBrokerClientListByRootScopeResponse) (DaprPubSubBrokerClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return DaprPubSubBrokerClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprPubSubBrokerClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprPubSubBrokerClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *DaprPubSubBrokerClient) listByRootScopeCreateRequest(ctx context.Context, options *DaprPubSubBrokerClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprPubSubBrokers" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *DaprPubSubBrokerClient) listByRootScopeHandleResponse(resp *http.Response) (DaprPubSubBrokerClientListByRootScopeResponse, error) { - result := DaprPubSubBrokerClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprPubSubBrokerResourceListResult); err != nil { - return DaprPubSubBrokerClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprsecretstore_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprsecretstore_client.go deleted file mode 100644 index 0f8e3e1959..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprsecretstore_client.go +++ /dev/null @@ -1,272 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// DaprSecretStoreClient contains the methods for the DaprSecretStore group. -// Don't use this type directly, use NewDaprSecretStoreClient() instead. -type DaprSecretStoreClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewDaprSecretStoreClient creates a new instance of DaprSecretStoreClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewDaprSecretStoreClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DaprSecretStoreClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &DaprSecretStoreClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a DaprSecretStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprSecretStoreName - DaprSecretStore name -// resource - Resource create parameters. -// options - DaprSecretStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprSecretStoreClient.CreateOrUpdate -// method. -func (client *DaprSecretStoreClient) CreateOrUpdate(ctx context.Context, daprSecretStoreName string, resource DaprSecretStoreResource, options *DaprSecretStoreClientCreateOrUpdateOptions) (DaprSecretStoreClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, daprSecretStoreName, resource, options) - if err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DaprSecretStoreClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DaprSecretStoreClient) createOrUpdateCreateRequest(ctx context.Context, daprSecretStoreName string, resource DaprSecretStoreResource, options *DaprSecretStoreClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprSecretStores/{daprSecretStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprSecretStoreName == "" { - return nil, errors.New("parameter daprSecretStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprSecretStoreName}", url.PathEscape(daprSecretStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *DaprSecretStoreClient) createOrUpdateHandleResponse(resp *http.Response) (DaprSecretStoreClientCreateOrUpdateResponse, error) { - result := DaprSecretStoreClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResource); err != nil { - return DaprSecretStoreClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing DaprSecretStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprSecretStoreName - DaprSecretStore name -// options - DaprSecretStoreClientDeleteOptions contains the optional parameters for the DaprSecretStoreClient.Delete method. -func (client *DaprSecretStoreClient) Delete(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientDeleteOptions) (DaprSecretStoreClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, daprSecretStoreName, options) - if err != nil { - return DaprSecretStoreClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return DaprSecretStoreClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return client.deleteHandleResponse(resp) -} - -// deleteCreateRequest creates the Delete request. -func (client *DaprSecretStoreClient) deleteCreateRequest(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprSecretStores/{daprSecretStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprSecretStoreName == "" { - return nil, errors.New("parameter daprSecretStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprSecretStoreName}", url.PathEscape(daprSecretStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteHandleResponse handles the Delete response. -func (client *DaprSecretStoreClient) deleteHandleResponse(resp *http.Response) (DaprSecretStoreClientDeleteResponse, error) { - result := DaprSecretStoreClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprSecretStoreClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a DaprSecretStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprSecretStoreName - DaprSecretStore name -// options - DaprSecretStoreClientGetOptions contains the optional parameters for the DaprSecretStoreClient.Get method. -func (client *DaprSecretStoreClient) Get(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientGetOptions) (DaprSecretStoreClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, daprSecretStoreName, options) - if err != nil { - return DaprSecretStoreClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprSecretStoreClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *DaprSecretStoreClient) getCreateRequest(ctx context.Context, daprSecretStoreName string, options *DaprSecretStoreClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprSecretStores/{daprSecretStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprSecretStoreName == "" { - return nil, errors.New("parameter daprSecretStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprSecretStoreName}", url.PathEscape(daprSecretStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *DaprSecretStoreClient) getHandleResponse(resp *http.Response) (DaprSecretStoreClientGetResponse, error) { - result := DaprSecretStoreClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResource); err != nil { - return DaprSecretStoreClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all DaprSecretStoreResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - DaprSecretStoreClientListByRootScopeOptions contains the optional parameters for the DaprSecretStoreClient.ListByRootScope -// method. -func (client *DaprSecretStoreClient) NewListByRootScopePager(options *DaprSecretStoreClientListByRootScopeOptions) (*runtime.Pager[DaprSecretStoreClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[DaprSecretStoreClientListByRootScopeResponse]{ - More: func(page DaprSecretStoreClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DaprSecretStoreClientListByRootScopeResponse) (DaprSecretStoreClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return DaprSecretStoreClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprSecretStoreClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprSecretStoreClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *DaprSecretStoreClient) listByRootScopeCreateRequest(ctx context.Context, options *DaprSecretStoreClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprSecretStores" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *DaprSecretStoreClient) listByRootScopeHandleResponse(resp *http.Response) (DaprSecretStoreClientListByRootScopeResponse, error) { - result := DaprSecretStoreClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprSecretStoreResourceListResult); err != nil { - return DaprSecretStoreClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprstatestore_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprstatestore_client.go deleted file mode 100644 index 0b6ea85741..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_daprstatestore_client.go +++ /dev/null @@ -1,276 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// DaprStateStoreClient contains the methods for the DaprStateStore group. -// Don't use this type directly, use NewDaprStateStoreClient() instead. -type DaprStateStoreClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewDaprStateStoreClient creates a new instance of DaprStateStoreClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewDaprStateStoreClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DaprStateStoreClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &DaprStateStoreClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprStateStoreName - DaprStateStore name -// resource - Resource create parameters. -// options - DaprStateStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprStateStoreClient.CreateOrUpdate -// method. -func (client *DaprStateStoreClient) CreateOrUpdate(ctx context.Context, daprStateStoreName string, resource DaprStateStoreResource, options *DaprStateStoreClientCreateOrUpdateOptions) (DaprStateStoreClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, daprStateStoreName, resource, options) - if err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DaprStateStoreClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *DaprStateStoreClient) createOrUpdateCreateRequest(ctx context.Context, daprStateStoreName string, resource DaprStateStoreResource, options *DaprStateStoreClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprStateStores/{daprStateStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprStateStoreName == "" { - return nil, errors.New("parameter daprStateStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprStateStoreName}", url.PathEscape(daprStateStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *DaprStateStoreClient) createOrUpdateHandleResponse(resp *http.Response) (DaprStateStoreClientCreateOrUpdateResponse, error) { - result := DaprStateStoreClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResource); err != nil { - return DaprStateStoreClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// BeginDelete - Deletes an existing DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprStateStoreName - DaprStateStore name -// options - DaprStateStoreClientBeginDeleteOptions contains the optional parameters for the DaprStateStoreClient.BeginDelete -// method. -func (client *DaprStateStoreClient) BeginDelete(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientBeginDeleteOptions) (*runtime.Poller[DaprStateStoreClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, daprStateStoreName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DaprStateStoreClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[DaprStateStoreClientDeleteResponse](options.ResumeToken, client.pl, nil) - } -} - -// Delete - Deletes an existing DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -func (client *DaprStateStoreClient) deleteOperation(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientBeginDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, daprStateStoreName, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *DaprStateStoreClient) deleteCreateRequest(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprStateStores/{daprStateStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprStateStoreName == "" { - return nil, errors.New("parameter daprStateStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprStateStoreName}", url.PathEscape(daprStateStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Retrieves information about a DaprStateStoreResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// daprStateStoreName - DaprStateStore name -// options - DaprStateStoreClientGetOptions contains the optional parameters for the DaprStateStoreClient.Get method. -func (client *DaprStateStoreClient) Get(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientGetOptions) (DaprStateStoreClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, daprStateStoreName, options) - if err != nil { - return DaprStateStoreClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprStateStoreClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprStateStoreClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *DaprStateStoreClient) getCreateRequest(ctx context.Context, daprStateStoreName string, options *DaprStateStoreClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprStateStores/{daprStateStoreName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if daprStateStoreName == "" { - return nil, errors.New("parameter daprStateStoreName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{daprStateStoreName}", url.PathEscape(daprStateStoreName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *DaprStateStoreClient) getHandleResponse(resp *http.Response) (DaprStateStoreClientGetResponse, error) { - result := DaprStateStoreClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResource); err != nil { - return DaprStateStoreClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all DaprStateStoreResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - DaprStateStoreClientListByRootScopeOptions contains the optional parameters for the DaprStateStoreClient.ListByRootScope -// method. -func (client *DaprStateStoreClient) NewListByRootScopePager(options *DaprStateStoreClientListByRootScopeOptions) (*runtime.Pager[DaprStateStoreClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[DaprStateStoreClientListByRootScopeResponse]{ - More: func(page DaprStateStoreClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DaprStateStoreClientListByRootScopeResponse) (DaprStateStoreClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return DaprStateStoreClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return DaprStateStoreClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DaprStateStoreClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *DaprStateStoreClient) listByRootScopeCreateRequest(ctx context.Context, options *DaprStateStoreClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/daprStateStores" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *DaprStateStoreClient) listByRootScopeHandleResponse(resp *http.Response) (DaprStateStoreClientListByRootScopeResponse, error) { - result := DaprStateStoreClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DaprStateStoreResourceListResult); err != nil { - return DaprStateStoreClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_extenders_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_extenders_client.go deleted file mode 100644 index 3fd40b233f..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_extenders_client.go +++ /dev/null @@ -1,297 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// ExtendersClient contains the methods for the Extenders group. -// Don't use this type directly, use NewExtendersClient() instead. -type ExtendersClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewExtendersClient creates a new instance of ExtendersClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewExtendersClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExtendersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &ExtendersClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a Extender resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// extenderName - The name of the Extender link resource -// extenderParameters - extender create parameters -// options - ExtendersClientCreateOrUpdateOptions contains the optional parameters for the ExtendersClient.CreateOrUpdate -// method. -func (client *ExtendersClient) CreateOrUpdate(ctx context.Context, extenderName string, extenderParameters ExtenderResource, options *ExtendersClientCreateOrUpdateOptions) (ExtendersClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, extenderName, extenderParameters, options) - if err != nil { - return ExtendersClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ExtendersClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ExtendersClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ExtendersClient) createOrUpdateCreateRequest(ctx context.Context, extenderName string, extenderParameters ExtenderResource, options *ExtendersClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/extenders/{extenderName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if extenderName == "" { - return nil, errors.New("parameter extenderName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{extenderName}", url.PathEscape(extenderName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, extenderParameters) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ExtendersClient) createOrUpdateHandleResponse(resp *http.Response) (ExtendersClientCreateOrUpdateResponse, error) { - result := ExtendersClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExtenderResource); err != nil { - return ExtendersClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing extender resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// extenderName - The name of the Extender link resource -// options - ExtendersClientDeleteOptions contains the optional parameters for the ExtendersClient.Delete method. -func (client *ExtendersClient) Delete(ctx context.Context, extenderName string, options *ExtendersClientDeleteOptions) (ExtendersClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, extenderName, options) - if err != nil { - return ExtendersClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ExtendersClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return ExtendersClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return ExtendersClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ExtendersClient) deleteCreateRequest(ctx context.Context, extenderName string, options *ExtendersClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/extenders/{extenderName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if extenderName == "" { - return nil, errors.New("parameter extenderName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{extenderName}", url.PathEscape(extenderName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Retrieves information about a extender resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// extenderName - The name of the Extender link resource -// options - ExtendersClientGetOptions contains the optional parameters for the ExtendersClient.Get method. -func (client *ExtendersClient) Get(ctx context.Context, extenderName string, options *ExtendersClientGetOptions) (ExtendersClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, extenderName, options) - if err != nil { - return ExtendersClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ExtendersClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExtendersClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *ExtendersClient) getCreateRequest(ctx context.Context, extenderName string, options *ExtendersClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/extenders/{extenderName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if extenderName == "" { - return nil, errors.New("parameter extenderName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{extenderName}", url.PathEscape(extenderName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ExtendersClient) getHandleResponse(resp *http.Response) (ExtendersClientGetResponse, error) { - result := ExtendersClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExtenderResource); err != nil { - return ExtendersClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all extender resources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - ExtendersClientListByRootScopeOptions contains the optional parameters for the ExtendersClient.ListByRootScope -// method. -func (client *ExtendersClient) NewListByRootScopePager(options *ExtendersClientListByRootScopeOptions) (*runtime.Pager[ExtendersClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[ExtendersClientListByRootScopeResponse]{ - More: func(page ExtendersClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExtendersClientListByRootScopeResponse) (ExtendersClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return ExtendersClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ExtendersClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExtendersClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *ExtendersClient) listByRootScopeCreateRequest(ctx context.Context, options *ExtendersClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/extenders" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *ExtendersClient) listByRootScopeHandleResponse(resp *http.Response) (ExtendersClientListByRootScopeResponse, error) { - result := ExtendersClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExtenderList); err != nil { - return ExtendersClientListByRootScopeResponse{}, err - } - return result, nil -} - -// ListSecrets - Lists secrets values for the specified Extender resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// extenderName - The name of the Extender link resource -// options - ExtendersClientListSecretsOptions contains the optional parameters for the ExtendersClient.ListSecrets method. -func (client *ExtendersClient) ListSecrets(ctx context.Context, extenderName string, options *ExtendersClientListSecretsOptions) (ExtendersClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, extenderName, options) - if err != nil { - return ExtendersClientListSecretsResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ExtendersClientListSecretsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExtendersClientListSecretsResponse{}, runtime.NewResponseError(resp) - } - return client.listSecretsHandleResponse(resp) -} - -// listSecretsCreateRequest creates the ListSecrets request. -func (client *ExtendersClient) listSecretsCreateRequest(ctx context.Context, extenderName string, options *ExtendersClientListSecretsOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/extenders/{extenderName}/listSecrets" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if extenderName == "" { - return nil, errors.New("parameter extenderName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{extenderName}", url.PathEscape(extenderName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listSecretsHandleResponse handles the ListSecrets response. -func (client *ExtendersClient) listSecretsHandleResponse(resp *http.Response) (ExtendersClientListSecretsResponse, error) { - result := ExtendersClientListSecretsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Value); err != nil { - return ExtendersClientListSecretsResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_models.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_models.go deleted file mode 100644 index 972ad17b70..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_models.go +++ /dev/null @@ -1,1047 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import "time" - -// BasicDaprResourceProperties - Basic properties of a Dapr component object. -type BasicDaprResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to -// use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// BasicResourceProperties - Basic properties of a Radius resource. -type BasicResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// DaprPubSubBrokerClientBeginDeleteOptions contains the optional parameters for the DaprPubSubBrokerClient.BeginDelete method. -type DaprPubSubBrokerClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DaprPubSubBrokerClientCreateOrUpdateOptions contains the optional parameters for the DaprPubSubBrokerClient.CreateOrUpdate -// method. -type DaprPubSubBrokerClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// DaprPubSubBrokerClientGetOptions contains the optional parameters for the DaprPubSubBrokerClient.Get method. -type DaprPubSubBrokerClientGetOptions struct { - // placeholder for future optional parameters -} - -// DaprPubSubBrokerClientListByRootScopeOptions contains the optional parameters for the DaprPubSubBrokerClient.ListByRootScope -// method. -type DaprPubSubBrokerClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// DaprPubSubBrokerProperties - DaprPubSubBroker link properties -type DaprPubSubBrokerProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // Metadata for the daprPubSubBroker resource. This should match the values specified in Dapr component spec - Metadata map[string]interface{} `json:"metadata,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the daprPubSubBroker link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // A collection of references to resources associated with the daprPubSubBroker - Resources []*ResourceReference `json:"resources,omitempty"` - - // DaprPubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format. - Type *string `json:"type,omitempty"` - - // Dapr component version - Version *string `json:"version,omitempty"` - - // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to -// use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` - - // READ-ONLY; Provisioning state of the daprPubSubBroker resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// DaprPubSubBrokerResource - DaprPubSubBroker link -type DaprPubSubBrokerResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // The resource-specific properties for this resource. - Properties *DaprPubSubBrokerProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// DaprPubSubBrokerResourceListResult - The response of a DaprPubSubBrokerResource list operation. -type DaprPubSubBrokerResourceListResult struct { - // REQUIRED; The DaprPubSubBrokerResource items on this page - Value []*DaprPubSubBrokerResource `json:"value,omitempty"` - - // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// DaprSecretStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprSecretStoreClient.CreateOrUpdate -// method. -type DaprSecretStoreClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// DaprSecretStoreClientDeleteOptions contains the optional parameters for the DaprSecretStoreClient.Delete method. -type DaprSecretStoreClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// DaprSecretStoreClientGetOptions contains the optional parameters for the DaprSecretStoreClient.Get method. -type DaprSecretStoreClientGetOptions struct { - // placeholder for future optional parameters -} - -// DaprSecretStoreClientListByRootScopeOptions contains the optional parameters for the DaprSecretStoreClient.ListByRootScope -// method. -type DaprSecretStoreClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// DaprSecretStoreProperties - DaprSecretStore link properties -type DaprSecretStoreProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // Metadata for the Secret Store resource. This should match the values specified in Dapr component spec - Metadata map[string]interface{} `json:"metadata,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the daprSecretStore link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // Dapr Secret Store type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/ - Type *string `json:"type,omitempty"` - - // Dapr component version - Version *string `json:"version,omitempty"` - - // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to -// use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` - - // READ-ONLY; Provisioning state of the dapr secret store link at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// DaprSecretStoreResource - DaprSecretStore link -type DaprSecretStoreResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // The resource-specific properties for this resource. - Properties *DaprSecretStoreProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// DaprSecretStoreResourceListResult - The response of a DaprSecretStoreResource list operation. -type DaprSecretStoreResourceListResult struct { - // REQUIRED; The DaprSecretStoreResource items on this page - Value []*DaprSecretStoreResource `json:"value,omitempty"` - - // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// DaprStateStoreClientBeginDeleteOptions contains the optional parameters for the DaprStateStoreClient.BeginDelete method. -type DaprStateStoreClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DaprStateStoreClientCreateOrUpdateOptions contains the optional parameters for the DaprStateStoreClient.CreateOrUpdate -// method. -type DaprStateStoreClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// DaprStateStoreClientGetOptions contains the optional parameters for the DaprStateStoreClient.Get method. -type DaprStateStoreClientGetOptions struct { - // placeholder for future optional parameters -} - -// DaprStateStoreClientListByRootScopeOptions contains the optional parameters for the DaprStateStoreClient.ListByRootScope -// method. -type DaprStateStoreClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// DaprStateStoreProperties - DaprStateStore link properties -type DaprStateStoreProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // Metadata for the state store resource. This should match the values specified in Dapr component spec - Metadata map[string]interface{} `json:"metadata,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the daprStateStore link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // A collection of references to resources associated with the state store - Resources []*ResourceReference `json:"resources,omitempty"` - - // Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format. - Type *string `json:"type,omitempty"` - - // Dapr component version - Version *string `json:"version,omitempty"` - - // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to -// use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` - - // READ-ONLY; Provisioning state of the DaprStateStore link at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// DaprStateStoreResource - DaprStateStore link -type DaprStateStoreResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // The resource-specific properties for this resource. - Properties *DaprStateStoreProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// DaprStateStoreResourceListResult - The response of a DaprStateStoreResource list operation. -type DaprStateStoreResourceListResult struct { - // REQUIRED; The DaprStateStoreResource items on this page - Value []*DaprStateStoreResource `json:"value,omitempty"` - - // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// ErrorAdditionalInfo - The resource management error additional info. -type ErrorAdditionalInfo struct { - // READ-ONLY; The additional info. - Info map[string]interface{} `json:"info,omitempty" azure:"ro"` - - // READ-ONLY; The additional info type. - Type *string `json:"type,omitempty" azure:"ro"` -} - -// ErrorDetail - The error detail. -type ErrorDetail struct { - // READ-ONLY; The error additional info. - AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` - - // READ-ONLY; The error code. - Code *string `json:"code,omitempty" azure:"ro"` - - // READ-ONLY; The error details. - Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` - - // READ-ONLY; The error message. - Message *string `json:"message,omitempty" azure:"ro"` - - // READ-ONLY; The error target. - Target *string `json:"target,omitempty" azure:"ro"` -} - -// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. -// (This also follows the OData error response format.). -type ErrorResponse struct { - // The error object. - Error *ErrorDetail `json:"error,omitempty"` -} - -// ExtenderList - Object that includes an array of Extender and a possible link for next set -type ExtenderList struct { - // The link used to fetch the next page of Extender list. - NextLink *string `json:"nextLink,omitempty"` - - // List of Extender resources - Value []*ExtenderResource `json:"value,omitempty"` -} - -// ExtenderProperties - Extender link properties -type ExtenderProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // OPTIONAL; Contains additional key/value pairs not defined in the schema. - AdditionalProperties map[string]interface{} - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the Extender link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // The secret values for the given Extender resource - Secrets map[string]interface{} `json:"secrets,omitempty"` - - // READ-ONLY; Provisioning state of the extender link at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// ExtenderResource - Extender link -type ExtenderResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // REQUIRED; Extender link properties - Properties *ExtenderProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// ExtendersClientCreateOrUpdateOptions contains the optional parameters for the ExtendersClient.CreateOrUpdate method. -type ExtendersClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ExtendersClientDeleteOptions contains the optional parameters for the ExtendersClient.Delete method. -type ExtendersClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ExtendersClientGetOptions contains the optional parameters for the ExtendersClient.Get method. -type ExtendersClientGetOptions struct { - // placeholder for future optional parameters -} - -// ExtendersClientListByRootScopeOptions contains the optional parameters for the ExtendersClient.ListByRootScope method. -type ExtendersClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// ExtendersClientListSecretsOptions contains the optional parameters for the ExtendersClient.ListSecrets method. -type ExtendersClientListSecretsOptions struct { - // placeholder for future optional parameters -} - -// MongoDatabaseListSecretsResult - The secret values for the given MongoDatabase resource -type MongoDatabaseListSecretsResult struct { - // Connection string used to connect to the target Mongo database - ConnectionString *string `json:"connectionString,omitempty"` - - // Password to use when connecting to the target Mongo database - Password *string `json:"password,omitempty"` -} - -// MongoDatabaseProperties - MongoDatabase link properties -type MongoDatabaseProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // Database name of the target Mongo database - Database *string `json:"database,omitempty"` - - // Host name of the target Mongo database - Host *string `json:"host,omitempty"` - - // Port value of the target Mongo database - Port *int32 `json:"port,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the MongoDB link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // List of the resource IDs that support the MongoDB resource - Resources []*ResourceReference `json:"resources,omitempty"` - - // Secret values provided for the resource - Secrets *MongoDatabaseSecrets `json:"secrets,omitempty"` - - // Username to use when connecting to the target Mongo database - Username *string `json:"username,omitempty"` - - // READ-ONLY; Provisioning state of the mongo database link at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// MongoDatabaseResource - MongoDatabase link -type MongoDatabaseResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // The resource-specific properties for this resource. - Properties *MongoDatabaseProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// MongoDatabaseResourceListResult - The response of a MongoDatabaseResource list operation. -type MongoDatabaseResourceListResult struct { - // REQUIRED; The MongoDatabaseResource items on this page - Value []*MongoDatabaseResource `json:"value,omitempty"` - - // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// MongoDatabaseSecrets - The secret values for the given MongoDatabase resource -type MongoDatabaseSecrets struct { - // Connection string used to connect to the target Mongo database - ConnectionString *string `json:"connectionString,omitempty"` - - // Password to use when connecting to the target Mongo database - Password *string `json:"password,omitempty"` -} - -// MongoDatabasesClientBeginDeleteOptions contains the optional parameters for the MongoDatabasesClient.BeginDelete method. -type MongoDatabasesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MongoDatabasesClientCreateOrUpdateOptions contains the optional parameters for the MongoDatabasesClient.CreateOrUpdate -// method. -type MongoDatabasesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// MongoDatabasesClientGetOptions contains the optional parameters for the MongoDatabasesClient.Get method. -type MongoDatabasesClientGetOptions struct { - // placeholder for future optional parameters -} - -// MongoDatabasesClientListByRootScopeOptions contains the optional parameters for the MongoDatabasesClient.ListByRootScope -// method. -type MongoDatabasesClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// MongoDatabasesClientListSecretsOptions contains the optional parameters for the MongoDatabasesClient.ListSecrets method. -type MongoDatabasesClientListSecretsOptions struct { - // placeholder for future optional parameters -} - -// Operation - Details of a REST API operation, returned from the Resource Provider Operations API -type Operation struct { - // Localized display information for this particular operation. - Display *OperationDisplay `json:"display,omitempty"` - - // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` - - // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane -// operations. - IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` - - // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", -// "Microsoft.Compute/virtualMachines/capture/action" - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default -// value is "user,system" - Origin *Origin `json:"origin,omitempty" azure:"ro"` -} - -// OperationDisplay - Localized display information for this particular operation. -type OperationDisplay struct { - // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. - Description *string `json:"description,omitempty" azure:"ro"` - - // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual -// Machine", "Restart Virtual Machine". - Operation *string `json:"operation,omitempty" azure:"ro"` - - // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft -// Compute". - Provider *string `json:"provider,omitempty" azure:"ro"` - - // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job -// Schedule Collections". - Resource *string `json:"resource,omitempty" azure:"ro"` -} - -// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to -// get the next set of results. -type OperationListResult struct { - // READ-ONLY; URL to get the next set of operation list results (if there are any). - NextLink *string `json:"nextLink,omitempty" azure:"ro"` - - // READ-ONLY; List of operations supported by the resource provider - Value []*Operation `json:"value,omitempty" azure:"ro"` -} - -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - -// RabbitMQListSecretsResult - The secret values for the given RabbitMQMessageQueue resource -type RabbitMQListSecretsResult struct { - // The password used to connect to the RabbitMQ instance - Password *string `json:"password,omitempty"` - - // The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. -// Can be overridden with a custom value - URI *string `json:"uri,omitempty"` -} - -// RabbitMQMessageQueueProperties - RabbitMQMessageQueue link properties -type RabbitMQMessageQueueProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // The hostname of the RabbitMQ instance - Host *string `json:"host,omitempty"` - - // The port of the RabbitMQ instance. Defaults to 5672 - Port *int32 `json:"port,omitempty"` - - // The name of the queue - Queue *string `json:"queue,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the rabbitMQ link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // List of the resource IDs that support the rabbitMQ resource - Resources []*ResourceReference `json:"resources,omitempty"` - - // Secrets provided by resources, - Secrets *RabbitMQSecrets `json:"secrets,omitempty"` - - // Specifies whether to use SSL when connecting to the RabbitMQ instance - TLS *bool `json:"tls,omitempty"` - - // The username to use when connecting to the RabbitMQ instance - Username *string `json:"username,omitempty"` - - // The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost. - VHost *string `json:"vHost,omitempty"` - - // READ-ONLY; Provisioning state of the rabbitMQ message queue link at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// RabbitMQMessageQueueResource - RabbitMQMessageQueue link -type RabbitMQMessageQueueResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // The resource-specific properties for this resource. - Properties *RabbitMQMessageQueueProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// RabbitMQMessageQueueResourceListResult - The response of a RabbitMQMessageQueueResource list operation. -type RabbitMQMessageQueueResourceListResult struct { - // REQUIRED; The RabbitMQMessageQueueResource items on this page - Value []*RabbitMQMessageQueueResource `json:"value,omitempty"` - - // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// RabbitMQSecrets - The secret values for the given RabbitMQMessageQueue resource -type RabbitMQSecrets struct { - // The password used to connect to the RabbitMQ instance - Password *string `json:"password,omitempty"` - - // The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. -// Can be overridden with a custom value - URI *string `json:"uri,omitempty"` -} - -// RabbitMqMessageQueuesClientCreateOrUpdateOptions contains the optional parameters for the RabbitMqMessageQueuesClient.CreateOrUpdate -// method. -type RabbitMqMessageQueuesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// RabbitMqMessageQueuesClientDeleteOptions contains the optional parameters for the RabbitMqMessageQueuesClient.Delete method. -type RabbitMqMessageQueuesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// RabbitMqMessageQueuesClientGetOptions contains the optional parameters for the RabbitMqMessageQueuesClient.Get method. -type RabbitMqMessageQueuesClientGetOptions struct { - // placeholder for future optional parameters -} - -// RabbitMqMessageQueuesClientListByRootScopeOptions contains the optional parameters for the RabbitMqMessageQueuesClient.ListByRootScope -// method. -type RabbitMqMessageQueuesClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// RabbitMqMessageQueuesClientListSecretsOptions contains the optional parameters for the RabbitMqMessageQueuesClient.ListSecrets -// method. -type RabbitMqMessageQueuesClientListSecretsOptions struct { - // placeholder for future optional parameters -} - -// Recipe - The recipe used to automatically deploy underlying infrastructure for a link -type Recipe struct { - // REQUIRED; The name of the recipe within the environment to use - Name *string `json:"name,omitempty"` - - // Key/value parameters to pass into the recipe at deployment - Parameters map[string]interface{} `json:"parameters,omitempty"` -} - -// RedisCacheListSecretsResult - The secret values for the given RedisCache resource -type RedisCacheListSecretsResult struct { - // The connection string used to connect to the Redis cache - ConnectionString *string `json:"connectionString,omitempty"` - - // The password for this Redis cache instance - Password *string `json:"password,omitempty"` - - // The URL used to connect to the Redis cache - URL *string `json:"url,omitempty"` -} - -// RedisCacheProperties - RedisCache link properties -type RedisCacheProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // The host name of the target Redis cache - Host *string `json:"host,omitempty"` - - // The port value of the target Redis cache - Port *int32 `json:"port,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the Redis caches link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // List of the resource IDs that support the Redis resource - Resources []*ResourceReference `json:"resources,omitempty"` - - // Secrets provided by resource - Secrets *RedisCacheSecrets `json:"secrets,omitempty"` - - // Specifies whether to enable SSL connections to the Redis cache - TLS *bool `json:"tls,omitempty"` - - // The username for Redis cache - Username *string `json:"username,omitempty"` - - // READ-ONLY; Provisioning state of the redis cache link at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// RedisCacheResource - RedisCache link -type RedisCacheResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // The resource-specific properties for this resource. - Properties *RedisCacheProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// RedisCacheResourceListResult - The response of a RedisCacheResource list operation. -type RedisCacheResourceListResult struct { - // REQUIRED; The RedisCacheResource items on this page - Value []*RedisCacheResource `json:"value,omitempty"` - - // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// RedisCacheSecrets - The secret values for the given RedisCache resource -type RedisCacheSecrets struct { - // The connection string used to connect to the Redis cache - ConnectionString *string `json:"connectionString,omitempty"` - - // The password for this Redis cache instance - Password *string `json:"password,omitempty"` - - // The URL used to connect to the Redis cache - URL *string `json:"url,omitempty"` -} - -// RedisCachesClientCreateOrUpdateOptions contains the optional parameters for the RedisCachesClient.CreateOrUpdate method. -type RedisCachesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// RedisCachesClientDeleteOptions contains the optional parameters for the RedisCachesClient.Delete method. -type RedisCachesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// RedisCachesClientGetOptions contains the optional parameters for the RedisCachesClient.Get method. -type RedisCachesClientGetOptions struct { - // placeholder for future optional parameters -} - -// RedisCachesClientListByRootScopeOptions contains the optional parameters for the RedisCachesClient.ListByRootScope method. -type RedisCachesClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// RedisCachesClientListSecretsOptions contains the optional parameters for the RedisCachesClient.ListSecrets method. -type RedisCachesClientListSecretsOptions struct { - // placeholder for future optional parameters -} - -// Resource - Common fields that are returned in the response for all Azure Resource Manager resources -type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// ResourceReference - Describes a reference to an existing resource -type ResourceReference struct { - // REQUIRED; Resource id of an existing resource - ID *string `json:"id,omitempty"` -} - -// ResourceStatus - Status of a resource. -type ResourceStatus struct { - // Properties of an output resource - OutputResources []map[string]interface{} `json:"outputResources,omitempty"` -} - -// SQLDatabaseListSecretsResult - The secret values for the given SqlDatabase resource -type SQLDatabaseListSecretsResult struct { - // Connection string used to connect to the target Sql database - ConnectionString *string `json:"connectionString,omitempty"` - - // Password to use when connecting to the target Sql database - Password *string `json:"password,omitempty"` -} - -// SQLDatabaseProperties - SqlDatabase properties -type SQLDatabaseProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the link is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the link is consumed by - Application *string `json:"application,omitempty"` - - // The name of the Sql database. - Database *string `json:"database,omitempty"` - - // Port value of the target Sql database - Port *int32 `json:"port,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the sqldatabases link - Recipe *Recipe `json:"recipe,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // List of the resource IDs that support the SqlDatabase resource - Resources []*ResourceReference `json:"resources,omitempty"` - - // Secret values provided for the resource - Secrets *SQLDatabaseSecrets `json:"secrets,omitempty"` - - // The fully qualified domain name of the Sql database. - Server *string `json:"server,omitempty"` - - // Username to use when connecting to the target Sql database - Username *string `json:"username,omitempty"` - - // READ-ONLY; Provisioning state of the Sql database link at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} - -// SQLDatabaseResource - SqlDatabase link -type SQLDatabaseResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // The resource-specific properties for this resource. - Properties *SQLDatabaseProperties `json:"properties,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -// SQLDatabaseResourceListResult - The response of a SqlDatabaseResource list operation. -type SQLDatabaseResourceListResult struct { - // REQUIRED; The SqlDatabaseResource items on this page - Value []*SQLDatabaseResource `json:"value,omitempty"` - - // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// SQLDatabaseSecrets - The secret values for the given SqlDatabase resource -type SQLDatabaseSecrets struct { - // Connection string used to connect to the target Sql database - ConnectionString *string `json:"connectionString,omitempty"` - - // Password to use when connecting to the target Sql database - Password *string `json:"password,omitempty"` -} - -// SQLDatabasesClientCreateOrUpdateOptions contains the optional parameters for the SQLDatabasesClient.CreateOrUpdate method. -type SQLDatabasesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// SQLDatabasesClientDeleteOptions contains the optional parameters for the SQLDatabasesClient.Delete method. -type SQLDatabasesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// SQLDatabasesClientGetOptions contains the optional parameters for the SQLDatabasesClient.Get method. -type SQLDatabasesClientGetOptions struct { - // placeholder for future optional parameters -} - -// SQLDatabasesClientListByRootScopeOptions contains the optional parameters for the SQLDatabasesClient.ListByRootScope method. -type SQLDatabasesClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// SQLDatabasesClientListSecretsOptions contains the optional parameters for the SQLDatabasesClient.ListSecrets method. -type SQLDatabasesClientListSecretsOptions struct { - // placeholder for future optional parameters -} - -// SystemData - Metadata pertaining to creation and last modification of the resource. -type SystemData struct { - // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` - - // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` - - // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - - // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` - - // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - - // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' -// and a 'location' -type TrackedResource struct { - // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_models_serde.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_models_serde.go deleted file mode 100644 index 81f556a64a..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_models_serde.go +++ /dev/null @@ -1,2010 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type BasicDaprResourceProperties. -func (b BasicDaprResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "componentName", b.ComponentName) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicDaprResourceProperties. -func (b *BasicDaprResourceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "componentName": - err = unpopulate(val, "ComponentName", &b.ComponentName) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type BasicResourceProperties. -func (b BasicResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicResourceProperties. -func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerProperties. -func (d DaprPubSubBrokerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", d.Application) - populate(objectMap, "componentName", d.ComponentName) - populate(objectMap, "environment", d.Environment) - populate(objectMap, "metadata", d.Metadata) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "recipe", d.Recipe) - populate(objectMap, "resourceProvisioning", d.ResourceProvisioning) - populate(objectMap, "resources", d.Resources) - populate(objectMap, "status", d.Status) - populate(objectMap, "type", d.Type) - populate(objectMap, "version", d.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprPubSubBrokerProperties. -func (d *DaprPubSubBrokerProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &d.Application) - delete(rawMsg, key) - case "componentName": - err = unpopulate(val, "ComponentName", &d.ComponentName) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &d.Environment) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &d.Metadata) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &d.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &d.Resources) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &d.Status) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &d.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerResource. -func (d DaprPubSubBrokerResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "systemData", d.SystemData) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprPubSubBrokerResource. -func (d *DaprPubSubBrokerResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &d.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &d.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprPubSubBrokerResourceListResult. -func (d DaprPubSubBrokerResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", d.NextLink) - populate(objectMap, "value", d.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprPubSubBrokerResourceListResult. -func (d *DaprPubSubBrokerResourceListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreProperties. -func (d DaprSecretStoreProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", d.Application) - populate(objectMap, "componentName", d.ComponentName) - populate(objectMap, "environment", d.Environment) - populate(objectMap, "metadata", d.Metadata) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "recipe", d.Recipe) - populate(objectMap, "resourceProvisioning", d.ResourceProvisioning) - populate(objectMap, "status", d.Status) - populate(objectMap, "type", d.Type) - populate(objectMap, "version", d.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprSecretStoreProperties. -func (d *DaprSecretStoreProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &d.Application) - delete(rawMsg, key) - case "componentName": - err = unpopulate(val, "ComponentName", &d.ComponentName) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &d.Environment) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &d.Metadata) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &d.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &d.Status) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &d.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreResource. -func (d DaprSecretStoreResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "systemData", d.SystemData) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprSecretStoreResource. -func (d *DaprSecretStoreResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &d.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &d.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprSecretStoreResourceListResult. -func (d DaprSecretStoreResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", d.NextLink) - populate(objectMap, "value", d.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprSecretStoreResourceListResult. -func (d *DaprSecretStoreResourceListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprStateStoreProperties. -func (d DaprStateStoreProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", d.Application) - populate(objectMap, "componentName", d.ComponentName) - populate(objectMap, "environment", d.Environment) - populate(objectMap, "metadata", d.Metadata) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "recipe", d.Recipe) - populate(objectMap, "resourceProvisioning", d.ResourceProvisioning) - populate(objectMap, "resources", d.Resources) - populate(objectMap, "status", d.Status) - populate(objectMap, "type", d.Type) - populate(objectMap, "version", d.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprStateStoreProperties. -func (d *DaprStateStoreProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &d.Application) - delete(rawMsg, key) - case "componentName": - err = unpopulate(val, "ComponentName", &d.ComponentName) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &d.Environment) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &d.Metadata) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &d.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &d.ResourceProvisioning) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &d.Resources) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &d.Status) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &d.Version) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprStateStoreResource. -func (d DaprStateStoreResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "systemData", d.SystemData) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprStateStoreResource. -func (d *DaprStateStoreResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &d.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &d.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &d.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &d.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &d.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DaprStateStoreResourceListResult. -func (d DaprStateStoreResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", d.NextLink) - populate(objectMap, "value", d.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DaprStateStoreResourceListResult. -func (d *DaprStateStoreResourceListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &d.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. -func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "info", e.Info) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. -func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "info": - err = unpopulate(val, "Info", &e.Info) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. -func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "additionalInfo", e.AdditionalInfo) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) - populate(objectMap, "target", e.Target) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. -func (e *ErrorDetail) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "additionalInfo": - err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) - delete(rawMsg, key) - case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &e.Target) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. -func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "error", e.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (e *ErrorResponse) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExtenderList. -func (e ExtenderList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExtenderList. -func (e *ExtenderList) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &e.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &e.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExtenderProperties. -func (e ExtenderProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", e.Application) - populate(objectMap, "environment", e.Environment) - populate(objectMap, "provisioningState", e.ProvisioningState) - populate(objectMap, "recipe", e.Recipe) - populate(objectMap, "resourceProvisioning", e.ResourceProvisioning) - populate(objectMap, "secrets", e.Secrets) - populate(objectMap, "status", e.Status) - if e.AdditionalProperties != nil { - for key, val := range e.AdditionalProperties { - objectMap[key] = val - } - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExtenderProperties. -func (e *ExtenderProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &e.Application) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &e.Environment) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &e.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &e.ResourceProvisioning) - delete(rawMsg, key) - case "secrets": - err = unpopulate(val, "Secrets", &e.Secrets) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - default: - if e.AdditionalProperties == nil { - e.AdditionalProperties = map[string]interface{}{} - } - if val != nil { - var aux interface{} - err = json.Unmarshal(val, &aux) - e.AdditionalProperties[key] = aux - } - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExtenderResource. -func (e ExtenderResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", e.ID) - populate(objectMap, "location", e.Location) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "systemData", e.SystemData) - populate(objectMap, "tags", e.Tags) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExtenderResource. -func (e *ExtenderResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &e.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &e.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &e.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &e.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &e.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type MongoDatabaseListSecretsResult. -func (m MongoDatabaseListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "connectionString", m.ConnectionString) - populate(objectMap, "password", m.Password) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDatabaseListSecretsResult. -func (m *MongoDatabaseListSecretsResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "connectionString": - err = unpopulate(val, "ConnectionString", &m.ConnectionString) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &m.Password) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type MongoDatabaseProperties. -func (m MongoDatabaseProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", m.Application) - populate(objectMap, "database", m.Database) - populate(objectMap, "environment", m.Environment) - populate(objectMap, "host", m.Host) - populate(objectMap, "port", m.Port) - populate(objectMap, "provisioningState", m.ProvisioningState) - populate(objectMap, "recipe", m.Recipe) - populate(objectMap, "resourceProvisioning", m.ResourceProvisioning) - populate(objectMap, "resources", m.Resources) - populate(objectMap, "secrets", m.Secrets) - populate(objectMap, "status", m.Status) - populate(objectMap, "username", m.Username) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDatabaseProperties. -func (m *MongoDatabaseProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &m.Application) - delete(rawMsg, key) - case "database": - err = unpopulate(val, "Database", &m.Database) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &m.Environment) - delete(rawMsg, key) - case "host": - err = unpopulate(val, "Host", &m.Host) - delete(rawMsg, key) - case "port": - err = unpopulate(val, "Port", &m.Port) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &m.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &m.ResourceProvisioning) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &m.Resources) - delete(rawMsg, key) - case "secrets": - err = unpopulate(val, "Secrets", &m.Secrets) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &m.Status) - delete(rawMsg, key) - case "username": - err = unpopulate(val, "Username", &m.Username) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type MongoDatabaseResource. -func (m MongoDatabaseResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", m.ID) - populate(objectMap, "location", m.Location) - populate(objectMap, "name", m.Name) - populate(objectMap, "properties", m.Properties) - populate(objectMap, "systemData", m.SystemData) - populate(objectMap, "tags", m.Tags) - populate(objectMap, "type", m.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDatabaseResource. -func (m *MongoDatabaseResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &m.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &m.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &m.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &m.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &m.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &m.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &m.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type MongoDatabaseResourceListResult. -func (m MongoDatabaseResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", m.NextLink) - populate(objectMap, "value", m.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDatabaseResourceListResult. -func (m *MongoDatabaseResourceListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &m.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &m.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type MongoDatabaseSecrets. -func (m MongoDatabaseSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "connectionString", m.ConnectionString) - populate(objectMap, "password", m.Password) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MongoDatabaseSecrets. -func (m *MongoDatabaseSecrets) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "connectionString": - err = unpopulate(val, "ConnectionString", &m.ConnectionString) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &m.Password) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", m, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Operation. -func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "actionType", o.ActionType) - populate(objectMap, "display", o.Display) - populate(objectMap, "isDataAction", o.IsDataAction) - populate(objectMap, "name", o.Name) - populate(objectMap, "origin", o.Origin) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. -func (o *Operation) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "actionType": - err = unpopulate(val, "ActionType", &o.ActionType) - delete(rawMsg, key) - case "display": - err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "origin": - err = unpopulate(val, "Origin", &o.Origin) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", o.Description) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. -func (o *OperationDisplay) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "description": - err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) - delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type OperationListResult. -func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. -func (o *OperationListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RabbitMQListSecretsResult. -func (r RabbitMQListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "password", r.Password) - populate(objectMap, "uri", r.URI) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RabbitMQListSecretsResult. -func (r *RabbitMQListSecretsResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "password": - err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) - case "uri": - err = unpopulate(val, "URI", &r.URI) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RabbitMQMessageQueueProperties. -func (r RabbitMQMessageQueueProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", r.Application) - populate(objectMap, "environment", r.Environment) - populate(objectMap, "host", r.Host) - populate(objectMap, "port", r.Port) - populate(objectMap, "provisioningState", r.ProvisioningState) - populate(objectMap, "queue", r.Queue) - populate(objectMap, "recipe", r.Recipe) - populate(objectMap, "resourceProvisioning", r.ResourceProvisioning) - populate(objectMap, "resources", r.Resources) - populate(objectMap, "secrets", r.Secrets) - populate(objectMap, "status", r.Status) - populate(objectMap, "tls", r.TLS) - populate(objectMap, "username", r.Username) - populate(objectMap, "vHost", r.VHost) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RabbitMQMessageQueueProperties. -func (r *RabbitMQMessageQueueProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &r.Application) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &r.Environment) - delete(rawMsg, key) - case "host": - err = unpopulate(val, "Host", &r.Host) - delete(rawMsg, key) - case "port": - err = unpopulate(val, "Port", &r.Port) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) - delete(rawMsg, key) - case "queue": - err = unpopulate(val, "Queue", &r.Queue) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &r.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &r.ResourceProvisioning) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &r.Resources) - delete(rawMsg, key) - case "secrets": - err = unpopulate(val, "Secrets", &r.Secrets) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &r.Status) - delete(rawMsg, key) - case "tls": - err = unpopulate(val, "TLS", &r.TLS) - delete(rawMsg, key) - case "username": - err = unpopulate(val, "Username", &r.Username) - delete(rawMsg, key) - case "vHost": - err = unpopulate(val, "VHost", &r.VHost) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RabbitMQMessageQueueResource. -func (r RabbitMQMessageQueueResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "systemData", r.SystemData) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RabbitMQMessageQueueResource. -func (r *RabbitMQMessageQueueResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &r.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &r.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &r.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RabbitMQMessageQueueResourceListResult. -func (r RabbitMQMessageQueueResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", r.NextLink) - populate(objectMap, "value", r.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RabbitMQMessageQueueResourceListResult. -func (r *RabbitMQMessageQueueResourceListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &r.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &r.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RabbitMQSecrets. -func (r RabbitMQSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "password", r.Password) - populate(objectMap, "uri", r.URI) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RabbitMQSecrets. -func (r *RabbitMQSecrets) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "password": - err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) - case "uri": - err = unpopulate(val, "URI", &r.URI) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Recipe. -func (r Recipe) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "name", r.Name) - populate(objectMap, "parameters", r.Parameters) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Recipe. -func (r *Recipe) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "parameters": - err = unpopulate(val, "Parameters", &r.Parameters) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RedisCacheListSecretsResult. -func (r RedisCacheListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "connectionString", r.ConnectionString) - populate(objectMap, "password", r.Password) - populate(objectMap, "url", r.URL) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RedisCacheListSecretsResult. -func (r *RedisCacheListSecretsResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "connectionString": - err = unpopulate(val, "ConnectionString", &r.ConnectionString) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) - case "url": - err = unpopulate(val, "URL", &r.URL) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RedisCacheProperties. -func (r RedisCacheProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", r.Application) - populate(objectMap, "environment", r.Environment) - populate(objectMap, "host", r.Host) - populate(objectMap, "port", r.Port) - populate(objectMap, "provisioningState", r.ProvisioningState) - populate(objectMap, "recipe", r.Recipe) - populate(objectMap, "resourceProvisioning", r.ResourceProvisioning) - populate(objectMap, "resources", r.Resources) - populate(objectMap, "secrets", r.Secrets) - populate(objectMap, "status", r.Status) - populate(objectMap, "tls", r.TLS) - populate(objectMap, "username", r.Username) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RedisCacheProperties. -func (r *RedisCacheProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &r.Application) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &r.Environment) - delete(rawMsg, key) - case "host": - err = unpopulate(val, "Host", &r.Host) - delete(rawMsg, key) - case "port": - err = unpopulate(val, "Port", &r.Port) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &r.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &r.ResourceProvisioning) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &r.Resources) - delete(rawMsg, key) - case "secrets": - err = unpopulate(val, "Secrets", &r.Secrets) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &r.Status) - delete(rawMsg, key) - case "tls": - err = unpopulate(val, "TLS", &r.TLS) - delete(rawMsg, key) - case "username": - err = unpopulate(val, "Username", &r.Username) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RedisCacheResource. -func (r RedisCacheResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "systemData", r.SystemData) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RedisCacheResource. -func (r *RedisCacheResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &r.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &r.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &r.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RedisCacheResourceListResult. -func (r RedisCacheResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", r.NextLink) - populate(objectMap, "value", r.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RedisCacheResourceListResult. -func (r *RedisCacheResourceListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &r.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &r.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RedisCacheSecrets. -func (r RedisCacheSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "connectionString", r.ConnectionString) - populate(objectMap, "password", r.Password) - populate(objectMap, "url", r.URL) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RedisCacheSecrets. -func (r *RedisCacheSecrets) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "connectionString": - err = unpopulate(val, "ConnectionString", &r.ConnectionString) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) - case "url": - err = unpopulate(val, "URL", &r.URL) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "systemData", r.SystemData) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. -func (r *Resource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceReference. -func (r ResourceReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReference. -func (r *ResourceReference) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceStatus. -func (r ResourceStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "outputResources", r.OutputResources) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceStatus. -func (r *ResourceStatus) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "outputResources": - err = unpopulate(val, "OutputResources", &r.OutputResources) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SQLDatabaseListSecretsResult. -func (s SQLDatabaseListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "connectionString", s.ConnectionString) - populate(objectMap, "password", s.Password) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SQLDatabaseListSecretsResult. -func (s *SQLDatabaseListSecretsResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "connectionString": - err = unpopulate(val, "ConnectionString", &s.ConnectionString) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &s.Password) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SQLDatabaseProperties. -func (s SQLDatabaseProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", s.Application) - populate(objectMap, "database", s.Database) - populate(objectMap, "environment", s.Environment) - populate(objectMap, "port", s.Port) - populate(objectMap, "provisioningState", s.ProvisioningState) - populate(objectMap, "recipe", s.Recipe) - populate(objectMap, "resourceProvisioning", s.ResourceProvisioning) - populate(objectMap, "resources", s.Resources) - populate(objectMap, "secrets", s.Secrets) - populate(objectMap, "server", s.Server) - populate(objectMap, "status", s.Status) - populate(objectMap, "username", s.Username) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SQLDatabaseProperties. -func (s *SQLDatabaseProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &s.Application) - delete(rawMsg, key) - case "database": - err = unpopulate(val, "Database", &s.Database) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &s.Environment) - delete(rawMsg, key) - case "port": - err = unpopulate(val, "Port", &s.Port) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) - delete(rawMsg, key) - case "recipe": - err = unpopulate(val, "Recipe", &s.Recipe) - delete(rawMsg, key) - case "resourceProvisioning": - err = unpopulate(val, "ResourceProvisioning", &s.ResourceProvisioning) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &s.Resources) - delete(rawMsg, key) - case "secrets": - err = unpopulate(val, "Secrets", &s.Secrets) - delete(rawMsg, key) - case "server": - err = unpopulate(val, "Server", &s.Server) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &s.Status) - delete(rawMsg, key) - case "username": - err = unpopulate(val, "Username", &s.Username) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SQLDatabaseResource. -func (s SQLDatabaseResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "location", s.Location) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "systemData", s.SystemData) - populate(objectMap, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SQLDatabaseResource. -func (s *SQLDatabaseResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &s.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &s.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &s.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &s.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &s.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &s.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &s.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SQLDatabaseResourceListResult. -func (s SQLDatabaseResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", s.NextLink) - populate(objectMap, "value", s.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SQLDatabaseResourceListResult. -func (s *SQLDatabaseResourceListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &s.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &s.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SQLDatabaseSecrets. -func (s SQLDatabaseSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "connectionString", s.ConnectionString) - populate(objectMap, "password", s.Password) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SQLDatabaseSecrets. -func (s *SQLDatabaseSecrets) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "connectionString": - err = unpopulate(val, "ConnectionString", &s.ConnectionString) - delete(rawMsg, key) - case "password": - err = unpopulate(val, "Password", &s.Password) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "systemData", t.SystemData) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. -func (t *TrackedResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &t.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_mongodatabases_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_mongodatabases_client.go deleted file mode 100644 index 2a3ca06251..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_mongodatabases_client.go +++ /dev/null @@ -1,325 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// MongoDatabasesClient contains the methods for the MongoDatabases group. -// Don't use this type directly, use NewMongoDatabasesClient() instead. -type MongoDatabasesClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewMongoDatabasesClient creates a new instance of MongoDatabasesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewMongoDatabasesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MongoDatabasesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &MongoDatabasesClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a MongoDatabaseResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the MongoDatabase link resource -// resource - Resource create parameters. -// options - MongoDatabasesClientCreateOrUpdateOptions contains the optional parameters for the MongoDatabasesClient.CreateOrUpdate -// method. -func (client *MongoDatabasesClient) CreateOrUpdate(ctx context.Context, mongoDatabaseName string, resource MongoDatabaseResource, options *MongoDatabasesClientCreateOrUpdateOptions) (MongoDatabasesClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, mongoDatabaseName, resource, options) - if err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return MongoDatabasesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *MongoDatabasesClient) createOrUpdateCreateRequest(ctx context.Context, mongoDatabaseName string, resource MongoDatabaseResource, options *MongoDatabasesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/mongoDatabases/{mongoDatabaseName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if mongoDatabaseName == "" { - return nil, errors.New("parameter mongoDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *MongoDatabasesClient) createOrUpdateHandleResponse(resp *http.Response) (MongoDatabasesClientCreateOrUpdateResponse, error) { - result := MongoDatabasesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.MongoDatabaseResource); err != nil { - return MongoDatabasesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// BeginDelete - Deletes an existing MongoDatabaseResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the MongoDatabase link resource -// options - MongoDatabasesClientBeginDeleteOptions contains the optional parameters for the MongoDatabasesClient.BeginDelete -// method. -func (client *MongoDatabasesClient) BeginDelete(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientBeginDeleteOptions) (*runtime.Poller[MongoDatabasesClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, mongoDatabaseName, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MongoDatabasesClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[MongoDatabasesClientDeleteResponse](options.ResumeToken, client.pl, nil) - } -} - -// Delete - Deletes an existing MongoDatabaseResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -func (client *MongoDatabasesClient) deleteOperation(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientBeginDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, mongoDatabaseName, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *MongoDatabasesClient) deleteCreateRequest(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/mongoDatabases/{mongoDatabaseName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if mongoDatabaseName == "" { - return nil, errors.New("parameter mongoDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Retrieves information about a MongoDatabaseResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the MongoDatabase link resource -// options - MongoDatabasesClientGetOptions contains the optional parameters for the MongoDatabasesClient.Get method. -func (client *MongoDatabasesClient) Get(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientGetOptions) (MongoDatabasesClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, mongoDatabaseName, options) - if err != nil { - return MongoDatabasesClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return MongoDatabasesClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MongoDatabasesClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *MongoDatabasesClient) getCreateRequest(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/mongoDatabases/{mongoDatabaseName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if mongoDatabaseName == "" { - return nil, errors.New("parameter mongoDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *MongoDatabasesClient) getHandleResponse(resp *http.Response) (MongoDatabasesClientGetResponse, error) { - result := MongoDatabasesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.MongoDatabaseResource); err != nil { - return MongoDatabasesClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all MongoDatabaseResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - MongoDatabasesClientListByRootScopeOptions contains the optional parameters for the MongoDatabasesClient.ListByRootScope -// method. -func (client *MongoDatabasesClient) NewListByRootScopePager(options *MongoDatabasesClientListByRootScopeOptions) (*runtime.Pager[MongoDatabasesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[MongoDatabasesClientListByRootScopeResponse]{ - More: func(page MongoDatabasesClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *MongoDatabasesClientListByRootScopeResponse) (MongoDatabasesClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return MongoDatabasesClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return MongoDatabasesClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MongoDatabasesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *MongoDatabasesClient) listByRootScopeCreateRequest(ctx context.Context, options *MongoDatabasesClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/mongoDatabases" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *MongoDatabasesClient) listByRootScopeHandleResponse(resp *http.Response) (MongoDatabasesClientListByRootScopeResponse, error) { - result := MongoDatabasesClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.MongoDatabaseResourceListResult); err != nil { - return MongoDatabasesClientListByRootScopeResponse{}, err - } - return result, nil -} - -// ListSecrets - Lists secrets values for the specified MongoDatabase resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// mongoDatabaseName - The name of the MongoDatabase link resource -// options - MongoDatabasesClientListSecretsOptions contains the optional parameters for the MongoDatabasesClient.ListSecrets -// method. -func (client *MongoDatabasesClient) ListSecrets(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientListSecretsOptions) (MongoDatabasesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, mongoDatabaseName, options) - if err != nil { - return MongoDatabasesClientListSecretsResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return MongoDatabasesClientListSecretsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MongoDatabasesClientListSecretsResponse{}, runtime.NewResponseError(resp) - } - return client.listSecretsHandleResponse(resp) -} - -// listSecretsCreateRequest creates the ListSecrets request. -func (client *MongoDatabasesClient) listSecretsCreateRequest(ctx context.Context, mongoDatabaseName string, options *MongoDatabasesClientListSecretsOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/mongoDatabases/{mongoDatabaseName}/listSecrets" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if mongoDatabaseName == "" { - return nil, errors.New("parameter mongoDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{mongoDatabaseName}", url.PathEscape(mongoDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listSecretsHandleResponse handles the ListSecrets response. -func (client *MongoDatabasesClient) listSecretsHandleResponse(resp *http.Response) (MongoDatabasesClientListSecretsResponse, error) { - result := MongoDatabasesClientListSecretsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.MongoDatabaseListSecretsResult); err != nil { - return MongoDatabasesClientListSecretsResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_rabbitmqmessagequeues_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_rabbitmqmessagequeues_client.go deleted file mode 100644 index 00ff5aa150..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_rabbitmqmessagequeues_client.go +++ /dev/null @@ -1,323 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// RabbitMqMessageQueuesClient contains the methods for the RabbitMqMessageQueues group. -// Don't use this type directly, use NewRabbitMqMessageQueuesClient() instead. -type RabbitMqMessageQueuesClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewRabbitMqMessageQueuesClient creates a new instance of RabbitMqMessageQueuesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewRabbitMqMessageQueuesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RabbitMqMessageQueuesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &RabbitMqMessageQueuesClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a RabbitMQMessageQueueResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// rabbitMQMessageQueueName - The name of the RabbitMQMessageQueue link resource -// resource - Resource create parameters. -// options - RabbitMqMessageQueuesClientCreateOrUpdateOptions contains the optional parameters for the RabbitMqMessageQueuesClient.CreateOrUpdate -// method. -func (client *RabbitMqMessageQueuesClient) CreateOrUpdate(ctx context.Context, rabbitMQMessageQueueName string, resource RabbitMQMessageQueueResource, options *RabbitMqMessageQueuesClientCreateOrUpdateOptions) (RabbitMqMessageQueuesClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, rabbitMQMessageQueueName, resource, options) - if err != nil { - return RabbitMqMessageQueuesClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RabbitMqMessageQueuesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return RabbitMqMessageQueuesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *RabbitMqMessageQueuesClient) createOrUpdateCreateRequest(ctx context.Context, rabbitMQMessageQueueName string, resource RabbitMQMessageQueueResource, options *RabbitMqMessageQueuesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues/{rabbitMQMessageQueueName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if rabbitMQMessageQueueName == "" { - return nil, errors.New("parameter rabbitMQMessageQueueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{rabbitMQMessageQueueName}", url.PathEscape(rabbitMQMessageQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *RabbitMqMessageQueuesClient) createOrUpdateHandleResponse(resp *http.Response) (RabbitMqMessageQueuesClientCreateOrUpdateResponse, error) { - result := RabbitMqMessageQueuesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return RabbitMqMessageQueuesClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.RabbitMQMessageQueueResource); err != nil { - return RabbitMqMessageQueuesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing RabbitMQMessageQueueResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// rabbitMQMessageQueueName - The name of the RabbitMQMessageQueue link resource -// options - RabbitMqMessageQueuesClientDeleteOptions contains the optional parameters for the RabbitMqMessageQueuesClient.Delete -// method. -func (client *RabbitMqMessageQueuesClient) Delete(ctx context.Context, rabbitMQMessageQueueName string, options *RabbitMqMessageQueuesClientDeleteOptions) (RabbitMqMessageQueuesClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, rabbitMQMessageQueueName, options) - if err != nil { - return RabbitMqMessageQueuesClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RabbitMqMessageQueuesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return RabbitMqMessageQueuesClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return client.deleteHandleResponse(resp) -} - -// deleteCreateRequest creates the Delete request. -func (client *RabbitMqMessageQueuesClient) deleteCreateRequest(ctx context.Context, rabbitMQMessageQueueName string, options *RabbitMqMessageQueuesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues/{rabbitMQMessageQueueName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if rabbitMQMessageQueueName == "" { - return nil, errors.New("parameter rabbitMQMessageQueueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{rabbitMQMessageQueueName}", url.PathEscape(rabbitMQMessageQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteHandleResponse handles the Delete response. -func (client *RabbitMqMessageQueuesClient) deleteHandleResponse(resp *http.Response) (RabbitMqMessageQueuesClientDeleteResponse, error) { - result := RabbitMqMessageQueuesClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return RabbitMqMessageQueuesClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a RabbitMQMessageQueueResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// rabbitMQMessageQueueName - The name of the RabbitMQMessageQueue link resource -// options - RabbitMqMessageQueuesClientGetOptions contains the optional parameters for the RabbitMqMessageQueuesClient.Get -// method. -func (client *RabbitMqMessageQueuesClient) Get(ctx context.Context, rabbitMQMessageQueueName string, options *RabbitMqMessageQueuesClientGetOptions) (RabbitMqMessageQueuesClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, rabbitMQMessageQueueName, options) - if err != nil { - return RabbitMqMessageQueuesClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RabbitMqMessageQueuesClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RabbitMqMessageQueuesClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *RabbitMqMessageQueuesClient) getCreateRequest(ctx context.Context, rabbitMQMessageQueueName string, options *RabbitMqMessageQueuesClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues/{rabbitMQMessageQueueName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if rabbitMQMessageQueueName == "" { - return nil, errors.New("parameter rabbitMQMessageQueueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{rabbitMQMessageQueueName}", url.PathEscape(rabbitMQMessageQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *RabbitMqMessageQueuesClient) getHandleResponse(resp *http.Response) (RabbitMqMessageQueuesClientGetResponse, error) { - result := RabbitMqMessageQueuesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RabbitMQMessageQueueResource); err != nil { - return RabbitMqMessageQueuesClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all RabbitMQMessageQueueResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - RabbitMqMessageQueuesClientListByRootScopeOptions contains the optional parameters for the RabbitMqMessageQueuesClient.ListByRootScope -// method. -func (client *RabbitMqMessageQueuesClient) NewListByRootScopePager(options *RabbitMqMessageQueuesClientListByRootScopeOptions) (*runtime.Pager[RabbitMqMessageQueuesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[RabbitMqMessageQueuesClientListByRootScopeResponse]{ - More: func(page RabbitMqMessageQueuesClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *RabbitMqMessageQueuesClientListByRootScopeResponse) (RabbitMqMessageQueuesClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return RabbitMqMessageQueuesClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RabbitMqMessageQueuesClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RabbitMqMessageQueuesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *RabbitMqMessageQueuesClient) listByRootScopeCreateRequest(ctx context.Context, options *RabbitMqMessageQueuesClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *RabbitMqMessageQueuesClient) listByRootScopeHandleResponse(resp *http.Response) (RabbitMqMessageQueuesClientListByRootScopeResponse, error) { - result := RabbitMqMessageQueuesClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RabbitMQMessageQueueResourceListResult); err != nil { - return RabbitMqMessageQueuesClientListByRootScopeResponse{}, err - } - return result, nil -} - -// ListSecrets - Lists secrets values for the specified RabbitMQMessageQueue resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// rabbitMQMessageQueueName - The name of the RabbitMQMessageQueue link resource -// options - RabbitMqMessageQueuesClientListSecretsOptions contains the optional parameters for the RabbitMqMessageQueuesClient.ListSecrets -// method. -func (client *RabbitMqMessageQueuesClient) ListSecrets(ctx context.Context, rabbitMQMessageQueueName string, options *RabbitMqMessageQueuesClientListSecretsOptions) (RabbitMqMessageQueuesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, rabbitMQMessageQueueName, options) - if err != nil { - return RabbitMqMessageQueuesClientListSecretsResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RabbitMqMessageQueuesClientListSecretsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RabbitMqMessageQueuesClientListSecretsResponse{}, runtime.NewResponseError(resp) - } - return client.listSecretsHandleResponse(resp) -} - -// listSecretsCreateRequest creates the ListSecrets request. -func (client *RabbitMqMessageQueuesClient) listSecretsCreateRequest(ctx context.Context, rabbitMQMessageQueueName string, options *RabbitMqMessageQueuesClientListSecretsOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues/{rabbitMQMessageQueueName}/listSecrets" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if rabbitMQMessageQueueName == "" { - return nil, errors.New("parameter rabbitMQMessageQueueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{rabbitMQMessageQueueName}", url.PathEscape(rabbitMQMessageQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listSecretsHandleResponse handles the ListSecrets response. -func (client *RabbitMqMessageQueuesClient) listSecretsHandleResponse(resp *http.Response) (RabbitMqMessageQueuesClientListSecretsResponse, error) { - result := RabbitMqMessageQueuesClientListSecretsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RabbitMQListSecretsResult); err != nil { - return RabbitMqMessageQueuesClientListSecretsResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_rediscaches_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_rediscaches_client.go deleted file mode 100644 index 8f4785fe13..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_rediscaches_client.go +++ /dev/null @@ -1,320 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// RedisCachesClient contains the methods for the RedisCaches group. -// Don't use this type directly, use NewRedisCachesClient() instead. -type RedisCachesClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewRedisCachesClient creates a new instance of RedisCachesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewRedisCachesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RedisCachesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &RedisCachesClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a RedisCacheResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the RedisCache link resource -// resource - Resource create parameters. -// options - RedisCachesClientCreateOrUpdateOptions contains the optional parameters for the RedisCachesClient.CreateOrUpdate -// method. -func (client *RedisCachesClient) CreateOrUpdate(ctx context.Context, redisCacheName string, resource RedisCacheResource, options *RedisCachesClientCreateOrUpdateOptions) (RedisCachesClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, redisCacheName, resource, options) - if err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return RedisCachesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *RedisCachesClient) createOrUpdateCreateRequest(ctx context.Context, redisCacheName string, resource RedisCacheResource, options *RedisCachesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/redisCaches/{redisCacheName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if redisCacheName == "" { - return nil, errors.New("parameter redisCacheName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *RedisCachesClient) createOrUpdateHandleResponse(resp *http.Response) (RedisCachesClientCreateOrUpdateResponse, error) { - result := RedisCachesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.RedisCacheResource); err != nil { - return RedisCachesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing RedisCacheResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the RedisCache link resource -// options - RedisCachesClientDeleteOptions contains the optional parameters for the RedisCachesClient.Delete method. -func (client *RedisCachesClient) Delete(ctx context.Context, redisCacheName string, options *RedisCachesClientDeleteOptions) (RedisCachesClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, redisCacheName, options) - if err != nil { - return RedisCachesClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RedisCachesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return RedisCachesClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return client.deleteHandleResponse(resp) -} - -// deleteCreateRequest creates the Delete request. -func (client *RedisCachesClient) deleteCreateRequest(ctx context.Context, redisCacheName string, options *RedisCachesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/redisCaches/{redisCacheName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if redisCacheName == "" { - return nil, errors.New("parameter redisCacheName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteHandleResponse handles the Delete response. -func (client *RedisCachesClient) deleteHandleResponse(resp *http.Response) (RedisCachesClientDeleteResponse, error) { - result := RedisCachesClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return RedisCachesClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a RedisCacheResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the RedisCache link resource -// options - RedisCachesClientGetOptions contains the optional parameters for the RedisCachesClient.Get method. -func (client *RedisCachesClient) Get(ctx context.Context, redisCacheName string, options *RedisCachesClientGetOptions) (RedisCachesClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, redisCacheName, options) - if err != nil { - return RedisCachesClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RedisCachesClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RedisCachesClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *RedisCachesClient) getCreateRequest(ctx context.Context, redisCacheName string, options *RedisCachesClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/redisCaches/{redisCacheName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if redisCacheName == "" { - return nil, errors.New("parameter redisCacheName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *RedisCachesClient) getHandleResponse(resp *http.Response) (RedisCachesClientGetResponse, error) { - result := RedisCachesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RedisCacheResource); err != nil { - return RedisCachesClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all RedisCacheResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - RedisCachesClientListByRootScopeOptions contains the optional parameters for the RedisCachesClient.ListByRootScope -// method. -func (client *RedisCachesClient) NewListByRootScopePager(options *RedisCachesClientListByRootScopeOptions) (*runtime.Pager[RedisCachesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[RedisCachesClientListByRootScopeResponse]{ - More: func(page RedisCachesClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *RedisCachesClientListByRootScopeResponse) (RedisCachesClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return RedisCachesClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RedisCachesClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RedisCachesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *RedisCachesClient) listByRootScopeCreateRequest(ctx context.Context, options *RedisCachesClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/redisCaches" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *RedisCachesClient) listByRootScopeHandleResponse(resp *http.Response) (RedisCachesClientListByRootScopeResponse, error) { - result := RedisCachesClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RedisCacheResourceListResult); err != nil { - return RedisCachesClientListByRootScopeResponse{}, err - } - return result, nil -} - -// ListSecrets - Lists secrets values for the specified RedisCache resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// redisCacheName - The name of the RedisCache link resource -// options - RedisCachesClientListSecretsOptions contains the optional parameters for the RedisCachesClient.ListSecrets method. -func (client *RedisCachesClient) ListSecrets(ctx context.Context, redisCacheName string, options *RedisCachesClientListSecretsOptions) (RedisCachesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, redisCacheName, options) - if err != nil { - return RedisCachesClientListSecretsResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return RedisCachesClientListSecretsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RedisCachesClientListSecretsResponse{}, runtime.NewResponseError(resp) - } - return client.listSecretsHandleResponse(resp) -} - -// listSecretsCreateRequest creates the ListSecrets request. -func (client *RedisCachesClient) listSecretsCreateRequest(ctx context.Context, redisCacheName string, options *RedisCachesClientListSecretsOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/redisCaches/{redisCacheName}/listSecrets" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if redisCacheName == "" { - return nil, errors.New("parameter redisCacheName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{redisCacheName}", url.PathEscape(redisCacheName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listSecretsHandleResponse handles the ListSecrets response. -func (client *RedisCachesClient) listSecretsHandleResponse(resp *http.Response) (RedisCachesClientListSecretsResponse, error) { - result := RedisCachesClientListSecretsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.RedisCacheListSecretsResult); err != nil { - return RedisCachesClientListSecretsResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_response_types.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_response_types.go deleted file mode 100644 index 85821cf6f9..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_response_types.go +++ /dev/null @@ -1,219 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -// DaprPubSubBrokerClientCreateOrUpdateResponse contains the response from method DaprPubSubBrokerClient.CreateOrUpdate. -type DaprPubSubBrokerClientCreateOrUpdateResponse struct { - DaprPubSubBrokerResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// DaprPubSubBrokerClientDeleteResponse contains the response from method DaprPubSubBrokerClient.Delete. -type DaprPubSubBrokerClientDeleteResponse struct { - // placeholder for future response values -} - -// DaprPubSubBrokerClientGetResponse contains the response from method DaprPubSubBrokerClient.Get. -type DaprPubSubBrokerClientGetResponse struct { - DaprPubSubBrokerResource -} - -// DaprPubSubBrokerClientListByRootScopeResponse contains the response from method DaprPubSubBrokerClient.ListByRootScope. -type DaprPubSubBrokerClientListByRootScopeResponse struct { - DaprPubSubBrokerResourceListResult -} - -// DaprSecretStoreClientCreateOrUpdateResponse contains the response from method DaprSecretStoreClient.CreateOrUpdate. -type DaprSecretStoreClientCreateOrUpdateResponse struct { - DaprSecretStoreResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// DaprSecretStoreClientDeleteResponse contains the response from method DaprSecretStoreClient.Delete. -type DaprSecretStoreClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// DaprSecretStoreClientGetResponse contains the response from method DaprSecretStoreClient.Get. -type DaprSecretStoreClientGetResponse struct { - DaprSecretStoreResource -} - -// DaprSecretStoreClientListByRootScopeResponse contains the response from method DaprSecretStoreClient.ListByRootScope. -type DaprSecretStoreClientListByRootScopeResponse struct { - DaprSecretStoreResourceListResult -} - -// DaprStateStoreClientCreateOrUpdateResponse contains the response from method DaprStateStoreClient.CreateOrUpdate. -type DaprStateStoreClientCreateOrUpdateResponse struct { - DaprStateStoreResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// DaprStateStoreClientDeleteResponse contains the response from method DaprStateStoreClient.Delete. -type DaprStateStoreClientDeleteResponse struct { - // placeholder for future response values -} - -// DaprStateStoreClientGetResponse contains the response from method DaprStateStoreClient.Get. -type DaprStateStoreClientGetResponse struct { - DaprStateStoreResource -} - -// DaprStateStoreClientListByRootScopeResponse contains the response from method DaprStateStoreClient.ListByRootScope. -type DaprStateStoreClientListByRootScopeResponse struct { - DaprStateStoreResourceListResult -} - -// ExtendersClientCreateOrUpdateResponse contains the response from method ExtendersClient.CreateOrUpdate. -type ExtendersClientCreateOrUpdateResponse struct { - ExtenderResource -} - -// ExtendersClientDeleteResponse contains the response from method ExtendersClient.Delete. -type ExtendersClientDeleteResponse struct { - // placeholder for future response values -} - -// ExtendersClientGetResponse contains the response from method ExtendersClient.Get. -type ExtendersClientGetResponse struct { - ExtenderResource -} - -// ExtendersClientListByRootScopeResponse contains the response from method ExtendersClient.ListByRootScope. -type ExtendersClientListByRootScopeResponse struct { - ExtenderList -} - -// ExtendersClientListSecretsResponse contains the response from method ExtendersClient.ListSecrets. -type ExtendersClientListSecretsResponse struct { - // The secret values for the given Extender resource - Value map[string]interface{} -} - -// MongoDatabasesClientCreateOrUpdateResponse contains the response from method MongoDatabasesClient.CreateOrUpdate. -type MongoDatabasesClientCreateOrUpdateResponse struct { - MongoDatabaseResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// MongoDatabasesClientDeleteResponse contains the response from method MongoDatabasesClient.Delete. -type MongoDatabasesClientDeleteResponse struct { - // placeholder for future response values -} - -// MongoDatabasesClientGetResponse contains the response from method MongoDatabasesClient.Get. -type MongoDatabasesClientGetResponse struct { - MongoDatabaseResource -} - -// MongoDatabasesClientListByRootScopeResponse contains the response from method MongoDatabasesClient.ListByRootScope. -type MongoDatabasesClientListByRootScopeResponse struct { - MongoDatabaseResourceListResult -} - -// MongoDatabasesClientListSecretsResponse contains the response from method MongoDatabasesClient.ListSecrets. -type MongoDatabasesClientListSecretsResponse struct { - MongoDatabaseListSecretsResult -} - -// OperationsClientListResponse contains the response from method OperationsClient.List. -type OperationsClientListResponse struct { - OperationListResult -} - -// RabbitMqMessageQueuesClientCreateOrUpdateResponse contains the response from method RabbitMqMessageQueuesClient.CreateOrUpdate. -type RabbitMqMessageQueuesClientCreateOrUpdateResponse struct { - RabbitMQMessageQueueResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// RabbitMqMessageQueuesClientDeleteResponse contains the response from method RabbitMqMessageQueuesClient.Delete. -type RabbitMqMessageQueuesClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// RabbitMqMessageQueuesClientGetResponse contains the response from method RabbitMqMessageQueuesClient.Get. -type RabbitMqMessageQueuesClientGetResponse struct { - RabbitMQMessageQueueResource -} - -// RabbitMqMessageQueuesClientListByRootScopeResponse contains the response from method RabbitMqMessageQueuesClient.ListByRootScope. -type RabbitMqMessageQueuesClientListByRootScopeResponse struct { - RabbitMQMessageQueueResourceListResult -} - -// RabbitMqMessageQueuesClientListSecretsResponse contains the response from method RabbitMqMessageQueuesClient.ListSecrets. -type RabbitMqMessageQueuesClientListSecretsResponse struct { - RabbitMQListSecretsResult -} - -// RedisCachesClientCreateOrUpdateResponse contains the response from method RedisCachesClient.CreateOrUpdate. -type RedisCachesClientCreateOrUpdateResponse struct { - RedisCacheResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// RedisCachesClientDeleteResponse contains the response from method RedisCachesClient.Delete. -type RedisCachesClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// RedisCachesClientGetResponse contains the response from method RedisCachesClient.Get. -type RedisCachesClientGetResponse struct { - RedisCacheResource -} - -// RedisCachesClientListByRootScopeResponse contains the response from method RedisCachesClient.ListByRootScope. -type RedisCachesClientListByRootScopeResponse struct { - RedisCacheResourceListResult -} - -// RedisCachesClientListSecretsResponse contains the response from method RedisCachesClient.ListSecrets. -type RedisCachesClientListSecretsResponse struct { - RedisCacheListSecretsResult -} - -// SQLDatabasesClientCreateOrUpdateResponse contains the response from method SQLDatabasesClient.CreateOrUpdate. -type SQLDatabasesClientCreateOrUpdateResponse struct { - SQLDatabaseResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// SQLDatabasesClientDeleteResponse contains the response from method SQLDatabasesClient.Delete. -type SQLDatabasesClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 -} - -// SQLDatabasesClientGetResponse contains the response from method SQLDatabasesClient.Get. -type SQLDatabasesClientGetResponse struct { - SQLDatabaseResource -} - -// SQLDatabasesClientListByRootScopeResponse contains the response from method SQLDatabasesClient.ListByRootScope. -type SQLDatabasesClientListByRootScopeResponse struct { - SQLDatabaseResourceListResult -} - -// SQLDatabasesClientListSecretsResponse contains the response from method SQLDatabasesClient.ListSecrets. -type SQLDatabasesClientListSecretsResponse struct { - SQLDatabaseListSecretsResult -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_sqldatabases_client.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_sqldatabases_client.go deleted file mode 100644 index d69b970ac4..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_sqldatabases_client.go +++ /dev/null @@ -1,321 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// SQLDatabasesClient contains the methods for the SQLDatabases group. -// Don't use this type directly, use NewSQLDatabasesClient() instead. -type SQLDatabasesClient struct { - host string - rootScope string - pl runtime.Pipeline -} - -// NewSQLDatabasesClient creates a new instance of SQLDatabasesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewSQLDatabasesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLDatabasesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &SQLDatabasesClient{ - rootScope: rootScope, - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a SqlDatabaseResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SqlDatabase link resource -// resource - Resource create parameters. -// options - SQLDatabasesClientCreateOrUpdateOptions contains the optional parameters for the SQLDatabasesClient.CreateOrUpdate -// method. -func (client *SQLDatabasesClient) CreateOrUpdate(ctx context.Context, sqlDatabaseName string, resource SQLDatabaseResource, options *SQLDatabasesClientCreateOrUpdateOptions) (SQLDatabasesClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, sqlDatabaseName, resource, options) - if err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return SQLDatabasesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *SQLDatabasesClient) createOrUpdateCreateRequest(ctx context.Context, sqlDatabaseName string, resource SQLDatabaseResource, options *SQLDatabasesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/sqlDatabases/{sqlDatabaseName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if sqlDatabaseName == "" { - return nil, errors.New("parameter sqlDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *SQLDatabasesClient) createOrUpdateHandleResponse(resp *http.Response) (SQLDatabasesClientCreateOrUpdateResponse, error) { - result := SQLDatabasesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.SQLDatabaseResource); err != nil { - return SQLDatabasesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing SqlDatabaseResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SqlDatabase link resource -// options - SQLDatabasesClientDeleteOptions contains the optional parameters for the SQLDatabasesClient.Delete method. -func (client *SQLDatabasesClient) Delete(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientDeleteOptions) (SQLDatabasesClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, sqlDatabaseName, options) - if err != nil { - return SQLDatabasesClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return SQLDatabasesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return SQLDatabasesClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return client.deleteHandleResponse(resp) -} - -// deleteCreateRequest creates the Delete request. -func (client *SQLDatabasesClient) deleteCreateRequest(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/sqlDatabases/{sqlDatabaseName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if sqlDatabaseName == "" { - return nil, errors.New("parameter sqlDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteHandleResponse handles the Delete response. -func (client *SQLDatabasesClient) deleteHandleResponse(resp *http.Response) (SQLDatabasesClientDeleteResponse, error) { - result := SQLDatabasesClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return SQLDatabasesClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a SqlDatabaseResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SqlDatabase link resource -// options - SQLDatabasesClientGetOptions contains the optional parameters for the SQLDatabasesClient.Get method. -func (client *SQLDatabasesClient) Get(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientGetOptions) (SQLDatabasesClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, sqlDatabaseName, options) - if err != nil { - return SQLDatabasesClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return SQLDatabasesClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SQLDatabasesClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *SQLDatabasesClient) getCreateRequest(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientGetOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/sqlDatabases/{sqlDatabaseName}" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if sqlDatabaseName == "" { - return nil, errors.New("parameter sqlDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *SQLDatabasesClient) getHandleResponse(resp *http.Response) (SQLDatabasesClientGetResponse, error) { - result := SQLDatabasesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SQLDatabaseResource); err != nil { - return SQLDatabasesClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all SqlDatabaseResources in the given root scope -// Generated from API version 2022-03-15-privatepreview -// options - SQLDatabasesClientListByRootScopeOptions contains the optional parameters for the SQLDatabasesClient.ListByRootScope -// method. -func (client *SQLDatabasesClient) NewListByRootScopePager(options *SQLDatabasesClientListByRootScopeOptions) (*runtime.Pager[SQLDatabasesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[SQLDatabasesClientListByRootScopeResponse]{ - More: func(page SQLDatabasesClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *SQLDatabasesClientListByRootScopeResponse) (SQLDatabasesClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return SQLDatabasesClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return SQLDatabasesClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SQLDatabasesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *SQLDatabasesClient) listByRootScopeCreateRequest(ctx context.Context, options *SQLDatabasesClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/sqlDatabases" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *SQLDatabasesClient) listByRootScopeHandleResponse(resp *http.Response) (SQLDatabasesClientListByRootScopeResponse, error) { - result := SQLDatabasesClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SQLDatabaseResourceListResult); err != nil { - return SQLDatabasesClientListByRootScopeResponse{}, err - } - return result, nil -} - -// ListSecrets - Lists secrets values for the specified SqlDatabase resource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-15-privatepreview -// sqlDatabaseName - The name of the SqlDatabase link resource -// options - SQLDatabasesClientListSecretsOptions contains the optional parameters for the SQLDatabasesClient.ListSecrets -// method. -func (client *SQLDatabasesClient) ListSecrets(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientListSecretsOptions) (SQLDatabasesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, sqlDatabaseName, options) - if err != nil { - return SQLDatabasesClientListSecretsResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return SQLDatabasesClientListSecretsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SQLDatabasesClientListSecretsResponse{}, runtime.NewResponseError(resp) - } - return client.listSecretsHandleResponse(resp) -} - -// listSecretsCreateRequest creates the ListSecrets request. -func (client *SQLDatabasesClient) listSecretsCreateRequest(ctx context.Context, sqlDatabaseName string, options *SQLDatabasesClientListSecretsOptions) (*policy.Request, error) { - urlPath := "/{rootScope}/providers/Applications.Link/sqlDatabases/{sqlDatabaseName}/listSecrets" - urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - if sqlDatabaseName == "" { - return nil, errors.New("parameter sqlDatabaseName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{sqlDatabaseName}", url.PathEscape(sqlDatabaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-15-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listSecretsHandleResponse handles the ListSecrets response. -func (client *SQLDatabasesClient) listSecretsHandleResponse(resp *http.Response) (SQLDatabasesClientListSecretsResponse, error) { - result := SQLDatabasesClientListSecretsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.SQLDatabaseListSecretsResult); err != nil { - return SQLDatabasesClientListSecretsResponse{}, err - } - return result, nil -} - diff --git a/pkg/linkrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go b/pkg/linkrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go deleted file mode 100644 index cea28fe8b6..0000000000 --- a/pkg/linkrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go +++ /dev/null @@ -1,91 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220315privatepreview - - - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - - - -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) - -type timeRFC3339 time.Time - -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t timeRFC3339) MarshalText() (text []byte, err error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON - if tzOffsetRegex.Match(data) { - layout = rfc3339JSON - } - return t.Parse(layout, string(data)) -} - -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *timeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) - return err -} - - -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*timeRFC3339)(t) -} - -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux timeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/pkg/linkrp/backend/controller/createorupdateresource.go b/pkg/linkrp/backend/controller/createorupdateresource.go deleted file mode 100644 index aa96741971..0000000000 --- a/pkg/linkrp/backend/controller/createorupdateresource.go +++ /dev/null @@ -1,165 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "context" - "errors" - "fmt" - - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/configloader" - "github.com/project-radius/radius/pkg/recipes/engine" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" -) - -// CreateOrUpdateResource is the async operation controller to create or update Applications.Link resources. -type CreateOrUpdateResource[P interface { - *T - rpv1.RadiusResourceModel -}, T any] struct { - ctrl.BaseController - processor processors.ResourceProcessor[P, T] - engine engine.Engine - client processors.ResourceClient - configurationLoader configloader.ConfigurationLoader -} - -// NewCreateOrUpdateResource creates a new controller for creating or updating a resource with the given processor, engine, -// client, configurationLoader and options. The processor function will be called to process updates to the resource. -func NewCreateOrUpdateResource[P interface { - *T - rpv1.RadiusResourceModel -}, T any](processor processors.ResourceProcessor[P, T], eng engine.Engine, client processors.ResourceClient, configurationLoader configloader.ConfigurationLoader, opts ctrl.Options) (ctrl.Controller, error) { - return &CreateOrUpdateResource[P, T]{ctrl.NewBaseAsyncController(opts), processor, eng, client, configurationLoader}, nil -} - -// Run retrieves an existing resource, executes a recipe if needed, loads runtime configuration, -// processes the resource, cleans up any obsolete output resources, and saves the updated resource. -func (c *CreateOrUpdateResource[P, T]) Run(ctx context.Context, req *ctrl.Request) (ctrl.Result, error) { - obj, err := c.StorageClient().Get(ctx, req.ResourceID) - if errors.Is(&store.ErrNotFound{ID: req.ResourceID}, err) { - return ctrl.Result{}, err - } else if err != nil { - return ctrl.Result{}, err - } - - data := P(new(T)) - if err = obj.As(data); err != nil { - return ctrl.Result{}, err - } - - // Clone existing output resources so we can diff them later. - previousOutputResources := c.copyOutputResources(data) - - // Now we're ready to process recipes (if needed). - recipeOutput, err := c.executeRecipeIfNeeded(ctx, data) - if err != nil { - return ctrl.Result{}, err - } - - // Load details about the runtime for the processor to access. - runtimeConfiguration, err := c.loadRuntimeConfiguration(ctx, data.ResourceMetadata().Environment, data.ResourceMetadata().Application, data.GetBaseResource().ID) - if err != nil { - return ctrl.Result{}, err - } - - // Now we're ready to process the resource. This will handle the updates to any user-visible state. - err = c.processor.Process(ctx, data, processors.Options{RecipeOutput: recipeOutput, RuntimeConfiguration: *runtimeConfiguration}) - if err != nil { - return ctrl.Result{}, err - } - - // Now we need to clean up any obsolete output resources. - diff := rpv1.GetGCOutputResources(data.OutputResources(), previousOutputResources) - err = c.garbageCollectResources(ctx, req.ResourceID, diff) - if err != nil { - return ctrl.Result{}, err - } - - update := &store.Object{ - Metadata: store.Metadata{ - ID: req.ResourceID, - }, - Data: data, - } - err = c.StorageClient().Save(ctx, update, store.WithETag(obj.ETag)) - if err != nil { - return ctrl.Result{}, err - } - - return ctrl.Result{}, err -} - -func (c *CreateOrUpdateResource[P, T]) copyOutputResources(data P) []rpv1.OutputResource { - previousOutputResources := make([]rpv1.OutputResource, len(data.OutputResources())) - copy(previousOutputResources, data.OutputResources()) - return previousOutputResources -} - -func (c *CreateOrUpdateResource[P, T]) executeRecipeIfNeeded(ctx context.Context, data P) (*recipes.RecipeOutput, error) { - // 'any' is required here to convert to an interface type, only then can we use a type assertion. - recipeDataModel, supportsRecipes := any(data).(datamodel.RecipeDataModel) - if !supportsRecipes { - return nil, nil - } - - input := recipeDataModel.Recipe() - if input == nil { - return nil, nil - } - request := recipes.ResourceMetadata{ - Name: input.Name, - Parameters: input.Parameters, - EnvironmentID: data.ResourceMetadata().Environment, - ApplicationID: data.ResourceMetadata().Application, - ResourceID: data.GetBaseResource().ID, - } - - return c.engine.Execute(ctx, request) -} - -func (c *CreateOrUpdateResource[P, T]) loadRuntimeConfiguration(ctx context.Context, environmentID string, applicationID string, resourceID string) (*recipes.RuntimeConfiguration, error) { - metadata := recipes.ResourceMetadata{EnvironmentID: environmentID, ApplicationID: applicationID, ResourceID: resourceID} - config, err := c.configurationLoader.LoadConfiguration(ctx, metadata) - if err != nil { - return nil, err - } - - return &config.Runtime, nil -} - -func (c *CreateOrUpdateResource[P, T]) garbageCollectResources(ctx context.Context, id string, diff []rpv1.OutputResource) error { - logger := ucplog.FromContextOrDiscard(ctx) - for _, resource := range diff { - id := resource.Identity.GetID() - logger.Info(fmt.Sprintf("Deleting output resource: %q", id), ucplog.LogFieldTargetResourceID, id) - err := c.client.Delete(ctx, id, resourcemodel.APIVersionUnknown) - if err != nil { - return err - } - logger.Info(fmt.Sprintf("Deleted output resource: %q", id), ucplog.LogFieldTargetResourceID, id) - } - - return nil -} diff --git a/pkg/linkrp/backend/controller/createorupdateresource_test.go b/pkg/linkrp/backend/controller/createorupdateresource_test.go deleted file mode 100644 index 8e28e536df..0000000000 --- a/pkg/linkrp/backend/controller/createorupdateresource_test.go +++ /dev/null @@ -1,456 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "context" - "encoding/json" - "errors" - "testing" - - "github.com/golang/mock/gomock" - "github.com/google/uuid" - "github.com/mitchellh/mapstructure" - "github.com/stretchr/testify/require" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/configloader" - "github.com/project-radius/radius/pkg/recipes/engine" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/store" -) - -const ( - TestResourceType = "Applications.Test/testResources" - TestEnvironmentID = "/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env" - TestApplicationID = "/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app" - TestResourceID = "/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Test/testResources/tr" -) - -type TestResource struct { - v1.BaseResource - - // LinkMetadata represents internal DataModel properties common to all link types. - datamodel.LinkMetadata - - // Properties is the properties of the resource. - Properties TestResourceProperties `json:"properties"` -} - -// ApplyDeploymentOutput updates the status of the TestResource instance with the DeploymentOutput values. -func (r *TestResource) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - r.ComputedValues = do.ComputedValues - r.SecretValues = do.SecretValues - - return nil -} - -// OutputResources returns the OutputResources from the Status field of the Properties field of the TestResource instance. -func (r *TestResource) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the TestResource instance. -func (r *TestResource) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// Recipe returns a pointer to the LinkRecipe stored in the Properties field of the TestResource struct. -func (t *TestResource) Recipe() *linkrp.LinkRecipe { - return &t.Properties.Recipe -} - -type TestResourceProperties struct { - rpv1.BasicResourceProperties - IsProcessed bool `json:"isProcessed"` - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` -} - -type SuccessProcessor struct { -} - -// Process sets a computed value and adds an output resource to the TestResource object, and returns no error. -func (p *SuccessProcessor) Process(ctx context.Context, data *TestResource, options processors.Options) error { - // Simulate setting a computed value and adding an output resource. - data.Properties.IsProcessed = true - data.Properties.Status.OutputResources = []rpv1.OutputResource{ - newOutputResource, - } - return nil -} - -var successProcessorReference = processors.ResourceProcessor[*TestResource, TestResource](&SuccessProcessor{}) - -type ErrorProcessor struct { -} - -// Process always returns a processorErr. -func (p *ErrorProcessor) Process(ctx context.Context, data *TestResource, options processors.Options) error { - return processorErr -} - -var errorProcessorReference = processors.ResourceProcessor[*TestResource, TestResource](&ErrorProcessor{}) -var processorErr = errors.New("processor error") -var configurationErr = errors.New("configuration error") - -var oldOutputResourceResourceID = "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1" -var oldOutputResource = rpv1.OutputResource{ - Identity: resourcemodel.NewARMIdentity(&resourcemodel.ResourceType{ - Type: "System.Test/testResources", - Provider: resourcemodel.ProviderAzure, - }, oldOutputResourceResourceID, "2022-01-01"), -} - -var newOutputResourceResourceID = "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test2" -var newOutputResource = rpv1.OutputResource{ - Identity: resourcemodel.NewARMIdentity(&resourcemodel.ResourceType{ - Type: "System.Test/testResources", - Provider: resourcemodel.ProviderAzure, - }, newOutputResourceResourceID, "2022-01-01"), -} - -func TestCreateOrUpdateResource_Run(t *testing.T) { - setupTest := func(tb testing.TB) (*store.MockStorageClient, *engine.MockEngine, *processors.MockResourceClient, *configloader.MockConfigurationLoader) { - mctrl := gomock.NewController(t) - - msc := store.NewMockStorageClient(mctrl) - eng := engine.NewMockEngine(mctrl) - cfg := configloader.NewMockConfigurationLoader(mctrl) - client := processors.NewMockResourceClient(mctrl) - return msc, eng, client, cfg - } - - cases := []struct { - description string - factory func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) - getErr error - conversionFailure bool - recipeErr error - runtimeConfigurationErr error - processorErr error - resourceClientErr error - saveErr error - expectedErr error - }{ - { - "get-not-found", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(errorProcessorReference, eng, client, cfg, options) - }, - &store.ErrNotFound{ID: TestResourceID}, - false, - nil, - nil, - nil, - nil, - nil, - &store.ErrNotFound{ID: TestResourceID}, - }, - { - "get-error", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(errorProcessorReference, eng, client, cfg, options) - }, - &store.ErrInvalid{}, - false, - nil, - nil, - nil, - nil, - nil, - &store.ErrInvalid{}, - }, - { - "conversion-failure", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(errorProcessorReference, eng, client, cfg, options) - }, - nil, - true, - nil, - nil, - nil, - nil, - nil, - &mapstructure.Error{Errors: []string{"'type' expected type 'string', got unconvertible type 'int', value: '3'"}}, - }, - { - "recipe-err", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(errorProcessorReference, eng, client, cfg, options) - }, - nil, - false, - &recipes.ErrRecipeNotFound{}, - nil, - nil, - nil, - nil, - &recipes.ErrRecipeNotFound{}, - }, - { - "runtime-configuration-err", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(errorProcessorReference, eng, client, cfg, options) - }, - nil, - false, - nil, - configurationErr, - nil, - nil, - nil, - configurationErr, - }, - { - "processor-err", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(errorProcessorReference, eng, client, cfg, options) - }, - nil, - false, - nil, - nil, - processorErr, - nil, - nil, - processorErr, - }, - { - "resourceclient-err", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(successProcessorReference, eng, client, cfg, options) - }, - nil, - false, - nil, - nil, - nil, - errors.New("resource client failed"), - nil, - errors.New("resource client failed"), - }, - { - "save-err", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(successProcessorReference, eng, client, cfg, options) - }, - nil, - false, - nil, - nil, - nil, - nil, - errors.New("resource save failed"), - errors.New("resource save failed"), - }, - { - "success", - func(eng engine.Engine, client processors.ResourceClient, cfg configloader.ConfigurationLoader, options ctrl.Options) (ctrl.Controller, error) { - return NewCreateOrUpdateResource(successProcessorReference, eng, client, cfg, options) - }, - nil, - false, - nil, - nil, - nil, - nil, - nil, - nil, - }, - } - - for _, tt := range cases { - t.Run(tt.description, func(t *testing.T) { - msc, eng, client, cfg := setupTest(t) - - req := &ctrl.Request{ - OperationID: uuid.New(), - OperationType: "APPLICATIONS.TEST/TESTRESOURCES|PUT", // Operation does not affect the behavior of the controller. - ResourceID: TestResourceID, - CorrelationID: uuid.NewString(), - OperationTimeout: &ctrl.DefaultAsyncOperationTimeout, - } - - // Set up an output resource so we can cover resource deletion. - status := rpv1.ResourceStatus{ - OutputResources: []rpv1.OutputResource{ - oldOutputResource, - }, - } - sb, err := json.Marshal(&status) - require.NoError(t, err) - - sm := map[string]interface{}{} - err = json.Unmarshal(sb, &sm) - require.NoError(t, err) - - data := map[string]any{ - "name": "tr", - "type": "Applications.Test/testResources", - "id": TestResourceID, - "location": v1.LocationGlobal, - "properties": map[string]any{ - "application": TestApplicationID, - "environment": TestEnvironmentID, - "provisioningState": "Accepted", - "status": sm, - "recipe": map[string]any{ - "name": "test-recipe", - "parameters": map[string]any{ - "p1": "v1", - }, - }, - }, - } - - // Note: this test walks through the mock setup in same order as the controller - // performs these steps. That makes it easier to reason about what to configure - // for the desired test case. - // - // This flag is used to track whether the "current" test will reach the current - // control flow. - stillPassing := true - - if stillPassing && tt.getErr != nil { - stillPassing = false - msc.EXPECT(). - Get(gomock.Any(), TestResourceID). - Return(&store.Object{Data: nil}, tt.getErr). - Times(1) - } else if stillPassing { - msc.EXPECT(). - Get(gomock.Any(), TestResourceID). - Return(&store.Object{Data: data}, nil). - Times(1) - } - - if tt.conversionFailure { - stillPassing = false - data["type"] = 3 // This won't convert to our data model. - } - - recipeMetadata := recipes.ResourceMetadata{ - Name: "test-recipe", - EnvironmentID: TestEnvironmentID, - ApplicationID: TestApplicationID, - ResourceID: TestResourceID, - Parameters: map[string]any{ - "p1": "v1", - }, - } - - if stillPassing && tt.recipeErr != nil { - stillPassing = false - eng.EXPECT(). - Execute(gomock.Any(), recipeMetadata). - Return(&recipes.RecipeOutput{}, tt.recipeErr). - Times(1) - } else if stillPassing { - eng.EXPECT(). - Execute(gomock.Any(), recipeMetadata). - Return(&recipes.RecipeOutput{}, nil). - Times(1) - } - - if stillPassing && tt.runtimeConfigurationErr != nil { - stillPassing = false - cfg.EXPECT(). - LoadConfiguration(gomock.Any(), recipes.ResourceMetadata{ - EnvironmentID: TestEnvironmentID, - ApplicationID: TestApplicationID, - ResourceID: TestResourceID, - }). - Return(nil, tt.runtimeConfigurationErr). - Times(1) - } else if stillPassing { - configuration := &recipes.Configuration{ - Runtime: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - EnvironmentNamespace: "test-env-namespace", - }, - }, - } - cfg.EXPECT(). - LoadConfiguration(gomock.Any(), recipes.ResourceMetadata{ - EnvironmentID: TestEnvironmentID, - ApplicationID: TestApplicationID, - ResourceID: TestResourceID, - }). - Return(configuration, nil). - Times(1) - } - - // No mock for the processor... - if stillPassing && tt.processorErr != nil { - stillPassing = false - } - - if stillPassing && tt.resourceClientErr != nil { - stillPassing = false - client.EXPECT(). - Delete(gomock.Any(), oldOutputResourceResourceID, resourcemodel.APIVersionUnknown). - Return(tt.resourceClientErr). - Times(1) - } else if stillPassing { - client.EXPECT(). - Delete(gomock.Any(), oldOutputResourceResourceID, resourcemodel.APIVersionUnknown). - Return(nil). - Times(1) - } - - if stillPassing && tt.saveErr != nil { - stillPassing = false - msc.EXPECT(). - Save(gomock.Any(), gomock.Any(), gomock.Any()). - Return(tt.saveErr). - Times(1) - } else if stillPassing && tt.resourceClientErr == nil { - msc.EXPECT(). - Save(gomock.Any(), gomock.Any(), gomock.Any()). - Return(nil). - Times(1) - } - - opts := ctrl.Options{ - StorageClient: msc, - } - - genCtrl, err := tt.factory(eng, client, cfg, opts) - require.NoError(t, err) - - res, err := genCtrl.Run(context.Background(), req) - if tt.expectedErr != nil { - require.False(t, stillPassing) - require.Error(t, err) - require.Equal(t, tt.expectedErr, err) - } else { - require.True(t, stillPassing) - require.NoError(t, err) - require.Equal(t, ctrl.Result{}, res) - } - }) - } -} diff --git a/pkg/linkrp/backend/controller/deleteresource.go b/pkg/linkrp/backend/controller/deleteresource.go deleted file mode 100644 index 55d11a17e6..0000000000 --- a/pkg/linkrp/backend/controller/deleteresource.go +++ /dev/null @@ -1,138 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "context" - "fmt" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - dapr_dm "github.com/project-radius/radius/pkg/daprrp/datamodel" - ds_dm "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - msg_dm "github.com/project-radius/radius/pkg/messagingrp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/engine" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" -) - -var _ ctrl.Controller = (*DeleteResource)(nil) - -// DeleteResource is the async operation controller to delete Applications.Link resource. -type DeleteResource struct { - ctrl.BaseController - engine engine.Engine -} - -// NewDeleteResource creates a new DeleteResource controller which is used to delete resources asynchronously. -func NewDeleteResource(opts ctrl.Options, engine engine.Engine) (ctrl.Controller, error) { - return &DeleteResource{ctrl.NewBaseAsyncController(opts), engine}, nil -} - -// Run retrieves a resource from storage, parses the resource ID, gets the data model, deletes the output -// resources, and deletes the resource from storage. It returns an error if any of these steps fail. -func (c *DeleteResource) Run(ctx context.Context, request *ctrl.Request) (ctrl.Result, error) { - obj, err := c.StorageClient().Get(ctx, request.ResourceID) - if err != nil { - return ctrl.NewFailedResult(v1.ErrorDetails{Message: err.Error()}), err - } - - // This code is general and we might be processing an async job for a resource or a scope, so using the general Parse function. - id, err := resources.Parse(request.ResourceID) - if err != nil { - return ctrl.Result{}, err - } - - dataModel, err := getDataModel(id) - if err != nil { - return ctrl.Result{}, err - } - - if err = obj.As(dataModel); err != nil { - return ctrl.Result{}, err - } - - resourceDataModel, ok := dataModel.(rpv1.RadiusResourceModel) - if !ok { - return ctrl.NewFailedResult(v1.ErrorDetails{Message: "deployment data model conversion error"}), nil - } - - recipeDataModel, supportsRecipes := dataModel.(datamodel.RecipeDataModel) - if supportsRecipes && recipeDataModel.Recipe() != nil { - recipeData := recipes.ResourceMetadata{ - Name: recipeDataModel.Recipe().Name, - EnvironmentID: resourceDataModel.ResourceMetadata().Environment, - ApplicationID: resourceDataModel.ResourceMetadata().Application, - Parameters: recipeDataModel.Recipe().Parameters, - ResourceID: id.String(), - } - - err = c.engine.Delete(ctx, recipeData, resourceDataModel.OutputResources()) - if err != nil { - return ctrl.Result{}, err - } - } - - err = c.StorageClient().Delete(ctx, request.ResourceID) - if err != nil { - return ctrl.Result{}, err - } - - return ctrl.Result{}, err -} - -func getDataModel(id resources.ID) (v1.ResourceDataModel, error) { - resourceType := strings.ToLower(id.Type()) - switch resourceType { - case strings.ToLower(linkrp.MongoDatabasesResourceType): - return &datamodel.MongoDatabase{}, nil - case strings.ToLower(linkrp.RedisCachesResourceType): - return &datamodel.RedisCache{}, nil - case strings.ToLower(linkrp.SqlDatabasesResourceType): - return &datamodel.SqlDatabase{}, nil - case strings.ToLower(linkrp.DaprStateStoresResourceType): - return &datamodel.DaprStateStore{}, nil - case strings.ToLower(linkrp.RabbitMQMessageQueuesResourceType): - return &datamodel.RabbitMQMessageQueue{}, nil - case strings.ToLower(linkrp.DaprSecretStoresResourceType): - return &datamodel.DaprSecretStore{}, nil - case strings.ToLower(linkrp.DaprPubSubBrokersResourceType): - return &datamodel.DaprPubSubBroker{}, nil - case strings.ToLower(linkrp.ExtendersResourceType): - return &datamodel.Extender{}, nil - case strings.ToLower(linkrp.N_MongoDatabasesResourceType): - return &ds_dm.MongoDatabase{}, nil - case strings.ToLower(linkrp.N_RedisCachesResourceType): - return &ds_dm.RedisCache{}, nil - case strings.ToLower(linkrp.N_SqlDatabasesResourceType): - return &ds_dm.SqlDatabase{}, nil - case strings.ToLower(linkrp.N_DaprStateStoresResourceType): - return &dapr_dm.DaprStateStore{}, nil - case strings.ToLower(linkrp.N_RabbitMQQueuesResourceType): - return &msg_dm.RabbitMQQueue{}, nil - case strings.ToLower(linkrp.N_DaprSecretStoresResourceType): - return &dapr_dm.DaprSecretStore{}, nil - case strings.ToLower(linkrp.N_DaprPubSubBrokersResourceType): - return &dapr_dm.DaprPubSubBroker{}, nil - default: - return nil, fmt.Errorf("async delete operation unsupported on resource type: %q. Resource ID: %q", resourceType, id.String()) - } -} diff --git a/pkg/linkrp/backend/controller/deleteresource_test.go b/pkg/linkrp/backend/controller/deleteresource_test.go deleted file mode 100644 index 3631e9b7c5..0000000000 --- a/pkg/linkrp/backend/controller/deleteresource_test.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "context" - "encoding/json" - "errors" - "testing" - - "github.com/golang/mock/gomock" - "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/engine" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/stretchr/testify/require" -) - -var outputResourceResourceID = "/subscriptions/test-sub/resourceGroups/test-rg/providers/Microsoft.DocumentDB/databaseAccounts/mongoDatabases" -var outputResource = rpv1.OutputResource{ - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: "Microsoft.DocumentDB/databaseAccounts/mongoDatabases", - Provider: resourcemodel.ProviderAzure, - }, - Data: map[string]any{ - "id": outputResourceResourceID, - "apiVersion": "2022-01-01", - }, - }, - RadiusManaged: to.Ptr(true), -} - -func TestDeleteResourceRun_20220315PrivatePreview(t *testing.T) { - resourceID := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongoDatabases/mongo0" - setupTest := func(tb testing.TB) (func(tb testing.TB), *store.MockStorageClient, *ctrl.Request, *engine.MockEngine) { - mctrl := gomock.NewController(t) - - msc := store.NewMockStorageClient(mctrl) - eng := engine.NewMockEngine(mctrl) - - req := &ctrl.Request{ - OperationID: uuid.New(), - OperationType: "APPLICATIONS.LINK/MONGODATABASES|DELETE", - ResourceID: resourceID, - CorrelationID: uuid.NewString(), - OperationTimeout: &ctrl.DefaultAsyncOperationTimeout, - } - - return func(tb testing.TB) { - mctrl.Finish() - }, msc, req, eng - } - - t.Parallel() - - deleteCases := []struct { - desc string - getErr error - engDelErr error - scDelErr error - }{ - {"delete-existing-resource", nil, nil, nil}, - {"delete-non-existing-resource", &store.ErrNotFound{ID: resourceID}, nil, nil}, - {"delete-resource-engine-delete-error", nil, errors.New("engine delete error"), nil}, - {"delete-resource-delete-from-db-error", nil, nil, errors.New("delete from db error")}, - } - - for _, tt := range deleteCases { - t.Run(tt.desc, func(t *testing.T) { - teardownTest, msc, req, eng := setupTest(t) - defer teardownTest(t) - - status := rpv1.ResourceStatus{ - OutputResources: []rpv1.OutputResource{ - outputResource, - }, - } - sb, err := json.Marshal(&status) - require.NoError(t, err) - - sm := map[string]interface{}{} - err = json.Unmarshal(sb, &sm) - require.NoError(t, err) - - data := map[string]any{ - "name": "tr", - "type": "Applications.Test/testResources", - "id": TestResourceID, - "location": v1.LocationGlobal, - "properties": map[string]any{ - "application": TestApplicationID, - "environment": TestEnvironmentID, - "provisioningState": "Accepted", - "status": sm, - }, - } - - recipeData := recipes.ResourceMetadata{ - Name: "", - EnvironmentID: TestEnvironmentID, - ApplicationID: TestApplicationID, - Parameters: nil, - ResourceID: resourceID, - } - - msc.EXPECT(). - Get(gomock.Any(), gomock.Any()). - Return(&store.Object{Data: data}, tt.getErr). - Times(1) - - if tt.getErr == nil { - eng.EXPECT(). - Delete(gomock.Any(), recipeData, status.OutputResources). - Return(tt.engDelErr). - Times(1) - if tt.engDelErr == nil { - msc.EXPECT(). - Delete(gomock.Any(), gomock.Any()). - Return(tt.scDelErr). - Times(1) - } - } - opts := ctrl.Options{ - StorageClient: msc, - } - - ctrl, err := NewDeleteResource(opts, eng) - require.NoError(t, err) - - _, err = ctrl.Run(context.Background(), req) - - if tt.getErr != nil || tt.engDelErr != nil || tt.scDelErr != nil { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestDeleteResourceRunInvalidResourceType_20220315PrivatePreview(t *testing.T) { - - setupTest := func(tb testing.TB) (func(tb testing.TB), *store.MockStorageClient, *ctrl.Request, *gomock.Controller) { - mctrl := gomock.NewController(t) - - msc := store.NewMockStorageClient(mctrl) - - req := &ctrl.Request{ - OperationID: uuid.New(), - OperationType: "APPLICATIONS.LINK/INVALID|DELETE", - ResourceID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/invalidType/invalid", - CorrelationID: uuid.NewString(), - OperationTimeout: &ctrl.DefaultAsyncOperationTimeout, - } - - return func(tb testing.TB) { - mctrl.Finish() - }, msc, req, mctrl - } - - t.Parallel() - - t.Run("deleting-invalid-resource", func(t *testing.T) { - teardownTest, msc, req, mctrl := setupTest(t) - defer teardownTest(t) - - msc.EXPECT(). - Get(gomock.Any(), gomock.Any()). - Return(&store.Object{}, nil). - Times(1) - opts := ctrl.Options{ - StorageClient: msc, - } - - eng := engine.NewMockEngine(mctrl) - ctrl, err := NewDeleteResource(opts, eng) - require.NoError(t, err) - - _, err = ctrl.Run(context.Background(), req) - require.Error(t, err) - require.Equal(t, "async delete operation unsupported on resource type: \"applications.link/invalidtype\". Resource ID: \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/invalidType/invalid\"", err.Error()) - }) -} diff --git a/pkg/linkrp/backend/service.go b/pkg/linkrp/backend/service.go deleted file mode 100644 index 5a938fbc80..0000000000 --- a/pkg/linkrp/backend/service.go +++ /dev/null @@ -1,227 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package backend - -import ( - "context" - "fmt" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/worker" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - dapr_dm "github.com/project-radius/radius/pkg/daprrp/datamodel" - "github.com/project-radius/radius/pkg/daprrp/processors/pubsubbrokers" - "github.com/project-radius/radius/pkg/daprrp/processors/secretstores" - "github.com/project-radius/radius/pkg/daprrp/processors/statestores" - ds_dm "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - mongo_prc "github.com/project-radius/radius/pkg/datastoresrp/processors/mongodatabases" - redis_prc "github.com/project-radius/radius/pkg/datastoresrp/processors/rediscaches" - sql_prc "github.com/project-radius/radius/pkg/datastoresrp/processors/sqldatabases" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/frontend/handler" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/processors/daprpubsubbrokers" - "github.com/project-radius/radius/pkg/linkrp/processors/daprsecretstores" - "github.com/project-radius/radius/pkg/linkrp/processors/daprstatestores" - "github.com/project-radius/radius/pkg/linkrp/processors/extenders" - "github.com/project-radius/radius/pkg/linkrp/processors/mongodatabases" - "github.com/project-radius/radius/pkg/linkrp/processors/rabbitmqmessagequeues" - "github.com/project-radius/radius/pkg/linkrp/processors/rediscaches" - "github.com/project-radius/radius/pkg/linkrp/processors/sqldatabases" - msg_dm "github.com/project-radius/radius/pkg/messagingrp/datamodel" - "github.com/project-radius/radius/pkg/messagingrp/processors/rabbitmqqueues" - - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/configloader" - "github.com/project-radius/radius/pkg/recipes/driver" - "github.com/project-radius/radius/pkg/recipes/engine" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/sdk/clients" - "k8s.io/client-go/discovery" - - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - backend_ctrl "github.com/project-radius/radius/pkg/linkrp/backend/controller" - - "github.com/project-radius/radius/pkg/ucp/secret/provider" -) - -type Service struct { - worker.Service -} - -// NewService creates a new Service instance with the given options. -func NewService(options hostoptions.HostOptions) *Service { - return &Service{ - worker.Service{ - Options: options, - ProviderName: handler.LinkProviderNamespace, - }, - } -} - -// Name returns a string containing the namespace of the LinkProvider. -func (s *Service) Name() string { - return fmt.Sprintf("%s async worker", handler.LinkProviderNamespace) -} - -// Run initializes the service and registers controllers for each resource type to handle create/update/delete operations. -func (s *Service) Run(ctx context.Context) error { - if err := s.Init(ctx); err != nil { - return err - } - - runtimeClient, err := kubeutil.NewRuntimeClient(s.Options.K8sConfig) - if err != nil { - return err - } - - discoveryClient, err := discovery.NewDiscoveryClientForConfig(s.Options.K8sConfig) - if err != nil { - return err - } - - // Use legacy discovery client to avoid the issue of the staled GroupVersion discovery(api.ucp.dev/v1alpha3). - // TODO: Disable UseLegacyDiscovery once https://github.com/project-radius/radius/issues/5974 is resolved. - discoveryClient.UseLegacyDiscovery = true - - client := processors.NewResourceClient(s.Options.Arm, s.Options.UCPConnection, runtimeClient, discoveryClient) - clientOptions := sdk.NewClientOptions(s.Options.UCPConnection) - - deploymentEngineClient, err := clients.NewResourceDeploymentsClient(&clients.Options{ - Cred: &aztoken.AnonymousCredential{}, - BaseURI: s.Options.UCPConnection.Endpoint(), - ARMClientOptions: sdk.NewClientOptions(s.Options.UCPConnection), - }) - if err != nil { - return err - } - - configLoader := configloader.NewEnvironmentLoader(clientOptions) - engine := engine.NewEngine(engine.Options{ - ConfigurationLoader: configLoader, - Drivers: map[string]driver.Driver{ - recipes.TemplateKindBicep: driver.NewBicepDriver(clientOptions, deploymentEngineClient, client), - recipes.TemplateKindTerraform: driver.NewTerraformDriver(s.Options.UCPConnection, provider.NewSecretProvider(s.Options.Config.SecretProvider), - driver.TerraformOptions{ - Path: s.Options.Config.Terraform.Path, - }, s.KubeClientSet), - }, - }) - - // resourceTypes is the array that holds resource types that needs async processing. - // We use this array to register backend controllers for each resource. - resourceTypes := []struct { - TypeName string - CreatePutController func(options ctrl.Options) (ctrl.Controller, error) - }{ - {linkrp.MongoDatabasesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &mongodatabases.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.MongoDatabase, datamodel.MongoDatabase](processor, engine, client, configLoader, options) - }}, - {linkrp.RedisCachesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &rediscaches.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.RedisCache, datamodel.RedisCache](processor, engine, client, configLoader, options) - }}, - {linkrp.SqlDatabasesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &sqldatabases.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.SqlDatabase, datamodel.SqlDatabase](processor, engine, client, configLoader, options) - }}, - {linkrp.RabbitMQMessageQueuesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &rabbitmqmessagequeues.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.RabbitMQMessageQueue, datamodel.RabbitMQMessageQueue](processor, engine, client, configLoader, options) - }}, - {linkrp.DaprStateStoresResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &daprstatestores.Processor{Client: runtimeClient} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.DaprStateStore, datamodel.DaprStateStore](processor, engine, client, configLoader, options) - }}, - {linkrp.DaprSecretStoresResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &daprsecretstores.Processor{Client: runtimeClient} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.DaprSecretStore, datamodel.DaprSecretStore](processor, engine, client, configLoader, options) - }}, - {linkrp.DaprPubSubBrokersResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &daprpubsubbrokers.Processor{Client: runtimeClient} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.DaprPubSubBroker, datamodel.DaprPubSubBroker](processor, engine, client, configLoader, options) - }}, - {linkrp.ExtendersResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &extenders.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*datamodel.Extender, datamodel.Extender](processor, engine, client, configLoader, options) - }}, - - // Updates for Spliting Linkrp Namespace - {linkrp.N_RabbitMQQueuesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &rabbitmqqueues.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*msg_dm.RabbitMQQueue, msg_dm.RabbitMQQueue](processor, engine, client, configLoader, options) - }}, - {linkrp.N_DaprStateStoresResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &statestores.Processor{Client: runtimeClient} - return backend_ctrl.NewCreateOrUpdateResource[*dapr_dm.DaprStateStore, dapr_dm.DaprStateStore](processor, engine, client, configLoader, options) - }}, - {linkrp.N_DaprSecretStoresResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &secretstores.Processor{Client: runtimeClient} - return backend_ctrl.NewCreateOrUpdateResource[*dapr_dm.DaprSecretStore, dapr_dm.DaprSecretStore](processor, engine, client, configLoader, options) - }}, - {linkrp.N_DaprPubSubBrokersResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &pubsubbrokers.Processor{Client: runtimeClient} - return backend_ctrl.NewCreateOrUpdateResource[*dapr_dm.DaprPubSubBroker, dapr_dm.DaprPubSubBroker](processor, engine, client, configLoader, options) - }}, - {linkrp.N_MongoDatabasesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &mongo_prc.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*ds_dm.MongoDatabase, ds_dm.MongoDatabase](processor, engine, client, configLoader, options) - }}, - {linkrp.N_RedisCachesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &redis_prc.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*ds_dm.RedisCache, ds_dm.RedisCache](processor, engine, client, configLoader, options) - }}, - {linkrp.N_SqlDatabasesResourceType, func(options ctrl.Options) (ctrl.Controller, error) { - processor := &sql_prc.Processor{} - return backend_ctrl.NewCreateOrUpdateResource[*ds_dm.SqlDatabase, ds_dm.SqlDatabase](processor, engine, client, configLoader, options) - }}, - } - - opts := ctrl.Options{ - DataProvider: s.StorageProvider, - KubeClient: s.KubeClient, - } - - for _, rt := range resourceTypes { - // Register controllers - err = s.Controllers.Register(ctx, rt.TypeName, v1.OperationDelete, func(options ctrl.Options) (ctrl.Controller, error) { - return backend_ctrl.NewDeleteResource(options, engine) - }, opts) - if err != nil { - return err - } - err = s.Controllers.Register(ctx, rt.TypeName, v1.OperationPut, rt.CreatePutController, opts) - if err != nil { - return err - } - } - workerOpts := worker.Options{} - if s.Options.Config.WorkerServer != nil { - if s.Options.Config.WorkerServer.MaxOperationConcurrency != nil { - workerOpts.MaxOperationConcurrency = *s.Options.Config.WorkerServer.MaxOperationConcurrency - } - if s.Options.Config.WorkerServer.MaxOperationRetryCount != nil { - workerOpts.MaxOperationRetryCount = *s.Options.Config.WorkerServer.MaxOperationRetryCount - } - } - - return s.Start(ctx, workerOpts) -} diff --git a/pkg/linkrp/datamodel/converter/daprpubsubbroker_converter.go b/pkg/linkrp/datamodel/converter/daprpubsubbroker_converter.go deleted file mode 100644 index 22a54469f3..0000000000 --- a/pkg/linkrp/datamodel/converter/daprpubsubbroker_converter.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// DaprPubSubBrokerDataModelFromVersioned converts version agnostic DaprPubSubBroker datamodel to versioned model. -// It returns an error if the version is not supported. -func DaprPubSubBrokerDataModelToVersioned(model *datamodel.DaprPubSubBroker, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.DaprPubSubBrokerResource{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// DaprPubSubBrokerDataModelToVersioned converts versioned DaprPubSubBroker model to datamodel and returns -// an error if the version is unsupported. -func DaprPubSubBrokerDataModelFromVersioned(content []byte, version string) (*datamodel.DaprPubSubBroker, error) { - switch version { - case v20220315privatepreview.Version: - am := &v20220315privatepreview.DaprPubSubBrokerResource{} - if err := json.Unmarshal(content, am); err != nil { - return nil, err - } - dm, err := am.ConvertTo() - if err != nil { - return nil, err - } - - return dm.(*datamodel.DaprPubSubBroker), err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/daprpubsubbroker_converter_test.go b/pkg/linkrp/datamodel/converter/daprpubsubbroker_converter_test.go deleted file mode 100644 index f862d08536..0000000000 --- a/pkg/linkrp/datamodel/converter/daprpubsubbroker_converter_test.go +++ /dev/null @@ -1,220 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "testing" - "time" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestDaprPubSubBrokerDataModelToVersioned(t *testing.T) { - createdAt, err := time.Parse(time.RFC3339Nano, "2021-09-24T19:09:54.2403864Z") - require.NoError(t, err) - - lastModifiedAt, err := time.Parse(time.RFC3339Nano, "2021-09-24T20:09:54.2403864Z") - require.NoError(t, err) - - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - expected *v20220315privatepreview.DaprPubSubBrokerResource - err error - }{ - { - "../../api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_datamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.DaprPubSubBrokerResource{}, - &v20220315privatepreview.DaprPubSubBrokerResource{ - Location: to.Ptr("global"), - Properties: &v20220315privatepreview.DaprPubSubBrokerProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - Metadata: map[string]interface{}{ - "foo": "bar", - }, - Recipe: nil, - ResourceProvisioning: to.Ptr(v20220315privatepreview.ResourceProvisioningManual), - Resources: []*v20220315privatepreview.ResourceReference{ - { - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/radius-eastus-async"), - }, - }, - Type: to.Ptr("pubsub.azure.servicebus"), - Version: to.Ptr("v1"), - ComponentName: to.Ptr("test-dpsb"), - ProvisioningState: to.Ptr(v20220315privatepreview.ProvisioningStateAccepted), - Status: &v20220315privatepreview.ResourceStatus{ - OutputResources: []map[string]any{ - { - "LocalID": "Deployment", - "Provider": "kubernetes", - "Identity": nil, - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb"), - Name: to.Ptr("test-dpsb"), - SystemData: &v20220315privatepreview.SystemData{ - CreatedAt: &createdAt, - CreatedBy: to.Ptr("fakeid@live.com"), - CreatedByType: to.Ptr(v20220315privatepreview.CreatedByTypeUser), - LastModifiedAt: &lastModifiedAt, - LastModifiedBy: to.Ptr("fakeid@live.com"), - LastModifiedByType: to.Ptr(v20220315privatepreview.CreatedByTypeUser), - }, - Type: to.Ptr("Applications.Link/daprPubSubBrokers"), - }, - nil, - }, - { - "../../api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_generic_datamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.DaprPubSubBrokerResource{}, - &v20220315privatepreview.DaprPubSubBrokerResource{ - Location: to.Ptr("global"), - Properties: &v20220315privatepreview.DaprPubSubBrokerProperties{ - Environment: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env"), - Application: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app"), - Metadata: map[string]interface{}{ - "foo": "bar", - }, - Recipe: nil, - ResourceProvisioning: to.Ptr(v20220315privatepreview.ResourceProvisioningManual), - Resources: nil, - Type: to.Ptr("pubsub.kafka"), - Version: to.Ptr("v1"), - ComponentName: to.Ptr("test-dpsb"), - ProvisioningState: to.Ptr(v20220315privatepreview.ProvisioningStateAccepted), - Status: &v20220315privatepreview.ResourceStatus{ - OutputResources: []map[string]any{ - { - "LocalID": "Deployment", - "Provider": "kubernetes", - "Identity": nil, - }, - }, - }, - }, - Tags: map[string]*string{ - "env": to.Ptr("dev"), - }, - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/daprPubSubBrokers/test-dpsb"), - Name: to.Ptr("test-dpsb"), - SystemData: &v20220315privatepreview.SystemData{ - CreatedAt: &createdAt, - CreatedBy: to.Ptr("fakeid@live.com"), - CreatedByType: to.Ptr(v20220315privatepreview.CreatedByTypeUser), - LastModifiedAt: &lastModifiedAt, - LastModifiedBy: to.Ptr("fakeid@live.com"), - LastModifiedByType: to.Ptr(v20220315privatepreview.CreatedByTypeUser), - }, - Type: to.Ptr("Applications.Link/daprPubSubBrokers"), - }, - nil, - }, - { - "", - "unsupported", - nil, - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.DaprPubSubBroker{} - _ = json.Unmarshal(c, dm) - - am, err := DaprPubSubBrokerDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - require.Equal(t, tc.expected, am) - } - }) - } -} - -func TestDaprPubSubBrokerDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidrecipe_resource.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: "multiple errors were found:\n\tmetadata cannot be specified when resourceProvisioning is set to recipe (default)\n\ttype cannot be specified when resourceProvisioning is set to recipe (default)\n\tversion cannot be specified when resourceProvisioning is set to recipe (default)", - }, - }, - { - "../../api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_invalidmanual_resource.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{ - Code: "BadRequest", - Message: "multiple errors were found:\n\trecipe details cannot be specified when resourceProvisioning is set to manual\n\tmetadata must be specified when resourceProvisioning is set to manual\n\ttype must be specified when resourceProvisioning is set to manual\n\tversion must be specified when resourceProvisioning is set to manual", - }, - }, - { - "../../api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_recipe_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/daprpubsubbroker/daprpubsubbroker_manual_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := DaprPubSubBrokerDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.Equal(t, tc.err, err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/daprsecretstore_converter.go b/pkg/linkrp/datamodel/converter/daprsecretstore_converter.go deleted file mode 100644 index 61c5dfc871..0000000000 --- a/pkg/linkrp/datamodel/converter/daprsecretstore_converter.go +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// DaprSecretStoreDataModelToVersioned converts a DaprSecretStore data model to a versioned model interface based on the version provided, -// and returns an error if the version is unsupported. -func DaprSecretStoreDataModelToVersioned(model *datamodel.DaprSecretStore, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.DaprSecretStoreResource{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// DaprSecretStoreDataModelFromVersioned unmarshals a JSON content into a DaprSecretStoreResource object and then converts -// it to a DaprSecretStore object, returning an error if either of these steps fail. -func DaprSecretStoreDataModelFromVersioned(content []byte, version string) (*datamodel.DaprSecretStore, error) { - switch version { - case v20220315privatepreview.Version: - am := &v20220315privatepreview.DaprSecretStoreResource{} - if err := json.Unmarshal(content, am); err != nil { - return nil, err - } - dm, err := am.ConvertTo() - if err != nil { - return nil, err - } - return dm.(*datamodel.DaprSecretStore), err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/daprsecretstore_converter_test.go b/pkg/linkrp/datamodel/converter/daprsecretstore_converter_test.go deleted file mode 100644 index 8846596a87..0000000000 --- a/pkg/linkrp/datamodel/converter/daprsecretstore_converter_test.go +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "errors" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestDaprSecretStoreDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/daprsecretstore_manual_resourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.DaprSecretStoreResource{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.DaprSecretStore{} - _ = json.Unmarshal(c, dm) - am, err := DaprSecretStoreDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} - -func TestDaprSecretStoreDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/daprsecretstore_manual_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/daprsecretstoreresource-invalid.json", - "2022-03-15-privatepreview", - errors.New("json: cannot unmarshal number into Go struct field DaprSecretStoreProperties.properties.version of type string"), - }, - { - "../../api/v20220315privatepreview/testdata/daprsecretstore_invalidvalues_resource.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{Code: "BadRequest", Message: "multiple errors were found:\n\trecipe details cannot be specified when resourceProvisioning is set to manual\n\tmetadata must be specified when resourceProvisioning is set to manual\n\ttype must be specified when resourceProvisioning is set to manual\n\tversion must be specified when resourceProvisioning is set to manual"}, - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := DaprSecretStoreDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/daprstatestore_converter.go b/pkg/linkrp/datamodel/converter/daprstatestore_converter.go deleted file mode 100644 index 7006604e60..0000000000 --- a/pkg/linkrp/datamodel/converter/daprstatestore_converter.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// DaprStateStoreDataModelToVersioned converts a DaprStateStore data model to a versioned model interface -// and returns an error if the version is unsupported. -func DaprStateStoreDataModelToVersioned(model *datamodel.DaprStateStore, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.DaprStateStoreResource{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// DaprStateStoreDataModelFromVersioned unmarshals a JSON byte slice into a DaprStateStoreResource object and converts it -// to a DaprStateStore object, returning an error if either operation fails. -func DaprStateStoreDataModelFromVersioned(content []byte, version string) (*datamodel.DaprStateStore, error) { - switch version { - case v20220315privatepreview.Version: - am := &v20220315privatepreview.DaprStateStoreResource{} - if err := json.Unmarshal(content, am); err != nil { - return nil, err - } - dm, err := am.ConvertTo() - if err != nil { - return nil, err - } - - return dm.(*datamodel.DaprStateStore), nil - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/daprstatestore_converter_test.go b/pkg/linkrp/datamodel/converter/daprstatestore_converter_test.go deleted file mode 100644 index 82240a8db0..0000000000 --- a/pkg/linkrp/datamodel/converter/daprstatestore_converter_test.go +++ /dev/null @@ -1,124 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestDaprStateStoreDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/daprstatestoresqlserverresourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.DaprStateStoreResource{}, - nil, - }, - { - "../../api/v20220315privatepreview/testdata/daprstatestoreazuretablestorageresourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.DaprStateStoreResource{}, - nil, - }, - { - "../../api/v20220315privatepreview/testdata/daprstatestogenericreresourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.DaprStateStoreResource{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.DaprStateStore{} - _ = json.Unmarshal(c, dm) - am, err := DaprStateStoreDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} - -func TestDaprStateStoreDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/daprstatestore_invalidrecipe_resource.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{Code: v1.CodeInvalid, Message: "multiple errors were found:\n\tmetadata cannot be specified when resourceProvisioning is set to recipe (default)\n\ttype cannot be specified when resourceProvisioning is set to recipe (default)\n\tversion cannot be specified when resourceProvisioning is set to recipe (default)"}, - }, - { - "../../api/v20220315privatepreview/testdata/daprstatestore_invalidvalues_resource.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{Code: "BadRequest", Message: "multiple errors were found:\n\trecipe details cannot be specified when resourceProvisioning is set to manual\n\tmetadata must be specified when resourceProvisioning is set to manual\n\ttype must be specified when resourceProvisioning is set to manual\n\tversion must be specified when resourceProvisioning is set to manual"}, - }, - { - "../../api/v20220315privatepreview/testdata/daprstatestore_recipe_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/daprstatestore_values_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := DaprStateStoreDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.Equal(t, tc.err, err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/extender_converter.go b/pkg/linkrp/datamodel/converter/extender_converter.go deleted file mode 100644 index 9c041369bd..0000000000 --- a/pkg/linkrp/datamodel/converter/extender_converter.go +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// ExtenderDataModelToVersioned converts a datamodel.Extender to a versioned model interface based on the given version -// string, returning an error if the conversion fails. -func ExtenderDataModelToVersioned(model *datamodel.Extender, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.ExtenderResource{} - err := versioned.ConvertFrom(model) - if err != nil { - return nil, err - } - - return versioned, nil - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// ExtenderDataModelFromVersioned unmarshals a JSON byte slice into a version-specific ExtenderResource struct, then -// converts it to a datamodel.Extender struct and returns it, or returns an error if the unmarshal or conversion fails. -func ExtenderDataModelFromVersioned(content []byte, version string) (*datamodel.Extender, error) { - switch version { - case v20220315privatepreview.Version: - am := &v20220315privatepreview.ExtenderResource{} - if err := json.Unmarshal(content, am); err != nil { - return nil, err - } - dm, err := am.ConvertTo() - if err != nil { - return nil, err - } - return dm.(*datamodel.Extender), err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/extender_converter_test.go b/pkg/linkrp/datamodel/converter/extender_converter_test.go deleted file mode 100644 index 743f1c134c..0000000000 --- a/pkg/linkrp/datamodel/converter/extender_converter_test.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "errors" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestExtenderDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/extenderresourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.ExtenderResource{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.Extender{} - _ = json.Unmarshal(c, dm) - am, err := ExtenderDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} - -func TestExtenderDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/extender_manual.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/extenderresource-invalid.json", - "2022-03-15-privatepreview", - errors.New("json: cannot unmarshal number into Go struct field ExtenderProperties.properties.resource of type string"), - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := ExtenderDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/mongodatabase_converter.go b/pkg/linkrp/datamodel/converter/mongodatabase_converter.go deleted file mode 100644 index 00c9197d01..0000000000 --- a/pkg/linkrp/datamodel/converter/mongodatabase_converter.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// MongoDatabaseDataModelToVersioned converts a MongoDatabase data model to a versioned model interface based on the -// specified version, and returns an error if the version is not supported. -func MongoDatabaseDataModelToVersioned(model *datamodel.MongoDatabase, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.MongoDatabaseResource{} - err := versioned.ConvertFrom(model) - return versioned, err - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// MongoDatabaseDataModelFromVersioned takes in a byte slice and a version string and returns a MongoDatabase instance and -// an error if the version is unsupported. -func MongoDatabaseDataModelFromVersioned(content []byte, version string) (*datamodel.MongoDatabase, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.MongoDatabaseResource{} - if err := json.Unmarshal(content, versioned); err != nil { - return nil, err - } - dm, err := versioned.ConvertTo() - if err != nil { - return nil, err - } - return dm.(*datamodel.MongoDatabase), err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// MongoDatabaseSecretsDataModelFromVersioned converts version agnostic MongoDatabaseSecrets datamodel to versioned model. -// - -// MongoDatabaseSecretsDataModelToVersioned converts a MongoDatabaseSecrets data model to a versioned model interface and -// returns an error if the version is not supported. -func MongoDatabaseSecretsDataModelToVersioned(model *datamodel.MongoDatabaseSecrets, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.MongoDatabaseSecrets{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/mongodatabase_converter_test.go b/pkg/linkrp/datamodel/converter/mongodatabase_converter_test.go deleted file mode 100644 index 782eff07cf..0000000000 --- a/pkg/linkrp/datamodel/converter/mongodatabase_converter_test.go +++ /dev/null @@ -1,144 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "errors" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestMongoDatabaseDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/mongodatabaseresourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.MongoDatabaseResource{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.MongoDatabase{} - _ = json.Unmarshal(c, dm) - am, err := MongoDatabaseDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} -func TestMongoDatabaseDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/mongodatabaseresource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/mongodatabaseresource-invalid.json", - "2022-03-15-privatepreview", - errors.New("json: cannot unmarshal number into Go struct field MongoDatabaseProperties.properties.resource of type string"), - }, - { - "../../api/v20220315privatepreview/testdata/mongodatabaseresource-missinginputs.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{Code: "BadRequest", Message: "multiple errors were found:\n\thost must be specified when resourceProvisioning is set to manual\n\tport must be specified when resourceProvisioning is set to manual\n\tdatabase must be specified when resourceProvisioning is set to manual"}, - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := MongoDatabaseDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} - -func TestMongoDatabaseSecretsDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/mongodatabasesecretsdatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.MongoDatabaseSecrets{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.MongoDatabaseSecrets{} - _ = json.Unmarshal(c, dm) - am, err := MongoDatabaseSecretsDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/rabbitmq_converter.go b/pkg/linkrp/datamodel/converter/rabbitmq_converter.go deleted file mode 100644 index 0ddd5079b8..0000000000 --- a/pkg/linkrp/datamodel/converter/rabbitmq_converter.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// RabbitMQMessageQueueDataModelToVersioned converts a datamodel.RabbitMQMessageQueue to a versioned model interface based -// on the given version, and returns an error if the version is not supported. -func RabbitMQMessageQueueDataModelToVersioned(model *datamodel.RabbitMQMessageQueue, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.RabbitMQMessageQueueResource{} - err := versioned.ConvertFrom(model) - return versioned, err - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// RabbitMQMessageQueueDataModelFromVersioned unmarshals a JSON byte slice into a versioned RabbitMQMessageQueueResource -// struct, then converts it to a datamodel.RabbitMQMessageQueue struct and returns it, or returns an error if the version -// is unsupported. -func RabbitMQMessageQueueDataModelFromVersioned(content []byte, version string) (*datamodel.RabbitMQMessageQueue, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.RabbitMQMessageQueueResource{} - if err := json.Unmarshal(content, versioned); err != nil { - return nil, err - } - dm, err := versioned.ConvertTo() - if err != nil { - return nil, err - } - return dm.(*datamodel.RabbitMQMessageQueue), err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// RabbitMQSecretsDataModelToVersioned converts a datamodel.RabbitMQSecrets to a versioned model based on the given -// version string, or returns an error if the version is not supported. -func RabbitMQSecretsDataModelToVersioned(model *datamodel.RabbitMQSecrets, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.RabbitMQSecrets{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/rabbitmq_converter_test.go b/pkg/linkrp/datamodel/converter/rabbitmq_converter_test.go deleted file mode 100644 index 4cfe2aa85a..0000000000 --- a/pkg/linkrp/datamodel/converter/rabbitmq_converter_test.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "errors" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestRabbitMQMessageQueueDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.RabbitMQMessageQueueResource{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.RabbitMQMessageQueue{} - _ = json.Unmarshal(c, dm) - am, err := RabbitMQMessageQueueDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} - -func TestRabbitMQMessageQueueDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/rabbitmq_manual_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/rabbitmqresource-invalid.json", - "2022-03-15-privatepreview", - errors.New("json: cannot unmarshal number into Go struct field RabbitMQMessageQueueProperties.properties.resource of type string"), - }, - { - "../../api/v20220315privatepreview/testdata/rabbitmq_invalid_properties_resource.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{Code: "BadRequest", Message: "queue is required when resourceProvisioning is manual"}, - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := RabbitMQMessageQueueDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} - -func TestRabbitMQSecretsDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/rabbitmqsecretsdatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.RabbitMQSecrets{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.RabbitMQSecrets{} - _ = json.Unmarshal(c, dm) - am, err := RabbitMQSecretsDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/rediscache_converter.go b/pkg/linkrp/datamodel/converter/rediscache_converter.go deleted file mode 100644 index 8bef090432..0000000000 --- a/pkg/linkrp/datamodel/converter/rediscache_converter.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// RedisCacheDataModelToVersioned converts a RedisCache data model to a versioned model interface and returns an error if -// the conversion fails. -func RedisCacheDataModelToVersioned(model *datamodel.RedisCache, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.RedisCacheResource{} - err := versioned.ConvertFrom(model) - if err != nil { - return nil, err - } - - return versioned, nil - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// RedisCacheDataModelFromVersioned converts a versioned RedisCacheResource to a datamodel.RedisCache and returns an error -// if the conversion fails. -func RedisCacheDataModelFromVersioned(content []byte, version string) (*datamodel.RedisCache, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.RedisCacheResource{} - if err := json.Unmarshal(content, versioned); err != nil { - return nil, err - } - dm, err := versioned.ConvertTo() - if err != nil { - return nil, err - } - return dm.(*datamodel.RedisCache), err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// RedisCacheSecretsDataModelToVersioned takes in a pointer to a RedisCacheSecrets datamodel and a version string, and -// returns a VersionedModelInterface and an error if the version is not supported. -func RedisCacheSecretsDataModelToVersioned(model *datamodel.RedisCacheSecrets, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.RedisCacheSecrets{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/rediscache_converter_test.go b/pkg/linkrp/datamodel/converter/rediscache_converter_test.go deleted file mode 100644 index a7cccf06e0..0000000000 --- a/pkg/linkrp/datamodel/converter/rediscache_converter_test.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "errors" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestRedisCacheDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/rediscacheresourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.RedisCacheResource{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.RedisCache{} - _ = json.Unmarshal(c, dm) - am, err := RedisCacheDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} - -func TestRedisCacheDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/rediscacheresource_manual.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/rediscacheresource-invalidinput.json", - "2022-03-15-privatepreview", - errors.New("json: cannot unmarshal number into Go struct field RedisCacheProperties.properties.host of type string"), - }, - { - "../../api/v20220315privatepreview/testdata/rediscacheresource-invalid2.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{Code: "BadRequest", Message: "multiple errors were found:\n\thost must be specified when resourceProvisioning is set to manual\n\tport must be specified when resourceProvisioning is set to manual"}, - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := RedisCacheDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} - -func TestRedisCacheSecretsDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/rediscachesecretsdatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.RedisCacheSecrets{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.RedisCacheSecrets{} - _ = json.Unmarshal(c, dm) - am, err := RedisCacheSecretsDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/sqldatabase_converter.go b/pkg/linkrp/datamodel/converter/sqldatabase_converter.go deleted file mode 100644 index 22702b5f2f..0000000000 --- a/pkg/linkrp/datamodel/converter/sqldatabase_converter.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" -) - -// SqlDatabaseDataModelToVersioned converts a SqlDatabase data model to a VersionedModelInterface based on the specified -// version, returning an error if the version is unsupported. -func SqlDatabaseDataModelToVersioned(model *datamodel.SqlDatabase, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.SQLDatabaseResource{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// SqlDatabaseDataModelFromVersioned takes in a byte slice and a version string and returns a SqlDatabase object and an -// error if one occurs. -func SqlDatabaseDataModelFromVersioned(content []byte, version string) (*datamodel.SqlDatabase, error) { - switch version { - case v20220315privatepreview.Version: - am := &v20220315privatepreview.SQLDatabaseResource{} - if err := json.Unmarshal(content, am); err != nil { - return nil, err - } - dm, err := am.ConvertTo() - if err != nil { - return nil, err - } - return dm.(*datamodel.SqlDatabase), err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} - -// This function converts a SqlDatabaseSecretsDataModel to a VersionedModelInterface based on the version provided, and -// returns an error if the version is unsupported. -func SqlDatabaseSecretsDataModelToVersioned(model *datamodel.SqlDatabaseSecrets, version string) (v1.VersionedModelInterface, error) { - switch version { - case v20220315privatepreview.Version: - versioned := &v20220315privatepreview.SQLDatabaseSecrets{} - err := versioned.ConvertFrom(model) - return versioned, err - - default: - return nil, v1.ErrUnsupportedAPIVersion - } -} diff --git a/pkg/linkrp/datamodel/converter/sqldatabase_converter_test.go b/pkg/linkrp/datamodel/converter/sqldatabase_converter_test.go deleted file mode 100644 index aee8c83222..0000000000 --- a/pkg/linkrp/datamodel/converter/sqldatabase_converter_test.go +++ /dev/null @@ -1,156 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "encoding/json" - "errors" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/stretchr/testify/require" -) - -// Validates type conversion between versioned client side data model and RP data model. -func TestSqlDatabaseDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/sqldatabase_manual_resourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.SQLDatabaseResource{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.SqlDatabase{} - _ = json.Unmarshal(c, dm) - am, err := SqlDatabaseDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} - -func TestSqlDatabaseDataModelFromVersioned(t *testing.T) { - testset := []struct { - versionedModelFile string - apiVersion string - err error - }{ - { - "../../api/v20220315privatepreview/testdata/sqldatabase_manual_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/sqldatabase_recipe_resource.json", - "2022-03-15-privatepreview", - nil, - }, - { - "../../api/v20220315privatepreview/testdata/sqldatabaseresource-invalid.json", - "2022-03-15-privatepreview", - errors.New("json: cannot unmarshal number into Go struct field SqlDatabaseProperties.properties.database of type string"), - }, - { - "../../api/v20220315privatepreview/testdata/sqldatabase_invalid_properties_resource.json", - "2022-03-15-privatepreview", - &v1.ErrClientRP{Code: v1.CodeInvalid, Message: "multiple errors were found:\n\tserver must be specified when resourceProvisioning is set to manual\n\tport must be specified when resourceProvisioning is set to manual\n\tdatabase must be specified when resourceProvisioning is set to manual"}, - }, - { - "", - "unsupported", - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.versionedModelFile) - dm, err := SqlDatabaseDataModelFromVersioned(c, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiVersion, dm.InternalMetadata.UpdatedAPIVersion) - } - }) - } -} - -func TestSqlDatabaseSecretsDataModelToVersioned(t *testing.T) { - testset := []struct { - dataModelFile string - apiVersion string - apiModelType any - err error - }{ - { - "../../api/v20220315privatepreview/testdata/sqldatabase_secrets_datamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.SQLDatabaseSecrets{}, - nil, - }, - { - "../../api/v20220315privatepreview/testdata/sqldatabase_recipe_resourcedatamodel.json", - "2022-03-15-privatepreview", - &v20220315privatepreview.SQLDatabaseSecrets{}, - nil, - }, - { - "", - "unsupported", - nil, - v1.ErrUnsupportedAPIVersion, - }, - } - - for _, tc := range testset { - t.Run(tc.apiVersion, func(t *testing.T) { - c := loadTestData(tc.dataModelFile) - dm := &datamodel.SqlDatabaseSecrets{} - _ = json.Unmarshal(c, dm) - am, err := SqlDatabaseSecretsDataModelToVersioned(dm, tc.apiVersion) - if tc.err != nil { - require.ErrorAs(t, tc.err, &err) - } else { - require.NoError(t, err) - require.IsType(t, tc.apiModelType, am) - } - }) - } -} diff --git a/pkg/linkrp/datamodel/converter/test_util.go b/pkg/linkrp/datamodel/converter/test_util.go deleted file mode 100644 index 3c99654ed3..0000000000 --- a/pkg/linkrp/datamodel/converter/test_util.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package converter - -import ( - "os" -) - -func loadTestData(testfile string) []byte { - d, err := os.ReadFile(testfile) - if err != nil { - return nil - } - return d -} diff --git a/pkg/linkrp/datamodel/daprdetector.go b/pkg/linkrp/datamodel/daprdetector.go deleted file mode 100644 index 871edef361..0000000000 --- a/pkg/linkrp/datamodel/daprdetector.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "context" - - apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -const ( - daprComponentCRD = "components.dapr.io" - - // DaprMissingError is an error message that can be used when Dapr is not installed on the cluster. - DaprMissingError = "Dapr is not installed in your Kubernetes cluster. Please install Dapr by following the instructions at https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/." -) - -// IsDaprInstalled will check for Dapr to be installed in the deployment environment and return -// and true if it is installed. Callers of this function can use DaprMissingError for a friendly error -// message to send back to users. -// -// This check is based on the Dapr Component CRD, and only supports Kubernetes. It checks if the Dapr component -// CustomResourceDefinition exists in the Kubernetes cluster and returns a boolean and an error if one occurs. -func IsDaprInstalled(ctx context.Context, kubeClient client.Client) (bool, error) { - crd := &apiextv1.CustomResourceDefinition{} - err := kubeClient.Get(ctx, client.ObjectKey{Name: daprComponentCRD}, crd) - if apierrors.IsNotFound(err) { - return false, nil - } else if err != nil { - return false, err - } - - return true, nil -} diff --git a/pkg/linkrp/datamodel/daprpubsubbroker.go b/pkg/linkrp/datamodel/daprpubsubbroker.go deleted file mode 100644 index e5b0383d8f..0000000000 --- a/pkg/linkrp/datamodel/daprpubsubbroker.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// DaprPubSubBroker represents DaprPubSubBroker link resource. -type DaprPubSubBroker struct { - v1.BaseResource - - // Properties is the properties of the resource. - Properties DaprPubSubBrokerProperties `json:"properties"` - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata -} - -// ApplyDeploymentOutput applies the properties changes based on the deployment output. It updates the -// OutputResources of the DaprPubSubBroker resource with the output resources from a DeploymentOutput object. -func (r *DaprPubSubBroker) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - return nil -} - -// OutputResources returns the OutputResources of the DaprPubSubBroker resource. -func (r *DaprPubSubBroker) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the DaprPubSubBroker resource i.e. application resources metadata. -func (r *DaprPubSubBroker) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// ResourceTypeName returns the resource type of the DaprPubSubBroker resource. -func (daprPubSub *DaprPubSubBroker) ResourceTypeName() string { - return linkrp.DaprPubSubBrokersResourceType -} - -// Recipe returns the recipe information of the resource. Returns nil if recipe execution is disabled. -func (r *DaprPubSubBroker) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &r.Properties.Recipe -} - -// DaprPubSubBrokerProperties represents the properties of DaprPubSubBroker resource. -type DaprPubSubBrokerProperties struct { - rpv1.BasicResourceProperties - rpv1.BasicDaprResourceProperties - - // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // Metadata of the Dapr Pub/Sub Broker resource. - Metadata map[string]any `json:"metadata,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the Dapr Pub/Sub Broker resource. - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - - // List of the resource IDs that support the Dapr Pub/Sub Broker resource. - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` - - // Type of the Dapr Pub/Sub Broker resource. - Type string `json:"type,omitempty"` - - // Version of the Dapr Pub/Sub Broker resource. - Version string `json:"version,omitempty"` -} diff --git a/pkg/linkrp/datamodel/daprsecretstore.go b/pkg/linkrp/datamodel/daprsecretstore.go deleted file mode 100644 index ea2388e74a..0000000000 --- a/pkg/linkrp/datamodel/daprsecretstore.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// DaprSecretStore represents DaprSecretStore link resource. -type DaprSecretStore struct { - v1.BaseResource - - // Properties is the properties of the resource. - Properties DaprSecretStoreProperties `json:"properties"` - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata -} - -// ApplyDeploymentOutput updates the Status.OutputResources field of Properties with the DeployedOutputResources -// from the DeploymentOutput and returns no error. -func (r *DaprSecretStore) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - return nil -} - -// OutputResources returns the OutputResources array from Properties of the DaprSecretStore resource. -func (r *DaprSecretStore) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the DaprSecretStore resource i.e. application resources metadata. -func (r *DaprSecretStore) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// ResourceTypeName returns the resource type of the DaprSecretStore resource. -func (daprSecretStore *DaprSecretStore) ResourceTypeName() string { - return linkrp.DaprSecretStoresResourceType -} - -// DaprSecretStoreProperties represents the properties of DaprSecretStore resource. -type DaprSecretStoreProperties struct { - rpv1.BasicResourceProperties - rpv1.BasicDaprResourceProperties - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` - Metadata map[string]any `json:"metadata,omitempty"` - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` -} - -// Recipe returns the Recipe from the DaprSecretStore Properties if ResourceProvisioning is not set to Manual, -// otherwise it returns nil. -func (daprSecretStore *DaprSecretStore) Recipe() *linkrp.LinkRecipe { - if daprSecretStore.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &daprSecretStore.Properties.Recipe -} diff --git a/pkg/linkrp/datamodel/daprstatestore.go b/pkg/linkrp/datamodel/daprstatestore.go deleted file mode 100644 index 17b4d6a20c..0000000000 --- a/pkg/linkrp/datamodel/daprstatestore.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/renderers" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// DaprStateStore represents DaprStateStore link resource. -type DaprStateStore struct { - v1.BaseResource - - // Properties is the properties of the resource. - Properties DaprStateStoreProperties `json:"properties"` - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata -} - -// ApplyDeploymentOutput updates the DaprStateStore resource with the DeploymentOutput values. -func (r *DaprStateStore) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - r.ComputedValues = do.ComputedValues - r.SecretValues = do.SecretValues - if cn, ok := do.ComputedValues[renderers.ComponentNameKey].(string); ok { - r.Properties.ComponentName = cn - } - return nil -} - -// OutputResources returns the OutputResources from the Properties of the DaprStateStore resource. -func (r *DaprStateStore) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the DaprStateStore resource i.e. application resources metadata. -func (r *DaprStateStore) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// ResourceTypeName returns the resource type of the DaprStateStore resource. -func (daprStateStore *DaprStateStore) ResourceTypeName() string { - return linkrp.DaprStateStoresResourceType -} - -// Recipe returns the recipe information of the resource. It returns nil if the ResourceProvisioning is set to manual. -func (r *DaprStateStore) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &r.Properties.Recipe -} - -// DaprStateStoreProperties represents the properties of DaprStateStore resource. -type DaprStateStoreProperties struct { - rpv1.BasicResourceProperties - rpv1.BasicDaprResourceProperties - // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - Metadata map[string]any `json:"metadata,omitempty"` - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` - Type string `json:"type,omitempty"` - Version string `json:"version,omitempty"` -} diff --git a/pkg/linkrp/datamodel/daprstatestore_test.go b/pkg/linkrp/datamodel/daprstatestore_test.go deleted file mode 100644 index 9f39803ca1..0000000000 --- a/pkg/linkrp/datamodel/daprstatestore_test.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "testing" - - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func TestDaprStateStore_ApplyDeploymentOutput(t *testing.T) { - tests := []struct { - name string - dss *DaprStateStore - do *rpv1.DeploymentOutput - wantErr bool - }{ - { - name: "with component name", - dss: &DaprStateStore{}, - do: &rpv1.DeploymentOutput{ - DeployedOutputResources: []rpv1.OutputResource{ - { - LocalID: rpv1.LocalIDDaprStateStoreAzureStorage, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Data: resourcemodel.ARMIdentity{}, - }, - RadiusManaged: to.Ptr(true), - Dependencies: []rpv1.Dependency{ - { - LocalID: "", - }, - }, - }, - }, - ComputedValues: map[string]any{ - renderers.ComponentNameKey: "dapr-state-store-test", - }, - }, - wantErr: false, - }, - { - name: "without component name", - dss: &DaprStateStore{}, - do: &rpv1.DeploymentOutput{ - DeployedOutputResources: []rpv1.OutputResource{ - { - LocalID: rpv1.LocalIDDaprStateStoreAzureStorage, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.DaprStateStoreAzureStorage, - Provider: resourcemodel.ProviderAzure, - }, - Data: resourcemodel.ARMIdentity{}, - }, - RadiusManaged: to.Ptr(true), - Dependencies: []rpv1.Dependency{ - { - LocalID: "", - }, - }, - }, - }, - ComputedValues: map[string]any{}, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := tt.dss.ApplyDeploymentOutput(*tt.do); (err != nil) != tt.wantErr { - t.Errorf("DaprStateStore.ApplyDeploymentOutput() error = %v, wantErr %v", err, tt.wantErr) - } - - if !tt.wantErr { - require.EqualValues(t, tt.do.DeployedOutputResources, tt.dss.Properties.Status.OutputResources) - require.EqualValues(t, tt.do.ComputedValues, tt.dss.ComputedValues) - require.EqualValues(t, tt.do.SecretValues, tt.dss.SecretValues) - require.Condition(t, func() bool { - if tt.do.ComputedValues[renderers.ComponentNameKey] != nil { - return tt.dss.Properties.ComponentName == tt.do.ComputedValues[renderers.ComponentNameKey] - } - return tt.dss.Properties.ComponentName == "" - }, "component name should be equal") - } - }) - } -} diff --git a/pkg/linkrp/datamodel/doc.go b/pkg/linkrp/datamodel/doc.go deleted file mode 100644 index 81ecd10f0b..0000000000 --- a/pkg/linkrp/datamodel/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This is the version nuetral data model. Structures present in this package must be used internally. -// API version specific models should be exist under /pkg/linkrp/api. This api package should be able -// to convert among the versions. - -package datamodel diff --git a/pkg/linkrp/datamodel/extender.go b/pkg/linkrp/datamodel/extender.go deleted file mode 100644 index 64222be6d1..0000000000 --- a/pkg/linkrp/datamodel/extender.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// Extender represents Extender link resource. -type Extender struct { - v1.BaseResource - - // Properties is the properties of the resource. - Properties ExtenderProperties `json:"properties"` - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata -} - -// ApplyDeploymentOutput updates the Status of Properties of the Extender resource with the DeployedOutputResources and returns no error. -func (r *Extender) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - return nil -} - -// OutputResources returns the OutputResources of the Extender resource. -func (r *Extender) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the Extender resource. -func (r *Extender) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// ResourceTypeName returns the resource type of the extender resource. -func (extender *Extender) ResourceTypeName() string { - return linkrp.ExtendersResourceType -} - -// Recipe returns the LinkRecipe associated with the Extender if the ResourceProvisioning is not set to Manual, -// otherwise it returns nil. -func (extender *Extender) Recipe() *linkrp.LinkRecipe { - if extender.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &extender.Properties.Recipe -} - -// ExtenderProperties represents the properties of Extender resource. -type ExtenderProperties struct { - rpv1.BasicResourceProperties - // Additional properties for the resource - AdditionalProperties map[string]any `json:"additionalProperties,omitempty"` - // Secrets values provided for the resource - Secrets map[string]any `json:"secrets,omitempty"` - // The recipe used to automatically deploy underlying infrastructure for the Extender - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` -} diff --git a/pkg/linkrp/datamodel/linkmetadata.go b/pkg/linkrp/datamodel/linkmetadata.go deleted file mode 100644 index ac02d56066..0000000000 --- a/pkg/linkrp/datamodel/linkmetadata.go +++ /dev/null @@ -1,48 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// LinkMetadata represents internal DataModel properties common to all link types. -type LinkMetadata struct { - // ComputedValues map is any resource values that will be needed for more operations. - // For example; database name to generate secrets for cosmos DB. - ComputedValues map[string]any `json:"computedValues,omitempty"` - - // Stores action to retrieve secret values. For Azure, connectionstring is accessed through cosmos listConnectionString operation, if secrets are not provided as input - SecretValues map[string]rpv1.SecretValueReference `json:"secretValues,omitempty"` - - RecipeData linkrp.RecipeData `json:"recipeData,omitempty"` -} - -// LinkMode specifies how to build a Link. Options are to build automatically via ‘recipe’ or ‘resource’, or build manually via ‘values’. Selection determines which set of fields to additionally require. -type LinkMode string - -const ( - // LinkModeRecipe is the recipe mode for link deployment - LinkModeRecipe LinkMode = "recipe" - // LinkModeResource is the resource mode for link deployment - LinkModeResource LinkMode = "resource" - // LinkModeResource is the values mode for link deployment - LinkModeValues LinkMode = "values" - // RecipeContextParameter is the parameter context for recipe deployment - RecipeContextParameter string = "context" -) diff --git a/pkg/linkrp/datamodel/mongodatabase.go b/pkg/linkrp/datamodel/mongodatabase.go deleted file mode 100644 index bcd599cb94..0000000000 --- a/pkg/linkrp/datamodel/mongodatabase.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "fmt" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/renderers" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// MongoDatabase represents MongoDatabase link resource. -type MongoDatabase struct { - v1.BaseResource - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata - - // Properties is the properties of the resource. - Properties MongoDatabaseProperties `json:"properties"` -} - -// MongoDatabaseProperties represents the properties of MongoDatabase resource. -type MongoDatabaseProperties struct { - rpv1.BasicResourceProperties - // Secrets values provided for the resource - Secrets MongoDatabaseSecrets `json:"secrets,omitempty"` - // Host name of the target Mongo database - Host string `json:"host,omitempty"` - // Port value of the target Mongo database - Port int32 `json:"port,omitempty"` - // Database name of the target Mongo database - Database string `json:"database,omitempty"` - // The recipe used to automatically deploy underlying infrastructure for the MongoDB link - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - // List of the resource IDs that support the MongoDB resource - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` - // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - // Username of the Mongo database - Username string `json:"username,omitempty"` -} - -// Secrets values consisting of secrets provided for the resource -type MongoDatabaseSecrets struct { - Password string `json:"password"` - ConnectionString string `json:"connectionString"` -} - -// IsEmpty checks if the MongoDatabaseSecrets instance is empty. -func (mongoSecrets MongoDatabaseSecrets) IsEmpty() bool { - return mongoSecrets == MongoDatabaseSecrets{} -} - -// VerifyInputs checks if the manual resource provisioning fields are set and returns an error if any of them are missing. -func (mongodb *MongoDatabase) VerifyInputs() error { - msgs := []string{} - if mongodb.Properties.ResourceProvisioning != "" && mongodb.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - if mongodb.Properties.Host == "" { - msgs = append(msgs, "host must be specified when resourceProvisioning is set to manual") - } - if mongodb.Properties.Port == 0 { - msgs = append(msgs, "port must be specified when resourceProvisioning is set to manual") - } - if mongodb.Properties.Database == "" { - msgs = append(msgs, "database must be specified when resourceProvisioning is set to manual") - } - } - - if len(msgs) == 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: msgs[0], - } - } else if len(msgs) > 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: fmt.Sprintf("multiple errors were found:\n\t%v", strings.Join(msgs, "\n\t")), - } - } - - return nil -} - -// ApplyDeploymentOutput updates the MongoDatabase instance's database property, output resources, computed values -// and secret values with the given DeploymentOutput. -func (r *MongoDatabase) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - r.ComputedValues = do.ComputedValues - r.SecretValues = do.SecretValues - if database, ok := do.ComputedValues[renderers.DatabaseNameValue].(string); ok { - r.Properties.Database = database - } - - return nil -} - -// OutputResources returns the OutputResources of the MongoDatabase instance. -func (r *MongoDatabase) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the MongoDatabase instance i.e. application resource metadata. -func (r *MongoDatabase) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// Recipe returns the LinkRecipe associated with the MongoDatabase instance, or nil if the -// ResourceProvisioning is set to Manual. -func (r *MongoDatabase) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &r.Properties.Recipe -} - -// ResourceTypeName returns the resource type for MongoDatabase resource. -func (mongoSecrets *MongoDatabaseSecrets) ResourceTypeName() string { - return linkrp.MongoDatabasesResourceType -} - -// ResourceTypeName returns the resource type for MongoDatabase resource. -func (mongo *MongoDatabase) ResourceTypeName() string { - return linkrp.MongoDatabasesResourceType -} diff --git a/pkg/linkrp/datamodel/rabbitmq.go b/pkg/linkrp/datamodel/rabbitmq.go deleted file mode 100644 index 1bf8f4c7c2..0000000000 --- a/pkg/linkrp/datamodel/rabbitmq.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "fmt" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// RabbitMQMessageQueue represents RabbitMQMessageQueue link resource. -type RabbitMQMessageQueue struct { - v1.BaseResource - - // Properties is the properties of the resource. - Properties RabbitMQMessageQueueProperties `json:"properties"` - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata -} - -// ApplyDeploymentOutput updates the output resources of the RabbitMQMessageQueue resource with -// the DeployedOutputResources. -func (r *RabbitMQMessageQueue) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - return nil -} - -// OutputResources returns the OutputResources of the RabbitMQMessageQueue resource. -func (r *RabbitMQMessageQueue) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the RabbitMQMessageQueue resource. -func (r *RabbitMQMessageQueue) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// ResourceTypeName returns the resource type for RabbitMQMessageQueue resource. -func (rabbitmq *RabbitMQMessageQueue) ResourceTypeName() string { - return linkrp.RabbitMQMessageQueuesResourceType -} - -// RabbitMQMessageQueueProperties represents the properties of RabbitMQMessageQueue response resource. -type RabbitMQMessageQueueProperties struct { - rpv1.BasicResourceProperties - Queue string `json:"queue,omitempty"` - Host string `json:"host,omitempty"` - Port int32 `json:"port,omitempty"` - VHost string `json:"vHost,omitempty"` - Username string `json:"username,omitempty"` - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - Secrets RabbitMQSecrets `json:"secrets,omitempty"` - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - TLS bool `json:"tls,omitempty"` -} - -// Secrets values consisting of secrets provided for the resource -type RabbitMQSecrets struct { - URI string `json:"uri,omitempty"` - Password string `json:"password,omitempty"` -} - -// ResourceTypeName returns the resource type for RabbitMQMessageQueue resource. -func (rabbitmq RabbitMQSecrets) ResourceTypeName() string { - return linkrp.RabbitMQMessageQueuesResourceType -} - -// Recipe returns the LinkRecipe associated with the RabbitMQMessageQueue resource, or nil if the -// ResourceProvisioning is set to Manual. -func (r *RabbitMQMessageQueue) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &r.Properties.Recipe -} - -// VerifyInputs checks if the required fields are present in the RabbitMQMessageQueue instance and returns an error if not. -func (rabbitmq *RabbitMQMessageQueue) VerifyInputs() error { - properties := rabbitmq.Properties - msgs := []string{} - if properties.ResourceProvisioning != "" && properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - if properties.Queue == "" { - return &v1.ErrClientRP{Code: "Bad Request", Message: fmt.Sprintf("queue is required when resourceProvisioning is %s", linkrp.ResourceProvisioningManual)} - } - if properties.Host == "" { - msgs = append(msgs, "host must be specified when resourceProvisioning is set to manual") - } - if properties.Port == 0 { - msgs = append(msgs, "port must be specified when resourceProvisioning is set to manual") - } - if properties.Username == "" && properties.Secrets.Password != "" { - msgs = append(msgs, "username must be provided with password") - } - } - if len(msgs) == 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: msgs[0], - } - } else if len(msgs) > 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: fmt.Sprintf("multiple errors were found:\n\t%v", strings.Join(msgs, "\n\t")), - } - } - return nil -} diff --git a/pkg/linkrp/datamodel/rediscache.go b/pkg/linkrp/datamodel/rediscache.go deleted file mode 100644 index 11d42c10d6..0000000000 --- a/pkg/linkrp/datamodel/rediscache.go +++ /dev/null @@ -1,169 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "errors" - "fmt" - "strconv" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/renderers" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// RedisCache represents RedisCache link resource. -type RedisCache struct { - v1.BaseResource - - // Properties is the properties of the resource. - Properties RedisCacheProperties `json:"properties"` - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata -} - -// ApplyDeploymentOutput sets the Status, ComputedValues, SecretValues, Host, Port and Username properties of the -// RedisCache instance based on the DeploymentOutput object. -func (r *RedisCache) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - r.ComputedValues = do.ComputedValues - r.SecretValues = do.SecretValues - if host, ok := do.ComputedValues[renderers.Host].(string); ok { - r.Properties.Host = host - } - if port, ok := do.ComputedValues[renderers.Port]; ok { - if port != nil { - switch p := port.(type) { - case float64: - r.Properties.Port = int32(p) - case int32: - r.Properties.Port = p - case string: - converted, err := strconv.Atoi(p) - if err != nil { - return err - } - r.Properties.Port = int32(converted) - default: - return errors.New("unhandled type for the property port") - } - } - } - if username, ok := do.ComputedValues[renderers.UsernameStringValue].(string); ok { - r.Properties.Username = username - } - return nil -} - -// OutputResources returns the OutputResources of the RedisCache resource. -func (r *RedisCache) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the RedisCache resource. -func (r *RedisCache) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// ResourceTypeName returns the resource type of RedisCache resource. -func (redis *RedisCache) ResourceTypeName() string { - return linkrp.RedisCachesResourceType -} - -// Recipe returns the LinkRecipe from the RedisCache Properties if ResourceProvisioning is not set to Manual, -// otherwise it returns nil. -func (redis *RedisCache) Recipe() *linkrp.LinkRecipe { - if redis.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &redis.Properties.Recipe -} - -// IsEmpty checks if the RedisCacheSecrets instance is empty or not. -func (redisSecrets *RedisCacheSecrets) IsEmpty() bool { - return redisSecrets == nil || *redisSecrets == RedisCacheSecrets{} -} - -// VerifyInputs checks if the required fields are set when the resourceProvisioning is set to manual -// and returns an error if not. -func (redisCache *RedisCache) VerifyInputs() error { - msgs := []string{} - if redisCache.Properties.ResourceProvisioning != "" && redisCache.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - if redisCache.Properties.Host == "" { - msgs = append(msgs, "host must be specified when resourceProvisioning is set to manual") - } - if redisCache.Properties.Port == 0 { - msgs = append(msgs, "port must be specified when resourceProvisioning is set to manual") - } - } - - if len(msgs) == 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: msgs[0], - } - } else if len(msgs) > 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: fmt.Sprintf("multiple errors were found:\n\t%v", strings.Join(msgs, "\n\t")), - } - } - - return nil -} - -type RedisCacheProperties struct { - rpv1.BasicResourceProperties - // The host name of the target Redis cache - Host string `json:"host,omitempty"` - - // The port value of the target Redis cache - Port int32 `json:"port,omitempty"` - - // The username for Redis cache - Username string `json:"username,omitempty"` - - // Specifies whether to enable non-SSL or SSL connections - TLS bool `json:"tls,omitempty"` - - // The recipe used to automatically deploy underlying infrastructure for the Redis caches link - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - - // Secrets provided by resource - Secrets RedisCacheSecrets `json:"secrets,omitempty"` - - // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - - // List of the resource IDs that support the Redis resource - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` -} - -// Secrets values consisting of secrets provided for the resource -type RedisCacheSecrets struct { - ConnectionString string `json:"connectionString"` - Password string `json:"password"` - URL string `json:"url"` -} - -// ResourceTypeName returns the resource type of RedisCache resource. -func (redis RedisCacheSecrets) ResourceTypeName() string { - return linkrp.RedisCachesResourceType -} diff --git a/pkg/linkrp/datamodel/sqldatabase.go b/pkg/linkrp/datamodel/sqldatabase.go deleted file mode 100644 index 62e933c71f..0000000000 --- a/pkg/linkrp/datamodel/sqldatabase.go +++ /dev/null @@ -1,139 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -import ( - "fmt" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// Recipe returns the LinkRecipe associated with the SqlDatabase instance if the ResourceProvisioning is not -// set to Manual, otherwise it returns nil. -func (sql *SqlDatabase) Recipe() *linkrp.LinkRecipe { - if sql.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - return nil - } - return &sql.Properties.Recipe -} - -// SqlDatabase represents SqlDatabase link resource. -type SqlDatabase struct { - v1.BaseResource - - // Properties is the properties of the resource. - Properties SqlDatabaseProperties `json:"properties"` - - // LinkMetadata represents internal DataModel properties common to all link types. - LinkMetadata -} - -// ApplyDeploymentOutput updates the output resources of a SqlDatabase resource with the output resources of a DeploymentOutput -// object and returns no error. -func (r *SqlDatabase) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources - return nil -} - -// OutputResources returns the OutputResources of the SqlDatabase resource. -func (r *SqlDatabase) OutputResources() []rpv1.OutputResource { - return r.Properties.Status.OutputResources -} - -// ResourceMetadata returns the BasicResourceProperties of the SqlDatabase resource. -func (r *SqlDatabase) ResourceMetadata() *rpv1.BasicResourceProperties { - return &r.Properties.BasicResourceProperties -} - -// ResourceTypeName returns the resource type of the SqlDatabase resource. -func (sql *SqlDatabase) ResourceTypeName() string { - return linkrp.SqlDatabasesResourceType -} - -// SqlDatabaseProperties represents the properties of SqlDatabase resource. -type SqlDatabaseProperties struct { - rpv1.BasicResourceProperties - // The recipe used to automatically deploy underlying infrastructure for the SqlDB link - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - // Database name of the target Sql database - Database string `json:"database,omitempty"` - // The fully qualified domain name of the Sql database - Server string `json:"server,omitempty"` - // Port value of the target Sql database - Port int32 `json:"port,omitempty"` - // Specifies how the underlying service/resource is provisioned and managed - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - // List of the resource IDs that support the SqlDB resource - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` - // Username of the Sql database - Username string `json:"username,omitempty"` - // Secrets values provided for the resource - Secrets SqlDatabaseSecrets `json:"secrets,omitempty"` -} - -// Secrets values consisting of secrets provided for the resource -type SqlDatabaseSecrets struct { - Password string `json:"password"` - ConnectionString string `json:"connectionString"` -} - -// VerifyInputs checks that the inputs for manual resource provisioning are all provided -// - -// VerifyInputs checks if the required fields are set when the resourceProvisioning is set to manual and returns an error -// if any of the required fields are not set. -func (sql *SqlDatabase) VerifyInputs() error { - msgs := []string{} - if sql.Properties.ResourceProvisioning != "" && sql.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { - if sql.Properties.Server == "" { - msgs = append(msgs, "server must be specified when resourceProvisioning is set to manual") - } - if sql.Properties.Port == 0 { - msgs = append(msgs, "port must be specified when resourceProvisioning is set to manual") - } - if sql.Properties.Database == "" { - msgs = append(msgs, "database must be specified when resourceProvisioning is set to manual") - } - } - - if len(msgs) == 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: msgs[0], - } - } else if len(msgs) > 1 { - return &v1.ErrClientRP{ - Code: v1.CodeInvalid, - Message: fmt.Sprintf("multiple errors were found:\n\t%v", strings.Join(msgs, "\n\t")), - } - } - - return nil -} - -// IsEmpty checks if the SqlDatabaseSecrets struct is empty. -func (sqlSecrets SqlDatabaseSecrets) IsEmpty() bool { - return sqlSecrets == SqlDatabaseSecrets{} -} - -// ResourceTypeName returns the resource type of the SqlDatabase resource. -func (sqlSecrets *SqlDatabaseSecrets) ResourceTypeName() string { - return linkrp.SqlDatabasesResourceType -} diff --git a/pkg/linkrp/frontend/controller/extenders/listsecretsextender.go b/pkg/linkrp/frontend/controller/extenders/listsecretsextender.go deleted file mode 100644 index f0c948b2b8..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/listsecretsextender.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package extenders - -import ( - "context" - "net/http" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/datamodel/converter" -) - -var _ ctrl.Controller = (*ListSecretsExtender)(nil) - -// ListSecretsExtender is the controller implementation to list secrets for the to access the connected extender resource resource id passed in the request body. -type ListSecretsExtender struct { - ctrl.Operation[*datamodel.Extender, datamodel.Extender] -} - -// NewListSecretsExtender creates a new instance of ListSecretsExtender. -func NewListSecretsExtender(opts ctrl.Options) (ctrl.Controller, error) { - return &ListSecretsExtender{ - Operation: ctrl.NewOperation(opts, - ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - }), - }, nil -} - -// Run returns secrets values for the specified Extender resource -func (ctrl *ListSecretsExtender) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { - sCtx := v1.ARMRequestContextFromContext(ctx) - - // Request route for listsecrets has name of the operation as suffix which should be removed to get the resource id. - // route id format: subscriptions//resourceGroups//providers/Applications.Link/extenders//listsecrets - parsedResourceID := sCtx.ResourceID.Truncate() - resource, _, err := ctrl.GetResource(ctx, parsedResourceID) - if err != nil { - return nil, err - } - - if resource == nil { - return rest.NewNotFoundResponse(sCtx.ResourceID), nil - } - - secrets := map[string]string{} - for key, secret := range resource.SecretValues { - secrets[key] = secret.Value - } - - return rest.NewOKResponse(secrets), nil -} diff --git a/pkg/linkrp/frontend/controller/extenders/listsecretsextender_test.go b/pkg/linkrp/frontend/controller/extenders/listsecretsextender_test.go deleted file mode 100644 index c788061996..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/listsecretsextender_test.go +++ /dev/null @@ -1,148 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package extenders - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/http/httptest" - "testing" - - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/store" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" -) - -func TestListSecrets_20220315PrivatePreview(t *testing.T) { - setupTest := func(tb testing.TB) (func(tb testing.TB), *store.MockStorageClient, *statusmanager.MockStatusManager) { - mctrl := gomock.NewController(t) - mds := store.NewMockStorageClient(mctrl) - msm := statusmanager.NewMockStatusManager(mctrl) - - return func(tb testing.TB) { - mctrl.Finish() - }, mds, msm - } - ctx := context.Background() - - _, extenderDataModel, _ := getTestModels20220315privatepreview() - expectedSecrets := map[string]any{ - "accountSid": "sid", - "authToken:": "token", - } - - t.Run("listSecrets non-existing resource", func(t *testing.T) { - teardownTest, mds, msm := setupTest(t) - defer teardownTest(t) - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - - mds. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, &store.ErrNotFound{ID: id} - }) - - opts := ctrl.Options{ - StorageClient: mds, - StatusManager: msm, - } - - ctl, err := NewListSecretsExtender(opts) - - require.NoError(t, err) - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - _ = resp.Apply(ctx, w, req) - require.Equal(t, 404, w.Result().StatusCode) - }) - - t.Run("listSecrets existing resource", func(t *testing.T) { - teardownTest, mds, msm := setupTest(t) - defer teardownTest(t) - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - - mds. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: extenderDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mds, - StatusManager: msm, - } - - ctl, err := NewListSecretsExtender(opts) - - require.NoError(t, err) - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := map[string]any{} - _ = json.Unmarshal(w.Body.Bytes(), &actualOutput) - - require.Equal(t, expectedSecrets["accountSid"], actualOutput["accountSid"]) - require.Equal(t, expectedSecrets["authToken"], actualOutput["authToken"]) - }) - - t.Run("listSecrets error retrieving resource", func(t *testing.T) { - teardownTest, mds, msm := setupTest(t) - defer teardownTest(t) - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - w := httptest.NewRecorder() - - mds. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, errors.New("failed to get the resource from data store") - }) - - opts := ctrl.Options{ - StorageClient: mds, - StatusManager: msm, - } - - ctl, err := NewListSecretsExtender(opts) - - require.NoError(t, err) - _, err = ctl.Run(ctx, w, req) - require.Error(t, err) - }) - -} diff --git a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_datamodel.json b/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_datamodel.json deleted file mode 100644 index 61ee87a2eb..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_datamodel.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/extenders/extender0", - "name": "extender0", - "type": "applications.link/extenders", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "additionalProperties":{ - "fromNumber": "222-222-2222" - }, - "secrets": { - "accountSid": "sid", - "authToken:": "token" - } - }, - "computedValues": { - "fromNumber": "222-222-2222" - }, - "secretValues": { - "accountSid": { - "value": "sid" - }, - "authToken:": { - "value": "token" - } - }, - "resourceProvisioning": "manual", - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_input.json b/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_input.json deleted file mode 100644 index 42988b83f8..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_input.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_input_diff_env.json b/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_input_diff_env.json deleted file mode 100644 index 51cff92fd1..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_input_diff_env.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/invalid", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_output.json b/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_output.json deleted file mode 100644 index b703b37f04..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_output.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/extenders/extender0", - "location": "West US", - "name": "extender0", - "properties": { - "status": { - "outputResources": null - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual", - "provisioningState": "Succeeded" - }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "tags": {}, - "type": "applications.link/extenders" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_requestheaders.json b/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_requestheaders.json deleted file mode 100644 index 22a1e736a9..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreview_requestheaders.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "en-US", - "Content-Length": "305", - "Content-Type": "application/json; charset=utf-8", - "Referer": "https://radius.dev/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/extenders/extender0?api-version=2022-03-15-privatepreview", - "Traceparent": "00-000011048df2134ca37c9a689c3a0000-0000000000000000-01", - "User-Agent": "ARMClient/1.6.0.0", - "Via": "1.1 Azure", - "X-Azure-Requestchain": "hops=1", - "X-Fd-Clienthttpversion": "1.1", - "X-Fd-Clientip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Fd-Edgeenvironment": "fake", - "X-Fd-Eventid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Impressionguid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Originalurl": "https://radius.dev:443/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/extenders/extender0?api-version=2022-03-15-privatepreview", - "X-Fd-Partner": "AzureResourceManager_Test", - "X-Fd-Ref": "Ref A: xxxx Ref B: xxxx Ref C: 2022-03-22T18:54:50Z", - "X-Fd-Revip": "country=United States,iso=us,state=Washington,city=Redmond,zip=00000,tz=-8,asn=0,lat=0,long=-1,countrycf=8,citycf=8", - "X-Fd-Routekey": "000075000", - "X-Fd-Socketip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Forwarded-For": "192.168.0.10", - "X-Forwarded-Host": "radius.dev", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https", - "X-Forwarded-Scheme": "https", - "X-Ms-Activity-Vector": "IN.0P", - "X-Ms-Arm-Network-Source": "PublicNetwork", - "X-Ms-Arm-Request-Tracking-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Arm-Resource-System-Data": "{\"lastModifiedBy\":\"fake@hotmail.com\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2022-03-22T18:57:52.6857175Z\"}", - "X-Ms-Arm-Service-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Acr": "1", - "X-Ms-Client-Alt-Sec-Id": "1:live.com:0006000017E40000", - "X-Ms-Client-App-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-App-Id-Acr": "0", - "X-Ms-Client-Audience": "https://management.core.windows.net/", - "X-Ms-Client-Authentication-Methods": "pwd", - "X-Ms-Client-Authorization-Source": "RoleBased", - "X-Ms-Client-Family-Name-Encoded": "fake", - "X-Ms-Client-Given-Name-Encoded": "fake", - "X-Ms-Client-Identity-Provider": "live.com", - "X-Ms-Client-Ip-Address": "192.168.0.10", - "X-Ms-Client-Issuer": "https://sts.windows-ppe.net/00000000-0000-0000-0000-000000000000/", - "X-Ms-Client-Location": "centralus", - "X-Ms-Client-Object-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Principal-Group-Membership-Source": "Token", - "X-Ms-Client-Principal-Id": "000000000000000", - "X-Ms-Client-Principal-Name": "live.com#fake@hotmail.com", - "X-Ms-Client-Puid": "000000000000000", - "X-Ms-Client-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Scope": "user_impersonation", - "X-Ms-Client-Tenant-Id": "00000000-0000-0000-0000-000000000001", - "X-Ms-Client-Wids": "00000000-0000-0000-0000-000000000000, 00000000-0000-0000-0000-000000000001", - "X-Ms-Correlation-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Home-Tenant-Id": "00000000-0000-0000-0000-000000000002", - "X-Ms-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Routing-Request-Id": "CENTRALUS:20220322T185452Z:00000000-0000-0000-0000-000000000000", - "X-Original-Forwarded-For": "0000:0000:0000:1:449b:f928:e40a:a351", - "X-Real-Ip": "192.168.0.10", - "X-Request-Id": "1000f6040000000000004bc7d1666424", - "X-Scheme": "https" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreviewgetandlist_output.json b/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreviewgetandlist_output.json deleted file mode 100644 index 0a36cafbd2..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/testdata/20220315privatepreviewgetandlist_output.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/extenders/extender0", - "location": "West US", - "name": "extender0", - "properties": { - "status": { - "outputResources": null - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "resourceProvisioning": "manual", - "provisioningState": "Succeeded" - }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "tags": {}, - "type": "applications.link/extenders" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/extenders/types.go b/pkg/linkrp/frontend/controller/extenders/types.go deleted file mode 100644 index 62a0d3668e..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package extenders - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/linkrp/frontend/controller/extenders/v20220315privatepreview_test.go b/pkg/linkrp/frontend/controller/extenders/v20220315privatepreview_test.go deleted file mode 100644 index f6567a8034..0000000000 --- a/pkg/linkrp/frontend/controller/extenders/v20220315privatepreview_test.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package extenders - -import ( - "encoding/json" - - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/test/testutil" -) - -const testHeaderfile = "20220315privatepreview_requestheaders.json" - -func getTestModels20220315privatepreview() (input *v20220315privatepreview.ExtenderResource, dataModel *datamodel.Extender, output *v20220315privatepreview.ExtenderResource) { - rawInput := testutil.ReadFixture("20220315privatepreview_input.json") - input = &v20220315privatepreview.ExtenderResource{} - _ = json.Unmarshal(rawInput, input) - - rawDataModel := testutil.ReadFixture("20220315privatepreview_datamodel.json") - dataModel = &datamodel.Extender{} - _ = json.Unmarshal(rawDataModel, dataModel) - - rawExpectedOutput := testutil.ReadFixture("20220315privatepreview_output.json") - output = &v20220315privatepreview.ExtenderResource{} - _ = json.Unmarshal(rawExpectedOutput, output) - - return input, dataModel, output -} diff --git a/pkg/linkrp/frontend/controller/mongodatabases/listsecretsmongodatabase.go b/pkg/linkrp/frontend/controller/mongodatabases/listsecretsmongodatabase.go deleted file mode 100644 index 056ad749f1..0000000000 --- a/pkg/linkrp/frontend/controller/mongodatabases/listsecretsmongodatabase.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mongodatabases - -import ( - "context" - "net/http" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/datamodel/converter" - "github.com/project-radius/radius/pkg/linkrp/renderers" -) - -var _ ctrl.Controller = (*ListSecretsMongoDatabase)(nil) - -// ListSecretsMongoDatabase is the controller implementation to list secrets for the to access the connected mongo database resource resource id passed in the request body. -type ListSecretsMongoDatabase struct { - ctrl.Operation[*datamodel.MongoDatabase, datamodel.MongoDatabase] -} - -// NewListSecretsMongoDatabase creates a new instance of ListSecretsMongoDatabase, or an error if the controller could not be created. -func NewListSecretsMongoDatabase(opts ctrl.Options) (ctrl.Controller, error) { - return &ListSecretsMongoDatabase{ - Operation: ctrl.NewOperation(opts, - ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - }), - }, nil -} - -// Run returns secrets values for the specified MongoDatabase resource -func (ctrl *ListSecretsMongoDatabase) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { - sCtx := v1.ARMRequestContextFromContext(ctx) - - parsedResourceID := sCtx.ResourceID.Truncate() - resource, _, err := ctrl.GetResource(ctx, parsedResourceID) - if err != nil { - return nil, err - } - - if resource == nil { - return rest.NewNotFoundResponse(sCtx.ResourceID), nil - } - - mongoSecrets := datamodel.MongoDatabaseSecrets{} - if password, ok := resource.SecretValues[renderers.PasswordStringHolder]; ok { - mongoSecrets.Password = password.Value - } - if connectionString, ok := resource.SecretValues[renderers.ConnectionStringValue]; ok { - mongoSecrets.ConnectionString = connectionString.Value - } - - versioned, _ := converter.MongoDatabaseSecretsDataModelToVersioned(&mongoSecrets, sCtx.APIVersion) - return rest.NewOKResponse(versioned), nil -} diff --git a/pkg/linkrp/frontend/controller/mongodatabases/listsecretsmongodatabase_test.go b/pkg/linkrp/frontend/controller/mongodatabases/listsecretsmongodatabase_test.go deleted file mode 100644 index 244fd81e5f..0000000000 --- a/pkg/linkrp/frontend/controller/mongodatabases/listsecretsmongodatabase_test.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mongodatabases - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/http/httptest" - "testing" - - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/ucp/store" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" -) - -func TestListSecrets_20220315PrivatePreview(t *testing.T) { - mctrl := gomock.NewController(t) - defer mctrl.Finish() - - mStorageClient := store.NewMockStorageClient(mctrl) - ctx := context.Background() - - _, mongoDataModel, _ := getTestModels20220315privatepreview() - - t.Run("listSecrets non-existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, &store.ErrNotFound{ID: id} - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsMongoDatabase(opts) - - require.NoError(t, err) - resp, err := ctl.Run(ctx, w, req) - - require.NoError(t, err) - _ = resp.Apply(ctx, w, req) - require.Equal(t, 404, w.Result().StatusCode) - }) - - t.Run("listSecrets existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - expectedSecrets := map[string]any{ - renderers.UsernameStringValue: "testUser", - renderers.PasswordStringHolder: "testPassword", - renderers.ConnectionStringValue: "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255", - } - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: mongoDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsMongoDatabase(opts) - require.NoError(t, err) - - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := &v20220315privatepreview.MongoDatabaseSecrets{} - _ = json.Unmarshal(w.Body.Bytes(), actualOutput) - - require.Equal(t, expectedSecrets[renderers.ConnectionStringValue], *actualOutput.ConnectionString) - require.Equal(t, expectedSecrets[renderers.PasswordStringHolder], *actualOutput.Password) - }) - - t.Run("listSecrets existing resource partial secrets", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - expectedSecrets := map[string]any{ - renderers.UsernameStringValue: "testUser", - renderers.ConnectionStringValue: "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255", - } - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: mongoDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsMongoDatabase(opts) - require.NoError(t, err) - - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := &v20220315privatepreview.MongoDatabaseSecrets{} - _ = json.Unmarshal(w.Body.Bytes(), actualOutput) - - require.Equal(t, expectedSecrets[renderers.ConnectionStringValue], *actualOutput.ConnectionString) - }) - - t.Run("listSecrets error retrieving resource", func(t *testing.T) { - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - w := httptest.NewRecorder() - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, errors.New("failed to get the resource from data store") - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsMongoDatabase(opts) - require.NoError(t, err) - - _, err = ctl.Run(ctx, w, req) - require.Error(t, err) - }) - -} diff --git a/pkg/linkrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_datamodel.json b/pkg/linkrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_datamodel.json deleted file mode 100644 index 431090ce3d..0000000000 --- a/pkg/linkrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_datamodel.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/mongodatabases/mongo0", - "name": "mongo0", - "type": "applications.link/mongodatabases", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "AzureCosmosAccount", - "Dependencies": null, - "ResourceType": { - "type": "azure.cosmosdb.account", - "provider": "azure" - } - } - ] - }, - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" - } - ], - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "secrets": { - "username": "testUser", - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - }, - "database": "db" - }, - "computedValues": { - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255 - }, - "secretValues": { - "username": { - "value": "testUser" - }, - "password": { - "value": "testPassword" - }, - "connectionString": { - "value": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - } - }, - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_requestheaders.json b/pkg/linkrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_requestheaders.json deleted file mode 100644 index 8a8af67d72..0000000000 --- a/pkg/linkrp/frontend/controller/mongodatabases/testdata/20220315privatepreview_requestheaders.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "en-US", - "Content-Length": "305", - "Content-Type": "application/json; charset=utf-8", - "Referer": "https://radius.dev/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/mongodatabases/mongo0?api-version=2022-03-15-privatepreview", - "Traceparent": "00-000011048df2134ca37c9a689c3a0000-0000000000000000-01", - "User-Agent": "ARMClient/1.6.0.0", - "Via": "1.1 Azure", - "X-Azure-Requestchain": "hops=1", - "X-Fd-Clienthttpversion": "1.1", - "X-Fd-Clientip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Fd-Edgeenvironment": "fake", - "X-Fd-Eventid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Impressionguid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Originalurl": "https://radius.dev:443/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/mongodatabase/mongo0?api-version=2022-03-15-privatepreview", - "X-Fd-Partner": "AzureResourceManager_Test", - "X-Fd-Ref": "Ref A: xxxx Ref B: xxxx Ref C: 2022-03-22T18:54:50Z", - "X-Fd-Revip": "country=United States,iso=us,state=Washington,city=Redmond,zip=00000,tz=-8,asn=0,lat=0,long=-1,countrycf=8,citycf=8", - "X-Fd-Routekey": "000075000", - "X-Fd-Socketip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Forwarded-For": "192.168.0.10", - "X-Forwarded-Host": "radius.dev", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https", - "X-Forwarded-Scheme": "https", - "X-Ms-Activity-Vector": "IN.0P", - "X-Ms-Arm-Network-Source": "PublicNetwork", - "X-Ms-Arm-Request-Tracking-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Arm-Resource-System-Data": "{\"lastModifiedBy\":\"fake@hotmail.com\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2022-03-22T18:57:52.6857175Z\"}", - "X-Ms-Arm-Service-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Acr": "1", - "X-Ms-Client-Alt-Sec-Id": "1:live.com:0006000017E40000", - "X-Ms-Client-App-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-App-Id-Acr": "0", - "X-Ms-Client-Audience": "https://management.core.windows.net/", - "X-Ms-Client-Authentication-Methods": "pwd", - "X-Ms-Client-Authorization-Source": "RoleBased", - "X-Ms-Client-Family-Name-Encoded": "fake", - "X-Ms-Client-Given-Name-Encoded": "fake", - "X-Ms-Client-Identity-Provider": "live.com", - "X-Ms-Client-Ip-Address": "192.168.0.10", - "X-Ms-Client-Issuer": "https://sts.windows-ppe.net/00000000-0000-0000-0000-000000000000/", - "X-Ms-Client-Location": "centralus", - "X-Ms-Client-Object-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Principal-Group-Membership-Source": "Token", - "X-Ms-Client-Principal-Id": "000000000000000", - "X-Ms-Client-Principal-Name": "live.com#fake@hotmail.com", - "X-Ms-Client-Puid": "000000000000000", - "X-Ms-Client-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Scope": "user_impersonation", - "X-Ms-Client-Tenant-Id": "00000000-0000-0000-0000-000000000001", - "X-Ms-Client-Wids": "00000000-0000-0000-0000-000000000000, 00000000-0000-0000-0000-000000000001", - "X-Ms-Correlation-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Home-Tenant-Id": "00000000-0000-0000-0000-000000000002", - "X-Ms-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Routing-Request-Id": "CENTRALUS:20220322T185452Z:00000000-0000-0000-0000-000000000000", - "X-Original-Forwarded-For": "0000:0000:0000:1:449b:f928:e40a:a351", - "X-Real-Ip": "192.168.0.10", - "X-Request-Id": "1000f6040000000000004bc7d1666424", - "X-Scheme": "https" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/mongodatabases/types.go b/pkg/linkrp/frontend/controller/mongodatabases/types.go deleted file mode 100644 index c9833d3940..0000000000 --- a/pkg/linkrp/frontend/controller/mongodatabases/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mongodatabases - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/linkrp/frontend/controller/mongodatabases/v20220315privatepreview_test.go b/pkg/linkrp/frontend/controller/mongodatabases/v20220315privatepreview_test.go deleted file mode 100644 index 94eda475fb..0000000000 --- a/pkg/linkrp/frontend/controller/mongodatabases/v20220315privatepreview_test.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mongodatabases - -import ( - "encoding/json" - - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/test/testutil" -) - -const testHeaderfile = "20220315privatepreview_requestheaders.json" - -func getTestModels20220315privatepreview() (input *v20220315privatepreview.MongoDatabaseResource, dataModel *datamodel.MongoDatabase, output *v20220315privatepreview.MongoDatabaseResource) { - rawDataModel := testutil.ReadFixture("20220315privatepreview_datamodel.json") - dataModel = &datamodel.MongoDatabase{} - _ = json.Unmarshal(rawDataModel, dataModel) - - return input, dataModel, output -} diff --git a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/listsecretsrabbitmq.go b/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/listsecretsrabbitmq.go deleted file mode 100644 index 5f02d83e2c..0000000000 --- a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/listsecretsrabbitmq.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rabbitmqmessagequeues - -import ( - "context" - "net/http" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/datamodel/converter" - "github.com/project-radius/radius/pkg/linkrp/renderers" -) - -var _ ctrl.Controller = (*ListSecretsRabbitMQMessageQueue)(nil) - -// ListSecretsRabbitMQMessageQueue is the controller implementation to list secrets for the to access the connected rabbitMQ resource resource id passed in the request body. -type ListSecretsRabbitMQMessageQueue struct { - ctrl.Operation[*datamodel.RabbitMQMessageQueue, datamodel.RabbitMQMessageQueue] -} - -// NewListSecretsRabbitMQMessageQueue creates a new instance of ListSecretsRabbitMQMessageQueue. -func NewListSecretsRabbitMQMessageQueue(opts ctrl.Options) (ctrl.Controller, error) { - return &ListSecretsRabbitMQMessageQueue{ - Operation: ctrl.NewOperation(opts, - ctrl.ResourceOptions[datamodel.RabbitMQMessageQueue]{ - RequestConverter: converter.RabbitMQMessageQueueDataModelFromVersioned, - ResponseConverter: converter.RabbitMQMessageQueueDataModelToVersioned, - }), - }, nil -} - -// Run returns secrets values for the specified RabbitMQMessageQueue resource -func (ctrl *ListSecretsRabbitMQMessageQueue) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { - sCtx := v1.ARMRequestContextFromContext(ctx) - - // Request route for listsecrets has name of the operation as suffix which should be removed to get the resource id. - // route id format: subscriptions//resourceGroups//providers/Applications.Link/rabbitMQMessageQueues//listsecrets - parsedResourceID := sCtx.ResourceID.Truncate() - resource, _, err := ctrl.GetResource(ctx, parsedResourceID) - if err != nil { - return nil, err - } - - if resource == nil { - return rest.NewNotFoundResponse(sCtx.ResourceID), nil - } - - rabbitMQSecrets := datamodel.RabbitMQSecrets{} - if uri, ok := resource.SecretValues[renderers.URI]; ok { - rabbitMQSecrets.URI = uri.Value - } - if password, ok := resource.SecretValues[renderers.PasswordStringHolder]; ok { - rabbitMQSecrets.Password = password.Value - } - - versioned, _ := converter.RabbitMQSecretsDataModelToVersioned(&rabbitMQSecrets, sCtx.APIVersion) - return rest.NewOKResponse(versioned), nil -} diff --git a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/listsecretsrabbitmq_test.go b/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/listsecretsrabbitmq_test.go deleted file mode 100644 index e4e444676a..0000000000 --- a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/listsecretsrabbitmq_test.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rabbitmqmessagequeues - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/http/httptest" - "testing" - - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/ucp/store" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" -) - -func TestListSecrets_20220315PrivatePreview(t *testing.T) { - mctrl := gomock.NewController(t) - defer mctrl.Finish() - - mStorageClient := store.NewMockStorageClient(mctrl) - ctx := context.Background() - - _, rabbitMQDataModel, _ := getTestModels20220315privatepreview() - - t.Run("listSecrets non-existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, &store.ErrNotFound{ID: id} - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsRabbitMQMessageQueue(opts) - require.NoError(t, err) - - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - - _ = resp.Apply(ctx, w, req) - require.Equal(t, 404, w.Result().StatusCode) - }) - - t.Run("listSecrets existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - expectedSecrets := map[string]any{ - renderers.URI: "connection://string", - } - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: rabbitMQDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsRabbitMQMessageQueue(opts) - require.NoError(t, err) - - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := &v20220315privatepreview.RabbitMQSecrets{} - _ = json.Unmarshal(w.Body.Bytes(), actualOutput) - - require.Equal(t, expectedSecrets[renderers.URI], *actualOutput.URI) - }) - - t.Run("listSecrets error retrieving resource", func(t *testing.T) { - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - w := httptest.NewRecorder() - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, errors.New("failed to get the resource from data store") - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsRabbitMQMessageQueue(opts) - require.NoError(t, err) - - _, err = ctl.Run(ctx, w, req) - require.Error(t, err) - }) - -} diff --git a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/testdata/20220315privatepreview_datamodel.json b/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/testdata/20220315privatepreview_datamodel.json deleted file mode 100644 index 8c08b15a02..0000000000 --- a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/testdata/20220315privatepreview_datamodel.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/rabbitmqmessagequeues/rabbitmq0", - "name": "rabbitmq0", - "type": "applications.link/rabbitmqmessagequeues", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "properties": { - "status": { - "outputResources": null - }, - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "resourceProvisioning": "manual", - "queue": "testQueue", - "secrets": { - "uri": "connection://string", - "password": "password" - } - }, - "computedValues": { - "queue": "testQueue" - }, - "secretValues": { - "uri": { - "value": "connection://string" - }, - "password": { - "value": "password" - } - }, - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/testdata/20220315privatepreview_requestheaders.json b/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/testdata/20220315privatepreview_requestheaders.json deleted file mode 100644 index c99c07a811..0000000000 --- a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/testdata/20220315privatepreview_requestheaders.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "en-US", - "Content-Length": "305", - "Content-Type": "application/json; charset=utf-8", - "Referer": "https://radius.dev/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/rabbitmqmessagequeues/rabbitmq0?api-version=2022-03-15-privatepreview", - "Traceparent": "00-000011048df2134ca37c9a689c3a0000-0000000000000000-01", - "User-Agent": "ARMClient/1.6.0.0", - "Via": "1.1 Azure", - "X-Azure-Requestchain": "hops=1", - "X-Fd-Clienthttpversion": "1.1", - "X-Fd-Clientip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Fd-Edgeenvironment": "fake", - "X-Fd-Eventid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Impressionguid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Originalurl": "https://radius.dev:443/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rabbitmqmessagequeue/rabbitmq0?api-version=2022-03-15-privatepreview", - "X-Fd-Partner": "AzureResourceManager_Test", - "X-Fd-Ref": "Ref A: xxxx Ref B: xxxx Ref C: 2022-03-22T18:54:50Z", - "X-Fd-Revip": "country=United States,iso=us,state=Washington,city=Redmond,zip=00000,tz=-8,asn=0,lat=0,long=-1,countrycf=8,citycf=8", - "X-Fd-Routekey": "000075000", - "X-Fd-Socketip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Forwarded-For": "192.168.0.10", - "X-Forwarded-Host": "radius.dev", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https", - "X-Forwarded-Scheme": "https", - "X-Ms-Activity-Vector": "IN.0P", - "X-Ms-Arm-Network-Source": "PublicNetwork", - "X-Ms-Arm-Request-Tracking-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Arm-Resource-System-Data": "{\"lastModifiedBy\":\"fake@hotmail.com\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2022-03-22T18:57:52.6857175Z\"}", - "X-Ms-Arm-Service-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Acr": "1", - "X-Ms-Client-Alt-Sec-Id": "1:live.com:0006000017E40000", - "X-Ms-Client-App-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-App-Id-Acr": "0", - "X-Ms-Client-Audience": "https://management.core.windows.net/", - "X-Ms-Client-Authentication-Methods": "pwd", - "X-Ms-Client-Authorization-Source": "RoleBased", - "X-Ms-Client-Family-Name-Encoded": "fake", - "X-Ms-Client-Given-Name-Encoded": "fake", - "X-Ms-Client-Identity-Provider": "live.com", - "X-Ms-Client-Ip-Address": "192.168.0.10", - "X-Ms-Client-Issuer": "https://sts.windows-ppe.net/00000000-0000-0000-0000-000000000000/", - "X-Ms-Client-Location": "centralus", - "X-Ms-Client-Object-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Principal-Group-Membership-Source": "Token", - "X-Ms-Client-Principal-Id": "000000000000000", - "X-Ms-Client-Principal-Name": "live.com#fake@hotmail.com", - "X-Ms-Client-Puid": "000000000000000", - "X-Ms-Client-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Scope": "user_impersonation", - "X-Ms-Client-Tenant-Id": "00000000-0000-0000-0000-000000000001", - "X-Ms-Client-Wids": "00000000-0000-0000-0000-000000000000, 00000000-0000-0000-0000-000000000001", - "X-Ms-Correlation-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Home-Tenant-Id": "00000000-0000-0000-0000-000000000002", - "X-Ms-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Routing-Request-Id": "CENTRALUS:20220322T185452Z:00000000-0000-0000-0000-000000000000", - "X-Original-Forwarded-For": "0000:0000:0000:1:449b:f928:e40a:a351", - "X-Real-Ip": "192.168.0.10", - "X-Request-Id": "1000f6040000000000004bc7d1666424", - "X-Scheme": "https" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/types.go b/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/types.go deleted file mode 100644 index c9b8865de2..0000000000 --- a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rabbitmqmessagequeues - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/v20220315privatepreview_test.go b/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/v20220315privatepreview_test.go deleted file mode 100644 index 7a6922291c..0000000000 --- a/pkg/linkrp/frontend/controller/rabbitmqmessagequeues/v20220315privatepreview_test.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rabbitmqmessagequeues - -import ( - "encoding/json" - - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/test/testutil" -) - -const testHeaderfile = "20220315privatepreview_requestheaders.json" - -func getTestModels20220315privatepreview() (input *v20220315privatepreview.RabbitMQMessageQueueResource, dataModel *datamodel.RabbitMQMessageQueue, output *v20220315privatepreview.RabbitMQMessageQueueResource) { - rawDataModel := testutil.ReadFixture("20220315privatepreview_datamodel.json") - dataModel = &datamodel.RabbitMQMessageQueue{} - _ = json.Unmarshal(rawDataModel, dataModel) - - return input, dataModel, output -} diff --git a/pkg/linkrp/frontend/controller/rediscaches/listsecretsrediscache.go b/pkg/linkrp/frontend/controller/rediscaches/listsecretsrediscache.go deleted file mode 100644 index 0774e6f3fb..0000000000 --- a/pkg/linkrp/frontend/controller/rediscaches/listsecretsrediscache.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rediscaches - -import ( - "context" - "errors" - "net/http" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/datamodel/converter" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/ucp/store" -) - -var _ ctrl.Controller = (*ListSecretsRedisCache)(nil) - -// ListSecretsRedisCache is the controller implementation to list secrets for the to access the connected redis cache resource resource id passed in the request body. -type ListSecretsRedisCache struct { - ctrl.Operation[*datamodel.RedisCache, datamodel.RedisCache] -} - -// NewListSecretsRedisCache creates a new instance of ListSecretsRedisCache and returns it without an error. -func NewListSecretsRedisCache(opts ctrl.Options) (ctrl.Controller, error) { - return &ListSecretsRedisCache{ - Operation: ctrl.NewOperation(opts, - ctrl.ResourceOptions[datamodel.RedisCache]{ - RequestConverter: converter.RedisCacheDataModelFromVersioned, - ResponseConverter: converter.RedisCacheDataModelToVersioned, - }), - }, nil -} - -// Run returns secrets values for the specified RedisCache resource -func (ctrl *ListSecretsRedisCache) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { - sCtx := v1.ARMRequestContextFromContext(ctx) - - // Request route for listsecrets has name of the operation as suffix which should be removed to get the resource id. - // route id format: subscriptions//resourceGroups//providers/Applications.Link/redisCaches//listsecrets - parsedResourceID := sCtx.ResourceID.Truncate() - resource, _, err := ctrl.GetResource(ctx, parsedResourceID) - if err != nil { - if errors.Is(&store.ErrNotFound{ID: parsedResourceID.String()}, err) { - return rest.NewNotFoundResponse(sCtx.ResourceID), nil - } - return nil, err - } - - if resource == nil { - return rest.NewNotFoundResponse(sCtx.ResourceID), nil - } - - redisSecrets := datamodel.RedisCacheSecrets{} - if password, ok := resource.SecretValues[renderers.PasswordStringHolder]; ok { - redisSecrets.Password = password.Value - } - if connectionString, ok := resource.SecretValues[renderers.ConnectionStringValue]; ok { - redisSecrets.ConnectionString = connectionString.Value - } - - versioned, _ := converter.RedisCacheSecretsDataModelToVersioned(&redisSecrets, sCtx.APIVersion) - return rest.NewOKResponse(versioned), nil -} diff --git a/pkg/linkrp/frontend/controller/rediscaches/listsecretsrediscache_test.go b/pkg/linkrp/frontend/controller/rediscaches/listsecretsrediscache_test.go deleted file mode 100644 index 4d8594cb1c..0000000000 --- a/pkg/linkrp/frontend/controller/rediscaches/listsecretsrediscache_test.go +++ /dev/null @@ -1,174 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rediscaches - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/http/httptest" - "testing" - - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/ucp/store" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" -) - -func TestListSecrets_20220315PrivatePreview(t *testing.T) { - mctrl := gomock.NewController(t) - defer mctrl.Finish() - - mStorageClient := store.NewMockStorageClient(mctrl) - ctx := context.Background() - - _, redisDataModel, _ := getTestModels20220315privatepreview() - - t.Run("listSecrets non-existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, &store.ErrNotFound{ID: id} - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - ctl, err := NewListSecretsRedisCache(opts) - require.NoError(t, err) - - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - - _ = resp.Apply(ctx, w, req) - require.Equal(t, 404, w.Result().StatusCode) - }) - - t.Run("listSecrets existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - expectedSecrets := map[string]any{ - renderers.PasswordStringHolder: "testPassword", - renderers.ConnectionStringValue: "test-connection-string", - } - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: redisDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsRedisCache(opts) - require.NoError(t, err) - - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := &v20220315privatepreview.RedisCacheSecrets{} - _ = json.Unmarshal(w.Body.Bytes(), actualOutput) - - require.Equal(t, expectedSecrets[renderers.ConnectionStringValue], *actualOutput.ConnectionString) - require.Equal(t, expectedSecrets[renderers.PasswordStringHolder], *actualOutput.Password) - }) - - t.Run("listSecrets existing resource partial secrets", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - expectedSecrets := map[string]any{ - renderers.PasswordStringHolder: "testPassword", - } - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: redisDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsRedisCache(opts) - require.NoError(t, err) - - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := &v20220315privatepreview.RedisCacheSecrets{} - _ = json.Unmarshal(w.Body.Bytes(), actualOutput) - - require.Equal(t, expectedSecrets[renderers.PasswordStringHolder], *actualOutput.Password) - }) - - t.Run("listSecrets error retrieving resource", func(t *testing.T) { - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - w := httptest.NewRecorder() - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, errors.New("failed to get the resource from data store") - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsRedisCache(opts) - require.NoError(t, err) - - _, err = ctl.Run(ctx, w, req) - require.Error(t, err) - }) - -} diff --git a/pkg/linkrp/frontend/controller/rediscaches/testdata/20220315privatepreview_datamodel.json b/pkg/linkrp/frontend/controller/rediscaches/testdata/20220315privatepreview_datamodel.json deleted file mode 100644 index f2d1f2b5b3..0000000000 --- a/pkg/linkrp/frontend/controller/rediscaches/testdata/20220315privatepreview_datamodel.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/rediscaches/redis0", - "name": "redis0", - "type": "applications.link/rediscaches", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "AzureRedis", - "Dependencies": null, - "ResourceType": { - "type": "azure.redis", - "provider": "azure" - } - } - ] - }, - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" - }, - "username": "redisusername" - }, - "computedValues": { - "host": "myrediscache.redis.cache.windows.net", - "port": 10255, - "username": "redisusername" - }, - "secretValues": { - "password": { - "value": "testPassword" - }, - "connectionString": { - "value": "test-connection-string" - } - }, - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/rediscaches/testdata/20220315privatepreview_requestheaders.json b/pkg/linkrp/frontend/controller/rediscaches/testdata/20220315privatepreview_requestheaders.json deleted file mode 100644 index 550f994e9f..0000000000 --- a/pkg/linkrp/frontend/controller/rediscaches/testdata/20220315privatepreview_requestheaders.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "en-US", - "Content-Length": "305", - "Content-Type": "application/json; charset=utf-8", - "Referer": "https://radius.dev/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/rediscaches/redis0?api-version=2022-03-15-privatepreview", - "Traceparent": "00-000011048df2134ca37c9a689c3a0000-0000000000000000-01", - "User-Agent": "ARMClient/1.6.0.0", - "Via": "1.1 Azure", - "X-Azure-Requestchain": "hops=1", - "X-Fd-Clienthttpversion": "1.1", - "X-Fd-Clientip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Fd-Edgeenvironment": "fake", - "X-Fd-Eventid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Impressionguid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Originalurl": "https://radius.dev:443/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/rediscache/redis0?api-version=2022-03-15-privatepreview", - "X-Fd-Partner": "AzureResourceManager_Test", - "X-Fd-Ref": "Ref A: xxxx Ref B: xxxx Ref C: 2022-03-22T18:54:50Z", - "X-Fd-Revip": "country=United States,iso=us,state=Washington,city=Redmond,zip=00000,tz=-8,asn=0,lat=0,long=-1,countrycf=8,citycf=8", - "X-Fd-Routekey": "000075000", - "X-Fd-Socketip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Forwarded-For": "192.168.0.10", - "X-Forwarded-Host": "radius.dev", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https", - "X-Forwarded-Scheme": "https", - "X-Ms-Activity-Vector": "IN.0P", - "X-Ms-Arm-Network-Source": "PublicNetwork", - "X-Ms-Arm-Request-Tracking-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Arm-Resource-System-Data": "{\"lastModifiedBy\":\"fake@hotmail.com\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2022-03-22T18:57:52.6857175Z\"}", - "X-Ms-Arm-Service-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Acr": "1", - "X-Ms-Client-Alt-Sec-Id": "1:live.com:0006000017E40000", - "X-Ms-Client-App-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-App-Id-Acr": "0", - "X-Ms-Client-Audience": "https://management.core.windows.net/", - "X-Ms-Client-Authentication-Methods": "pwd", - "X-Ms-Client-Authorization-Source": "RoleBased", - "X-Ms-Client-Family-Name-Encoded": "fake", - "X-Ms-Client-Given-Name-Encoded": "fake", - "X-Ms-Client-Identity-Provider": "live.com", - "X-Ms-Client-Ip-Address": "192.168.0.10", - "X-Ms-Client-Issuer": "https://sts.windows-ppe.net/00000000-0000-0000-0000-000000000000/", - "X-Ms-Client-Location": "centralus", - "X-Ms-Client-Object-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Principal-Group-Membership-Source": "Token", - "X-Ms-Client-Principal-Id": "000000000000000", - "X-Ms-Client-Principal-Name": "live.com#fake@hotmail.com", - "X-Ms-Client-Puid": "000000000000000", - "X-Ms-Client-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Scope": "user_impersonation", - "X-Ms-Client-Tenant-Id": "00000000-0000-0000-0000-000000000001", - "X-Ms-Client-Wids": "00000000-0000-0000-0000-000000000000, 00000000-0000-0000-0000-000000000001", - "X-Ms-Correlation-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Home-Tenant-Id": "00000000-0000-0000-0000-000000000002", - "X-Ms-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Routing-Request-Id": "CENTRALUS:20220322T185452Z:00000000-0000-0000-0000-000000000000", - "X-Original-Forwarded-For": "0000:0000:0000:1:449b:f928:e40a:a351", - "X-Real-Ip": "192.168.0.10", - "X-Request-Id": "1000f6040000000000004bc7d1666424", - "X-Scheme": "https" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/rediscaches/types.go b/pkg/linkrp/frontend/controller/rediscaches/types.go deleted file mode 100644 index 17e9f7961a..0000000000 --- a/pkg/linkrp/frontend/controller/rediscaches/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rediscaches - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/linkrp/frontend/controller/rediscaches/v20220315privatepreview_test.go b/pkg/linkrp/frontend/controller/rediscaches/v20220315privatepreview_test.go deleted file mode 100644 index 43ad718a12..0000000000 --- a/pkg/linkrp/frontend/controller/rediscaches/v20220315privatepreview_test.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rediscaches - -import ( - "encoding/json" - - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/test/testutil" -) - -const testHeaderfile = "20220315privatepreview_requestheaders.json" - -func getTestModels20220315privatepreview() (input *v20220315privatepreview.RedisCacheResource, dataModel *datamodel.RedisCache, output *v20220315privatepreview.RedisCacheResource) { - rawDataModel := testutil.ReadFixture("20220315privatepreview_datamodel.json") - dataModel = &datamodel.RedisCache{} - _ = json.Unmarshal(rawDataModel, dataModel) - - return input, dataModel, output -} diff --git a/pkg/linkrp/frontend/controller/sqldatabases/listsecretssqldatabase.go b/pkg/linkrp/frontend/controller/sqldatabases/listsecretssqldatabase.go deleted file mode 100644 index 1bb441a5cc..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/listsecretssqldatabase.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package sqldatabases - -import ( - "context" - "net/http" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/datamodel/converter" - "github.com/project-radius/radius/pkg/linkrp/renderers" -) - -var _ ctrl.Controller = (*ListSecretsSqlDatabase)(nil) - -// ListSecretsSqlDatabase is the controller implementation to list secrets for the to access the connected sql database resource resource id passed in the request body. -type ListSecretsSqlDatabase struct { - ctrl.Operation[*datamodel.SqlDatabase, datamodel.SqlDatabase] -} - -// NewListSecretsSqlDatabase creates a new instance of ListSecretsSqlDatabase. -func NewListSecretsSqlDatabase(opts ctrl.Options) (ctrl.Controller, error) { - return &ListSecretsSqlDatabase{ - Operation: ctrl.NewOperation(opts, - ctrl.ResourceOptions[datamodel.SqlDatabase]{ - RequestConverter: converter.SqlDatabaseDataModelFromVersioned, - ResponseConverter: converter.SqlDatabaseDataModelToVersioned, - }), - }, nil -} - -// Run returns secrets values for the specified SqlDatabase resource -func (ctrl *ListSecretsSqlDatabase) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { - sCtx := v1.ARMRequestContextFromContext(ctx) - - parsedResourceID := sCtx.ResourceID.Truncate() - resource, _, err := ctrl.GetResource(ctx, parsedResourceID) - if err != nil { - return nil, err - } - - if resource == nil { - return rest.NewNotFoundResponse(sCtx.ResourceID), nil - } - - sqlSecrets := datamodel.SqlDatabaseSecrets{} - if password, ok := resource.SecretValues[renderers.PasswordStringHolder]; ok { - sqlSecrets.Password = password.Value - } - if connectionString, ok := resource.SecretValues[renderers.ConnectionStringValue]; ok { - sqlSecrets.ConnectionString = connectionString.Value - } - - versioned, _ := converter.SqlDatabaseSecretsDataModelToVersioned(&sqlSecrets, sCtx.APIVersion) - return rest.NewOKResponse(versioned), nil -} diff --git a/pkg/linkrp/frontend/controller/sqldatabases/listsecretssqldatabase_test.go b/pkg/linkrp/frontend/controller/sqldatabases/listsecretssqldatabase_test.go deleted file mode 100644 index 53845ac180..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/listsecretssqldatabase_test.go +++ /dev/null @@ -1,176 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package sqldatabases - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/http/httptest" - "testing" - - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/ucp/store" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" -) - -func TestListSecrets_20220315PrivatePreview(t *testing.T) { - const ( - usernameStringValue string = "username" - passwordStringValue string = "password" - connectionStringValue string = "connectionString" - ) - mctrl := gomock.NewController(t) - defer mctrl.Finish() - - mStorageClient := store.NewMockStorageClient(mctrl) - ctx := context.Background() - - _, sqlDataModel, _ := getTestModels20220315privatepreview() - - t.Run("listSecrets non-existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, &store.ErrNotFound{ID: id} - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsSqlDatabase(opts) - - require.NoError(t, err) - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - _ = resp.Apply(ctx, w, req) - require.Equal(t, 404, w.Result().StatusCode) - }) - - t.Run("listSecrets existing resource", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - expectedSecrets := map[string]any{ - passwordStringValue: "testPassword", - connectionStringValue: "Data Source=tcp:testAccount1.sql.cosmos.azure.com,1433;Initial Catalog=testDatabase;User Id=testUser;Password=testPassword;Encrypt=True;TrustServerCertificate=True", - } - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: sqlDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsSqlDatabase(opts) - - require.NoError(t, err) - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := &v20220315privatepreview.SQLDatabaseSecrets{} - _ = json.Unmarshal(w.Body.Bytes(), actualOutput) - - require.Equal(t, expectedSecrets[connectionStringValue], *actualOutput.ConnectionString) - require.Equal(t, expectedSecrets[passwordStringValue], *actualOutput.Password) - }) - - t.Run("listSecrets existing resource partial secrets", func(t *testing.T) { - w := httptest.NewRecorder() - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - expectedSecrets := map[string]any{ - connectionStringValue: "Data Source=tcp:testAccount1.sql.cosmos.azure.com,1433;Initial Catalog=testDatabase;User Id=testUser;Password=testPassword;Encrypt=True;TrustServerCertificate=True", - } - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return &store.Object{ - Metadata: store.Metadata{ID: id}, - Data: sqlDataModel, - }, nil - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsSqlDatabase(opts) - - require.NoError(t, err) - resp, err := ctl.Run(ctx, w, req) - require.NoError(t, err) - _ = resp.Apply(ctx, w, req) - require.Equal(t, 200, w.Result().StatusCode) - - actualOutput := &v20220315privatepreview.SQLDatabaseSecrets{} - _ = json.Unmarshal(w.Body.Bytes(), actualOutput) - - require.Equal(t, expectedSecrets[connectionStringValue], *actualOutput.ConnectionString) - }) - - t.Run("listSecrets error retrieving resource", func(t *testing.T) { - req, err := rpctest.NewHTTPRequestFromJSON(ctx, http.MethodGet, testHeaderfile, nil) - require.NoError(t, err) - ctx := rpctest.NewARMRequestContext(req) - w := httptest.NewRecorder() - - mStorageClient. - EXPECT(). - Get(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx context.Context, id string, _ ...store.GetOptions) (*store.Object, error) { - return nil, errors.New("failed to get the resource from data store") - }) - - opts := ctrl.Options{ - StorageClient: mStorageClient, - } - - ctl, err := NewListSecretsSqlDatabase(opts) - - require.NoError(t, err) - _, err = ctl.Run(ctx, w, req) - require.Error(t, err) - }) - -} diff --git a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_datamodel.json b/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_datamodel.json deleted file mode 100644 index abbe084a5d..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_datamodel.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/sqldatabases/sql0", - "name": "sql0", - "type": "applications.link/sqldatabases", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "properties": { - "status": { - "outputResources": [ - { - "LocalID": "AzureSqlServer", - "Dependencies": null, - "ResourceType": { - "type": "azure.sql", - "provider": "azure" - } - } - ] - }, - "resourceProvisioning": "manual", - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "port": 1433, - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "Data Source=tcp:testAccount1.sql.cosmos.azure.com,1433;Initial Catalog=testDatabase;User Id=testUser;Password=testPassword;Encrypt=True;TrustServerCertificate=True" - } - }, - "computedValues": { - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "port": 1433, - "username": "testUser" - }, - "secretValues": { - "password": { - "value": "testPassword" - }, - "connectionString": { - "value": "Data Source=tcp:testAccount1.sql.cosmos.azure.com,1433;Initial Catalog=testDatabase;User Id=testUser;Password=testPassword;Encrypt=True;TrustServerCertificate=True" - } - }, - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_input.json b/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_input.json deleted file mode 100644 index 904cf96ea5..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_input.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning": "manual", - "port": 1433, - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "Data Source=tcp:testAccount1.sql.cosmos.azure.com,1433;Initial Catalog=testDatabase;User Id=testUser;Password=testPassword;Encrypt=True;TrustServerCertificate=True" - } - } -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_output.json b/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_output.json deleted file mode 100644 index e5fe62dbf6..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_output.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/sqldatabases/sql0", - "location": "West US", - "name": "sql0", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "AzureSqlServer", - "Provider": "azure", - "Identity": null - }] - }, - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "provisioningState": "Succeeded", - "resourceProvisioning": "manual", - "port": 1433, - "username": "testUser" - }, - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "tags": {}, - "type": "applications.link/sqldatabases" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_requestheaders.json b/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_requestheaders.json deleted file mode 100644 index d6aa6f52bb..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/testdata/20220315privatepreview_requestheaders.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "en-US", - "Content-Length": "305", - "Content-Type": "application/json; charset=utf-8", - "Referer": "https://radius.dev/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.link/sqldatabases/sql0?api-version=2022-03-15-privatepreview", - "Traceparent": "00-000011048df2134ca37c9a689c3a0000-0000000000000000-01", - "User-Agent": "ARMClient/1.6.0.0", - "Via": "1.1 Azure", - "X-Azure-Requestchain": "hops=1", - "X-Fd-Clienthttpversion": "1.1", - "X-Fd-Clientip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Fd-Edgeenvironment": "fake", - "X-Fd-Eventid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Impressionguid": "00005A12DDEC4F8B80B65BB768190000", - "X-Fd-Originalurl": "https://radius.dev:443/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Link/sqldatabase/sql0?api-version=2022-03-15-privatepreview", - "X-Fd-Partner": "AzureResourceManager_Test", - "X-Fd-Ref": "Ref A: xxxx Ref B: xxxx Ref C: 2022-03-22T18:54:50Z", - "X-Fd-Revip": "country=United States,iso=us,state=Washington,city=Redmond,zip=00000,tz=-8,asn=0,lat=0,long=-1,countrycf=8,citycf=8", - "X-Fd-Routekey": "000075000", - "X-Fd-Socketip": "0000:0000:0000:1:0000:0000:0000:0000", - "X-Forwarded-For": "192.168.0.10", - "X-Forwarded-Host": "radius.dev", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https", - "X-Forwarded-Scheme": "https", - "X-Ms-Activity-Vector": "IN.0P", - "X-Ms-Arm-Network-Source": "PublicNetwork", - "X-Ms-Arm-Request-Tracking-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Arm-Resource-System-Data": "{\"lastModifiedBy\":\"fake@hotmail.com\",\"lastModifiedByType\":\"User\",\"lastModifiedAt\":\"2022-03-22T18:57:52.6857175Z\"}", - "X-Ms-Arm-Service-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Acr": "1", - "X-Ms-Client-Alt-Sec-Id": "1:live.com:0006000017E40000", - "X-Ms-Client-App-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-App-Id-Acr": "0", - "X-Ms-Client-Audience": "https://management.core.windows.net/", - "X-Ms-Client-Authentication-Methods": "pwd", - "X-Ms-Client-Authorization-Source": "RoleBased", - "X-Ms-Client-Family-Name-Encoded": "fake", - "X-Ms-Client-Given-Name-Encoded": "fake", - "X-Ms-Client-Identity-Provider": "live.com", - "X-Ms-Client-Ip-Address": "192.168.0.10", - "X-Ms-Client-Issuer": "https://sts.windows-ppe.net/00000000-0000-0000-0000-000000000000/", - "X-Ms-Client-Location": "centralus", - "X-Ms-Client-Object-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Principal-Group-Membership-Source": "Token", - "X-Ms-Client-Principal-Id": "000000000000000", - "X-Ms-Client-Principal-Name": "live.com#fake@hotmail.com", - "X-Ms-Client-Puid": "000000000000000", - "X-Ms-Client-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Client-Scope": "user_impersonation", - "X-Ms-Client-Tenant-Id": "00000000-0000-0000-0000-000000000001", - "X-Ms-Client-Wids": "00000000-0000-0000-0000-000000000000, 00000000-0000-0000-0000-000000000001", - "X-Ms-Correlation-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Home-Tenant-Id": "00000000-0000-0000-0000-000000000002", - "X-Ms-Request-Id": "00000000-0000-0000-0000-000000000000", - "X-Ms-Routing-Request-Id": "CENTRALUS:20220322T185452Z:00000000-0000-0000-0000-000000000000", - "X-Original-Forwarded-For": "0000:0000:0000:1:449b:f928:e40a:a351", - "X-Real-Ip": "192.168.0.10", - "X-Request-Id": "1000f6040000000000004bc7d1666424", - "X-Scheme": "https" -} \ No newline at end of file diff --git a/pkg/linkrp/frontend/controller/sqldatabases/types.go b/pkg/linkrp/frontend/controller/sqldatabases/types.go deleted file mode 100644 index 1e801ba341..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/types.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package sqldatabases - -const ( - // User defined operation names - OperationListSecret = "LISTSECRETS" -) diff --git a/pkg/linkrp/frontend/controller/sqldatabases/v20220315privatepreview_test.go b/pkg/linkrp/frontend/controller/sqldatabases/v20220315privatepreview_test.go deleted file mode 100644 index b4da57c9f3..0000000000 --- a/pkg/linkrp/frontend/controller/sqldatabases/v20220315privatepreview_test.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package sqldatabases - -import ( - "encoding/json" - - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/test/testutil" -) - -const testHeaderfile = "20220315privatepreview_requestheaders.json" - -func getTestModels20220315privatepreview() (input *v20220315privatepreview.SQLDatabaseResource, dataModel *datamodel.SqlDatabase, output *v20220315privatepreview.SQLDatabaseResource) { - rawInput := testutil.ReadFixture("20220315privatepreview_input.json") - input = &v20220315privatepreview.SQLDatabaseResource{} - _ = json.Unmarshal(rawInput, input) - - rawDataModel := testutil.ReadFixture("20220315privatepreview_datamodel.json") - dataModel = &datamodel.SqlDatabase{} - _ = json.Unmarshal(rawDataModel, dataModel) - - rawExpectedOutput := testutil.ReadFixture("20220315privatepreview_output.json") - output = &v20220315privatepreview.SQLDatabaseResource{} - _ = json.Unmarshal(rawExpectedOutput, output) - - return input, dataModel, output -} diff --git a/pkg/linkrp/frontend/controller/types.go b/pkg/linkrp/frontend/controller/types.go deleted file mode 100644 index 0d016b7d74..0000000000 --- a/pkg/linkrp/frontend/controller/types.go +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "time" -) - -var ( - // AsyncOperationRetryAfter is polling interval for async create/update or delete resource operations. - AsyncOperationRetryAfter = time.Duration(5) * time.Second - - // AsyncCreateOrUpdateMongoDatabaseTimeout is the timeout for async create or update mongo database - AsyncCreateOrUpdateMongoDatabaseTimeout = time.Duration(10) * time.Minute - // AsyncDeleteMongoDatabaseTimeout is the timeout for async delete mongo database - AsyncDeleteMongoDatabaseTimeout = time.Duration(15) * time.Minute - - // AsyncCreateOrUpdateSqlTimeout is the timeout for async create or update sql database - AsyncCreateOrUpdateSqlDatabaseTimeout = time.Duration(10) * time.Minute - // AsyncDeleteSqlDatabaseTimeout is the timeout for async delete sql database - AsyncDeleteSqlDatabaseTimeout = time.Duration(15) * time.Minute - - // AsyncCreateOrUpdateRedisCacheTimeout is the timeout for async create or update redis cache - AsyncCreateOrUpdateRedisCacheTimeout = time.Duration(60) * time.Minute - // AsyncDeleteRedisCacheTimeout is the timeout for async delete redis cache - AsyncDeleteRedisCacheTimeout = time.Duration(30) * time.Minute - - // AsyncCreateOrUpdateRabbitMQTimeout is the timeout for async create or update rabbitMQ - AsyncCreateOrUpdateRabbitMQTimeout = time.Duration(60) * time.Minute - // AsyncDeleteRabbitMQTimeout is the timeout for async delete rabbitMQ - AsyncDeleteRabbitMQTimeout = time.Duration(30) * time.Minute - - // AsyncCreateOrUpdateDaprStateStoreTimeout is the timeout for async create or update dapr state store - AsyncCreateOrUpdateDaprStateStoreTimeout = time.Duration(60) * time.Minute - // AsyncDeleteDaprStateStoreTimeout is the timeout for async delete dapr state store - AsyncDeleteDaprStateStoreTimeout = time.Duration(30) * time.Minute - - // AsyncCreateOrUpdateDaprSecretStoreTimeout is the timeout for async create or update dapr secret store - AsyncCreateOrUpdateDaprSecretStoreTimeout = time.Duration(60) * time.Minute - // AsyncDeleteDaprSecretStoreTimeout is the timeout for async delete dapr secret store - AsyncDeleteDaprSecretStoreTimeout = time.Duration(30) * time.Minute - - // AsyncCreateOrUpdateDaprPubSubBrokerTimeout is the timeout for async create or update dapr pub sub broker - AsyncCreateOrUpdateDaprPubSubBrokerTimeout = time.Duration(60) * time.Minute - // AsyncDeleteDaprPubSubBrokerTimeout is the timeout for async delete dapr pub sub broker - AsyncDeleteDaprPubSubBrokerTimeout = time.Duration(30) * time.Minute - - // AsyncCreateOrUpdateExtenderTimeout is the timeout for async create or update extender - AsyncCreateOrUpdateExtenderTimeout = time.Duration(60) * time.Minute - // AsyncDeleteExtenderTimeout is the timeout for async delete extender - AsyncDeleteExtenderTimeout = time.Duration(30) * time.Minute -) diff --git a/pkg/linkrp/frontend/handler/getoperations.go b/pkg/linkrp/frontend/handler/getoperations.go deleted file mode 100644 index cc2a746a6b..0000000000 --- a/pkg/linkrp/frontend/handler/getoperations.go +++ /dev/null @@ -1,710 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - "net/http" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - v20220315privatepreview "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" -) - -var _ ctrl.Controller = (*GetOperations)(nil) - -// GetOperations is the controller implementation to get arm rpc available operations. -type GetOperations struct { - ctrl.BaseController -} - -// NewGetOperations creates a new GetOperations controller and returns it, or returns an error if one occurs. -func NewGetOperations(opts ctrl.Options) (ctrl.Controller, error) { - return &GetOperations{ctrl.NewBaseController(opts)}, nil -} - -// Run returns the list of available operations/permission for the resource provider at tenant level. -// Spec: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/proxy-api-reference.md#exposing-available-operations -func (opctrl *GetOperations) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { - sCtx := v1.ARMRequestContextFromContext(ctx) - - switch sCtx.APIVersion { - case v20220315privatepreview.Version: - return rest.NewOKResponse(opctrl.availableOperationsV1()), nil - } - - return rest.NewNotFoundAPIVersionResponse("operations", LinkProviderNamespace, sCtx.APIVersion), nil -} - -func (opctrl *GetOperations) availableOperationsV1() *v1.PaginatedList { - return &v1.PaginatedList{ - Value: []any{ - &v1.Operation{ - Name: "Applications.Link/operations/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "operations", - Operation: "Get operations", - Description: "Get the list of operations.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/mongoDatabases/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "mongoDatabases", - Operation: "Get/List mongoDatabases", - Description: "Gets/Lists mongoDatabase link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/mongoDatabases/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "mongoDatabases", - Operation: "Create/Update mongoDatabases", - Description: "Creates or updates a mongo database link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/mongoDatabases/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "mongoDatabases", - Operation: "Delete mongoDatabase", - Description: "Deletes a mongoDatabase link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/mongoDatabases/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "mongoDatabases", - Operation: "List secrets", - Description: "Lists mongoDatabase secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/register/action", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: LinkProviderNamespace, - Operation: "Register Applications.Link resource provider", - Description: "Registers 'Applications.Link' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/unregister/action", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "Applications.Link", - Operation: "Unregister 'Applications.Link' resource provider", - Description: "Unregisters 'Applications.Link' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/sqlDatabases/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "sqlDatabases", - Operation: "Get/List sqlDatabases", - Description: "Gets/Lists sqlDatabase link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/sqlDatabases/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "sqlDatabases", - Operation: "Create/Update sqlDatabases", - Description: "Creates or updates a sql database link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/sqlDatabases/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "sqlDatabases", - Operation: "Delete sqlDatabase", - Description: "Deletes a sqlDatabase link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/sqlDatabases/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "sqlDatabases", - Operation: "List secrets", - Description: "Lists sqlDatabase secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/redisCaches/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "redisCaches", - Operation: "Get/List redisCaches", - Description: "Gets/Lists redisCache link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/redisCaches/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "redisCaches", - Operation: "Create/Update redisCaches", - Description: "Creates or updates a redisCache link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/redisCaches/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "redisCaches", - Operation: "Delete redisCache", - Description: "Deletes a redisCache link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/redisCaches/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "redisCaches", - Operation: "List secrets", - Description: "Lists redisCache secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/rabbitMQMessageQueues/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "rabbitMQMessageQueues", - Operation: "Get/List rabbitMQMessageQueues", - Description: "Gets/Lists rabbitMQMessageQueue link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/rabbitMQMessageQueues/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "rabbitMQMessageQueues", - Operation: "Create/Update rabbitMQMessageQueues", - Description: "Creates or updates a rabbitMQMessageQueue link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/rabbitMQMessageQueues/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "rabbitMQMessageQueues", - Operation: "Delete rabbitMQMessageQueue", - Description: "Deletes a rabbitMQMessageQueue link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/rabbitMQMessageQueues/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "rabbitMQMessageQueues", - Operation: "List secrets", - Description: "Lists rabbitMQMessageQueue secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/extenders/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "extenders", - Operation: "Get/List extenders", - Description: "Gets/Lists extender link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/extenders/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "extenders", - Operation: "Create/Update extenders", - Description: "Creates or updates a extender link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/extenders/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "extenders", - Operation: "Delete extender", - Description: "Deletes a extender link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/extenders/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "extenders", - Operation: "List secrets", - Description: "Lists extender secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprSecretStores/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprSecretStores", - Operation: "Get/List daprSecretStores", - Description: "Gets/Lists daprSecretStore link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprSecretStores/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprSecretStores", - Operation: "Create/Update daprSecretStores", - Description: "Creates or updates a daprSecretStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprSecretStores/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprSecretStores", - Operation: "Delete daprSecretStore", - Description: "Deletes a daprSecretStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprStateStores/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprStateStores", - Operation: "Get/List daprStateStores", - Description: "Gets/Lists daprStateStore link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprStateStores/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprStateStores", - Operation: "Create/Update daprStateStores", - Description: "Creates or updates a daprStateStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprStateStores/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprStateStores", - Operation: "Delete daprStateStore", - Description: "Deletes a daprStateStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprPubSubBrokers/read", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprPubSubBrokers", - Operation: "Get/List daprPubSubBrokers", - Description: "Gets/Lists daprPubSubBroker link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprPubSubBrokers/write", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprPubSubBrokers", - Operation: "Create/Update daprPubSubBrokers", - Description: "Creates or updates a daprPubSubBroker link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Link/daprPubSubBrokers/delete", - Display: &v1.OperationDisplayProperties{ - Provider: LinkProviderNamespace, - Resource: "daprPubSubBrokers", - Operation: "Delete daprPubSubBroker", - Description: "Deletes a daprPubSubBroker link.", - }, - IsDataAction: false, - }, - // Split Namespace Resources - &v1.Operation{ - Name: "Applications.Dapr/operations/read", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "operations", - Operation: "Get operations", - Description: "Get the list of operations.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/operations/read", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "operations", - Operation: "Get operations", - Description: "Get the list of operations.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Messaging/operations/read", - Display: &v1.OperationDisplayProperties{ - Provider: MessagingProviderNamespace, - Resource: "operations", - Operation: "Get operations", - Description: "Get the list of operations.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/mongoDatabases/read", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "mongoDatabases", - Operation: "Get/List mongoDatabases", - Description: "Gets/Lists mongoDatabase link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/mongoDatabases/write", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "mongoDatabases", - Operation: "Create/Update mongoDatabases", - Description: "Creates or updates a mongo database link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/mongoDatabases/delete", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "mongoDatabases", - Operation: "Delete mongoDatabase", - Description: "Deletes a mongoDatabase link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/mongoDatabases/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "mongoDatabases", - Operation: "List secrets", - Description: "Lists mongoDatabase secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/register/action", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: DatastoresProviderNamespace, - Operation: "Register Applications.Datastores resource provider", - Description: "Registers 'Applications.Datastores' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/register/action", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: DaprProviderNamespace, - Operation: "Register Applications.Dapr resource provider", - Description: "Registers 'Applications.Dapr' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Messaging/register/action", - Display: &v1.OperationDisplayProperties{ - Provider: MessagingProviderNamespace, - Resource: MessagingProviderNamespace, - Operation: "Register Applications.Messaging resource provider", - Description: "Registers 'Applications.Messaging' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/unregister/action", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "Applications.Datastores", - Operation: "Unregister 'Applications.Datastores' resource provider", - Description: "Unregisters 'Applications.Datastores' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/unregister/action", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "Applications.Datastores", - Operation: "Unregister 'Applications.Dapr' resource provider", - Description: "Unregisters 'Applications.Dapr' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Messaging/unregister/action", - Display: &v1.OperationDisplayProperties{ - Provider: MessagingProviderNamespace, - Resource: "Applications.Datastores", - Operation: "Unregister 'Applications.Messaging' resource provider", - Description: "Unregisters 'Applications.Messaging' resource provider with a subscription.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/sqlDatabases/read", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "sqlDatabases", - Operation: "Get/List sqlDatabases", - Description: "Gets/Lists sqlDatabase link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/sqlDatabases/write", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "sqlDatabases", - Operation: "Create/Update sqlDatabases", - Description: "Creates or updates a sql database link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/sqlDatabases/delete", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "sqlDatabases", - Operation: "Delete sqlDatabase", - Description: "Deletes a sqlDatabase link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/redisCaches/read", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "redisCaches", - Operation: "Get/List redisCaches", - Description: "Gets/Lists redisCache link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/redisCaches/write", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "redisCaches", - Operation: "Create/Update redisCaches", - Description: "Creates or updates a redisCache link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/redisCaches/delete", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "redisCaches", - Operation: "Delete redisCache", - Description: "Deletes a redisCache link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Datastores/redisCaches/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: DatastoresProviderNamespace, - Resource: "redisCaches", - Operation: "List secrets", - Description: "Lists redisCache secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Messaging/rabbitMQQueues/read", - Display: &v1.OperationDisplayProperties{ - Provider: MessagingProviderNamespace, - Resource: "rabbitMQQueues", - Operation: "Get/List rabbitMQQueues", - Description: "Gets/Lists rabbitMQQueue link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Messaging/rabbitMQQueues/write", - Display: &v1.OperationDisplayProperties{ - Provider: MessagingProviderNamespace, - Resource: "rabbitMQQueues", - Operation: "Create/Update rabbitMQQueues", - Description: "Creates or updates a rabbitMQQueue link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Messaging/rabbitMQQueues/delete", - Display: &v1.OperationDisplayProperties{ - Provider: MessagingProviderNamespace, - Resource: "rabbitMQQueues", - Operation: "Delete rabbitMQQueue", - Description: "Deletes a rabbitMQQueue link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Messaging/rabbitMQQueues/listsecrets/action", - Display: &v1.OperationDisplayProperties{ - Provider: MessagingProviderNamespace, - Resource: "rabbitMQQueues", - Operation: "List secrets", - Description: "Lists rabbitMQQueue secrets.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/secretStores/read", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprSecretStores", - Operation: "Get/List daprSecretStores", - Description: "Gets/Lists daprSecretStore link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/secretStores/write", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprSecretStores", - Operation: "Create/Update daprSecretStores", - Description: "Creates or updates a daprSecretStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/secretStores/delete", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprSecretStores", - Operation: "Delete daprSecretStore", - Description: "Deletes a daprSecretStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/stateStores/read", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprStateStores", - Operation: "Get/List daprStateStores", - Description: "Gets/Lists daprStateStore link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/stateStores/write", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprStateStores", - Operation: "Create/Update daprStateStores", - Description: "Creates or updates a daprStateStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/stateStores/delete", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprStateStores", - Operation: "Delete daprStateStore", - Description: "Deletes a daprStateStore link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/pubSubBrokers/read", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprPubSubBrokers", - Operation: "Get/List daprPubSubBrokers", - Description: "Gets/Lists daprPubSubBroker link(s).", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/pubSubBrokers/write", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprPubSubBrokers", - Operation: "Create/Update daprPubSubBrokers", - Description: "Creates or updates a daprPubSubBroker link.", - }, - IsDataAction: false, - }, - &v1.Operation{ - Name: "Applications.Dapr/pubSubBrokers/delete", - Display: &v1.OperationDisplayProperties{ - Provider: DaprProviderNamespace, - Resource: "daprPubSubBrokers", - Operation: "Delete daprPubSubBroker", - Description: "Deletes a daprPubSubBroker link.", - }, - IsDataAction: false, - }, - }, - } -} diff --git a/pkg/linkrp/frontend/handler/getoperations_test.go b/pkg/linkrp/frontend/handler/getoperations_test.go deleted file mode 100644 index 2324bba775..0000000000 --- a/pkg/linkrp/frontend/handler/getoperations_test.go +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - "net/http/httptest" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - v20220315privatepreview "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/stretchr/testify/require" -) - -func TestRunWith20220315PrivatePreview(t *testing.T) { - // arrange - opts := ctrl.Options{} - op, err := NewGetOperations(opts) - require.NoError(t, err) - ctx := v1.WithARMRequestContext(context.Background(), &v1.ARMRequestContext{ - APIVersion: v20220315privatepreview.Version, - }) - w := httptest.NewRecorder() - - // act - resp, err := op.Run(ctx, w, nil) - - // assert - require.NoError(t, err) - switch v := resp.(type) { - case *rest.OKResponse: - pagination, ok := v.Body.(*v1.PaginatedList) - require.True(t, ok) - require.Equal(t, 65, len(pagination.Value)) - default: - require.Truef(t, false, "should not return error") - } -} - -func TestRunWithUnsupportedAPIVersion(t *testing.T) { - // arrange - opts := ctrl.Options{} - op, err := NewGetOperations(opts) - require.NoError(t, err) - ctx := v1.WithARMRequestContext(context.Background(), &v1.ARMRequestContext{ - APIVersion: "unknownversion", - }) - w := httptest.NewRecorder() - - // act - resp, err := op.Run(ctx, w, nil) - - // assert - require.NoError(t, err) - switch v := resp.(type) { - case *rest.NotFoundResponse: - armerr := v.Body - require.Equal(t, v1.CodeInvalidResourceType, armerr.Error.Code) - default: - require.Truef(t, false, "should not return error") - } -} diff --git a/pkg/linkrp/frontend/handler/routes.go b/pkg/linkrp/frontend/handler/routes.go deleted file mode 100644 index fed9fa6e1d..0000000000 --- a/pkg/linkrp/frontend/handler/routes.go +++ /dev/null @@ -1,1731 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - - "github.com/go-chi/chi/v5" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - frontend_ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - "github.com/project-radius/radius/pkg/linkrp" - rp_frontend "github.com/project-radius/radius/pkg/rp/frontend" - "github.com/project-radius/radius/pkg/validator" - "github.com/project-radius/radius/swagger" - - // TODO: Rename alias to remove n prefix for resources in new namespace - dapr_dm "github.com/project-radius/radius/pkg/daprrp/datamodel" - dapr_conv "github.com/project-radius/radius/pkg/daprrp/datamodel/converter" - ds_dm "github.com/project-radius/radius/pkg/datastoresrp/datamodel" - ds_conv "github.com/project-radius/radius/pkg/datastoresrp/datamodel/converter" - mongon_ctrl "github.com/project-radius/radius/pkg/datastoresrp/frontend/controller/mongodatabases" - redisn_ctrl "github.com/project-radius/radius/pkg/datastoresrp/frontend/controller/rediscaches" - sqln_ctrl "github.com/project-radius/radius/pkg/datastoresrp/frontend/controller/sqldatabases" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/datamodel/converter" - link_frontend_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller" - extender_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/extenders" - mongo_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/mongodatabases" - rabbitmq_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/rabbitmqmessagequeues" - redis_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/rediscaches" - sql_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/sqldatabases" - msg_dm "github.com/project-radius/radius/pkg/messagingrp/datamodel" - msg_conv "github.com/project-radius/radius/pkg/messagingrp/datamodel/converter" - msg_ctrl "github.com/project-radius/radius/pkg/messagingrp/frontend/controller/rabbitmqqueues" -) - -const ( - LinkProviderNamespace = "Applications.Link" - DaprProviderNamespace = "Applications.Dapr" - DatastoresProviderNamespace = "Applications.Datastores" - MessagingProviderNamespace = "Applications.Messaging" - resourceGroupPath = "/resourcegroups/{resourceGroupName}" -) - -// AddRoutes configures routes and handlers for Datastores, Messaging, Dapr Resource Providers. -func AddRoutes(ctx context.Context, router chi.Router, isARM bool, ctrlOpts frontend_ctrl.Options) error { - rootScopePath := ctrlOpts.PathBase - rootScopePath += getRootScopePath(isARM) - - // URLs may use either the subscription/plane scope or resource group scope. - // These paths are order sensitive and the longer path MUST be registered first. - prefixes := []string{ - rootScopePath + resourceGroupPath, - rootScopePath, - } - - err := AddLinkRoutes(ctx, router, rootScopePath, prefixes, isARM, ctrlOpts) - if err != nil { - return err - } - - err = AddMessagingRoutes(ctx, router, rootScopePath, prefixes, isARM, ctrlOpts) - if err != nil { - return err - } - - err = AddDaprRoutes(ctx, router, rootScopePath, prefixes, isARM, ctrlOpts) - if err != nil { - return err - } - - err = AddDatastoresRoutes(ctx, router, rootScopePath, prefixes, isARM, ctrlOpts) - if err != nil { - return err - } - - return nil -} - -// AddMessagingRoutes configures the default ARM handlers and registers handlers for the RabbitMQQueue resource type for -// the List, Get, Put, Patch and Delete operations. -func AddMessagingRoutes(ctx context.Context, r chi.Router, rootScopePath string, prefixes []string, isARM bool, ctrlOpts frontend_ctrl.Options) error { - // Configure the default ARM handlers. - err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, MessagingProviderNamespace, NewGetOperations, ctrlOpts) - if err != nil { - return err - } - - specLoader, err := validator.LoadSpec(ctx, MessagingProviderNamespace, swagger.SpecFiles, prefixes, "rootScope") - if err != nil { - return err - } - - validator := validator.APIValidator(validator.Options{ - SpecLoader: specLoader, - ResourceTypeGetter: validator.RadiusResourceTypeGetter, - }) - - // Register resource routers. - // - // Note: We have to follow the below rules to enable API validators: - // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. - // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. - - // rabbitmqqueues router handlers: - rmqPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.messaging/rabbitmqqueues", validator) - rmqResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.messaging/rabbitmqqueues", validator) - rmqResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.messaging/rabbitmqqueues/{rabbitMQQueueName}", validator) - - // Messaging handlers: - handlerOptions := []server.HandlerOptions{ - { - ParentRouter: rmqPlaneRouter, - ResourceType: linkrp.N_RabbitMQQueuesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ - RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, - ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: rmqResourceGroupRouter, - ResourceType: linkrp.N_RabbitMQQueuesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ - RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, - ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, - }) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.N_RabbitMQQueuesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ - RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, - ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, - }) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.N_RabbitMQQueuesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ - RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, - ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[msg_dm.RabbitMQQueue]{ - rp_frontend.PrepareRadiusResource[*msg_dm.RabbitMQQueue], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRabbitMQTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.N_RabbitMQQueuesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ - RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, - ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[msg_dm.RabbitMQQueue]{ - rp_frontend.PrepareRadiusResource[*msg_dm.RabbitMQQueue], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRabbitMQTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.N_RabbitMQQueuesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ - RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, - ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteRabbitMQTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: rmqResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.N_RabbitMQQueuesResourceType, - Method: msg_ctrl.OperationListSecret, - ControllerFactory: msg_ctrl.NewListSecretsRabbitMQQueue, - }, - } - - for _, h := range handlerOptions { - if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { - return err - } - } - - return nil -} - -// AddDaprRoutes configures the default ARM handlers and adds handlers for Dapr resources such as Dapr PubSubBroker, -// SecretStore and StateStore. It registers handlers for various operations on these resources. -func AddDaprRoutes(ctx context.Context, r chi.Router, rootScopePath string, prefixes []string, isARM bool, ctrlOpts frontend_ctrl.Options) error { - - // Dapr - Configure the default ARM handlers. - err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, DaprProviderNamespace, NewGetOperations, ctrlOpts) - if err != nil { - return err - } - - specLoader, err := validator.LoadSpec(ctx, DaprProviderNamespace, swagger.SpecFiles, prefixes, "rootScope") - if err != nil { - return err - } - - validator := validator.APIValidator(validator.Options{ - SpecLoader: specLoader, - ResourceTypeGetter: validator.RadiusResourceTypeGetter, - }) - - // Register resource routers. - // - // Note: We have to follow the below rules to enable API validators: - // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. - // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. - - pubsubPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.dapr/pubsubbrokers", validator) - pubsubResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/pubsubbrokers", validator) - pubsubResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/pubsubbrokers/{daprPubSubBrokerName}", validator) - - handlerOptions := []server.HandlerOptions{ - { - ParentRouter: pubsubPlaneRouter, - ResourceType: linkrp.N_DaprPubSubBrokersResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ - RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, - ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: pubsubResourceGroupRouter, - ResourceType: linkrp.N_DaprPubSubBrokersResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ - RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, - ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, - }) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.N_DaprPubSubBrokersResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ - RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, - ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, - }) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.N_DaprPubSubBrokersResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ - RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, - ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprPubSubBroker]{ - rp_frontend.PrepareRadiusResource[*dapr_dm.DaprPubSubBroker], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.N_DaprPubSubBrokersResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ - RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, - ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprPubSubBroker]{ - rp_frontend.PrepareRadiusResource[*dapr_dm.DaprPubSubBroker], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.N_DaprPubSubBrokersResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ - RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, - ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - } - - secretStorePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.dapr/secretstores", validator) - secretStoreResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/secretstores", validator) - secretStoreResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/secretstores/{daprSecretStoreName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: secretStorePlaneRouter, - ResourceType: linkrp.N_DaprSecretStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ - RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: secretStoreResourceGroupRouter, - ResourceType: linkrp.N_DaprSecretStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ - RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.N_DaprSecretStoresResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ - RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.N_DaprSecretStoresResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ - RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprSecretStore]{ - rp_frontend.PrepareRadiusResource[*dapr_dm.DaprSecretStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprSecretStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.N_DaprSecretStoresResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ - RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprSecretStore]{ - rp_frontend.PrepareRadiusResource[*dapr_dm.DaprSecretStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprSecretStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.N_DaprSecretStoresResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ - RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteDaprSecretStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - stateStorePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.dapr/statestores", validator) - stateStoreResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/statestores", validator) - stateStoreResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/statestores/{daprStateStoreName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: stateStorePlaneRouter, - ResourceType: linkrp.N_DaprStateStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ - RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: stateStoreResourceGroupRouter, - ResourceType: linkrp.N_DaprStateStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ - RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.N_DaprStateStoresResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ - RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.N_DaprStateStoresResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ - RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprStateStore]{ - rp_frontend.PrepareRadiusResource[*dapr_dm.DaprStateStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprStateStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.N_DaprStateStoresResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ - RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprStateStore]{ - rp_frontend.PrepareRadiusResource[*dapr_dm.DaprStateStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprStateStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.N_DaprStateStoresResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ - RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, - ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteDaprStateStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - for _, h := range handlerOptions { - if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { - return err - } - } - - return nil -} - -// AddDatastoresRoutes configures the routes and handlers for Datastores Resource Provider. It registers handlers for List, Get, Put, -// Patch, and Delete operations for MongoDatabase, RedisCache, and SqlDatabase resources. -func AddDatastoresRoutes(ctx context.Context, r chi.Router, rootScopePath string, prefixes []string, isARM bool, ctrlOpts frontend_ctrl.Options) error { - // Datastores - Configure the default ARM handlers. - err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, DatastoresProviderNamespace, NewGetOperations, ctrlOpts) - if err != nil { - return err - } - - specLoader, err := validator.LoadSpec(ctx, DatastoresProviderNamespace, swagger.SpecFiles, prefixes, "rootScope") - if err != nil { - return err - } - - validator := validator.APIValidator(validator.Options{ - SpecLoader: specLoader, - ResourceTypeGetter: validator.RadiusResourceTypeGetter, - }) - - // Register resource routers. - // - // Note: We have to follow the below rules to enable API validators: - // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. - // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. - - mongoPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.datastores/mongodatabases", validator) - mongoResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/mongodatabases", validator) - mongoResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/mongodatabases/{mongoDatabaseName}", validator) - - // Datastores handlers: - handlerOptions := []server.HandlerOptions{ - { - ParentRouter: mongoPlaneRouter, - ResourceType: linkrp.N_MongoDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ - RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: mongoResourceGroupRouter, - ResourceType: linkrp.N_MongoDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ - RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.N_MongoDatabasesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ - RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.N_MongoDatabasesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ - RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.MongoDatabase]{ - rp_frontend.PrepareRadiusResource[*ds_dm.MongoDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateMongoDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.MongoDatabasesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.MongoDatabase]{ - rp_frontend.PrepareRadiusResource[*datamodel.MongoDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateMongoDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.N_MongoDatabasesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ - RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteMongoDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: mongoResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.N_MongoDatabasesResourceType, - Method: mongon_ctrl.OperationListSecret, - ControllerFactory: mongon_ctrl.NewListSecretsMongoDatabase, - }, - } - - redisPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.datastores/rediscaches", validator) - redisResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/rediscaches", validator) - redisResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/rediscaches/{redisCacheName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: redisPlaneRouter, - ResourceType: linkrp.N_RedisCachesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ - RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, - ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: redisResourceGroupRouter, - ResourceType: linkrp.N_RedisCachesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ - RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, - ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, - }) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.N_RedisCachesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ - RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, - ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, - }) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.N_RedisCachesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ - RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, - ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.RedisCache]{ - rp_frontend.PrepareRadiusResource[*ds_dm.RedisCache], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRedisCacheTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.N_RedisCachesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ - RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, - ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.RedisCache]{ - rp_frontend.PrepareRadiusResource[*ds_dm.RedisCache], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRedisCacheTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.N_RedisCachesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ - RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, - ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteRedisCacheTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: redisResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.N_RedisCachesResourceType, - Method: redisn_ctrl.OperationListSecret, - ControllerFactory: redisn_ctrl.NewListSecretsRedisCache, - }, - }...) - - sqlPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.datastores/sqldatabases", validator) - sqlResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/sqldatabases", validator) - sqlResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/sqldatabases/{sqlDatabaseName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: sqlPlaneRouter, - ResourceType: linkrp.N_SqlDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ - RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: sqlResourceGroupRouter, - ResourceType: linkrp.N_SqlDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ - RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.N_SqlDatabasesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ - RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.N_SqlDatabasesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ - RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.SqlDatabase]{ - rp_frontend.PrepareRadiusResource[*ds_dm.SqlDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateSqlDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.N_SqlDatabasesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ - RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.SqlDatabase]{ - rp_frontend.PrepareRadiusResource[*ds_dm.SqlDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateSqlDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.N_SqlDatabasesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ - RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, - ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteSqlDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: sqlResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.N_SqlDatabasesResourceType, - Method: sqln_ctrl.OperationListSecret, - ControllerFactory: sqln_ctrl.NewListSecretsSqlDatabase, - }, - }...) - - for _, h := range handlerOptions { - if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { - return err - } - } - - return nil -} - -// AddLinkRoutes sets up routes and registers handlers for various operations (GET, PUT, PATCH, DELETE) on different -// resources (MongoDatabases, DaprPubSubBrokers, DaprSecretStores, DaprStateStores, Extenders, RedisCaches, -// RabbitMQMessageQueues and SQLDatabases). It also sets up the necessary options for each handler. -func AddLinkRoutes(ctx context.Context, r chi.Router, rootScopePath string, prefixes []string, isARM bool, ctrlOpts frontend_ctrl.Options) error { - // Configure the default ARM handlers. - err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, LinkProviderNamespace, NewGetOperations, ctrlOpts) - if err != nil { - return err - } - - specLoader, err := validator.LoadSpec(ctx, LinkProviderNamespace, swagger.SpecFiles, prefixes, "rootScope") - if err != nil { - return err - } - - validator := validator.APIValidator(validator.Options{ - SpecLoader: specLoader, - ResourceTypeGetter: validator.RadiusResourceTypeGetter, - }) - - // Register resource routers. - // - // Note: We have to follow the below rules to enable API validators: - // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. - // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. - - mongoPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/mongodatabases", validator) - mongoResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/mongodatabases", validator) - mongoResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/mongodatabases/{mongoDatabaseName}", validator) - - handlerOptions := []server.HandlerOptions{ - { - ParentRouter: mongoPlaneRouter, - ResourceType: linkrp.MongoDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: mongoResourceGroupRouter, - ResourceType: linkrp.MongoDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.MongoDatabasesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.MongoDatabasesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.MongoDatabase]{ - rp_frontend.PrepareRadiusResource[*datamodel.MongoDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateMongoDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.MongoDatabasesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.MongoDatabase]{ - rp_frontend.PrepareRadiusResource[*datamodel.MongoDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateMongoDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: mongoResourceRouter, - ResourceType: linkrp.MongoDatabasesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ - RequestConverter: converter.MongoDatabaseDataModelFromVersioned, - ResponseConverter: converter.MongoDatabaseDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteMongoDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: mongoResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.MongoDatabasesResourceType, - Method: mongo_ctrl.OperationListSecret, - ControllerFactory: mongo_ctrl.NewListSecretsMongoDatabase, - }, - } - - pubsubPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/daprpubsubbrokers", validator) - pubsubResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/daprpubsubbrokers", validator) - pubsubResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/daprpubsubbrokers/{daprPubSubBrokerName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: pubsubPlaneRouter, - ResourceType: linkrp.DaprPubSubBrokersResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprPubSubBroker]{ - RequestConverter: converter.DaprPubSubBrokerDataModelFromVersioned, - ResponseConverter: converter.DaprPubSubBrokerDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: pubsubResourceGroupRouter, - ResourceType: linkrp.DaprPubSubBrokersResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprPubSubBroker]{ - RequestConverter: converter.DaprPubSubBrokerDataModelFromVersioned, - ResponseConverter: converter.DaprPubSubBrokerDataModelToVersioned, - }) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.DaprPubSubBrokersResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprPubSubBroker]{ - RequestConverter: converter.DaprPubSubBrokerDataModelFromVersioned, - ResponseConverter: converter.DaprPubSubBrokerDataModelToVersioned, - }) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.DaprPubSubBrokersResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprPubSubBroker]{ - RequestConverter: converter.DaprPubSubBrokerDataModelFromVersioned, - ResponseConverter: converter.DaprPubSubBrokerDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.DaprPubSubBroker]{ - rp_frontend.PrepareRadiusResource[*datamodel.DaprPubSubBroker], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.DaprPubSubBrokersResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprPubSubBroker]{ - RequestConverter: converter.DaprPubSubBrokerDataModelFromVersioned, - ResponseConverter: converter.DaprPubSubBrokerDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.DaprPubSubBroker]{ - rp_frontend.PrepareRadiusResource[*datamodel.DaprPubSubBroker], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: pubsubResourceRouter, - ResourceType: linkrp.DaprPubSubBrokersResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprPubSubBroker]{ - RequestConverter: converter.DaprPubSubBrokerDataModelFromVersioned, - ResponseConverter: converter.DaprPubSubBrokerDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - secretStorePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/daprsecretstores", validator) - secretStoreResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/daprsecretstores", validator) - secretStoreResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/daprsecretstores/{daprSecretStoreName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: secretStorePlaneRouter, - ResourceType: linkrp.DaprSecretStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprSecretStore]{ - RequestConverter: converter.DaprSecretStoreDataModelFromVersioned, - ResponseConverter: converter.DaprSecretStoreDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: secretStoreResourceGroupRouter, - ResourceType: linkrp.DaprSecretStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprSecretStore]{ - RequestConverter: converter.DaprSecretStoreDataModelFromVersioned, - ResponseConverter: converter.DaprSecretStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.DaprSecretStoresResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprSecretStore]{ - RequestConverter: converter.DaprSecretStoreDataModelFromVersioned, - ResponseConverter: converter.DaprSecretStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.DaprSecretStoresResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprSecretStore]{ - RequestConverter: converter.DaprSecretStoreDataModelFromVersioned, - ResponseConverter: converter.DaprSecretStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.DaprSecretStore]{ - rp_frontend.PrepareRadiusResource[*datamodel.DaprSecretStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprSecretStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.DaprSecretStoresResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprSecretStore]{ - RequestConverter: converter.DaprSecretStoreDataModelFromVersioned, - ResponseConverter: converter.DaprSecretStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.DaprSecretStore]{ - rp_frontend.PrepareRadiusResource[*datamodel.DaprSecretStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprSecretStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: secretStoreResourceRouter, - ResourceType: linkrp.DaprSecretStoresResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprSecretStore]{ - RequestConverter: converter.DaprSecretStoreDataModelFromVersioned, - ResponseConverter: converter.DaprSecretStoreDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteDaprSecretStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - stateStorePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/daprstatestores", validator) - stateStoreResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/daprstatestores", validator) - stateStoreResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/daprstatestores/{daprStateStoreName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: stateStorePlaneRouter, - ResourceType: linkrp.DaprStateStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprStateStore]{ - RequestConverter: converter.DaprStateStoreDataModelFromVersioned, - ResponseConverter: converter.DaprStateStoreDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: stateStoreResourceGroupRouter, - ResourceType: linkrp.DaprStateStoresResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprStateStore]{ - RequestConverter: converter.DaprStateStoreDataModelFromVersioned, - ResponseConverter: converter.DaprStateStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.DaprStateStoresResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprStateStore]{ - RequestConverter: converter.DaprStateStoreDataModelFromVersioned, - ResponseConverter: converter.DaprStateStoreDataModelToVersioned, - }) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.DaprStateStoresResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprStateStore]{ - RequestConverter: converter.DaprStateStoreDataModelFromVersioned, - ResponseConverter: converter.DaprStateStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.DaprStateStore]{ - rp_frontend.PrepareRadiusResource[*datamodel.DaprStateStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprStateStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.DaprStateStoresResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprStateStore]{ - RequestConverter: converter.DaprStateStoreDataModelFromVersioned, - ResponseConverter: converter.DaprStateStoreDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.DaprStateStore]{ - rp_frontend.PrepareRadiusResource[*datamodel.DaprStateStore], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateDaprStateStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: stateStoreResourceRouter, - ResourceType: linkrp.DaprStateStoresResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.DaprStateStore]{ - RequestConverter: converter.DaprStateStoreDataModelFromVersioned, - ResponseConverter: converter.DaprStateStoreDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteDaprStateStoreTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - }...) - - redisPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/rediscaches", validator) - redisResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/rediscaches", validator) - redisResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/rediscaches/{redisCacheName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: redisPlaneRouter, - ResourceType: linkrp.RedisCachesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.RedisCache]{ - RequestConverter: converter.RedisCacheDataModelFromVersioned, - ResponseConverter: converter.RedisCacheDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: redisResourceGroupRouter, - ResourceType: linkrp.RedisCachesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.RedisCache]{ - RequestConverter: converter.RedisCacheDataModelFromVersioned, - ResponseConverter: converter.RedisCacheDataModelToVersioned, - }) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.RedisCachesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.RedisCache]{ - RequestConverter: converter.RedisCacheDataModelFromVersioned, - ResponseConverter: converter.RedisCacheDataModelToVersioned, - }) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.RedisCachesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.RedisCache]{ - RequestConverter: converter.RedisCacheDataModelFromVersioned, - ResponseConverter: converter.RedisCacheDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.RedisCache]{ - rp_frontend.PrepareRadiusResource[*datamodel.RedisCache], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRedisCacheTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.RedisCachesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.RedisCache]{ - RequestConverter: converter.RedisCacheDataModelFromVersioned, - ResponseConverter: converter.RedisCacheDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.RedisCache]{ - rp_frontend.PrepareRadiusResource[*datamodel.RedisCache], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRedisCacheTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: redisResourceRouter, - ResourceType: linkrp.RedisCachesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.RedisCache]{ - RequestConverter: converter.RedisCacheDataModelFromVersioned, - ResponseConverter: converter.RedisCacheDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteRedisCacheTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: redisResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.RedisCachesResourceType, - Method: redis_ctrl.OperationListSecret, - ControllerFactory: redis_ctrl.NewListSecretsRedisCache, - }, - }...) - - rmqPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/rabbitmqmessagequeues", validator) - rmqResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/rabbitmqmessagequeues", validator) - rmqResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/rabbitmqmessagequeues/{rabbitMQMessageQueueName}", validator) - - // Messaging handlers: - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: rmqPlaneRouter, - ResourceType: linkrp.RabbitMQMessageQueuesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.RabbitMQMessageQueue]{ - RequestConverter: converter.RabbitMQMessageQueueDataModelFromVersioned, - ResponseConverter: converter.RabbitMQMessageQueueDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: rmqResourceGroupRouter, - ResourceType: linkrp.RabbitMQMessageQueuesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.RabbitMQMessageQueue]{ - RequestConverter: converter.RabbitMQMessageQueueDataModelFromVersioned, - ResponseConverter: converter.RabbitMQMessageQueueDataModelToVersioned, - }) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.RabbitMQMessageQueuesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.RabbitMQMessageQueue]{ - RequestConverter: converter.RabbitMQMessageQueueDataModelFromVersioned, - ResponseConverter: converter.RabbitMQMessageQueueDataModelToVersioned, - }) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.RabbitMQMessageQueuesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.RabbitMQMessageQueue]{ - RequestConverter: converter.RabbitMQMessageQueueDataModelFromVersioned, - ResponseConverter: converter.RabbitMQMessageQueueDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.RabbitMQMessageQueue]{ - rp_frontend.PrepareRadiusResource[*datamodel.RabbitMQMessageQueue], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRabbitMQTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.RabbitMQMessageQueuesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.RabbitMQMessageQueue]{ - RequestConverter: converter.RabbitMQMessageQueueDataModelFromVersioned, - ResponseConverter: converter.RabbitMQMessageQueueDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.RabbitMQMessageQueue]{ - rp_frontend.PrepareRadiusResource[*datamodel.RabbitMQMessageQueue], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateRabbitMQTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: rmqResourceRouter, - ResourceType: linkrp.RabbitMQMessageQueuesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.RabbitMQMessageQueue]{ - RequestConverter: converter.RabbitMQMessageQueueDataModelFromVersioned, - ResponseConverter: converter.RabbitMQMessageQueueDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteRabbitMQTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: rmqResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.RabbitMQMessageQueuesResourceType, - Method: rabbitmq_ctrl.OperationListSecret, - ControllerFactory: rabbitmq_ctrl.NewListSecretsRabbitMQMessageQueue, - }, - }...) - - sqlPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/sqldatabases", validator) - sqlResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/sqldatabases", validator) - sqlResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/sqldatabases/{sqlDatabaseName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: sqlPlaneRouter, - ResourceType: linkrp.SqlDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.SqlDatabase]{ - RequestConverter: converter.SqlDatabaseDataModelFromVersioned, - ResponseConverter: converter.SqlDatabaseDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: sqlResourceGroupRouter, - ResourceType: linkrp.SqlDatabasesResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.SqlDatabase]{ - RequestConverter: converter.SqlDatabaseDataModelFromVersioned, - ResponseConverter: converter.SqlDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.SqlDatabasesResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.SqlDatabase]{ - RequestConverter: converter.SqlDatabaseDataModelFromVersioned, - ResponseConverter: converter.SqlDatabaseDataModelToVersioned, - }) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.SqlDatabasesResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.SqlDatabase]{ - RequestConverter: converter.SqlDatabaseDataModelFromVersioned, - ResponseConverter: converter.SqlDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.SqlDatabase]{ - rp_frontend.PrepareRadiusResource[*datamodel.SqlDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateSqlDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.SqlDatabasesResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.SqlDatabase]{ - RequestConverter: converter.SqlDatabaseDataModelFromVersioned, - ResponseConverter: converter.SqlDatabaseDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.SqlDatabase]{ - rp_frontend.PrepareRadiusResource[*datamodel.SqlDatabase], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateSqlDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: sqlResourceRouter, - ResourceType: linkrp.SqlDatabasesResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.SqlDatabase]{ - RequestConverter: converter.SqlDatabaseDataModelFromVersioned, - ResponseConverter: converter.SqlDatabaseDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteSqlDatabaseTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: sqlResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.SqlDatabasesResourceType, - Method: sql_ctrl.OperationListSecret, - ControllerFactory: sql_ctrl.NewListSecretsSqlDatabase, - }, - }...) - - extPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.link/extenders", validator) - extResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/extenders", validator) - extResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.link/extenders/{extenderName}", validator) - - handlerOptions = append(handlerOptions, []server.HandlerOptions{ - { - ParentRouter: extPlaneRouter, - ResourceType: linkrp.ExtendersResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - ListRecursiveQuery: true, - }) - }, - }, - { - ParentRouter: extResourceGroupRouter, - ResourceType: linkrp.ExtendersResourceType, - Method: v1.OperationList, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewListResources(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - }) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: linkrp.ExtendersResourceType, - Method: v1.OperationGet, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewGetResource(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - }) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: linkrp.ExtendersResourceType, - Method: v1.OperationPut, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Extender]{ - rp_frontend.PrepareRadiusResource[*datamodel.Extender], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateExtenderTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: linkrp.ExtendersResourceType, - Method: v1.OperationPatch, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncPut(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.Extender]{ - rp_frontend.PrepareRadiusResource[*datamodel.Extender], - }, - AsyncOperationTimeout: link_frontend_ctrl.AsyncCreateOrUpdateExtenderTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: extResourceRouter, - ResourceType: linkrp.ExtendersResourceType, - Method: v1.OperationDelete, - ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { - return defaultoperation.NewDefaultAsyncDelete(opt, - frontend_ctrl.ResourceOptions[datamodel.Extender]{ - RequestConverter: converter.ExtenderDataModelFromVersioned, - ResponseConverter: converter.ExtenderDataModelToVersioned, - AsyncOperationTimeout: link_frontend_ctrl.AsyncDeleteExtenderTimeout, - AsyncOperationRetryAfter: link_frontend_ctrl.AsyncOperationRetryAfter, - }, - ) - }, - }, - { - ParentRouter: extResourceRouter, - Path: "/listsecrets", - ResourceType: linkrp.ExtendersResourceType, - Method: extender_ctrl.OperationListSecret, - ControllerFactory: extender_ctrl.NewListSecretsExtender, - }, - }...) - - for _, h := range handlerOptions { - if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { - return err - } - } - - return nil -} - -func getRootScopePath(isARM bool) string { - if isARM { - return "/subscriptions/{subscriptionID}" - } - return "/planes/radius/{planeName}" -} diff --git a/pkg/linkrp/frontend/handler/routes_test.go b/pkg/linkrp/frontend/handler/routes_test.go deleted file mode 100644 index e02e59e412..0000000000 --- a/pkg/linkrp/frontend/handler/routes_test.go +++ /dev/null @@ -1,522 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handler - -import ( - "context" - "net/http" - "testing" - - "github.com/go-chi/chi/v5" - "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/linkrp" - extender_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/extenders" - mongo_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/mongodatabases" - rabbitmq_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/rabbitmqmessagequeues" - redis_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/rediscaches" - sql_ctrl "github.com/project-radius/radius/pkg/linkrp/frontend/controller/sqldatabases" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/store" -) - -var handlerTests = []rpctest.HandlerTestSpec{ - // Routes for resources after Split Namespaces - { - OperationType: v1.OperationType{Type: linkrp.N_RabbitMQQueuesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.messaging/rabbitmqqueues", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RabbitMQQueuesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RabbitMQQueuesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RabbitMQQueuesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RabbitMQQueuesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RabbitMQQueuesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RabbitMQQueuesResourceType, Method: rabbitmq_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprPubSubBrokersResourceType, Method: v1.OperationList}, - Path: "/providers/applications.dapr/pubsubbrokers", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprPubSubBrokersResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprPubSubBrokersResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprPubSubBrokersResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprPubSubBrokersResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprPubSubBrokersResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprSecretStoresResourceType, Method: v1.OperationList}, - Path: "/providers/applications.dapr/secretstores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprSecretStoresResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprSecretStoresResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprSecretStoresResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprSecretStoresResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprSecretStoresResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprStateStoresResourceType, Method: v1.OperationList}, - Path: "/providers/applications.dapr/statestores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprStateStoresResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.dapr/statestores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprStateStoresResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprStateStoresResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprStateStoresResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.N_DaprStateStoresResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.N_MongoDatabasesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.datastores/mongodatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_MongoDatabasesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_MongoDatabasesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_MongoDatabasesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.N_MongoDatabasesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.N_MongoDatabasesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.N_MongoDatabasesResourceType, Method: mongo_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RedisCachesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.datastores/rediscaches", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RedisCachesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RedisCachesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RedisCachesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RedisCachesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RedisCachesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.N_RedisCachesResourceType, Method: redis_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.N_SqlDatabasesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.datastores/sqldatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_SqlDatabasesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_SqlDatabasesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.N_SqlDatabasesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.N_SqlDatabasesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.N_SqlDatabasesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.N_SqlDatabasesResourceType, Method: sql_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprPubSubBrokersResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/daprpubsubbrokers", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprPubSubBrokersResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/daprpubsubbrokers", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprPubSubBrokersResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/daprpubsubbrokers/daprpubsub", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprPubSubBrokersResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/daprpubsubbrokers/daprpubsub", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprPubSubBrokersResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/daprpubsubbrokers/daprpubsub", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprPubSubBrokersResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/daprpubsubbrokers/daprpubsub", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprSecretStoresResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/daprsecretstores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprSecretStoresResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/daprsecretstores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprSecretStoresResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/daprsecretstores/daprsecretstore", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprSecretStoresResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/daprsecretstores/daprsecretstore", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprSecretStoresResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/daprsecretstores/daprsecretstore", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprSecretStoresResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/daprsecretstores/daprsecretstore", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprStateStoresResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/daprstatestores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprStateStoresResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/daprstatestores", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprStateStoresResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/daprstatestores/daprstatestore", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprStateStoresResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/daprstatestores/daprstatestore", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprStateStoresResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/daprstatestores/daprstatestore", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.DaprStateStoresResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/daprstatestores/daprstatestore", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.ExtendersResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/extenders", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.ExtendersResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/extenders", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.ExtendersResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/extenders/extender", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.ExtendersResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/extenders/extender", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.ExtendersResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/extenders/extender", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.ExtendersResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/extenders/extender", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.ExtendersResourceType, Method: extender_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.link/extenders/extender/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.MongoDatabasesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/mongodatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.MongoDatabasesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/mongodatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.MongoDatabasesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/mongodatabases/mongo", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.MongoDatabasesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/mongodatabases/mongo", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.MongoDatabasesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/mongodatabases/mongo", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.MongoDatabasesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/mongodatabases/mongo", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.MongoDatabasesResourceType, Method: mongo_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.link/mongodatabases/mongo/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.RedisCachesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/rediscaches", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.RedisCachesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/rediscaches", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.RedisCachesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/rediscaches/redis", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.RedisCachesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/rediscaches/redis", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.RedisCachesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/rediscaches/redis", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.RedisCachesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/rediscaches/redis", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.RedisCachesResourceType, Method: redis_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.link/rediscaches/redis/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.RabbitMQMessageQueuesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/rabbitmqmessagequeues", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.RabbitMQMessageQueuesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/rabbitmqmessagequeues", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.RabbitMQMessageQueuesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/rabbitmqmessagequeues/rabbitmq", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.RabbitMQMessageQueuesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/rabbitmqmessagequeues/rabbitmq", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.RabbitMQMessageQueuesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/rabbitmqmessagequeues/rabbitmq", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.RabbitMQMessageQueuesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/rabbitmqmessagequeues/rabbitmq", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.RabbitMQMessageQueuesResourceType, Method: rabbitmq_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.link/rabbitmqmessagequeues/rabbitmq/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: linkrp.SqlDatabasesResourceType, Method: v1.OperationList}, - Path: "/providers/applications.link/sqldatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.SqlDatabasesResourceType, Method: v1.OperationList}, - Path: "/resourcegroups/testrg/providers/applications.link/sqldatabases", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.SqlDatabasesResourceType, Method: v1.OperationGet}, - Path: "/resourcegroups/testrg/providers/applications.link/sqldatabases/sql", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: linkrp.SqlDatabasesResourceType, Method: v1.OperationPut}, - Path: "/resourcegroups/testrg/providers/applications.link/sqldatabases/sql", - Method: http.MethodPut, - }, { - OperationType: v1.OperationType{Type: linkrp.SqlDatabasesResourceType, Method: v1.OperationPatch}, - Path: "/resourcegroups/testrg/providers/applications.link/sqldatabases/sql", - Method: http.MethodPatch, - }, { - OperationType: v1.OperationType{Type: linkrp.SqlDatabasesResourceType, Method: v1.OperationDelete}, - Path: "/resourcegroups/testrg/providers/applications.link/sqldatabases/sql", - Method: http.MethodDelete, - }, { - OperationType: v1.OperationType{Type: linkrp.SqlDatabasesResourceType, Method: sql_ctrl.OperationListSecret}, - Path: "/resourcegroups/testrg/providers/applications.link/sqldatabases/sql/listsecrets", - Method: http.MethodPost, - }, { - OperationType: v1.OperationType{Type: "Applications.Link/operationStatuses", Method: v1.OperationGetOperationStatuses}, - Path: "/providers/applications.link/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: "Applications.Link/operationStatuses", Method: v1.OperationGetOperationResult}, - Path: "/providers/applications.link/locations/global/operationresults/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: "Applications.Messaging/operationStatuses", Method: v1.OperationGetOperationStatuses}, - Path: "/providers/applications.messaging/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: "Applications.Messaging/operationStatuses", Method: v1.OperationGetOperationResult}, - Path: "/providers/applications.messaging/locations/global/operationresults/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, - { - OperationType: v1.OperationType{Type: "Applications.Dapr/operationStatuses", Method: v1.OperationGetOperationStatuses}, - Path: "/providers/applications.dapr/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, { - OperationType: v1.OperationType{Type: "Applications.Dapr/operationStatuses", Method: v1.OperationGetOperationResult}, - Path: "/providers/applications.dapr/locations/global/operationresults/00000000-0000-0000-0000-000000000000", - Method: http.MethodGet, - }, -} - -func TestHandlers(t *testing.T) { - mctrl := gomock.NewController(t) - defer mctrl.Finish() - - mockSP := dataprovider.NewMockDataStorageProvider(mctrl) - mockSC := store.NewMockStorageClient(mctrl) - - mockSC.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(&store.Object{}, nil).AnyTimes() - mockSC.EXPECT().Save(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - mockSP.EXPECT().GetStorageClient(gomock.Any(), gomock.Any()).Return(store.StorageClient(mockSC), nil).AnyTimes() - - t.Run("UCP", func(t *testing.T) { - // Test handlers for UCP resources. - rpctest.AssertRouters(t, handlerTests, "/api.ucp.dev", "/planes/radius/local", func(ctx context.Context) (chi.Router, error) { - r := chi.NewRouter() - return r, AddRoutes(ctx, r, false, ctrl.Options{PathBase: "/api.ucp.dev", DataProvider: mockSP}) - }) - }) - - t.Run("Azure", func(t *testing.T) { - // Add azure specific handlers. - azureHandlerTests := append(handlerTests, []rpctest.HandlerTestSpec{ - { - OperationType: v1.OperationType{Type: "Applications.Link/providers", Method: v1.OperationGet}, - Path: "/providers/applications.link/operations", - Method: http.MethodGet, - WithoutRootScope: true, - SkipOperationTypeValidation: true, - }, { - OperationType: v1.OperationType{Type: "Applications.Messaging/providers", Method: v1.OperationGet}, - Path: "/providers/applications.messaging/operations", - Method: http.MethodGet, - WithoutRootScope: true, - SkipOperationTypeValidation: true, - }, - { - OperationType: v1.OperationType{Type: "Applications.Dapr/providers", Method: v1.OperationGet}, - Path: "/providers/applications.dapr/operations", - Method: http.MethodGet, - WithoutRootScope: true, - SkipOperationTypeValidation: true, - }, - { - OperationType: v1.OperationType{Type: "Applications.Datastores/providers", Method: v1.OperationGet}, - Path: "/providers/applications.datastores/operations", - Method: http.MethodGet, - WithoutRootScope: true, - SkipOperationTypeValidation: true, - }, - }...) - - // Test handlers for Azure resources - rpctest.AssertRouters(t, azureHandlerTests, "", "/subscriptions/00000000-0000-0000-0000-000000000000", func(ctx context.Context) (chi.Router, error) { - r := chi.NewRouter() - return r, AddRoutes(ctx, r, true, ctrl.Options{PathBase: "", DataProvider: mockSP}) - }) - }) -} diff --git a/pkg/linkrp/frontend/service.go b/pkg/linkrp/frontend/service.go deleted file mode 100644 index 0507098b0c..0000000000 --- a/pkg/linkrp/frontend/service.go +++ /dev/null @@ -1,81 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package frontend - -import ( - "context" - "fmt" - - "github.com/go-chi/chi/v5" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/linkrp/frontend/handler" - - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" -) - -type Service struct { - server.Service -} - -// NewService creates a new Service instance with the given options. -func NewService(options hostoptions.HostOptions) *Service { - return &Service{ - server.Service{ - Options: options, - ProviderName: handler.LinkProviderNamespace, - }, - } -} - -// Name returns the namespace of the link provider. -func (s *Service) Name() string { - return handler.LinkProviderNamespace -} - -// Run sets up the server and starts it, returning an error if any. -func (s *Service) Run(ctx context.Context) error { - if err := s.Init(ctx); err != nil { - return err - } - - opts := ctrl.Options{ - Address: fmt.Sprintf("%s:%d", s.Options.Config.Server.Host, s.Options.Config.Server.Port), - PathBase: s.Options.Config.Server.PathBase, - DataProvider: s.StorageProvider, - KubeClient: s.KubeClient, - StatusManager: s.OperationStatusManager, - } - - err := s.Start(ctx, server.Options{ - Address: opts.Address, - ProviderNamespace: s.ProviderName, - Location: s.Options.Config.Env.RoleLocation, - PathBase: s.Options.Config.Server.PathBase, - // set the arm cert manager for managing client certificate - ArmCertMgr: s.ARMCertManager, - EnableArmAuth: s.Options.Config.Server.EnableArmAuth, // when enabled the client cert validation will be done - Configure: func(router chi.Router) error { - err := handler.AddRoutes(ctx, router, !hostoptions.IsSelfHosted(), opts) - if err != nil { - return err - } - return nil - }, - }) - return err -} diff --git a/pkg/linkrp/handlers/util.go b/pkg/linkrp/handlers/util.go deleted file mode 100644 index 58d4497f1c..0000000000 --- a/pkg/linkrp/handlers/util.go +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handlers - -import ( - "context" - "fmt" - "strings" - - "github.com/project-radius/radius/pkg/kubernetes" - - k8serrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -const daprConflictFmt = "the Dapr component name '%q' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again" - -// CheckDaprResourceNameUniqueness checks if the resource name is unique in the namespace. If the resource name is not unique, it returns an error. -// -// This protects against some of the following scenarios: -// -// - Two Dapr resources with the same component name but different types. -// - Two Dapr resources with different UCP resource names, but the same Dapr component name. -// -// Note: the Dapr component name and UCP resource name are NOT the same thing. Users can override the Dapr component name. -func CheckDaprResourceNameUniqueness(ctx context.Context, k8s client.Client, componentName string, namespace string, resourceName string, resourceType string) error { - u := &unstructured.Unstructured{} - u.SetGroupVersionKind(schema.GroupVersionKind{ - Kind: "Component", - Version: "dapr.io/v1alpha1", - }) - err := k8s.Get(ctx, client.ObjectKey{ - Namespace: namespace, - Name: componentName, - }, u) - if k8serrors.IsNotFound(err) { - // Object with the same name doesn't exist. - return nil - } else if err != nil { - return err - } - - // Object with the same name exists, checking the labels to see if they are 'owned' by the same Radius - // resource. - // - // We also need to handle the case where the component has no Radius labels. - resourceTypeLabel := u.GetLabels()[kubernetes.LabelRadiusResourceType] - resourceNameLabel := u.GetLabels()[kubernetes.LabelRadiusResource] - if strings.EqualFold(resourceNameLabel, resourceName) && - strings.EqualFold(kubernetes.ConvertLabelToResourceType(resourceTypeLabel), resourceType) { - return nil - } - - return fmt.Errorf(daprConflictFmt, componentName) -} diff --git a/pkg/linkrp/handlers/util_test.go b/pkg/linkrp/handlers/util_test.go deleted file mode 100644 index 210eb0479d..0000000000 --- a/pkg/linkrp/handlers/util_test.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package handlers - -import ( - "context" - "fmt" - "testing" - - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/test/k8sutil" - "github.com/stretchr/testify/require" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -func Test_CheckDaprResourceNameUniqueness_NotFound(t *testing.T) { - client := k8sutil.NewFakeKubeClient(nil) - - err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", linkrp.DaprStateStoresResourceType) - require.NoError(t, err) -} - -func Test_CheckDaprResourceNameUniqueness_SameRadiusResource(t *testing.T) { - labels := kubernetes.MakeDescriptiveDaprLabels("test-app", "test-resource", linkrp.DaprStateStoresResourceType) - existing := createUnstructuredComponent("test-component", "default", labels) - client := k8sutil.NewFakeKubeClient(nil, existing) - - err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", linkrp.DaprStateStoresResourceType) - require.NoError(t, err) -} - -func Test_CheckDaprResourceNameUniqueness_NoLabels(t *testing.T) { - existing := createUnstructuredComponent("test-component", "default", nil) - client := k8sutil.NewFakeKubeClient(nil, existing) - - err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", linkrp.DaprStateStoresResourceType) - require.Error(t, err) - require.Equal(t, fmt.Sprintf(daprConflictFmt, "test-component"), err.Error()) -} - -func Test_CheckDaprResourceNameUniqueness_DifferentResourceNames(t *testing.T) { - labels := kubernetes.MakeDescriptiveDaprLabels("test-app", "different-resource", linkrp.DaprStateStoresResourceType) - existing := createUnstructuredComponent("test-component", "default", labels) - client := k8sutil.NewFakeKubeClient(nil, existing) - - err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", linkrp.DaprStateStoresResourceType) - require.Error(t, err) - require.Equal(t, fmt.Sprintf(daprConflictFmt, "test-component"), err.Error()) -} - -func Test_CheckDaprResourceNameUniqueness_DifferentResourceTypes(t *testing.T) { - labels := kubernetes.MakeDescriptiveDaprLabels("test-app", "test-resource", linkrp.DaprPubSubBrokersResourceType) - existing := createUnstructuredComponent("test-component", "default", labels) - client := k8sutil.NewFakeKubeClient(nil, existing) - - err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", linkrp.DaprStateStoresResourceType) - require.Error(t, err) - require.Equal(t, fmt.Sprintf(daprConflictFmt, "test-component"), err.Error()) -} - -func createUnstructuredComponent(name string, namespace string, labels map[string]any) *unstructured.Unstructured { - u := &unstructured.Unstructured{} - u.SetGroupVersionKind(schema.GroupVersionKind{ - Kind: "Component", - Version: "dapr.io/v1alpha1", - }) - u.SetNamespace(namespace) - u.SetName(name) - - if labels == nil { - return u - } - - // This is (unfortunately) needed, because unstructured wants a map[string]string for labels. However - // some of the fake clients want a map[string]any and WILL NOT work with map[string]string. So our API - // returns map[string]any. - copy := map[string]string{} - for k, v := range labels { - copy[k] = v.(string) - } - - u.SetLabels(copy) - return u -} diff --git a/pkg/linkrp/processors/daprpubsubbrokers/doc.go b/pkg/linkrp/processors/daprpubsubbrokers/doc.go deleted file mode 100644 index 10043dcfac..0000000000 --- a/pkg/linkrp/processors/daprpubsubbrokers/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// daprpubsubbrokers contains the resource processor for Dapr Pub Sub Brokers. See the processors package for more information. -package daprpubsubbrokers diff --git a/pkg/linkrp/processors/daprpubsubbrokers/processor.go b/pkg/linkrp/processors/daprpubsubbrokers/processor.go deleted file mode 100644 index dc2d41ac75..0000000000 --- a/pkg/linkrp/processors/daprpubsubbrokers/processor.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package daprpubsubbrokers - -import ( - "context" - - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/handlers" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime_client "sigs.k8s.io/controller-runtime/pkg/client" -) - -type Processor struct { - Client runtime_client.Client -} - -// Process validates resource properties, and applies output values from the recipe output. If the resource is -// being provisioned manually, it creates a Dapr component in Kubernetes. -func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprPubSubBroker, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - validator.AddResourcesField(&resource.Properties.Resources) - validator.AddComputedStringField("componentName", &resource.Properties.ComponentName, func() (string, *processors.ValidationError) { - return kubernetes.NormalizeDaprResourceName(resource.Name), nil - }) - - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - if resource.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { - // If the resource is being provisioned by recipe then we expect the recipe to create the Dapr Component - // in Kubernetes. At this point we're done so we can just return. - return nil - } - - // If the resource is being provisioned manually then *we* are responsible for creating the Dapr Component. - // Let's do this now. - - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil { - return err // This should already be validated by this point. - } - - component, err := dapr.ConstructDaprGeneric( - dapr.DaprGeneric{ - Metadata: resource.Properties.Metadata, - Type: to.Ptr(resource.Properties.Type), - Version: to.Ptr(resource.Properties.Version), - }, - options.RuntimeConfiguration.Kubernetes.Namespace, - resource.Properties.ComponentName, - applicationID.Name(), - resource.Name, - linkrp.DaprPubSubBrokersResourceType) - if err != nil { - return err - } - - err = kubeutil.PatchNamespace(ctx, p.Client, component.GetNamespace()) - if err != nil { - return &processors.ResourceError{Inner: err} - } - - err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, linkrp.DaprPubSubBrokersResourceType) - if err != nil { - return &processors.ValidationError{Message: err.Error()} - } - - err = p.Client.Patch(ctx, &component, runtime_client.Apply, &runtime_client.PatchOptions{FieldManager: kubernetes.FieldManager}) - if err != nil { - return &processors.ResourceError{Inner: err} - } - - deployed := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) - deployed.RadiusManaged = to.Ptr(true) - resource.Properties.Status.OutputResources = append(resource.Properties.Status.OutputResources, deployed) - - return nil -} diff --git a/pkg/linkrp/processors/daprpubsubbrokers/processor_test.go b/pkg/linkrp/processors/daprpubsubbrokers/processor_test.go deleted file mode 100644 index 59313d12b4..0000000000 --- a/pkg/linkrp/processors/daprpubsubbrokers/processor_test.go +++ /dev/null @@ -1,335 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package daprpubsubbrokers - -import ( - "context" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/k8sutil" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/kubectl/pkg/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func Test_Process(t *testing.T) { - const externalResourceID1 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.Cache/redis/myredis1" - const externalResourceID2 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.Cache/redis/myredis2" - const kubernetesResource = "/planes/kubernetes/local/namespaces/test-namespace/providers/dapr.io/Component/test-component" - const appID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Core/applications/test-app" - const envID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Core/environments/test-env" - const componentName = "test-dapr-pubsub-broker" - - t.Run("success - recipe", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme), - } - - resource := &datamodel.DaprPubSubBroker{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: componentName, - }, - }, - Properties: datamodel.DaprPubSubBrokerProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: appID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - externalResourceID1, - kubernetesResource, - }, - Values: map[string]any{}, // Component name will be computed for resource name. - Secrets: map[string]any{}, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - - // No components created for a recipe - err = processor.Client.List(context.Background(), &components, - &client.ListOptions{ - Namespace: options.RuntimeConfiguration.Kubernetes.Namespace, - }, - ) - require.NoError(t, err) - require.Empty(t, components.Items) - }) - - t.Run("success - manual", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test-namespace"}}), - } - - resource := &datamodel.DaprPubSubBroker{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprPubSubBrokerProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: appID, - Environment: envID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{ - "config": "extrasecure", - }, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, - Type: "pubsub.redis", - Version: "v1", - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField(resource.Properties.Resources) - - generated := &unstructured.Unstructured{ - Object: map[string]any{ - "apiVersion": "dapr.io/v1alpha1", - "kind": "Component", - "metadata": map[string]any{ - "namespace": "test-namespace", - "name": "test-dapr-pubsub-broker", - "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", linkrp.DaprPubSubBrokersResourceType), - "resourceVersion": "1", - }, - "spec": map[string]any{ - "type": "pubsub.redis", - "version": "v1", - "metadata": []any{ - map[string]any{ - "name": "config", - "value": "extrasecure", - }, - }, - }, - }, - } - - component := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) - component.RadiusManaged = to.Ptr(true) - component.Resource = generated - expectedOutputResources = append(expectedOutputResources, component) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - err = processor.Client.List(context.Background(), &components, &client.ListOptions{Namespace: options.RuntimeConfiguration.Kubernetes.Namespace}) - require.NoError(t, err) - require.NotEmpty(t, components.Items) - require.Equal(t, []unstructured.Unstructured{*generated}, components.Items) - }) - - t.Run("success - recipe with overrides", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme), - } - - resource := &datamodel.DaprPubSubBroker{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprPubSubBrokerProperties{ - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - externalResourceID2, - kubernetesResource, - }, - - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "componentName": "akskdf", - }, - Secrets: map[string]any{}, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - - resourcesFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField(resource.Properties.Resources) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, resourcesFieldOutputResources...) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - err = processor.Client.List(context.Background(), &components, - &client.ListOptions{ - Namespace: options.RuntimeConfiguration.Kubernetes.Namespace, - }, - ) - require.NoError(t, err) - require.Empty(t, components.Items) - }) - - t.Run("failure - duplicate component", func(t *testing.T) { - // Create a duplicate with the same component name. - existing, err := dapr.ConstructDaprGeneric( - dapr.DaprGeneric{ - Type: to.Ptr("pubsub.redis"), - Version: to.Ptr("v1"), - Metadata: map[string]any{}, - }, - "test-namespace", - "test-dapr-pubsub-broker", - "test-app", - "some-other-other-name", - linkrp.DaprPubSubBrokersResourceType) - require.NoError(t, err) - - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test-namespace"}}, &existing), - } - resource := &datamodel.DaprPubSubBroker{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprPubSubBrokerProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: appID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{"config": "extrasecure"}, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, - Type: "pubsub.redis", - Version: "v1", - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - } - - err = processor.Process(context.Background(), resource, options) - require.Error(t, err) - assert.IsType(t, &processors.ValidationError{}, err) - assert.Equal(t, "the Dapr component name '\"test-dapr-pubsub-broker\"' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again", err.Error()) - }) -} diff --git a/pkg/linkrp/processors/daprsecretstores/doc.go b/pkg/linkrp/processors/daprsecretstores/doc.go deleted file mode 100644 index 4e06d921d3..0000000000 --- a/pkg/linkrp/processors/daprsecretstores/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// daprsecretstores contains the resource processor for Dapr Secret Stores. See the processors package for more information. -package daprsecretstores diff --git a/pkg/linkrp/processors/daprsecretstores/processor.go b/pkg/linkrp/processors/daprsecretstores/processor.go deleted file mode 100644 index 61fe9c8a26..0000000000 --- a/pkg/linkrp/processors/daprsecretstores/processor.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package daprsecretstores - -import ( - "context" - - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/handlers" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime_client "sigs.k8s.io/controller-runtime/pkg/client" -) - -type Processor struct { - Client runtime_client.Client -} - -// Process validates resource properties, and applies output values from the recipe output. If the resource is being -// provisioned manually, it creates a Dapr component in Kubernetes. -func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprSecretStore, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - validator.AddComputedStringField("componentName", &resource.Properties.ComponentName, func() (string, *processors.ValidationError) { - return kubernetes.NormalizeDaprResourceName(resource.Name), nil - }) - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - if resource.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { - // If the resource is being provisioned by recipe then we expect the recipe to create the Dapr Component - // in Kubernetes. At this point we're done so we can just return. - return nil - } - // If the resource is being provisioned manually then *we* are responsible for creating the Dapr Component. - // Let's do this now. - - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil { - return err // This should already be validated by this point. - } - - component, err := dapr.ConstructDaprGeneric( - dapr.DaprGeneric{ - Metadata: resource.Properties.Metadata, - Type: to.Ptr(resource.Properties.Type), - Version: to.Ptr(resource.Properties.Version), - }, - options.RuntimeConfiguration.Kubernetes.Namespace, - resource.Properties.ComponentName, - applicationID.Name(), - resource.Name, - linkrp.DaprSecretStoresResourceType) - if err != nil { - return err - } - - err = kubeutil.PatchNamespace(ctx, p.Client, component.GetNamespace()) - if err != nil { - return &processors.ResourceError{Inner: err} - } - - err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, linkrp.DaprSecretStoresResourceType) - if err != nil { - return &processors.ValidationError{Message: err.Error()} - } - - err = p.Client.Patch(ctx, &component, runtime_client.Apply, &runtime_client.PatchOptions{FieldManager: kubernetes.FieldManager}) - if err != nil { - return &processors.ResourceError{Inner: err} - } - - deployed := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) - deployed.RadiusManaged = to.Ptr(true) - resource.Properties.Status.OutputResources = append(resource.Properties.Status.OutputResources, deployed) - - return nil -} diff --git a/pkg/linkrp/processors/daprsecretstores/processor_test.go b/pkg/linkrp/processors/daprsecretstores/processor_test.go deleted file mode 100644 index d1894614aa..0000000000 --- a/pkg/linkrp/processors/daprsecretstores/processor_test.go +++ /dev/null @@ -1,308 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package daprsecretstores - -import ( - "context" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/k8sutil" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/kubectl/pkg/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func Test_Process(t *testing.T) { - const kubernetesResource = "/planes/kubernetes/local/namespaces/test-namespace/providers/dapr.io/Component/test-component" - const applicationID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Core/applications/test-app" - const componentName = "test-component" - - t.Run("success - recipe", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme), - } - - resource := &datamodel.DaprSecretStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: componentName, - }, - }, - Properties: datamodel.DaprSecretStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: applicationID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - }, - } - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - kubernetesResource, - }, - Values: map[string]any{}, // Component name will be computed for resource name. - Secrets: map[string]any{}, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - - // No components created for a recipe - err = processor.Client.List(context.Background(), &components, &client.ListOptions{Namespace: options.RuntimeConfiguration.Kubernetes.Namespace}) - require.NoError(t, err) - require.Empty(t, components.Items) - }) - - t.Run("success - values", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test-namespace"}}), - } - - resource := &datamodel.DaprSecretStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprSecretStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: applicationID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{"config": "extrasecure"}, - Type: "secretstores.kubernetes", - Version: "v1", - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - generated := &unstructured.Unstructured{ - Object: map[string]any{ - "apiVersion": "dapr.io/v1alpha1", - "kind": "Component", - "metadata": map[string]any{ - "namespace": "test-namespace", - "name": "test-component", - "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", linkrp.DaprSecretStoresResourceType), - "resourceVersion": "1", - }, - "spec": map[string]any{ - "type": "secretstores.kubernetes", - "version": "v1", - "metadata": []any{ - map[string]any{ - "name": "config", - "value": "extrasecure", - }, - }, - }, - }, - } - - component := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) - component.RadiusManaged = to.Ptr(true) - component.Resource = generated - expectedOutputResources := []rpv1.OutputResource{component} - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - err = processor.Client.List(context.Background(), &components, &client.ListOptions{Namespace: options.RuntimeConfiguration.Kubernetes.Namespace}) - require.NoError(t, err) - require.NotEmpty(t, components.Items) - require.Equal(t, []unstructured.Unstructured{*generated}, components.Items) - }) - - t.Run("success - recipe with value overrides", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme), - } - - resource := &datamodel.DaprSecretStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprSecretStoreProperties{ - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - }, - } - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - kubernetesResource, - }, - - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "componentName": "akskdf", - }, - Secrets: map[string]any{}, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - err = processor.Client.List(context.Background(), &components, &client.ListOptions{Namespace: options.RuntimeConfiguration.Kubernetes.Namespace}) - require.NoError(t, err) - require.Empty(t, components.Items) - }) - - t.Run("failure - duplicate component", func(t *testing.T) { - // Create a duplicate with the same component name. - existing, err := dapr.ConstructDaprGeneric( - dapr.DaprGeneric{ - Type: to.Ptr("secretstores.kubernetes"), - Version: to.Ptr("v1"), - Metadata: map[string]any{}, - }, - "test-namespace", - "test-component", - "test-app", - "some-other-other-name", - linkrp.DaprSecretStoresResourceType) - require.NoError(t, err) - - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test-namespace"}}, &existing), - } - resource := &datamodel.DaprSecretStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprSecretStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: applicationID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{"config": "extrasecure"}, - Type: "secretstores.kubernetes", - Version: "v1", - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - } - - err = processor.Process(context.Background(), resource, options) - require.Error(t, err) - assert.IsType(t, &processors.ValidationError{}, err) - assert.Equal(t, "the Dapr component name '\"test-component\"' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again", err.Error()) - }) -} diff --git a/pkg/linkrp/processors/daprstatestores/doc.go b/pkg/linkrp/processors/daprstatestores/doc.go deleted file mode 100644 index b15a2f1143..0000000000 --- a/pkg/linkrp/processors/daprstatestores/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// daprstatestores contains the resource processor for Dapr State Stores. See the processors package for more information. -package daprstatestores diff --git a/pkg/linkrp/processors/daprstatestores/processor.go b/pkg/linkrp/processors/daprstatestores/processor.go deleted file mode 100644 index 47cbdaee5a..0000000000 --- a/pkg/linkrp/processors/daprstatestores/processor.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package daprstatestores - -import ( - "context" - - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/handlers" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime_client "sigs.k8s.io/controller-runtime/pkg/client" -) - -type Processor struct { - Client runtime_client.Client -} - -// Process validates resource properties, and applies output values from the recipe output. If the resource is being -// provisioned manually, it creates a Dapr component in Kubernetes. -func (p *Processor) Process(ctx context.Context, resource *datamodel.DaprStateStore, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - validator.AddResourcesField(&resource.Properties.Resources) - validator.AddComputedStringField("componentName", &resource.Properties.ComponentName, func() (string, *processors.ValidationError) { - return kubernetes.NormalizeDaprResourceName(resource.Name), nil - }) - - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - if resource.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { - // If the resource is being provisioned by recipe then we expect the recipe to create the Dapr Component - // in Kubernetes. At this point we're done so we can just return. - return nil - } - - // If the resource is being provisioned manually then *we* are responsible for creating the Dapr Component. - // Let's do this now. - - applicationID, err := resources.ParseResource(resource.Properties.Application) - if err != nil { - return err // This should already be validated by this point. - } - - component, err := dapr.ConstructDaprGeneric( - dapr.DaprGeneric{ - Metadata: resource.Properties.Metadata, - Type: to.Ptr(resource.Properties.Type), - Version: to.Ptr(resource.Properties.Version), - }, - options.RuntimeConfiguration.Kubernetes.Namespace, - resource.Properties.ComponentName, - applicationID.Name(), - resource.Name, - linkrp.DaprStateStoresResourceType) - if err != nil { - return err - } - - err = kubeutil.PatchNamespace(ctx, p.Client, component.GetNamespace()) - if err != nil { - return &processors.ResourceError{Inner: err} - } - - err = handlers.CheckDaprResourceNameUniqueness(ctx, p.Client, resource.Properties.ComponentName, options.RuntimeConfiguration.Kubernetes.Namespace, resource.Name, linkrp.DaprStateStoresResourceType) - if err != nil { - return &processors.ValidationError{Message: err.Error()} - } - - err = p.Client.Patch(ctx, &component, runtime_client.Apply, &runtime_client.PatchOptions{FieldManager: kubernetes.FieldManager}) - if err != nil { - return &processors.ResourceError{Inner: err} - } - - deployed := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", &component, metav1.ObjectMeta{Name: component.GetName(), Namespace: component.GetNamespace()}) - deployed.RadiusManaged = to.Ptr(true) - resource.Properties.Status.OutputResources = append(resource.Properties.Status.OutputResources, deployed) - - return nil -} diff --git a/pkg/linkrp/processors/daprstatestores/processor_test.go b/pkg/linkrp/processors/daprstatestores/processor_test.go deleted file mode 100644 index 038249bc48..0000000000 --- a/pkg/linkrp/processors/daprstatestores/processor_test.go +++ /dev/null @@ -1,323 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package daprstatestores - -import ( - "context" - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers/dapr" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcekinds" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/test/k8sutil" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/kubectl/pkg/scheme" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func Test_Process(t *testing.T) { - - const externalResourceID1 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.Cache/redis/myredis1" - const externalResourceID2 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.Cache/redis/myredis2" - const kubernetesResource = "/planes/kubernetes/local/namespaces/test-namespace/providers/dapr.io/Component/test-component" - const applicationID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Core/applications/test-app" - const componentName = "test-component" - - t.Run("success - recipe", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme), - } - - resource := &datamodel.DaprStateStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: componentName, - }, - }, - Properties: datamodel.DaprStateStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: applicationID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - }, - } - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - externalResourceID1, - kubernetesResource, - }, - Values: map[string]any{}, // Component name will be computed for resource name. - Secrets: map[string]any{}, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - - // No components created for a recipe - err = processor.Client.List(context.Background(), &components, &client.ListOptions{Namespace: options.RuntimeConfiguration.Kubernetes.Namespace}) - require.NoError(t, err) - require.Empty(t, components.Items) - }) - - t.Run("success - manual", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test-namespace"}}), - } - - resource := &datamodel.DaprStateStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprStateStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: applicationID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{"config": "extrasecure"}, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, - Type: "state.redis", - Version: "v1", - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField(resource.Properties.Resources) - - generated := &unstructured.Unstructured{ - Object: map[string]any{ - "apiVersion": "dapr.io/v1alpha1", - "kind": "Component", - "metadata": map[string]any{ - "namespace": "test-namespace", - "name": "test-component", - "labels": kubernetes.MakeDescriptiveDaprLabels("test-app", "some-other-name", linkrp.DaprStateStoresResourceType), - "resourceVersion": "1", - }, - "spec": map[string]any{ - "type": "state.redis", - "version": "v1", - "metadata": []any{ - map[string]any{ - "name": "config", - "value": "extrasecure", - }, - }, - }, - }, - } - - component := rpv1.NewKubernetesOutputResource(resourcekinds.DaprComponent, "Component", generated, metav1.ObjectMeta{Name: generated.GetName(), Namespace: generated.GetNamespace()}) - component.RadiusManaged = to.Ptr(true) - component.Resource = generated - expectedOutputResources = append(expectedOutputResources, component) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - err = processor.Client.List(context.Background(), &components, &client.ListOptions{Namespace: options.RuntimeConfiguration.Kubernetes.Namespace}) - require.NoError(t, err) - require.NotEmpty(t, components.Items) - require.Equal(t, []unstructured.Unstructured{*generated}, components.Items) - }) - - t.Run("success - recipe with value overrides", func(t *testing.T) { - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme), - } - - resource := &datamodel.DaprStateStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprStateStoreProperties{ - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - }, - } - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - externalResourceID2, - kubernetesResource, - }, - - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "componentName": "akskdf", - }, - Secrets: map[string]any{}, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, componentName, resource.Properties.ComponentName) - - expectedValues := map[string]any{ - "componentName": componentName, - } - expectedSecrets := map[string]rpv1.SecretValueReference{} - - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - - resourcesFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField(resource.Properties.Resources) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, resourcesFieldOutputResources...) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - - components := unstructured.UnstructuredList{} - components.SetAPIVersion("dapr.io/v1alpha1") - components.SetKind("Component") - err = processor.Client.List(context.Background(), &components, &client.ListOptions{Namespace: options.RuntimeConfiguration.Kubernetes.Namespace}) - require.NoError(t, err) - require.Empty(t, components.Items) - }) - - t.Run("failure - duplicate component", func(t *testing.T) { - // Create a duplicate with the same component name. - existing, err := dapr.ConstructDaprGeneric( - dapr.DaprGeneric{ - Type: to.Ptr("state.redis"), - Version: to.Ptr("v1"), - Metadata: map[string]any{}, - }, - "test-namespace", - "test-component", - "test-app", - "some-other-other-name", - linkrp.DaprStateStoresResourceType) - require.NoError(t, err) - - processor := Processor{ - Client: k8sutil.NewFakeKubeClient(scheme.Scheme, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "test-namespace"}}, &existing), - } - resource := &datamodel.DaprStateStore{ - BaseResource: v1.BaseResource{ - TrackedResource: v1.TrackedResource{ - Name: "some-other-name", - }, - }, - Properties: datamodel.DaprStateStoreProperties{ - BasicResourceProperties: rpv1.BasicResourceProperties{ - Application: applicationID, - }, - BasicDaprResourceProperties: rpv1.BasicDaprResourceProperties{ - ComponentName: componentName, - }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, - Metadata: map[string]any{"config": "extrasecure"}, - Resources: []*linkrp.ResourceReference{{ID: externalResourceID1}}, - Type: "state.redis", - Version: "v1", - }, - } - - options := processors.Options{ - RuntimeConfiguration: recipes.RuntimeConfiguration{ - Kubernetes: &recipes.KubernetesRuntime{ - Namespace: "test-namespace", - }, - }, - } - - err = processor.Process(context.Background(), resource, options) - require.Error(t, err) - assert.IsType(t, &processors.ValidationError{}, err) - assert.Equal(t, "the Dapr component name '\"test-component\"' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again", err.Error()) - }) -} diff --git a/pkg/linkrp/processors/doc.go b/pkg/linkrp/processors/doc.go deleted file mode 100644 index 33f9f7aa74..0000000000 --- a/pkg/linkrp/processors/doc.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// processors contains the shared logic and interfaces for implementing a resource processor. -// -// Resource processors are responsible for processing the results of recipe execution or any -// other change to the lifecycle of a link resource. -// -// For example a mongo processor might take the results of executing a recipe and compute -// and store the connection string as part of the resource data model. -package processors diff --git a/pkg/linkrp/processors/extenders/doc.go b/pkg/linkrp/processors/extenders/doc.go deleted file mode 100644 index 70871bf83a..0000000000 --- a/pkg/linkrp/processors/extenders/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// extenders contains the resource processor for extenders. See the processors package for more information. -package extenders diff --git a/pkg/linkrp/processors/extenders/processor.go b/pkg/linkrp/processors/extenders/processor.go deleted file mode 100644 index 1ca1bf77d8..0000000000 --- a/pkg/linkrp/processors/extenders/processor.go +++ /dev/null @@ -1,71 +0,0 @@ -package extenders - -import ( - "context" - "fmt" - - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" -) - -// Processor is a processor for Extender resources. -type Processor struct { -} - -// Process implements the processors.Processor interface for Extender resources. It validates and merges output values from -// the recipe output with the existing values in the resource. It returns an error if the secret values are not of type string -// or if any of the other validations fail. -func (p *Processor) Process(ctx context.Context, resource *datamodel.Extender, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - - computedValues := mergeOutputValues(resource.Properties.AdditionalProperties, options.RecipeOutput, false) - for k, val := range computedValues { - value := val - validator.AddOptionalAnyField(k, value) - } - - secretValues := mergeOutputValues(resource.Properties.Secrets, options.RecipeOutput, true) - for k, val := range secretValues { - if secret, ok := val.(string); !ok { - return &processors.ValidationError{Message: fmt.Sprintf("secret '%s' must be of type string", k)} - } else { - value := secret - validator.AddOptionalSecretField(k, &value) - } - } - - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - if options.RecipeOutput != nil { - resource.Properties.AdditionalProperties = options.RecipeOutput.Values - resource.Properties.Secrets = options.RecipeOutput.Secrets - } - - return nil -} - -func mergeOutputValues(properties map[string]any, recipeOutput *recipes.RecipeOutput, secret bool) map[string]any { - values := make(map[string]any) - for k, val := range properties { - values[k] = val - } - if recipeOutput == nil { - return values - } - - var recipeProperties map[string]any - if secret { - recipeProperties = recipeOutput.Secrets - } else { - recipeProperties = recipeOutput.Values - } - - for k, val := range recipeProperties { - values[k] = val - } - return values -} diff --git a/pkg/linkrp/processors/extenders/processor_test.go b/pkg/linkrp/processors/extenders/processor_test.go deleted file mode 100644 index 24946d6b28..0000000000 --- a/pkg/linkrp/processors/extenders/processor_test.go +++ /dev/null @@ -1,228 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package extenders - -import ( - "context" - "testing" - - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/stretchr/testify/require" -) - -const ( - extenderResourceID1 = "/planes/aws/aws/accounts/123341234/regions/us-west-2/providers/AWS.S3/Bucket/myBucket" - extenderResourceID2 = "/planes/aws/aws/accounts/123341234/regions/us-west-2/providers/AWS.S3/Bucket/myBucket2" - password = "testpassword" -) - -func Test_Process(t *testing.T) { - processor := Processor{} - t.Run("success - recipe", func(t *testing.T) { - resource := &datamodel.Extender{} - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - extenderResourceID1, - }, - Values: map[string]any{ - "bucketName": "myBucket", - "region": "westus", - }, - Secrets: map[string]any{ - "databaseSecret": password, - "adminSecret": password, - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, "myBucket", resource.Properties.AdditionalProperties["bucketName"]) - require.Equal(t, "westus", resource.Properties.AdditionalProperties["region"]) - require.Equal(t, password, resource.Properties.Secrets["databaseSecret"]) - require.Equal(t, password, resource.Properties.Secrets["adminSecret"]) - - expectedValues := map[string]any{ - "bucketName": "myBucket", - "region": "westus", - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "databaseSecret": { - Value: password, - }, - "adminSecret": { - Value: password, - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - manual", func(t *testing.T) { - resource := &datamodel.Extender{ - Properties: datamodel.ExtenderProperties{ - AdditionalProperties: map[string]any{"bucketName": "myBucket"}, - Secrets: map[string]any{ - "databaseSecret": password, - }, - }, - } - err := processor.Process(context.Background(), resource, processors.Options{}) - require.NoError(t, err) - - require.Equal(t, "myBucket", resource.Properties.AdditionalProperties["bucketName"]) - require.Equal(t, password, resource.Properties.Secrets["databaseSecret"]) - - expectedValues := map[string]any{ - "bucketName": "myBucket", - } - - expectedSecrets := map[string]rpv1.SecretValueReference{ - "databaseSecret": { - Value: password, - }, - } - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - }) - - t.Run("success - recipe with value overrides", func(t *testing.T) { - resource := &datamodel.Extender{ - Properties: datamodel.ExtenderProperties{ - AdditionalProperties: map[string]any{ - "bucketName": "myBucket", - }, - Secrets: map[string]any{ - "databaseSecret": password, - }, - }, - } - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - extenderResourceID2, - }, - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "bucketName": "myBucket2", - }, - Secrets: map[string]any{ - "databaseSecret": "overridepassword", - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, "myBucket2", resource.Properties.AdditionalProperties["bucketName"]) - require.Equal(t, "overridepassword", resource.Properties.Secrets["databaseSecret"]) - - expectedValues := map[string]any{ - "bucketName": "myBucket2", - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "databaseSecret": { - Value: "overridepassword", - }, - } - - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("failure - missing required values", func(t *testing.T) { - resource := &datamodel.Extender{ - Properties: datamodel.ExtenderProperties{ - Secrets: map[string]any{ - "databaseSecret": 24, - }, - }, - } - options := processors.Options{RecipeOutput: &recipes.RecipeOutput{}} - - err := processor.Process(context.Background(), resource, options) - require.Error(t, err) - require.IsType(t, &processors.ValidationError{}, err) - require.Equal(t, `secret 'databaseSecret' must be of type string`, err.Error()) - - }) -} - -func Test_MergeOutputValues(t *testing.T) { - resource := &datamodel.Extender{ - Properties: datamodel.ExtenderProperties{ - AdditionalProperties: map[string]any{"bucketName": "myBucket"}, - Secrets: map[string]any{ - "databaseSecret1": password, - }, - }, - } - propertiesMap := mergeOutputValues(resource.Properties.AdditionalProperties, nil, false) - require.Equal(t, resource.Properties.AdditionalProperties, propertiesMap) - secretsMap := mergeOutputValues(resource.Properties.Secrets, nil, true) - require.Equal(t, resource.Properties.Secrets, secretsMap) - - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - extenderResourceID1, - }, - Values: map[string]any{ - "region": "westus", - }, - Secrets: map[string]any{ - "databaseSecret2": password, - "adminSecret": password, - }, - }, - } - - expectedAdditionalProperties := map[string]any{ - "bucketName": "myBucket", - "region": "westus", - } - expectedSecrets := map[string]any{ - "databaseSecret1": password, - "databaseSecret2": password, - "adminSecret": password, - } - - propertiesMap = mergeOutputValues(resource.Properties.AdditionalProperties, options.RecipeOutput, false) - require.Equal(t, expectedAdditionalProperties, propertiesMap) - secretsMap = mergeOutputValues(resource.Properties.Secrets, options.RecipeOutput, true) - require.Equal(t, expectedSecrets, secretsMap) -} diff --git a/pkg/linkrp/processors/mock_resourceclient.go b/pkg/linkrp/processors/mock_resourceclient.go deleted file mode 100644 index 036dd52ce5..0000000000 --- a/pkg/linkrp/processors/mock_resourceclient.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/linkrp/processors (interfaces: ResourceClient) - -// Package processors is a generated GoMock package. -package processors - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" -) - -// MockResourceClient is a mock of ResourceClient interface. -type MockResourceClient struct { - ctrl *gomock.Controller - recorder *MockResourceClientMockRecorder -} - -// MockResourceClientMockRecorder is the mock recorder for MockResourceClient. -type MockResourceClientMockRecorder struct { - mock *MockResourceClient -} - -// NewMockResourceClient creates a new mock instance. -func NewMockResourceClient(ctrl *gomock.Controller) *MockResourceClient { - mock := &MockResourceClient{ctrl: ctrl} - mock.recorder = &MockResourceClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockResourceClient) EXPECT() *MockResourceClientMockRecorder { - return m.recorder -} - -// Delete mocks base method. -func (m *MockResourceClient) Delete(arg0 context.Context, arg1, arg2 string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// Delete indicates an expected call of Delete. -func (mr *MockResourceClientMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockResourceClient)(nil).Delete), arg0, arg1, arg2) -} diff --git a/pkg/linkrp/processors/mongodatabases/doc.go b/pkg/linkrp/processors/mongodatabases/doc.go deleted file mode 100644 index f2b3458a41..0000000000 --- a/pkg/linkrp/processors/mongodatabases/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// mongodatabases contains the resource processor for Mongo databases. See the processors package for more information. -package mongodatabases diff --git a/pkg/linkrp/processors/mongodatabases/processor.go b/pkg/linkrp/processors/mongodatabases/processor.go deleted file mode 100644 index 4ddf999827..0000000000 --- a/pkg/linkrp/processors/mongodatabases/processor.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mongodatabases - -import ( - "context" - "fmt" - - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" -) - -// Processor is a processor for MongoDB resources. -type Processor struct { -} - -// Process implements the processors.Processor interface for MongoDB resources. It validates MongoDatabase properties -// and applies the values from the RecipeOutput. -func (p *Processor) Process(ctx context.Context, resource *datamodel.MongoDatabase, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - - validator.AddResourcesField(&resource.Properties.Resources) - validator.AddRequiredStringField(renderers.Host, &resource.Properties.Host) - validator.AddRequiredInt32Field(renderers.Port, &resource.Properties.Port) - validator.AddRequiredStringField(renderers.DatabaseNameValue, &resource.Properties.Database) - validator.AddOptionalStringField(renderers.UsernameStringValue, &resource.Properties.Username) - validator.AddOptionalSecretField(renderers.PasswordStringHolder, &resource.Properties.Secrets.Password) - validator.AddComputedSecretField(renderers.ConnectionStringValue, &resource.Properties.Secrets.ConnectionString, func() (string, *processors.ValidationError) { - return p.computeConnectionString(resource), nil - }) - - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - return nil -} - -func (p *Processor) computeConnectionString(resource *datamodel.MongoDatabase) string { - connectionString := "mongodb://" - - if resource.Properties.Username != "" { - connectionString += resource.Properties.Username + ":" - } - if resource.Properties.Secrets.Password != "" { - connectionString += resource.Properties.Secrets.Password + "@" - } - - connectionString = fmt.Sprintf("%s%s:%v/%s", connectionString, resource.Properties.Host, resource.Properties.Port, resource.Properties.Database) - return connectionString -} diff --git a/pkg/linkrp/processors/mongodatabases/processor_test.go b/pkg/linkrp/processors/mongodatabases/processor_test.go deleted file mode 100644 index cd359b07c1..0000000000 --- a/pkg/linkrp/processors/mongodatabases/processor_test.go +++ /dev/null @@ -1,237 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package mongodatabases - -import ( - "context" - "testing" - - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/stretchr/testify/require" -) - -func Test_Process(t *testing.T) { - processor := Processor{} - - const azureMongoResourceID1 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.DocumentDB/mongo/mongodb1" - const azureMongoResourceID2 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.DocumentDB/mongo/mongodb2" - - const host = "test.mongo.cosmos.azure.com" - const port = 10255 - const username = "testuser" - const password = "testpassword" - const database = "authdb" - const connectionString = "mongodb://testuser:testpassword@test.mongo.cosmos.azure.com:10255/authdb" - - t.Run("success - recipe", func(t *testing.T) { - resource := &datamodel.MongoDatabase{} - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - azureMongoResourceID1, - }, - Values: map[string]any{ - "host": host, - "port": port, - "database": database, - "username": username, - }, - Secrets: map[string]any{ - "password": password, - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, host, resource.Properties.Host) - require.Equal(t, int32(port), resource.Properties.Port) - require.Equal(t, database, resource.Properties.Database) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - - expectedValues := map[string]any{ - "host": host, - "port": int32(port), - "database": database, - "username": username, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "connectionString": { - Value: connectionString, - }, - "password": { - Value: password, - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - manual", func(t *testing.T) { - resource := &datamodel.MongoDatabase{ - Properties: datamodel.MongoDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureMongoResourceID1}}, - Host: host, - Port: port, - Database: database, - Username: username, - Secrets: datamodel.MongoDatabaseSecrets{ - Password: password, - ConnectionString: connectionString, - }, - }, - } - err := processor.Process(context.Background(), resource, processors.Options{}) - require.NoError(t, err) - - require.Equal(t, host, resource.Properties.Host) - require.Equal(t, int32(port), resource.Properties.Port) - require.Equal(t, database, resource.Properties.Database) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - - expectedValues := map[string]any{ - "host": host, - "port": int32(port), - "database": database, - "username": username, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: password, - }, - "connectionString": { - Value: connectionString, - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ - { - ID: azureMongoResourceID1, - }, - }) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - recipe with value overrides", func(t *testing.T) { - resource := &datamodel.MongoDatabase{ - Properties: datamodel.MongoDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureMongoResourceID1}}, - Host: host, - Port: port, - Database: database, - Username: username, - Secrets: datamodel.MongoDatabaseSecrets{ - Password: password, - ConnectionString: connectionString, - }, - }, - } - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - azureMongoResourceID2, - }, - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "host": "asdf", - "port": 3333, - "database": "asdf", - "username": username, - }, - Secrets: map[string]any{ - "password": "asdf", - "connectionString": "asdf", - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, host, resource.Properties.Host) - require.Equal(t, int32(port), resource.Properties.Port) - require.Equal(t, database, resource.Properties.Database) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - - expectedValues := map[string]any{ - "host": host, - "port": int32(port), - "database": database, - "username": username, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: password, - }, - "connectionString": { - Value: connectionString, - }, - } - - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - - resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ - { - ID: azureMongoResourceID1, - }, - }) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, resourceFieldOutputResources...) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("failure - missing required values", func(t *testing.T) { - resource := &datamodel.MongoDatabase{} - options := processors.Options{RecipeOutput: &recipes.RecipeOutput{}} - - err := processor.Process(context.Background(), resource, options) - require.Error(t, err) - require.IsType(t, &processors.ValidationError{}, err) - require.Equal(t, `validation returned multiple errors: - -the connection value "host" should be provided by the recipe, set '.properties.host' to provide a value manually -the connection value "port" should be provided by the recipe, set '.properties.port' to provide a value manually -the connection value "database" should be provided by the recipe, set '.properties.database' to provide a value manually`, err.Error()) - }) -} diff --git a/pkg/linkrp/processors/rabbitmqmessagequeues/doc.go b/pkg/linkrp/processors/rabbitmqmessagequeues/doc.go deleted file mode 100644 index b43e4837d5..0000000000 --- a/pkg/linkrp/processors/rabbitmqmessagequeues/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// rabbitmqmessagequeues contains the resource processor for rabbitMQ. See the processors package for more information. -package rabbitmqmessagequeues diff --git a/pkg/linkrp/processors/rabbitmqmessagequeues/processor.go b/pkg/linkrp/processors/rabbitmqmessagequeues/processor.go deleted file mode 100644 index 67a29f0485..0000000000 --- a/pkg/linkrp/processors/rabbitmqmessagequeues/processor.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rabbitmqmessagequeues - -import ( - "context" - "fmt" - - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" -) - -const ( - Queue = "queue" - // RabbitMQSSLPort is the default port for RabbitMQ SSL connections. - RabbitMQSSLPort = 5671 -) - -// Processor is a processor for RabbitMQQueue resources. -type Processor struct { -} - -// Process implements the processors.Processor interface for RabbitMQQueue resources. It validates the required and computed -// RabbitMQMessageQueue properties and applies the values from the RecipeOutput. It returns an error if validation fails. - -func (p *Processor) Process(ctx context.Context, resource *datamodel.RabbitMQMessageQueue, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - validator.AddResourcesField(&resource.Properties.Resources) - validator.AddRequiredStringField(Queue, &resource.Properties.Queue) - validator.AddRequiredStringField(renderers.Host, &resource.Properties.Host) - validator.AddOptionalStringField(renderers.VHost, &resource.Properties.VHost) - validator.AddRequiredInt32Field(renderers.Port, &resource.Properties.Port) - validator.AddOptionalStringField(renderers.UsernameStringValue, &resource.Properties.Username) - validator.AddOptionalSecretField(renderers.PasswordStringHolder, &resource.Properties.Secrets.Password) - validator.AddComputedBoolField(renderers.TLS, &resource.Properties.TLS, func() (bool, *processors.ValidationError) { - return p.computeSSL(resource), nil - }) - validator.AddComputedSecretField(renderers.URI, &resource.Properties.Secrets.URI, func() (string, *processors.ValidationError) { - return p.computeURI(resource), nil - }) - - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - return nil -} - -func (p *Processor) computeURI(resource *datamodel.RabbitMQMessageQueue) string { - rabbitMQProtocol := "amqp" - if resource.Properties.TLS { - rabbitMQProtocol = "amqps" - } - usernamePassword := "" - if resource.Properties.Username != "" || resource.Properties.Secrets.Password != "" { - usernamePassword = fmt.Sprintf("%s:%s@", resource.Properties.Username, resource.Properties.Secrets.Password) - } - return fmt.Sprintf("%s://%s%s:%v/%s", rabbitMQProtocol, usernamePassword, resource.Properties.Host, resource.Properties.Port, resource.Properties.VHost) -} - -func (p *Processor) computeSSL(resource *datamodel.RabbitMQMessageQueue) bool { - return resource.Properties.Port == RabbitMQSSLPort -} diff --git a/pkg/linkrp/processors/rabbitmqmessagequeues/processor_test.go b/pkg/linkrp/processors/rabbitmqmessagequeues/processor_test.go deleted file mode 100644 index 8be096c76e..0000000000 --- a/pkg/linkrp/processors/rabbitmqmessagequeues/processor_test.go +++ /dev/null @@ -1,190 +0,0 @@ -/* -Copyright 2023 The Radius Authors. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package rabbitmqmessagequeues - -import ( - "context" - "testing" - - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/stretchr/testify/require" -) - -func Test_Process(t *testing.T) { - processor := Processor{} - - const queue = "test-queue" - const uri = "connection://string" - const host = "test-host" - const vHost = "test-vHost" - const port int32 = 5672 - const username = "test-user" - const password = "test-password" - rabbitMQOutputResources := []string{ - "/planes/kubernetes/local/namespaces/rabbitmq/providers/core/Service/rabbitmq-svc", - "/planes/kubernetes/local/namespaces/rabbitmq/providers/apps/Deployment/rabbitmq-deployment", - } - - t.Run("success - recipe", func(t *testing.T) { - resource := &datamodel.RabbitMQMessageQueue{} - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: rabbitMQOutputResources, - Values: map[string]any{ - "queue": queue, - "host": host, - "port": port, - "username": username, - "vHost": vHost, - "tls": true, - }, - Secrets: map[string]any{ - "password": password, - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, queue, resource.Properties.Queue) - expectedValues := map[string]any{ - "queue": queue, - "host": host, - "port": port, - "username": username, - "vHost": vHost, - "tls": true, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: password, - }, - "uri": { - Value: "amqps://test-user:test-password@test-host:5672/test-vHost", - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - manual", func(t *testing.T) { - resource := &datamodel.RabbitMQMessageQueue{ - Properties: datamodel.RabbitMQMessageQueueProperties{ - Queue: queue, - Host: host, - Port: port, - Username: username, - }, - } - err := processor.Process(context.Background(), resource, processors.Options{}) - require.NoError(t, err) - - require.Equal(t, queue, resource.Properties.Queue) - - expectedValues := map[string]any{ - "queue": queue, - "host": host, - "port": port, - "username": username, - "tls": false, - } - require.NoError(t, err) - require.Equal(t, expectedValues, resource.ComputedValues) - }) - - t.Run("success - recipe with value overrides", func(t *testing.T) { - resource := &datamodel.RabbitMQMessageQueue{ - Properties: datamodel.RabbitMQMessageQueueProperties{ - Queue: "new-queue", - Host: "new-host", - Port: int32(5671), - Username: "new-user", - Secrets: datamodel.RabbitMQSecrets{ - Password: "new-passoword", - URI: uri, - }, - }, - } - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: rabbitMQOutputResources, - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "queue": queue, - "host": host, - "port": port, - "username": username, - }, - Secrets: map[string]any{ - "password": password, - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, "new-queue", resource.Properties.Queue) - - expectedValues := map[string]any{ - "queue": "new-queue", - "host": "new-host", - "port": int32(5671), - "username": "new-user", - "tls": true, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: "new-passoword", - }, - "uri": { - Value: uri, - }, - } - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("failure - missing required values", func(t *testing.T) { - resource := &datamodel.RabbitMQMessageQueue{} - options := processors.Options{RecipeOutput: &recipes.RecipeOutput{}} - - err := processor.Process(context.Background(), resource, options) - require.Error(t, err) - require.IsType(t, &processors.ValidationError{}, err) - require.Equal(t, `validation returned multiple errors: - -the connection value "queue" should be provided by the recipe, set '.properties.queue' to provide a value manually -the connection value "host" should be provided by the recipe, set '.properties.host' to provide a value manually -the connection value "port" should be provided by the recipe, set '.properties.port' to provide a value manually`, err.Error()) - - }) -} diff --git a/pkg/linkrp/processors/rediscaches/doc.go b/pkg/linkrp/processors/rediscaches/doc.go deleted file mode 100644 index 2dd50cd6ca..0000000000 --- a/pkg/linkrp/processors/rediscaches/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// rediscaches contains the resource processor for redis caches. See the processors package for more information. -package rediscaches diff --git a/pkg/linkrp/processors/rediscaches/processor.go b/pkg/linkrp/processors/rediscaches/processor.go deleted file mode 100644 index d6242e1a2e..0000000000 --- a/pkg/linkrp/processors/rediscaches/processor.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rediscaches - -import ( - "context" - "fmt" - - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" -) - -const ( - // RedisNonSSLPort is the default port for Redis non-SSL connections. - RedisNonSSLPort = 6379 - - // RedisSSLPort is the default port for Redis SSL connections. - RedisSSLPort = 6380 -) - -// Processor is a processor for RedisCache resources. -type Processor struct { -} - -// Process implements the processors.Processor interface for RedisCache resources. It validates the input parameters and computes -// the connection string and connection URI for the RedisCache resource, and applies the values from the RecipeOutput. -func (p *Processor) Process(ctx context.Context, resource *datamodel.RedisCache, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - - validator.AddResourcesField(&resource.Properties.Resources) - validator.AddRequiredStringField(renderers.Host, &resource.Properties.Host) - validator.AddRequiredInt32Field(renderers.Port, &resource.Properties.Port) - validator.AddOptionalStringField(renderers.UsernameStringValue, &resource.Properties.Username) - validator.AddComputedBoolField(renderers.TLS, &resource.Properties.TLS, func() (bool, *processors.ValidationError) { - return p.computeSSL(resource), nil - }) - validator.AddOptionalSecretField(renderers.PasswordStringHolder, &resource.Properties.Secrets.Password) - validator.AddComputedSecretField(renderers.ConnectionStringValue, &resource.Properties.Secrets.ConnectionString, func() (string, *processors.ValidationError) { - return p.computeConnectionString(resource), nil - }) - validator.AddComputedSecretField(renderers.ConnectionURIValue, &resource.Properties.Secrets.URL, func() (string, *processors.ValidationError) { - return p.computeConnectionURI(resource), nil - }) - - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - return nil -} - -func (p *Processor) computeSSL(resource *datamodel.RedisCache) bool { - return resource.Properties.Port == RedisSSLPort -} - -func (p *Processor) computeConnectionString(resource *datamodel.RedisCache) string { - connectionString := fmt.Sprintf("%s:%v,abortConnect=False", resource.Properties.Host, resource.Properties.Port) - if resource.Properties.TLS { - connectionString = connectionString + ",ssl=True" - } - - if resource.Properties.Username != "" { - connectionString = connectionString + ",user=" + resource.Properties.Username - } - if resource.Properties.Secrets.Password != "" { - connectionString = connectionString + ",password=" + resource.Properties.Secrets.Password - } - - return connectionString -} - -func (p *Processor) computeConnectionURI(resource *datamodel.RedisCache) string { - // Redis connection URIs are of the form: redis://[username:password@]host[:port][/db-number][?option=value] - connectionURI := "redis://" - if resource.Properties.TLS { - connectionURI = "rediss://" - } - - if resource.Properties.Username != "" { - connectionURI += resource.Properties.Username - } - if resource.Properties.Secrets.Password != "" { - connectionURI += ":" + resource.Properties.Secrets.Password + "@" - } - - connectionURI = fmt.Sprintf("%s%s:%v/0?", connectionURI, resource.Properties.Host, resource.Properties.Port) - return connectionURI -} diff --git a/pkg/linkrp/processors/rediscaches/processor_test.go b/pkg/linkrp/processors/rediscaches/processor_test.go deleted file mode 100644 index fc774ee185..0000000000 --- a/pkg/linkrp/processors/rediscaches/processor_test.go +++ /dev/null @@ -1,249 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rediscaches - -import ( - "context" - "testing" - - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/stretchr/testify/require" -) - -func Test_Process(t *testing.T) { - processor := Processor{} - - const azureRedisResourceID1 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.Cache/redis/myredis1" - const azureRedisResourceID2 = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.Cache/redis/myredis2" - const host = "myredis.redis.cache.windows.net" - const connectionString = "myredis.redis.cache.windows.net:6380,abortConnect=False,ssl=True,user=testuser,password=testpassword" - const connectionString_NonSSL = "myredis.redis.cache.windows.net:6379,abortConnect=False,user=testuser,password=testpassword" - const connectionURI = "rediss://testuser:testpassword@myredis.redis.cache.windows.net:6380/0?" - const connectionURI_NonSSL = "redis://testuser:testpassword@myredis.redis.cache.windows.net:6379/0?" - const username = "testuser" - const password = "testpassword" - - t.Run("success - recipe", func(t *testing.T) { - resource := &datamodel.RedisCache{} - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - azureRedisResourceID1, - }, - Values: map[string]any{ - "host": host, - "port": RedisNonSSLPort, - "username": username, - }, - Secrets: map[string]any{ - "password": password, - // Let the connection string be computed, it will result in the same value - // as the variable 'connectionString' - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, host, resource.Properties.Host) - require.Equal(t, int32(RedisNonSSLPort), resource.Properties.Port) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, false, resource.Properties.TLS) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString_NonSSL, resource.Properties.Secrets.ConnectionString) - require.Equal(t, connectionURI_NonSSL, resource.Properties.Secrets.URL) - - expectedValues := map[string]any{ - "host": host, - "port": int32(RedisNonSSLPort), - "username": username, - "tls": false, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "connectionString": { - Value: connectionString_NonSSL, - }, - "password": { - Value: password, - }, - "url": { - Value: connectionURI_NonSSL, - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - manual", func(t *testing.T) { - resource := &datamodel.RedisCache{ - Properties: datamodel.RedisCacheProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureRedisResourceID1}}, - Host: host, - Port: RedisSSLPort, - Username: username, - TLS: true, - Secrets: datamodel.RedisCacheSecrets{ - Password: password, - ConnectionString: connectionString, - URL: connectionURI, - }, - }, - } - err := processor.Process(context.Background(), resource, processors.Options{}) - require.NoError(t, err) - - require.Equal(t, host, resource.Properties.Host) - require.Equal(t, int32(RedisSSLPort), resource.Properties.Port) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - require.Equal(t, connectionURI, resource.Properties.Secrets.URL) - - expectedValues := map[string]any{ - "host": host, - "port": int32(RedisSSLPort), - "username": username, - "tls": true, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: password, - }, - "connectionString": { - Value: connectionString, - }, - "url": { - Value: connectionURI, - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ - { - ID: azureRedisResourceID1, - }, - }) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - recipe with value overrides", func(t *testing.T) { - resource := &datamodel.RedisCache{ - Properties: datamodel.RedisCacheProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureRedisResourceID1}}, - Host: host, - Port: RedisNonSSLPort, - Username: username, - TLS: true, - - Secrets: datamodel.RedisCacheSecrets{ - Password: password, - ConnectionString: connectionString, - }, - }, - } - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - azureRedisResourceID2, - }, - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "host": "asdf", - "port": 3333, - "username": "asdf", - }, - Secrets: map[string]any{ - "password": "asdf", - "connectionString": "asdf", - "url": "asdf", - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, host, resource.Properties.Host) - require.Equal(t, int32(RedisNonSSLPort), resource.Properties.Port) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - require.Equal(t, "asdf", resource.Properties.Secrets.URL) - - expectedValues := map[string]any{ - "host": host, - "port": int32(RedisNonSSLPort), - "username": username, - "tls": true, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: password, - }, - "connectionString": { - Value: connectionString, - }, - "url": { - Value: "asdf", - }, - } - - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - - resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ - { - ID: azureRedisResourceID1, - }, - }) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, resourceFieldOutputResources...) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("failure - missing required values", func(t *testing.T) { - resource := &datamodel.RedisCache{} - options := processors.Options{RecipeOutput: &recipes.RecipeOutput{}} - - err := processor.Process(context.Background(), resource, options) - require.Error(t, err) - require.IsType(t, &processors.ValidationError{}, err) - require.Equal(t, `validation returned multiple errors: - -the connection value "host" should be provided by the recipe, set '.properties.host' to provide a value manually -the connection value "port" should be provided by the recipe, set '.properties.port' to provide a value manually`, err.Error()) - }) -} diff --git a/pkg/linkrp/processors/resourceclient_test.go b/pkg/linkrp/processors/resourceclient_test.go deleted file mode 100644 index b093d12826..0000000000 --- a/pkg/linkrp/processors/resourceclient_test.go +++ /dev/null @@ -1,455 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package processors - -import ( - "context" - "encoding/json" - "net/http" - "net/http/httptest" - "testing" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client/fake" -) - -const ( - ARMResourceID = "/subscriptions/0000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/test-vm" - ARMProviderPath = "/subscriptions/0000/providers/Microsoft.Compute" - AzureUCPResourceID = "/planes/azure/azurecloud/subscriptions/0000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/test-vm" - ARMAPIVersion = "2020-01-01" - AWSResourceID = "/planes/aws/aws/accounts/0000/regions/us-east-1/providers/AWS.Kinesis/Streams/test-stream" - KubernetesCoreGroupResourceID = "/planes/kubernetes/local/namespaces/test-namespace/providers/core/Secret/test-name" - KubernetesNonCoreGroupResourceID = "/planes/kubernetes/local/namespaces/test-namespace/providers/apps/Deployment/test-name" -) - -func Test_Delete_InvalidResourceID(t *testing.T) { - c := NewResourceClient(nil, nil, nil, nil) - err := c.Delete(context.Background(), "invalid", "") - require.Error(t, err) -} - -func Test_Delete_ARM(t *testing.T) { - t.Run("success", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMResourceID, handleDeleteSuccess(t)) - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), ARMResourceID, ARMAPIVersion) - require.NoError(t, err) - }) - - t.Run("success (ucp absolute ID)", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMResourceID, handleDeleteSuccess(t)) // Note, the /planes... prefix is not part of the request. - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), AzureUCPResourceID, ARMAPIVersion) - require.NoError(t, err) - }) - - t.Run("failure - delete fails", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMResourceID, handleJSONResponse(t, v1.ErrorResponse{ - Error: v1.ErrorDetails{ - Code: v1.CodeConflict, - }, - }, 409)) - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), ARMResourceID, ARMAPIVersion) - require.Error(t, err) - require.IsType(t, &ResourceError{}, err) - }) - - t.Run("success - lookup API Version (default)", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMResourceID, handleDeleteSuccess(t)) - mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ - Namespace: to.Ptr("Microsoft.Compute"), - ResourceTypes: []*armresources.ProviderResourceType{ - { - ResourceType: to.Ptr("anotherType"), - APIVersions: []*string{}, - }, - { - ResourceType: to.Ptr("virtualMachines"), - DefaultAPIVersion: to.Ptr(ARMAPIVersion), - }, - }, - }, 200)) - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), ARMResourceID, "") - require.NoError(t, err) - }) - - t.Run("success - lookup API Version (first available)", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMResourceID, handleDeleteSuccess(t)) - mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ - Namespace: to.Ptr("Microsoft.Compute"), - ResourceTypes: []*armresources.ProviderResourceType{ - { - ResourceType: to.Ptr("virtualMachines"), - APIVersions: []*string{to.Ptr("2020-01-01"), to.Ptr("2020-01-02")}, - }, - }, - }, 200)) - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), ARMResourceID, "") - require.NoError(t, err) - }) - - t.Run("failure - lookup API Version - provider not found", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMProviderPath, handleNotFound(t)) - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), ARMResourceID, "") - require.Error(t, err) - require.IsType(t, &ResourceError{}, err) - }) - - t.Run("failure - lookup API Version - resource type not found", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ - Namespace: to.Ptr("Microsoft.Compute"), - ResourceTypes: []*armresources.ProviderResourceType{}, - }, 200)) - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), ARMResourceID, "") - require.Error(t, err) - require.IsType(t, &ResourceError{}, err) - require.Contains(t, err.Error(), "could not find API version for type \"Microsoft.Compute/virtualMachines\", type was not found") - }) - - t.Run("failure - lookup API Version - no api versions", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ - Namespace: to.Ptr("Microsoft.Compute"), - ResourceTypes: []*armresources.ProviderResourceType{ - { - ResourceType: to.Ptr("virtualMachines"), - APIVersions: []*string{}, - }, - }, - }, 200)) - - server := httptest.NewServer(mux) - defer server.Close() - - c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) - c.armClientOptions = newClientOptions(server.Client(), server.URL) - - err := c.Delete(context.Background(), ARMResourceID, "") - require.Error(t, err) - require.IsType(t, &ResourceError{}, err) - require.Contains(t, err.Error(), "could not find API version for type \"Microsoft.Compute/virtualMachines\", no supported API versions") - }) -} - -func Test_Delete_Kubernetes(t *testing.T) { - t.Run("success", func(t *testing.T) { - client := fake.NewClientBuilder().WithObjects(&corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-name", - Namespace: "test-namespace", - }, - }).Build() - - c := NewResourceClient(nil, nil, client, nil) - - err := c.Delete(context.Background(), KubernetesCoreGroupResourceID, "v1") - require.NoError(t, err) - }) - - t.Run("success (non-core)", func(t *testing.T) { - client := fake.NewClientBuilder().WithObjects(&appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-name", - Namespace: "test-namespace", - }, - }).Build() - - c := NewResourceClient(nil, nil, client, nil) - - err := c.Delete(context.Background(), KubernetesNonCoreGroupResourceID, "v1") - require.NoError(t, err) - }) - - // Note: unfortunately there isn't a great way to test a deletion failure with the runtime client. - - t.Run("success - lookup API Version (preferred namespaced resources)", func(t *testing.T) { - client := fake.NewClientBuilder().WithObjects(&corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-name", - Namespace: "test-namespace", - }, - }).Build() - - dc := &discoveryClient{ - Resources: []*metav1.APIResourceList{ - { - GroupVersion: "v1", - APIResources: []metav1.APIResource{ - { - Name: "api1", - Version: "v1", - Kind: "Secret", - }, - }, - }, - }, - } - - c := NewResourceClient(nil, nil, client, dc) - - err := c.Delete(context.Background(), KubernetesCoreGroupResourceID, "") - require.NoError(t, err) - }) - - t.Run("success - lookup API Version (preferred empty namespace)", func(t *testing.T) { - client := fake.NewClientBuilder().WithObjects(&corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-name", - }, - }).Build() - - dc := &discoveryClient{ - Resources: []*metav1.APIResourceList{ - { - GroupVersion: "v1", - APIResources: []metav1.APIResource{ - { - Name: "api1", - Version: "v1", - Kind: "Secret", - }, - }, - }, - }, - } - - c := NewResourceClient(nil, nil, client, dc) - - err := c.Delete(context.Background(), KubernetesCoreGroupResourceID, "") - require.NoError(t, err) - }) - - t.Run("failure - lookup API Version - resource list not found", func(t *testing.T) { - client := fake.NewClientBuilder().WithObjects(&corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-name", - Namespace: "test-namespace", - }, - }).Build() - - dc := &discoveryClient{ - Resources: []*metav1.APIResourceList{}, - } - - c := NewResourceClient(nil, nil, client, dc) - - err := c.Delete(context.Background(), KubernetesCoreGroupResourceID, "") - require.Error(t, err) - require.Contains(t, err.Error(), "could not find API version for type \"core/Secret\", type was not found") - }) -} - -func Test_Delete_UCP(t *testing.T) { - t.Run("success", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(AWSResourceID, handleDeleteSuccess(t)) - - server := httptest.NewServer(mux) - defer server.Close() - - connection, err := sdk.NewDirectConnection(server.URL) - require.NoError(t, err) - - c := NewResourceClient(nil, connection, nil, nil) - - err = c.Delete(context.Background(), AWSResourceID, "") - require.NoError(t, err) - }) - - t.Run("failure - delete fails", func(t *testing.T) { - mux := http.NewServeMux() - mux.HandleFunc(AWSResourceID, handleJSONResponse(t, v1.ErrorResponse{ - Error: v1.ErrorDetails{ - Code: v1.CodeConflict, - }, - }, 409)) - - server := httptest.NewServer(mux) - defer server.Close() - - connection, err := sdk.NewDirectConnection(server.URL) - require.NoError(t, err) - - c := NewResourceClient(nil, connection, nil, nil) - - err = c.Delete(context.Background(), AWSResourceID, "") - require.Error(t, err) - require.IsType(t, &ResourceError{}, err) - }) -} - -func newArmOptions(url string) *armauth.ArmConfig { - return &armauth.ArmConfig{ - ClientOptions: clientv2.Options{ - Cred: &aztoken.AnonymousCredential{}, - BaseURI: url, - }, - } -} - -func newClientOptions(c *http.Client, url string) *arm.ClientOptions { - return &arm.ClientOptions{ - ClientOptions: policy.ClientOptions{ - Transport: &wrapper{Client: c}, - Cloud: cloud.Configuration{ - Services: map[cloud.ServiceName]cloud.ServiceConfiguration{ - cloud.ResourceManager: { - Endpoint: url, - Audience: "https://management.core.windows.net", - }, - }, - }, - }, - } -} - -func handleDeleteSuccess(t *testing.T) func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - defer r.Body.Close() - w.WriteHeader(204) - } -} - -func handleJSONResponse(t *testing.T, response any, statusCode int) func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - defer r.Body.Close() - b, err := json.Marshal(&response) - require.NoError(t, err) - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(statusCode) - _, err = w.Write(b) - require.NoError(t, err) - } -} - -func handleNotFound(t *testing.T) func(w http.ResponseWriter, r *http.Request) { - return handleJSONResponse(t, v1.ErrorResponse{ - Error: v1.ErrorDetails{ - Code: v1.CodeNotFound, - }, - }, 404) -} - -// wrapper implements the INTERNAL interface that autorest uses for transport :(. -type wrapper struct { - Client *http.Client -} - -// Do is a method that sends an HTTP request and returns an HTTP response and an error if one occurs. -func (w *wrapper) Do(req *http.Request) (*http.Response, error) { - return w.Client.Do(req) -} - -type discoveryClient struct { - Groups *metav1.APIGroupList - Resources []*metav1.APIResourceList - APIGroup []*metav1.APIGroup -} - -// ServerGroups returns a list of API groups supported by the server. -func (d *discoveryClient) ServerGroups() (*metav1.APIGroupList, error) { - return d.Groups, nil -} - -// This function returns a slice of API resource lists. -func (d *discoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error) { - return d.Resources, nil -} - -// This function returns a slice of API resource lists. -func (d *discoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) { - return d.Resources, nil -} - -// ServerGroupsAndResources returns a list of API groups and resources associated with the discovery client. -func (d *discoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { - return d.APIGroup, d.Resources, nil -} - -// ServerResourcesForGroupVersion returns nil for the API resource list. -func (d *discoveryClient) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) { - return nil, nil -} diff --git a/pkg/linkrp/processors/sqldatabases/doc.go b/pkg/linkrp/processors/sqldatabases/doc.go deleted file mode 100644 index 5688fbd2f2..0000000000 --- a/pkg/linkrp/processors/sqldatabases/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// ------------------------------------------------------------ - -// sqldatabases contains the resource processor for sql databases. See the processors package for more information. -package sqldatabases diff --git a/pkg/linkrp/processors/sqldatabases/processor.go b/pkg/linkrp/processors/sqldatabases/processor.go deleted file mode 100644 index e3772b5aad..0000000000 --- a/pkg/linkrp/processors/sqldatabases/processor.go +++ /dev/null @@ -1,55 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// ------------------------------------------------------------ - -package sqldatabases - -import ( - "context" - "fmt" - - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" -) - -// Processor is a processor for SqlDatabase resources. -type Processor struct { -} - -// Process implements the processors.Processor interface for SqlDatabase resources. It validates the given resource properties -// and sets the computed values and secrets in the resource, and applies the values from the RecipeOutput. -func (p *Processor) Process(ctx context.Context, resource *datamodel.SqlDatabase, options processors.Options) error { - validator := processors.NewValidator(&resource.ComputedValues, &resource.SecretValues, &resource.Properties.Status.OutputResources) - - validator.AddResourcesField(&resource.Properties.Resources) - validator.AddRequiredStringField(renderers.DatabaseNameValue, &resource.Properties.Database) - validator.AddRequiredStringField(renderers.ServerNameValue, &resource.Properties.Server) - validator.AddRequiredInt32Field(renderers.Port, &resource.Properties.Port) - validator.AddOptionalStringField(renderers.UsernameStringValue, &resource.Properties.Username) - validator.AddOptionalSecretField(renderers.PasswordStringHolder, &resource.Properties.Secrets.Password) - validator.AddComputedSecretField(renderers.ConnectionStringValue, &resource.Properties.Secrets.ConnectionString, func() (string, *processors.ValidationError) { - return p.computeConnectionString(resource), nil - }) - - err := validator.SetAndValidate(options.RecipeOutput) - if err != nil { - return err - } - - return nil -} - -func (p *Processor) computeConnectionString(resource *datamodel.SqlDatabase) string { - var username, password string - if resource.Properties.Username != "" { - username = "User Id=" + resource.Properties.Username - } - if resource.Properties.Secrets.Password != "" { - password = "Password=" + resource.Properties.Secrets.Password - } - - connectionString := fmt.Sprintf("Data Source=tcp:%s,%v;Initial Catalog=%s;%s;%s;Encrypt=True;TrustServerCertificate=True", resource.Properties.Server, resource.Properties.Port, resource.Properties.Database, username, password) - return connectionString -} diff --git a/pkg/linkrp/processors/sqldatabases/processor_test.go b/pkg/linkrp/processors/sqldatabases/processor_test.go deleted file mode 100644 index 392c78f54d..0000000000 --- a/pkg/linkrp/processors/sqldatabases/processor_test.go +++ /dev/null @@ -1,224 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// ------------------------------------------------------------ - -package sqldatabases - -import ( - "context" - "testing" - - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/stretchr/testify/require" -) - -func Test_Process(t *testing.T) { - processor := Processor{} - - const azureSqlResourceID = "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/RadiusFunctionalTest/providers/Microsoft.Sql/servers/mssql-radiustest/databases/database-radiustest" - const server = "sql.server" - const database = "database-radiustest" - const port = 1433 - const username = "testuser" - const password = "testpassword" - const connectionString = "Data Source=tcp:sql.server,1433;Initial Catalog=database-radiustest;User Id=testuser;Password=testpassword;Encrypt=True;TrustServerCertificate=True" - - t.Run("success - recipe", func(t *testing.T) { - resource := &datamodel.SqlDatabase{} - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - azureSqlResourceID, - }, - Values: map[string]any{ - "database": database, - "server": server, - "port": port, - "username": username, - }, - Secrets: map[string]any{ - "password": password, - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, database, resource.Properties.Database) - require.Equal(t, server, resource.Properties.Server) - require.Equal(t, int32(port), resource.Properties.Port) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - - expectedValues := map[string]any{ - "database": database, - "server": server, - "port": int32(port), - "username": username, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "connectionString": { - Value: connectionString, - }, - "password": { - Value: password, - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - manual", func(t *testing.T) { - resource := &datamodel.SqlDatabase{ - Properties: datamodel.SqlDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureSqlResourceID}}, - Database: database, - Server: server, - Port: port, - Username: username, - Secrets: datamodel.SqlDatabaseSecrets{ - Password: password, - ConnectionString: connectionString, - }, - }, - } - err := processor.Process(context.Background(), resource, processors.Options{}) - require.NoError(t, err) - - require.Equal(t, database, resource.Properties.Database) - require.Equal(t, server, resource.Properties.Server) - require.Equal(t, int32(port), resource.Properties.Port) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - - expectedValues := map[string]any{ - "database": database, - "server": server, - "port": int32(port), - "username": username, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: password, - }, - "connectionString": { - Value: connectionString, - }, - } - - expectedOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ - { - ID: azureSqlResourceID, - }, - }) - require.NoError(t, err) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("success - recipe with value overrides", func(t *testing.T) { - resource := &datamodel.SqlDatabase{ - Properties: datamodel.SqlDatabaseProperties{ - Resources: []*linkrp.ResourceReference{{ID: azureSqlResourceID}}, - Database: database, - Server: server, - Port: port, - Username: username, - Secrets: datamodel.SqlDatabaseSecrets{ - Password: password, - ConnectionString: connectionString, - }, - }, - } - options := processors.Options{ - RecipeOutput: &recipes.RecipeOutput{ - Resources: []string{ - azureSqlResourceID, - }, - // Values and secrets will be overridden by the resource. - Values: map[string]any{ - "database": "override-database", - "server": "override.server", - "port": 3333, - "username": username, - }, - Secrets: map[string]any{ - "password": "asdf", - "connectionString": "asdf", - }, - }, - } - - err := processor.Process(context.Background(), resource, options) - require.NoError(t, err) - - require.Equal(t, database, resource.Properties.Database) - require.Equal(t, server, resource.Properties.Server) - require.Equal(t, int32(port), resource.Properties.Port) - require.Equal(t, username, resource.Properties.Username) - require.Equal(t, password, resource.Properties.Secrets.Password) - require.Equal(t, connectionString, resource.Properties.Secrets.ConnectionString) - - expectedValues := map[string]any{ - "database": database, - "server": server, - "port": int32(port), - "username": username, - } - expectedSecrets := map[string]rpv1.SecretValueReference{ - "password": { - Value: password, - }, - "connectionString": { - Value: connectionString, - }, - } - expectedOutputResources := []rpv1.OutputResource{} - - recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, recipeOutputResources...) - - resourceFieldOutputResources, err := processors.GetOutputResourcesFromResourcesField([]*linkrp.ResourceReference{ - { - ID: azureSqlResourceID, - }, - }) - require.NoError(t, err) - expectedOutputResources = append(expectedOutputResources, resourceFieldOutputResources...) - - require.Equal(t, expectedValues, resource.ComputedValues) - require.Equal(t, expectedSecrets, resource.SecretValues) - require.Equal(t, expectedOutputResources, resource.Properties.Status.OutputResources) - }) - - t.Run("failure - missing required values", func(t *testing.T) { - resource := &datamodel.SqlDatabase{} - options := processors.Options{RecipeOutput: &recipes.RecipeOutput{}} - - err := processor.Process(context.Background(), resource, options) - require.Error(t, err) - require.IsType(t, &processors.ValidationError{}, err) - require.Equal(t, `validation returned multiple errors: - -the connection value "database" should be provided by the recipe, set '.properties.database' to provide a value manually -the connection value "server" should be provided by the recipe, set '.properties.server' to provide a value manually -the connection value "port" should be provided by the recipe, set '.properties.port' to provide a value manually`, err.Error()) - - }) -} diff --git a/pkg/linkrp/processors/types.go b/pkg/linkrp/processors/types.go deleted file mode 100644 index af2258d4ea..0000000000 --- a/pkg/linkrp/processors/types.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package processors - -import ( - "context" - "fmt" - - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" -) - -// ResourceProcessor is responsible for processing the results of recipe execution or any -// other change to the lifecycle of a link resource. Each resource processor supports a single -// Radius resource type (eg: RedisCache). -type ResourceProcessor[P interface { - *T - rpv1.RadiusResourceModel -}, T any] interface { - // Process is called to process the results of recipe execution or any other changes to the resource - // data model. Process should modify the datamodel in place to perform updates. - Process(ctx context.Context, resource P, options Options) error -} - -// Options defines the options passed to the resource processor. -type Options struct { - // RuntimeConfiguration represents the configuration of the target runtime. - RuntimeConfiguration recipes.RuntimeConfiguration - - // RecipeOutput represents the output of executing a recipe (may be nil). - RecipeOutput *recipes.RecipeOutput -} - -// ValidationError represents a user-facing validation message reported by the processor. -type ValidationError struct { - Message string -} - -// Error returns a string containing the error message for ValidationError. -func (e *ValidationError) Error() string { - return e.Message -} - -//go:generate mockgen -destination=./mock_resourceclient.go -package=processors -self_package github.com/project-radius/radius/pkg/linkrp/processors github.com/project-radius/radius/pkg/linkrp/processors ResourceClient - -// ResourceClient is a client used by resource processors for interacting with UCP resources. -type ResourceClient interface { - // Delete deletes a resource by id. - // - // If the API version is omitted, then an attempt will be made to look up the API version. - Delete(ctx context.Context, id string, apiVersion string) error -} - -// ResourceError represents an error that occured while processing a resource. -type ResourceError struct { - ID string - Inner error -} - -// Error returns a string describing the error that occurred when attempting to delete a resource. -func (e *ResourceError) Error() string { - return fmt.Sprintf("failed to delete resource %q: %v", e.ID, e.Inner) -} - -// Unwrap returns the underlying error of ResourceError. -func (e *ResourceError) Unwrap() error { - return e.Inner -} diff --git a/pkg/linkrp/processors/util.go b/pkg/linkrp/processors/util.go deleted file mode 100644 index 8b93deedbe..0000000000 --- a/pkg/linkrp/processors/util.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package processors - -import ( - "fmt" - - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" -) - -// GetOutputResourcesFromResourcesField parses a slice of resource references and converts each resource into an OutputResource. -// It returns a slice of output resources and an error if any of the resource references are invalid. This should be used for -// processing the '.properties.resources' field of a resource. -func GetOutputResourcesFromResourcesField(field []*linkrp.ResourceReference) ([]rpv1.OutputResource, error) { - results := []rpv1.OutputResource{} - for i, resource := range field { - id, err := resources.ParseResource(resource.ID) - if err != nil { - return nil, &ValidationError{Message: fmt.Sprintf("resource id %q is invalid", resource.ID)} - } - - identity := resourcemodel.FromUCPID(id, "") - if (identity == resourcemodel.ResourceIdentity{}) { - return nil, &ValidationError{Message: fmt.Sprintf("resource id %q is invalid", resource)} - } - - result := rpv1.OutputResource{ - LocalID: fmt.Sprintf("Resource%d", i), // The dependency sorting code requires unique LocalIDs - Identity: identity, - ResourceType: *identity.ResourceType, - RadiusManaged: to.Ptr(false), // Generally when we parse a resource ID from a resource field, it's externally managed. - } - results = append(results, result) - } - - return results, nil -} - -// GetOutputResourcesFromRecipe parses the output resources from a recipe and returns a slice of OutputResource objects, -// returning an error if any of the resources are invalid. -func GetOutputResourcesFromRecipe(output *recipes.RecipeOutput) ([]rpv1.OutputResource, error) { - results := []rpv1.OutputResource{} - for i, resource := range output.Resources { - id, err := resources.ParseResource(resource) - if err != nil { - return nil, &ValidationError{Message: fmt.Sprintf("resource id %q returned by recipe is invalid", resource)} - } - - identity := resourcemodel.FromUCPID(id, "") - if (identity == resourcemodel.ResourceIdentity{}) { - return nil, &ValidationError{Message: fmt.Sprintf("resource id %q returned by recipe is invalid", resource)} - } - - result := rpv1.OutputResource{ - LocalID: fmt.Sprintf("RecipeResource%d", i), // The dependency sorting code requires unique LocalIDs - Identity: identity, - ResourceType: *identity.ResourceType, - RadiusManaged: to.Ptr(true), - } - - results = append(results, result) - } - - return results, nil -} diff --git a/pkg/linkrp/processors/util_test.go b/pkg/linkrp/processors/util_test.go deleted file mode 100644 index 1f76830ea0..0000000000 --- a/pkg/linkrp/processors/util_test.go +++ /dev/null @@ -1,118 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package processors - -import ( - "testing" - - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/stretchr/testify/require" -) - -func Test_GetOutputResourcesFromResourcesField(t *testing.T) { - resourcesField := []*linkrp.ResourceReference{ - {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource1"}, - {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource2"}, - } - - redisType := resourcemodel.ResourceType{ - Type: "Microsoft.Cache/redis", - Provider: resourcemodel.ProviderAzure, - } - - expected := []rpv1.OutputResource{ - { - LocalID: "Resource0", - ResourceType: redisType, - Identity: resourcemodel.NewARMIdentity(&redisType, resourcesField[0].ID, "unknown"), - RadiusManaged: to.Ptr(false), - }, - { - LocalID: "Resource1", - ResourceType: redisType, - Identity: resourcemodel.NewARMIdentity(&redisType, resourcesField[1].ID, "unknown"), - RadiusManaged: to.Ptr(false), - }, - } - - actual, err := GetOutputResourcesFromResourcesField(resourcesField) - require.NoError(t, err) - require.Equal(t, expected, actual) -} - -func Test_GetOutputResourceFromResourceID_Invalid(t *testing.T) { - resourcesField := []*linkrp.ResourceReference{ - {ID: "/////asdf////"}, - } - - actual, err := GetOutputResourcesFromResourcesField(resourcesField) - require.Error(t, err) - require.Empty(t, actual) - require.IsType(t, &ValidationError{}, err) - require.Equal(t, "resource id \"/////asdf////\" is invalid", err.Error()) -} - -func Test_GetOutputResourcesFromRecipe(t *testing.T) { - output := recipes.RecipeOutput{ - Resources: []string{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource1", - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource2", - }, - } - - redisType := resourcemodel.ResourceType{ - Type: "Microsoft.Cache/redis", - Provider: resourcemodel.ProviderAzure, - } - - expected := []rpv1.OutputResource{ - { - LocalID: "RecipeResource0", - ResourceType: redisType, - Identity: resourcemodel.NewARMIdentity(&redisType, output.Resources[0], "unknown"), - RadiusManaged: to.Ptr(true), - }, - { - LocalID: "RecipeResource1", - ResourceType: redisType, - Identity: resourcemodel.NewARMIdentity(&redisType, output.Resources[1], "unknown"), - RadiusManaged: to.Ptr(true), - }, - } - - actual, err := GetOutputResourcesFromRecipe(&output) - require.NoError(t, err) - require.Equal(t, expected, actual) -} - -func Test_GetOutputResourcesFromRecipe_Invalid(t *testing.T) { - output := recipes.RecipeOutput{ - Resources: []string{ - "/////asdf////", - }, - } - - actual, err := GetOutputResourcesFromRecipe(&output) - require.Error(t, err) - require.Empty(t, actual) - require.IsType(t, &ValidationError{}, err) - require.Equal(t, "resource id \"/////asdf////\" returned by recipe is invalid", err.Error()) -} diff --git a/pkg/linkrp/types.go b/pkg/linkrp/types.go deleted file mode 100644 index 7190518ded..0000000000 --- a/pkg/linkrp/types.go +++ /dev/null @@ -1,117 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package linkrp - -type RecipeData struct { - RecipeProperties - - // APIVersion is the API version to use to perform operations on resources supported by the link. - // For example for Azure resources, every service has different REST API version that must be specified in the request. - APIVersion string - - // Resource ids of the resources deployed by the recipe - Resources []string -} - -// RecipeProperties represents the information needed to deploy a recipe -type RecipeProperties struct { - LinkRecipe // LinkRecipe is the recipe of the resource to be deployed - LinkType string // LinkType represent the type of the link - TemplatePath string // TemplatePath represent the recipe location - EnvParameters map[string]any // EnvParameters represents the parameters set by the operator while linking the recipe to an environment -} - -// LinkRecipe is the recipe details used to automatically deploy underlying infrastructure for a link -type LinkRecipe struct { - // Name of the recipe within the environment to use - Name string `json:"name,omitempty"` - // Parameters are key/value parameters to pass into the recipe at deployment - Parameters map[string]any `json:"parameters,omitempty"` -} - -// ResourceReference represents a reference to a resource that was deployed by the user -// and specified as part of a link resource. -// -// This type should be used in datamodels for the '.properties.resources' field. -type ResourceReference struct { - ID string `json:"id"` -} - -// RecipeContext Recipe template authors can leverage the RecipeContext parameter to access Link properties to -// generate name and properties that are unique for the Link calling the recipe. -type RecipeContext struct { - Resource Resource `json:"resource,omitempty"` - Application ResourceInfo `json:"application,omitempty"` - Environment ResourceInfo `json:"environment,omitempty"` - Runtime Runtime `json:"runtime,omitempty"` -} - -// Resource contains the information needed to deploy a recipe. -// In the case the resource is a Link, it represents the Link's id, name and type. -type Resource struct { - ResourceInfo - Type string `json:"type"` -} - -// ResourceInfo name and id of the resource -type ResourceInfo struct { - Name string `json:"name"` - ID string `json:"id"` -} - -type Runtime struct { - Kubernetes Kubernetes `json:"kubernetes,omitempty"` -} - -type Kubernetes struct { - // Namespace is set to the applicationNamespace when the Link is application-scoped, and set to the environmentNamespace when the Link is environment scoped - Namespace string `json:"namespace"` - // EnvironmentNamespace is set to environment namespace. - EnvironmentNamespace string `json:"environmentNamespace"` -} - -const ( - DaprPubSubBrokersResourceType = "Applications.Link/daprPubSubBrokers" - DaprSecretStoresResourceType = "Applications.Link/daprSecretStores" - DaprStateStoresResourceType = "Applications.Link/daprStateStores" - ExtendersResourceType = "Applications.Link/extenders" - MongoDatabasesResourceType = "Applications.Link/mongoDatabases" - RabbitMQMessageQueuesResourceType = "Applications.Link/rabbitMQMessageQueues" - RedisCachesResourceType = "Applications.Link/redisCaches" - SqlDatabasesResourceType = "Applications.Link/sqlDatabases" - /* The following are new temporary resource type names. These values will replace the above resource type names after - testing for the new namespaces is completed. (https://github.com/project-radius/radius/issues/3499) - */ - N_DaprPubSubBrokersResourceType = "Applications.Dapr/pubSubBrokers" - N_DaprSecretStoresResourceType = "Applications.Dapr/secretStores" - N_DaprStateStoresResourceType = "Applications.Dapr/stateStores" - N_RabbitMQQueuesResourceType = "Applications.Messaging/rabbitMQQueues" - N_MongoDatabasesResourceType = "Applications.Datastores/mongoDatabases" - N_RedisCachesResourceType = "Applications.Datastores/redisCaches" - N_SqlDatabasesResourceType = "Applications.Datastores/sqlDatabases" - N_ExtendersResourceType = "Applications.Core/extenders" -) - -// ResourceProvisioning specifies how the resource should be managed -type ResourceProvisioning string - -const ( - // ResourceProvisioningRecipe is the scenario when Radius manages the lifecycle of the resource through a Recipe - ResourceProvisioningRecipe ResourceProvisioning = "recipe" - // ResourceProvisiongManual is the scenario wher the user manages the resource and provides the values - ResourceProvisioningManual ResourceProvisioning = "manual" -) diff --git a/pkg/logging/logfields.go b/pkg/logging/logfields.go index ba82c6b47e..a2f59545fd 100644 --- a/pkg/logging/logfields.go +++ b/pkg/logging/logfields.go @@ -17,9 +17,7 @@ package logging const ( AppCoreLoggerName string = "applications.core" - AppLinkLoggerName string = "applications.link" - - ServiceName string = "rp" + ServiceName string = "rp" ) // Field names for structured logging diff --git a/pkg/messagingrp/api/README.md b/pkg/messagingrp/api/README.md index 263318771a..5f850ef4b6 100644 --- a/pkg/messagingrp/api/README.md +++ b/pkg/messagingrp/api/README.md @@ -44,7 +44,7 @@ The following configuration generates track2 go models and client. ```yaml $(tag) != '' version: 3.*.* -use: "@autorest/go@4.0.0-preview.44" +use: "@autorest/go@4.0.0-preview.55" module-version: 0.0.1 file-prefix: zz_generated_ license-header: "Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information.\nCode generated by Microsoft (R) AutoRest Code Generator.\nChanges may cause incorrect behavior and will be lost if the code is regenerated." diff --git a/pkg/messagingrp/api/v20220315privatepreview/datamodel_util.go b/pkg/messagingrp/api/v20220315privatepreview/datamodel_util.go index 0ee66e2aeb..fe1e1724b3 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/datamodel_util.go +++ b/pkg/messagingrp/api/v20220315privatepreview/datamodel_util.go @@ -19,10 +19,10 @@ package v20220315privatepreview import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) func toProvisioningStateDataModel(state *ProvisioningState) v1.ProvisioningState { @@ -72,24 +72,24 @@ func fromProvisioningStateDataModel(state v1.ProvisioningState) *ProvisioningSta return &converted } -func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (linkrp.ResourceProvisioning, error) { +func toResourceProvisiongDataModel(provisioning *ResourceProvisioning) (portableresources.ResourceProvisioning, error) { if provisioning == nil { - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil } switch *provisioning { case ResourceProvisioningManual: - return linkrp.ResourceProvisioningManual, nil + return portableresources.ResourceProvisioningManual, nil case ResourceProvisioningRecipe: - return linkrp.ResourceProvisioningRecipe, nil + return portableresources.ResourceProvisioningRecipe, nil default: return "", &v1.ErrModelConversion{PropertyName: "$.properties.resourceProvisioning", ValidValue: fmt.Sprintf("one of %s", PossibleResourceProvisioningValues())} } } -func fromResourceProvisioningDataModel(provisioning linkrp.ResourceProvisioning) *ResourceProvisioning { +func fromResourceProvisioningDataModel(provisioning portableresources.ResourceProvisioning) *ResourceProvisioning { var converted ResourceProvisioning switch provisioning { - case linkrp.ResourceProvisioningManual: + case portableresources.ResourceProvisioningManual: converted = ResourceProvisioningManual default: converted = ResourceProvisioningRecipe @@ -102,22 +102,22 @@ func fromSystemDataModel(s v1.SystemData) *SystemData { return &SystemData{ CreatedBy: to.Ptr(s.CreatedBy), CreatedByType: (*CreatedByType)(to.Ptr(s.CreatedByType)), - CreatedAt: v20220315privatepreview.UnmarshalTimeString(s.CreatedAt), + CreatedAt: v1.UnmarshalTimeString(s.CreatedAt), LastModifiedBy: to.Ptr(s.LastModifiedBy), LastModifiedByType: (*CreatedByType)(to.Ptr(s.LastModifiedByType)), - LastModifiedAt: v20220315privatepreview.UnmarshalTimeString(s.LastModifiedAt), + LastModifiedAt: v1.UnmarshalTimeString(s.LastModifiedAt), } } -func toRecipeDataModel(r *Recipe) linkrp.LinkRecipe { +func toRecipeDataModel(r *Recipe) portableresources.ResourceRecipe { if r == nil { - return linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + return portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, } } - recipe := linkrp.LinkRecipe{} + recipe := portableresources.ResourceRecipe{} if r.Name == nil { - recipe.Name = v20220315privatepreview.DefaultRecipeName + recipe.Name = portableresources.DefaultRecipeName } else { recipe.Name = to.String(r.Name) } @@ -127,27 +127,27 @@ func toRecipeDataModel(r *Recipe) linkrp.LinkRecipe { return recipe } -func fromRecipeDataModel(r linkrp.LinkRecipe) *Recipe { +func fromRecipeDataModel(r portableresources.ResourceRecipe) *Recipe { return &Recipe{ Name: to.Ptr(r.Name), Parameters: r.Parameters, } } -func toResourcesDataModel(r []*ResourceReference) []*linkrp.ResourceReference { +func toResourcesDataModel(r []*ResourceReference) []*portableresources.ResourceReference { if r == nil { return nil } - resources := make([]*linkrp.ResourceReference, len(r)) + resources := make([]*portableresources.ResourceReference, len(r)) for i, resource := range r { - resources[i] = &linkrp.ResourceReference{ + resources[i] = &portableresources.ResourceReference{ ID: to.String(resource.ID), } } return resources } -func fromResourcesDataModel(r []*linkrp.ResourceReference) []*ResourceReference { +func fromResourcesDataModel(r []*portableresources.ResourceReference) []*ResourceReference { if r == nil { return nil } @@ -159,3 +159,23 @@ func fromResourcesDataModel(r []*linkrp.ResourceReference) []*ResourceReference } return resources } + +func toOutputResources(outputResources []rpv1.OutputResource) []*OutputResource { + var outResources []*OutputResource + for _, or := range outputResources { + r := &OutputResource{ + ID: to.Ptr(or.ID.String()), + } + + // We will not serialize the following fields if they are empty or nil. + if or.LocalID != "" { + r.LocalID = to.Ptr(or.LocalID) + } + if or.RadiusManaged != nil { + r.RadiusManaged = or.RadiusManaged + } + + outResources = append(outResources, r) + } + return outResources +} diff --git a/pkg/messagingrp/api/v20220315privatepreview/datamodel_util_test.go b/pkg/messagingrp/api/v20220315privatepreview/datamodel_util_test.go index 1e6c38fc52..e68b650625 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/datamodel_util_test.go +++ b/pkg/messagingrp/api/v20220315privatepreview/datamodel_util_test.go @@ -19,10 +19,9 @@ package v20220315privatepreview import ( "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) @@ -117,12 +116,12 @@ func TestFromSystemDataModel(t *testing.T) { func TestToRecipeDataModel(t *testing.T) { testset := []struct { versioned *Recipe - datamodel linkrp.LinkRecipe + datamodel portableresources.ResourceRecipe }{ { nil, - linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, }, }, { @@ -132,7 +131,7 @@ func TestToRecipeDataModel(t *testing.T) { "foo": "bar", }, }, - linkrp.LinkRecipe{ + portableresources.ResourceRecipe{ Name: "test", Parameters: map[string]any{ "foo": "bar", @@ -145,8 +144,8 @@ func TestToRecipeDataModel(t *testing.T) { "foo": "bar", }, }, - linkrp.LinkRecipe{ - Name: v20220315privatepreview.DefaultRecipeName, + portableresources.ResourceRecipe{ + Name: portableresources.DefaultRecipeName, Parameters: map[string]any{ "foo": "bar", }, @@ -161,15 +160,15 @@ func TestToRecipeDataModel(t *testing.T) { func TestFromResourcesDataModel(t *testing.T) { testset := []struct { - DMResources []*linkrp.ResourceReference + DMResources []*portableresources.ResourceReference VersionedResources []*ResourceReference }{ { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, + DMResources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, }, { - DMResources: []*linkrp.ResourceReference{}, + DMResources: []*portableresources.ResourceReference{}, VersionedResources: []*ResourceReference{}, }, } @@ -183,15 +182,15 @@ func TestFromResourcesDataModel(t *testing.T) { func TestToResourcesDataModel(t *testing.T) { testset := []struct { - DMResources []*linkrp.ResourceReference + DMResources []*portableresources.ResourceReference VersionedResources []*ResourceReference }{ { - DMResources: []*linkrp.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, + DMResources: []*portableresources.ResourceReference{{ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache"}, {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1"}}, VersionedResources: []*ResourceReference{{ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache")}, {ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Microsoft.Cache/Redis/testCache1")}}, }, { - DMResources: []*linkrp.ResourceReference{}, + DMResources: []*portableresources.ResourceReference{}, VersionedResources: []*ResourceReference{}, }, } diff --git a/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion.go b/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion.go index c9de629349..9602586f8a 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion.go +++ b/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion.go @@ -17,11 +17,11 @@ limitations under the License. package v20220315privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/messagingrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) // ConvertTo converts a versioned RabbitMQQueueResource to a version-agnostic datamodel.RabbitMQQueue @@ -55,7 +55,7 @@ func (src *RabbitMQQueueResource) ConvertTo() (v1.DataModelInterface, error) { return nil, err } - if converted.Properties.ResourceProvisioning != linkrp.ResourceProvisioningManual { + if converted.Properties.ResourceProvisioning != portableresources.ResourceProvisioningManual { converted.Properties.Recipe = toRecipeDataModel(properties.Recipe) } converted.Properties.Resources = toResourcesDataModel(properties.Resources) @@ -95,7 +95,7 @@ func (dst *RabbitMQQueueResource) ConvertFrom(src v1.DataModelInterface) error { dst.Tags = *to.StringMapPtr(rabbitmq.Tags) dst.Properties = &RabbitMQQueueProperties{ Status: &ResourceStatus{ - OutputResources: rpv1.BuildExternalOutputResources(rabbitmq.Properties.Status.OutputResources), + OutputResources: toOutputResources(rabbitmq.Properties.Status.OutputResources), }, ProvisioningState: fromProvisioningStateDataModel(rabbitmq.InternalMetadata.AsyncProvisioningState), Environment: to.Ptr(rabbitmq.Properties.Environment), @@ -109,7 +109,7 @@ func (dst *RabbitMQQueueResource) ConvertFrom(src v1.DataModelInterface) error { Resources: fromResourcesDataModel(rabbitmq.Properties.Resources), TLS: to.Ptr(rabbitmq.Properties.TLS), } - if rabbitmq.Properties.ResourceProvisioning == linkrp.ResourceProvisioningRecipe { + if rabbitmq.Properties.ResourceProvisioning == portableresources.ResourceProvisioningRecipe { dst.Properties.Recipe = fromRecipeDataModel(rabbitmq.Properties.Recipe) } return nil diff --git a/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion_test.go b/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion_test.go index aac0372abf..408ab20133 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion_test.go +++ b/pkg/messagingrp/api/v20220315privatepreview/rabbitmq_conversion_test.go @@ -20,12 +20,13 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/messagingrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -43,7 +44,7 @@ func TestRabbitMQQueue_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", Name: "rabbitmq0", - Type: linkrp.N_RabbitMQQueuesResourceType, + Type: portableresources.RabbitMQQueuesResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -61,7 +62,7 @@ func TestRabbitMQQueue_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningManual, + ResourceProvisioning: portableresources.ResourceProvisioningManual, Queue: "testQueue", Host: "test-host", VHost: "test-vhost", @@ -83,7 +84,7 @@ func TestRabbitMQQueue_ConvertVersionedToDataModel(t *testing.T) { TrackedResource: v1.TrackedResource{ ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", Name: "rabbitmq0", - Type: linkrp.N_RabbitMQQueuesResourceType, + Type: portableresources.RabbitMQQueuesResourceType, Location: v1.LocationGlobal, Tags: map[string]string{ "env": "dev", @@ -101,9 +102,9 @@ func TestRabbitMQQueue_ConvertVersionedToDataModel(t *testing.T) { Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", }, - ResourceProvisioning: linkrp.ResourceProvisioningRecipe, + ResourceProvisioning: portableresources.ResourceProvisioningRecipe, TLS: false, - Recipe: linkrp.LinkRecipe{ + Recipe: portableresources.ResourceRecipe{ Name: "rabbitmq", Parameters: map[string]any{ "foo": "bar", @@ -116,10 +117,9 @@ func TestRabbitMQQueue_ConvertVersionedToDataModel(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) versionedResource := &RabbitMQQueueResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) // act @@ -156,22 +156,14 @@ func TestRabbitMQQueue_ConvertDataModelToVersioned(t *testing.T) { Port: to.Ptr(int32(5672)), Username: to.Ptr("test-user"), TLS: to.Ptr(true), - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "rabbitmqProvider", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0"), Name: to.Ptr("rabbitmq0"), - Type: to.Ptr(linkrp.N_RabbitMQQueuesResourceType), + Type: to.Ptr(portableresources.RabbitMQQueuesResourceType), }, }, { @@ -196,31 +188,22 @@ func TestRabbitMQQueue_ConvertDataModelToVersioned(t *testing.T) { "foo": "bar", }, }, - Status: &ResourceStatus{ - OutputResources: []map[string]any{ - { - "Identity": nil, - "LocalID": "Deployment", - "Provider": "rabbitmqProvider", - }, - }, - }, + Status: resourcetypeutil.MustPopulateResourceStatus(&ResourceStatus{}), }, Tags: map[string]*string{ "env": to.Ptr("dev"), }, ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0"), Name: to.Ptr("rabbitmq0"), - Type: to.Ptr(linkrp.N_RabbitMQQueuesResourceType), + Type: to.Ptr(portableresources.RabbitMQQueuesResourceType), }, }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + tc.file) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(tc.file) resource := &datamodel.RabbitMQQueue{} - err = json.Unmarshal(rawPayload, resource) + err := json.Unmarshal(rawPayload, resource) require.NoError(t, err) versionedResource := &RabbitMQQueueResource{} @@ -255,10 +238,9 @@ func TestRabbitMQQueue_ConvertVersionedToDataModel_InvalidRequest(t *testing.T) for _, test := range testset { t.Run(test.payload, func(t *testing.T) { - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/" + test.payload) - require.NoError(t, err) + rawPayload := testutil.ReadFixture(test.payload) versionedResource := &RabbitMQQueueResource{} - err = json.Unmarshal(rawPayload, versionedResource) + err := json.Unmarshal(rawPayload, versionedResource) require.NoError(t, err) dm, err := versionedResource.ConvertTo() @@ -275,7 +257,7 @@ func TestRabbitMQQueue_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } @@ -288,10 +270,9 @@ func TestRabbitMQQueue_ConvertFromValidation(t *testing.T) { func TestRabbitMQSecrets_ConvertVersionedToDataModel(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/rabbitmqsecrets.json") - require.NoError(t, err) + rawPayload := testutil.ReadFixture("rabbitmqsecrets.json") versioned := &RabbitMQSecrets{} - err = json.Unmarshal(rawPayload, versioned) + err := json.Unmarshal(rawPayload, versioned) require.NoError(t, err) // act @@ -305,10 +286,9 @@ func TestRabbitMQSecrets_ConvertVersionedToDataModel(t *testing.T) { func TestRabbitMQSecrets_ConvertDataModelToVersioned(t *testing.T) { // arrange - rawPayload, err := v20220315privatepreview.LoadTestData("./testdata/rabbitmqsecretsdatamodel.json") - require.NoError(t, err) + rawPayload := testutil.ReadFixture("rabbitmqsecretsdatamodel.json") secrets := &datamodel.RabbitMQSecrets{} - err = json.Unmarshal(rawPayload, secrets) + err := json.Unmarshal(rawPayload, secrets) require.NoError(t, err) // act @@ -325,7 +305,7 @@ func TestRabbitMQSecrets_ConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&v20220315privatepreview.FakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json b/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json index dc7d2b9705..2f686b7856 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json +++ b/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_manual_datamodel.json @@ -1,41 +1,39 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Messaging/rabbitMQQueues", - "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" - }, - "tags": { - "env": "dev" - }, - "location": "global", - "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "rabbitmq", - "Provider": "rabbitmqProvider" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "resourceProvisioning":"manual", - "queue": "testQueue", - "host": "test-host", - "vHost": "test-vhost", - "port": 5672, - "username": "test-user", - "tls":true, - "secrets": { - "uri": "connection://string", - "password": "password" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "location": "global", + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] + }, + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "resourceProvisioning": "manual", + "queue": "testQueue", + "host": "test-host", + "vHost": "test-vhost", + "port": 5672, + "username": "test-user", + "tls": true, + "secrets": { + "uri": "connection://string", + "password": "password" } + } } \ No newline at end of file diff --git a/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_datamodel.json b/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_datamodel.json index f330bc499d..4b0e169796 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_datamodel.json +++ b/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_datamodel.json @@ -3,41 +3,39 @@ "name": "rabbitmq0", "type": "Applications.Messaging/rabbitMQQueues", "systemData": { - "createdBy": "fakeid@live.com", - "createdByType": "User", - "createdAt": "2021-09-24T19:09:54.2403864Z", - "lastModifiedBy": "fakeid@live.com", - "lastModifiedByType": "User", - "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" }, "tags": { - "env": "dev" + "env": "dev" }, "location": "global", "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "rabbitmq", - "Provider": "rabbitmqProvider" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "resourceProvisioning":"recipe", - "queue": "testQueue", - "host": "test-host", - "port": 5672, - "vHost": "test-vhost", - "username": "test-user", - "tls":false, - "recipe": { - "name": "rabbitmq", - "parameters":{ - "foo":"bar" - } + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "resourceProvisioning": "recipe", + "queue": "testQueue", + "host": "test-host", + "port": 5672, + "vHost": "test-vhost", + "username": "test-user", + "tls": false, + "recipe": { + "name": "rabbitmq", + "parameters": { + "foo": "bar" } + } } } \ No newline at end of file diff --git a/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_resource.json b/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_resource.json index 2433cbbb07..0e33a9e71d 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_resource.json +++ b/pkg/messagingrp/api/v20220315privatepreview/testdata/rabbitmq_recipe_resource.json @@ -4,26 +4,24 @@ "type": "Applications.Messaging/rabbitMQQueues", "location": "global", "tags": { - "env": "dev" + "env": "dev" }, "properties": { - "status": { - "outputResources": [{ - "LocalID": "Deployment", - "ResourceType": { - "Type": "rabbitmq", - "Provider": "rabbitmqProvider" - } - }] - }, - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", - "tls": false, - "recipe": { - "name": "rabbitmq", - "parameters":{ - "foo":"bar" - } + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" + } + ] + }, + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app", + "tls": false, + "recipe": { + "name": "rabbitmq", + "parameters": { + "foo": "bar" } + } } } \ No newline at end of file diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_client_factory.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_client_factory.go new file mode 100644 index 0000000000..d1e4153def --- /dev/null +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_client_factory.go @@ -0,0 +1,50 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + rootScope string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + rootScope: rootScope, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRabbitMqQueuesClient() *RabbitMqQueuesClient { + subClient, _ := NewRabbitMqQueuesClient(c.rootScope, c.credential, c.options) + return subClient +} + diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_constants.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_constants.go index e80a581e36..870ca85337 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_constants.go +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_constants.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -47,6 +46,24 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// IdentitySettingKind - IdentitySettingKind is the kind of supported external identity setting +type IdentitySettingKind string + +const ( + // IdentitySettingKindAzureComWorkload - azure ad workload identity + IdentitySettingKindAzureComWorkload IdentitySettingKind = "azure.com.workload" + // IdentitySettingKindUndefined - undefined identity + IdentitySettingKindUndefined IdentitySettingKind = "undefined" +) + +// PossibleIdentitySettingKindValues returns the possible values for the IdentitySettingKind const type. +func PossibleIdentitySettingKindValues() []IdentitySettingKind { + return []IdentitySettingKind{ + IdentitySettingKindAzureComWorkload, + IdentitySettingKindUndefined, + } +} + // Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" type Origin string @@ -70,12 +87,19 @@ func PossibleOriginValues() []Origin { type ProvisioningState string const ( + // ProvisioningStateAccepted - The resource create request has been accepted ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - The resource is being deleted ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is being provisioned ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is updating ProvisioningStateUpdating ProvisioningState = "Updating" ) @@ -98,7 +122,9 @@ func PossibleProvisioningStateValues() []ProvisioningState { type ResourceProvisioning string const ( + // ResourceProvisioningManual - The resource lifecycle will be managed by the user ResourceProvisioningManual ResourceProvisioning = "manual" + // ResourceProvisioningRecipe - The resource lifecycle will be managed by Radius ResourceProvisioningRecipe ResourceProvisioning = "recipe" ) @@ -110,3 +136,18 @@ func PossibleResourceProvisioningValues() []ResourceProvisioning { } } +// Versions - Supported API versions for the Applications.Messaging resource provider. +type Versions string + +const ( + // VersionsV20220315Privatepreview - 2022-03-15-privatepreview + VersionsV20220315Privatepreview Versions = "2022-03-15-privatepreview" +) + +// PossibleVersionsValues returns the possible values for the Versions const type. +func PossibleVersionsValues() []Versions { + return []Versions{ + VersionsV20220315Privatepreview, + } +} + diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_interfaces.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_interfaces.go new file mode 100644 index 0000000000..104e8355bd --- /dev/null +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_interfaces.go @@ -0,0 +1,18 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +// EnvironmentComputeClassification provides polymorphic access to related types. +// Call the interface's GetEnvironmentCompute() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EnvironmentCompute, *KubernetesCompute +type EnvironmentComputeClassification interface { + // GetEnvironmentCompute returns the EnvironmentCompute content of the underlying type. + GetEnvironmentCompute() *EnvironmentCompute +} + diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models.go index 497c1f46b5..58a8cd4afb 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models.go +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models.go @@ -2,331 +2,395 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview import "time" -// BasicDaprResourceProperties - Basic properties of a Dapr component object. -type BasicDaprResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` +// EnvironmentCompute - Represents backing compute resource +type EnvironmentCompute struct { + // REQUIRED; Discriminator property for EnvironmentCompute. + Kind *string - // READ-ONLY; The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to -// use the Dapr component. - ComponentName *string `json:"componentName,omitempty" azure:"ro"` + // Configuration for supported external identity providers + Identity *IdentitySettings - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + // The resource id of the compute resource for application environment. + ResourceID *string } -// BasicResourceProperties - Basic properties of a Radius resource. -type BasicResourceProperties struct { - // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` - - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` - - // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` -} +// GetEnvironmentCompute implements the EnvironmentComputeClassification interface for type EnvironmentCompute. +func (e *EnvironmentCompute) GetEnvironmentCompute() *EnvironmentCompute { return e } // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + Info map[string]any // READ-ONLY; The additional info type. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ErrorDetail - The error detail. type ErrorDetail struct { // READ-ONLY; The error additional info. - AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + AdditionalInfo []*ErrorAdditionalInfo // READ-ONLY; The error code. - Code *string `json:"code,omitempty" azure:"ro"` + Code *string // READ-ONLY; The error details. - Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + Details []*ErrorDetail // READ-ONLY; The error message. - Message *string `json:"message,omitempty" azure:"ro"` + Message *string // READ-ONLY; The error target. - Target *string `json:"target,omitempty" azure:"ro"` + Target *string } // ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. // (This also follows the OData error response format.). type ErrorResponse struct { // The error object. - Error *ErrorDetail `json:"error,omitempty"` + Error *ErrorDetail +} + +// IdentitySettings is the external identity setting. +type IdentitySettings struct { + // REQUIRED; kind of identity setting + Kind *IdentitySettingKind + + // The URI for your compute platform's OIDC issuer + OidcIssuer *string + + // The resource ID of the provisioned identity + Resource *string +} + +// KubernetesCompute - The Kubernetes compute configuration +type KubernetesCompute struct { + // REQUIRED; Discriminator property for EnvironmentCompute. + Kind *string + + // REQUIRED; The namespace to use for the environment. + Namespace *string + + // Configuration for supported external identity providers + Identity *IdentitySettings + + // The resource id of the compute resource for application environment. + ResourceID *string +} + +// GetEnvironmentCompute implements the EnvironmentComputeClassification interface for type KubernetesCompute. +func (k *KubernetesCompute) GetEnvironmentCompute() *EnvironmentCompute { + return &EnvironmentCompute{ + Identity: k.Identity, + Kind: k.Kind, + ResourceID: k.ResourceID, + } } // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. - Display *OperationDisplay `json:"display,omitempty"` + Display *OperationDisplay // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + ActionType *ActionType // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane // operations. - IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + IsDataAction *bool // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", // "Microsoft.Compute/virtualMachines/capture/action" - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default // value is "user,system" - Origin *Origin `json:"origin,omitempty" azure:"ro"` + Origin *Origin } // OperationDisplay - Localized display information for this particular operation. type OperationDisplay struct { // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. - Description *string `json:"description,omitempty" azure:"ro"` + Description *string // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual // Machine", "Restart Virtual Machine". - Operation *string `json:"operation,omitempty" azure:"ro"` + Operation *string // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft // Compute". - Provider *string `json:"provider,omitempty" azure:"ro"` + Provider *string // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job // Schedule Collections". - Resource *string `json:"resource,omitempty" azure:"ro"` + Resource *string } // OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to // get the next set of results. type OperationListResult struct { // READ-ONLY; URL to get the next set of operation list results (if there are any). - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of operations supported by the resource provider - Value []*Operation `json:"value,omitempty" azure:"ro"` + Value []*Operation } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters +// OutputResource - Properties of an output resource. +type OutputResource struct { + // The UCP resource ID of the underlying resource. + ID *string + + // The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency +// relationship. LocalIDs do not have any particular format or meaning beyond +// being compared to determine dependency relationships. + LocalID *string + + // Determines whether Radius manages the lifecycle of the underlying resource. + RadiusManaged *bool } // RabbitMQListSecretsResult - The secret values for the given RabbitMQQueue resource type RabbitMQListSecretsResult struct { // The password used to connect to the RabbitMQ instance - Password *string `json:"password,omitempty"` + Password *string // The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. // Can be overridden with a custom value - URI *string `json:"uri,omitempty"` + URI *string } // RabbitMQQueueProperties - RabbitMQQueue portable resource properties type RabbitMQQueueProperties struct { // REQUIRED; Fully qualified resource ID for the environment that the portable resource is linked to - Environment *string `json:"environment,omitempty"` + Environment *string - // Fully qualified resource ID for the application that the portable resource is consumed by - Application *string `json:"application,omitempty"` + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string // The hostname of the RabbitMQ instance - Host *string `json:"host,omitempty"` + Host *string // The port of the RabbitMQ instance. Defaults to 5672 - Port *int32 `json:"port,omitempty"` + Port *int32 // The name of the queue - Queue *string `json:"queue,omitempty"` + Queue *string - // The recipe used to automatically deploy underlying infrastructure for the rabbitMQQueue portable resource - Recipe *Recipe `json:"recipe,omitempty"` + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *Recipe // Specifies how the underlying service/resource is provisioned and managed. - ResourceProvisioning *ResourceProvisioning `json:"resourceProvisioning,omitempty"` + ResourceProvisioning *ResourceProvisioning // List of the resource IDs that support the rabbitMQ resource - Resources []*ResourceReference `json:"resources,omitempty"` + Resources []*ResourceReference - // Secrets provided by resources, - Secrets *RabbitMQSecrets `json:"secrets,omitempty"` + // The secrets to connect to the RabbitMQ instance + Secrets *RabbitMQSecrets // Specifies whether to use SSL when connecting to the RabbitMQ instance - TLS *bool `json:"tls,omitempty"` + TLS *bool // The username to use when connecting to the RabbitMQ instance - Username *string `json:"username,omitempty"` + Username *string // The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost. - VHost *string `json:"vHost,omitempty"` + VHost *string - // READ-ONLY; Provisioning state of the rabbitMQ message queue portable resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState // READ-ONLY; Status of a resource. - Status *ResourceStatus `json:"status,omitempty" azure:"ro"` + Status *ResourceStatus } // RabbitMQQueueResource - RabbitMQQueue portable resource type RabbitMQQueueResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *RabbitMQQueueProperties `json:"properties,omitempty"` + Properties *RabbitMQQueueProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // RabbitMQQueueResourceListResult - The response of a RabbitMQQueueResource list operation. type RabbitMQQueueResourceListResult struct { // REQUIRED; The RabbitMQQueueResource items on this page - Value []*RabbitMQQueueResource `json:"value,omitempty"` + Value []*RabbitMQQueueResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// RabbitMQSecrets - The secret values for the given RabbitMQQueue resource -type RabbitMQSecrets struct { - // The password used to connect to the RabbitMQ instance - Password *string `json:"password,omitempty"` +// RabbitMQQueueResourceUpdate - The type used for update operations of the RabbitMQQueueResource. +type RabbitMQQueueResourceUpdate struct { + // The updatable properties of the RabbitMQQueueResource. + Properties *RabbitMQQueueResourceUpdateProperties - // The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. -// Can be overridden with a custom value - URI *string `json:"uri,omitempty"` + // Resource tags. + Tags map[string]*string } -// RabbitMqQueuesClientCreateOrUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.CreateOrUpdate -// method. -type RabbitMqQueuesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} +// RabbitMQQueueResourceUpdateProperties - The updatable properties of the RabbitMQQueueResource. +type RabbitMQQueueResourceUpdateProperties struct { + // Fully qualified resource ID for the application that the portable resource is consumed by (if applicable) + Application *string -// RabbitMqQueuesClientDeleteOptions contains the optional parameters for the RabbitMqQueuesClient.Delete method. -type RabbitMqQueuesClientDeleteOptions struct { - // placeholder for future optional parameters -} + // Fully qualified resource ID for the environment that the portable resource is linked to + Environment *string -// RabbitMqQueuesClientGetOptions contains the optional parameters for the RabbitMqQueuesClient.Get method. -type RabbitMqQueuesClientGetOptions struct { - // placeholder for future optional parameters -} + // The hostname of the RabbitMQ instance + Host *string + + // The port of the RabbitMQ instance. Defaults to 5672 + Port *int32 + + // The name of the queue + Queue *string + + // The recipe used to automatically deploy underlying infrastructure for the resource + Recipe *RecipeUpdate + + // Specifies how the underlying service/resource is provisioned and managed. + ResourceProvisioning *ResourceProvisioning + + // List of the resource IDs that support the rabbitMQ resource + Resources []*ResourceReference + + // The secrets to connect to the RabbitMQ instance + Secrets *RabbitMQSecrets + + // Specifies whether to use SSL when connecting to the RabbitMQ instance + TLS *bool -// RabbitMqQueuesClientListByRootScopeOptions contains the optional parameters for the RabbitMqQueuesClient.ListByRootScope -// method. -type RabbitMqQueuesClientListByRootScopeOptions struct { - // placeholder for future optional parameters + // The username to use when connecting to the RabbitMQ instance + Username *string + + // The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost. + VHost *string } -// RabbitMqQueuesClientListSecretsOptions contains the optional parameters for the RabbitMqQueuesClient.ListSecrets method. -type RabbitMqQueuesClientListSecretsOptions struct { - // placeholder for future optional parameters +// RabbitMQSecrets - The connection secrets properties to the RabbitMQ instance +type RabbitMQSecrets struct { + // The password used to connect to the RabbitMQ instance + Password *string + + // The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. +// Can be overridden with a custom value + URI *string } // Recipe - The recipe used to automatically deploy underlying infrastructure for a portable resource type Recipe struct { // REQUIRED; The name of the recipe within the environment to use - Name *string `json:"name,omitempty"` + Name *string + + // Key/value parameters to pass into the recipe at deployment + Parameters map[string]any +} + +// RecipeUpdate - The recipe used to automatically deploy underlying infrastructure for a portable resource +type RecipeUpdate struct { + // The name of the recipe within the environment to use + Name *string // Key/value parameters to pass into the recipe at deployment - Parameters map[string]interface{} `json:"parameters,omitempty"` + Parameters map[string]any } // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ResourceReference - Describes a reference to an existing resource type ResourceReference struct { // REQUIRED; Resource id of an existing resource - ID *string `json:"id,omitempty"` + ID *string } // ResourceStatus - Status of a resource. type ResourceStatus struct { + // The compute resource associated with the resource. + Compute EnvironmentComputeClassification + // Properties of an output resource - OutputResources []map[string]interface{} `json:"outputResources,omitempty"` + OutputResources []*OutputResource } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAt *time.Time // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` + CreatedBy *string // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAt *time.Time // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedBy *string // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *CreatedByType } // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' // and a 'location' type TrackedResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models_serde.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models_serde.go index 14a413334c..f3bb6ae9f5 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models_serde.go +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_models_serde.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -15,75 +14,36 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type BasicDaprResourceProperties. -func (b BasicDaprResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "componentName", b.ComponentName) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) +// MarshalJSON implements the json.Marshaller interface for type EnvironmentCompute. +func (e EnvironmentCompute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", e.Identity) + objectMap["kind"] = e.Kind + populate(objectMap, "resourceId", e.ResourceID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicDaprResourceProperties. -func (b *BasicDaprResourceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentCompute. +func (e *EnvironmentCompute) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "componentName": - err = unpopulate(val, "ComponentName", &b.ComponentName) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type BasicResourceProperties. -func (b BasicResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "application", b.Application) - populate(objectMap, "environment", b.Environment) - populate(objectMap, "status", b.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicResourceProperties. -func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "application": - err = unpopulate(val, "Application", &b.Application) - delete(rawMsg, key) - case "environment": - err = unpopulate(val, "Environment", &b.Environment) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &b.Status) - delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &e.ResourceID) + delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil @@ -91,7 +51,7 @@ func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -108,10 +68,10 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { switch key { case "info": err = unpopulate(val, "Info", &e.Info) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -122,7 +82,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -142,19 +102,19 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { switch key { case "additionalInfo": err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) - delete(rawMsg, key) + delete(rawMsg, key) case "code": err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) + delete(rawMsg, key) case "details": err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) + delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) + delete(rawMsg, key) case "target": err = unpopulate(val, "Target", &e.Target) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -165,7 +125,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -181,7 +141,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { switch key { case "error": err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -190,9 +150,83 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type IdentitySettings. +func (i IdentitySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "kind", i.Kind) + populate(objectMap, "oidcIssuer", i.OidcIssuer) + populate(objectMap, "resource", i.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentitySettings. +func (i *IdentitySettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "oidcIssuer": + err = unpopulate(val, "OidcIssuer", &i.OidcIssuer) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &i.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KubernetesCompute. +func (k KubernetesCompute) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", k.Identity) + objectMap["kind"] = "kubernetes" + populate(objectMap, "namespace", k.Namespace) + populate(objectMap, "resourceId", k.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesCompute. +func (k *KubernetesCompute) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &k.Identity) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &k.Kind) + delete(rawMsg, key) + case "namespace": + err = unpopulate(val, "Namespace", &k.Namespace) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &k.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) @@ -212,19 +246,19 @@ func (o *Operation) UnmarshalJSON(data []byte) error { switch key { case "actionType": err = unpopulate(val, "ActionType", &o.ActionType) - delete(rawMsg, key) + delete(rawMsg, key) case "display": err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) + delete(rawMsg, key) case "isDataAction": err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "origin": err = unpopulate(val, "Origin", &o.Origin) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -235,7 +269,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -254,16 +288,16 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { switch key { case "description": err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) + delete(rawMsg, key) case "operation": err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) + delete(rawMsg, key) case "provider": err = unpopulate(val, "Provider", &o.Provider) - delete(rawMsg, key) + delete(rawMsg, key) case "resource": err = unpopulate(val, "Resource", &o.Resource) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -274,7 +308,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -291,10 +325,45 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &o.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OutputResource. +func (o OutputResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "localId", o.LocalID) + populate(objectMap, "radiusManaged", o.RadiusManaged) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OutputResource. +func (o *OutputResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "localId": + err = unpopulate(val, "LocalID", &o.LocalID) + delete(rawMsg, key) + case "radiusManaged": + err = unpopulate(val, "RadiusManaged", &o.RadiusManaged) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -305,7 +374,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RabbitMQListSecretsResult. func (r RabbitMQListSecretsResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "password", r.Password) populate(objectMap, "uri", r.URI) return json.Marshal(objectMap) @@ -322,10 +391,10 @@ func (r *RabbitMQListSecretsResult) UnmarshalJSON(data []byte) error { switch key { case "password": err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) + delete(rawMsg, key) case "uri": err = unpopulate(val, "URI", &r.URI) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -336,7 +405,7 @@ func (r *RabbitMQListSecretsResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RabbitMQQueueProperties. func (r RabbitMQQueueProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "application", r.Application) populate(objectMap, "environment", r.Environment) populate(objectMap, "host", r.Host) @@ -365,46 +434,46 @@ func (r *RabbitMQQueueProperties) UnmarshalJSON(data []byte) error { switch key { case "application": err = unpopulate(val, "Application", &r.Application) - delete(rawMsg, key) + delete(rawMsg, key) case "environment": err = unpopulate(val, "Environment", &r.Environment) - delete(rawMsg, key) + delete(rawMsg, key) case "host": err = unpopulate(val, "Host", &r.Host) - delete(rawMsg, key) + delete(rawMsg, key) case "port": err = unpopulate(val, "Port", &r.Port) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "queue": err = unpopulate(val, "Queue", &r.Queue) - delete(rawMsg, key) + delete(rawMsg, key) case "recipe": err = unpopulate(val, "Recipe", &r.Recipe) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProvisioning": err = unpopulate(val, "ResourceProvisioning", &r.ResourceProvisioning) - delete(rawMsg, key) + delete(rawMsg, key) case "resources": err = unpopulate(val, "Resources", &r.Resources) - delete(rawMsg, key) + delete(rawMsg, key) case "secrets": err = unpopulate(val, "Secrets", &r.Secrets) - delete(rawMsg, key) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &r.Status) - delete(rawMsg, key) + delete(rawMsg, key) case "tls": err = unpopulate(val, "TLS", &r.TLS) - delete(rawMsg, key) + delete(rawMsg, key) case "username": err = unpopulate(val, "Username", &r.Username) - delete(rawMsg, key) + delete(rawMsg, key) case "vHost": err = unpopulate(val, "VHost", &r.VHost) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -415,7 +484,7 @@ func (r *RabbitMQQueueProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RabbitMQQueueResource. func (r RabbitMQQueueResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "location", r.Location) populate(objectMap, "name", r.Name) @@ -437,25 +506,25 @@ func (r *RabbitMQQueueResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &r.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &r.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &r.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -466,7 +535,7 @@ func (r *RabbitMQQueueResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RabbitMQQueueResourceListResult. func (r RabbitMQQueueResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -483,10 +552,112 @@ func (r *RabbitMQQueueResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &r.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &r.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RabbitMQQueueResourceUpdate. +func (r RabbitMQQueueResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RabbitMQQueueResourceUpdate. +func (r *RabbitMQQueueResourceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RabbitMQQueueResourceUpdateProperties. +func (r RabbitMQQueueResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "application", r.Application) + populate(objectMap, "environment", r.Environment) + populate(objectMap, "host", r.Host) + populate(objectMap, "port", r.Port) + populate(objectMap, "queue", r.Queue) + populate(objectMap, "recipe", r.Recipe) + populate(objectMap, "resourceProvisioning", r.ResourceProvisioning) + populate(objectMap, "resources", r.Resources) + populate(objectMap, "secrets", r.Secrets) + populate(objectMap, "tls", r.TLS) + populate(objectMap, "username", r.Username) + populate(objectMap, "vHost", r.VHost) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RabbitMQQueueResourceUpdateProperties. +func (r *RabbitMQQueueResourceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "application": + err = unpopulate(val, "Application", &r.Application) + delete(rawMsg, key) + case "environment": + err = unpopulate(val, "Environment", &r.Environment) + delete(rawMsg, key) + case "host": + err = unpopulate(val, "Host", &r.Host) + delete(rawMsg, key) + case "port": + err = unpopulate(val, "Port", &r.Port) + delete(rawMsg, key) + case "queue": + err = unpopulate(val, "Queue", &r.Queue) + delete(rawMsg, key) + case "recipe": + err = unpopulate(val, "Recipe", &r.Recipe) + delete(rawMsg, key) + case "resourceProvisioning": + err = unpopulate(val, "ResourceProvisioning", &r.ResourceProvisioning) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &r.Resources) + delete(rawMsg, key) + case "secrets": + err = unpopulate(val, "Secrets", &r.Secrets) + delete(rawMsg, key) + case "tls": + err = unpopulate(val, "TLS", &r.TLS) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &r.Username) + delete(rawMsg, key) + case "vHost": + err = unpopulate(val, "VHost", &r.VHost) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -497,7 +668,7 @@ func (r *RabbitMQQueueResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RabbitMQSecrets. func (r RabbitMQSecrets) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "password", r.Password) populate(objectMap, "uri", r.URI) return json.Marshal(objectMap) @@ -514,10 +685,10 @@ func (r *RabbitMQSecrets) UnmarshalJSON(data []byte) error { switch key { case "password": err = unpopulate(val, "Password", &r.Password) - delete(rawMsg, key) + delete(rawMsg, key) case "uri": err = unpopulate(val, "URI", &r.URI) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -528,7 +699,7 @@ func (r *RabbitMQSecrets) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Recipe. func (r Recipe) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", r.Name) populate(objectMap, "parameters", r.Parameters) return json.Marshal(objectMap) @@ -545,10 +716,41 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { switch key { case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &r.Parameters) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecipeUpdate. +func (r RecipeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "parameters", r.Parameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecipeUpdate. +func (r *RecipeUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) case "parameters": err = unpopulate(val, "Parameters", &r.Parameters) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -559,7 +761,7 @@ func (r *Recipe) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "systemData", r.SystemData) @@ -578,16 +780,16 @@ func (r *Resource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -598,7 +800,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceReference. func (r ResourceReference) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) return json.Marshal(objectMap) } @@ -614,7 +816,7 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -625,7 +827,8 @@ func (r *ResourceReference) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceStatus. func (r ResourceStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) + populate(objectMap, "compute", r.Compute) populate(objectMap, "outputResources", r.OutputResources) return json.Marshal(objectMap) } @@ -639,9 +842,12 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "compute": + r.Compute, err = unmarshalEnvironmentComputeClassification(val) + delete(rawMsg, key) case "outputResources": err = unpopulate(val, "OutputResources", &r.OutputResources) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -652,7 +858,7 @@ func (r *ResourceStatus) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -673,22 +879,22 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { switch key { case "createdAt": err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "createdByType": err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedAt": err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedByType": err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -699,7 +905,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -720,22 +926,22 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &t.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -744,7 +950,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -754,7 +960,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_operations_client.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_operations_client.go index d7100cd3fe..10aac8e976 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_operations_client.go +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_operations_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -12,8 +11,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,35 +19,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, -pl: pl, + internal: cl, } return client, nil } // NewListPager - List the operations for the provider +// // Generated from API version 2022-03-15-privatepreview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) (*runtime.Pager[OperationsClientListResponse]) { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -67,7 +56,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -82,7 +71,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Applications.Messaging/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_options.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_options.go new file mode 100644 index 0000000000..105b2c29cf --- /dev/null +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_options.go @@ -0,0 +1,49 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// RabbitMqQueuesClientBeginCreateOrUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.BeginCreateOrUpdate +// method. +type RabbitMqQueuesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RabbitMqQueuesClientBeginDeleteOptions contains the optional parameters for the RabbitMqQueuesClient.BeginDelete method. +type RabbitMqQueuesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RabbitMqQueuesClientBeginUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.BeginUpdate method. +type RabbitMqQueuesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// RabbitMqQueuesClientGetOptions contains the optional parameters for the RabbitMqQueuesClient.Get method. +type RabbitMqQueuesClientGetOptions struct { + // placeholder for future optional parameters +} + +// RabbitMqQueuesClientListByScopeOptions contains the optional parameters for the RabbitMqQueuesClient.NewListByScopePager +// method. +type RabbitMqQueuesClientListByScopeOptions struct { + // placeholder for future optional parameters +} + +// RabbitMqQueuesClientListSecretsOptions contains the optional parameters for the RabbitMqQueuesClient.ListSecrets method. +type RabbitMqQueuesClientListSecretsOptions struct { + // placeholder for future optional parameters +} + diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go new file mode 100644 index 0000000000..83f13ff53e --- /dev/null +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_polymorphic_helpers.go @@ -0,0 +1,32 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220315privatepreview + +import "encoding/json" + +func unmarshalEnvironmentComputeClassification(rawMsg json.RawMessage) (EnvironmentComputeClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b EnvironmentComputeClassification + switch m["kind"] { + case "kubernetes": + b = &KubernetesCompute{} + default: + b = &EnvironmentCompute{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_rabbitmqqueues_client.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_rabbitmqqueues_client.go index 70178b3461..3f473894c6 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_rabbitmqqueues_client.go +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_rabbitmqqueues_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -13,79 +12,91 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) // RabbitMqQueuesClient contains the methods for the RabbitMqQueues group. // Don't use this type directly, use NewRabbitMqQueuesClient() instead. type RabbitMqQueuesClient struct { - host string + internal *arm.Client rootScope string - pl runtime.Pipeline } // NewRabbitMqQueuesClient creates a new instance of RabbitMqQueuesClient with the specified values. -// rootScope - The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - rootScope - The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} +// and Azure resource scope is +// /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID} +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRabbitMqQueuesClient(rootScope string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RabbitMqQueuesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RabbitMqQueuesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RabbitMqQueuesClient{ rootScope: rootScope, - host: ep, -pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or updates a RabbitMQQueueResource +// BeginCreateOrUpdate - Create a RabbitMQQueueResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - rabbitMQQueueName - The name of the RabbitMQQueue portable resource resource +// - resource - Resource create parameters. +// - options - RabbitMqQueuesClientBeginCreateOrUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.BeginCreateOrUpdate +// method. +func (client *RabbitMqQueuesClient) BeginCreateOrUpdate(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, options *RabbitMqQueuesClientBeginCreateOrUpdateOptions) (*runtime.Poller[RabbitMqQueuesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, rabbitMQQueueName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RabbitMqQueuesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[RabbitMqQueuesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create a RabbitMQQueueResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// rabbitMQQueueName - The name of the RabbitMQQueue portable resource -// resource - Resource create parameters. -// options - RabbitMqQueuesClientCreateOrUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.CreateOrUpdate -// method. -func (client *RabbitMqQueuesClient) CreateOrUpdate(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, options *RabbitMqQueuesClientCreateOrUpdateOptions) (RabbitMqQueuesClientCreateOrUpdateResponse, error) { +func (client *RabbitMqQueuesClient) createOrUpdate(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, options *RabbitMqQueuesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, rabbitMQQueueName, resource, options) if err != nil { - return RabbitMqQueuesClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RabbitMqQueuesClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return RabbitMqQueuesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.createOrUpdateHandleResponse(resp) + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *RabbitMqQueuesClient) createOrUpdateCreateRequest(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, options *RabbitMqQueuesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) createOrUpdateCreateRequest(ctx context.Context, rabbitMQQueueName string, resource RabbitMQQueueResource, options *RabbitMqQueuesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { return nil, errors.New("parameter rabbitMQQueueName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rabbitMQQueueName}", url.PathEscape(rabbitMQQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -93,55 +104,64 @@ func (client *RabbitMqQueuesClient) createOrUpdateCreateRequest(ctx context.Cont reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *RabbitMqQueuesClient) createOrUpdateHandleResponse(resp *http.Response) (RabbitMqQueuesClientCreateOrUpdateResponse, error) { - result := RabbitMqQueuesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) +// BeginDelete - Delete a RabbitMQQueueResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - rabbitMQQueueName - The name of the RabbitMQQueue portable resource resource +// - options - RabbitMqQueuesClientBeginDeleteOptions contains the optional parameters for the RabbitMqQueuesClient.BeginDelete +// method. +func (client *RabbitMqQueuesClient) BeginDelete(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientBeginDeleteOptions) (*runtime.Poller[RabbitMqQueuesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, rabbitMQQueueName, options) if err != nil { - return RabbitMqQueuesClientCreateOrUpdateResponse{}, err + return nil, err } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.RabbitMQQueueResource); err != nil { - return RabbitMqQueuesClientCreateOrUpdateResponse{}, err + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RabbitMqQueuesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[RabbitMqQueuesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - return result, nil } -// Delete - Deletes an existing RabbitMQQueueResource +// Delete - Delete a RabbitMQQueueResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// rabbitMQQueueName - The name of the RabbitMQQueue portable resource -// options - RabbitMqQueuesClientDeleteOptions contains the optional parameters for the RabbitMqQueuesClient.Delete method. -func (client *RabbitMqQueuesClient) Delete(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientDeleteOptions) (RabbitMqQueuesClientDeleteResponse, error) { +func (client *RabbitMqQueuesClient) deleteOperation(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, rabbitMQQueueName, options) if err != nil { - return RabbitMqQueuesClientDeleteResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return RabbitMqQueuesClientDeleteResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return RabbitMqQueuesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.deleteHandleResponse(resp) + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *RabbitMqQueuesClient) deleteCreateRequest(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientDeleteOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) deleteCreateRequest(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { return nil, errors.New("parameter rabbitMQQueueName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rabbitMQQueueName}", url.PathEscape(rabbitMQQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -152,38 +172,28 @@ func (client *RabbitMqQueuesClient) deleteCreateRequest(ctx context.Context, rab return req, nil } -// deleteHandleResponse handles the Delete response. -func (client *RabbitMqQueuesClient) deleteHandleResponse(resp *http.Response) (RabbitMqQueuesClientDeleteResponse, error) { - result := RabbitMqQueuesClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return RabbitMqQueuesClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a RabbitMQQueueResource +// Get - Get a RabbitMQQueueResource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// rabbitMQQueueName - The name of the RabbitMQQueue portable resource -// options - RabbitMqQueuesClientGetOptions contains the optional parameters for the RabbitMqQueuesClient.Get method. +// - rabbitMQQueueName - The name of the RabbitMQQueue portable resource resource +// - options - RabbitMqQueuesClientGetOptions contains the optional parameters for the RabbitMqQueuesClient.Get method. func (client *RabbitMqQueuesClient) Get(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientGetOptions) (RabbitMqQueuesClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, rabbitMQQueueName, options) if err != nil { return RabbitMqQueuesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RabbitMqQueuesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RabbitMqQueuesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RabbitMqQueuesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -194,7 +204,7 @@ func (client *RabbitMqQueuesClient) getCreateRequest(ctx context.Context, rabbit return nil, errors.New("parameter rabbitMQQueueName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rabbitMQQueueName}", url.PathEscape(rabbitMQQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -214,43 +224,44 @@ func (client *RabbitMqQueuesClient) getHandleResponse(resp *http.Response) (Rabb return result, nil } -// NewListByRootScopePager - Lists information about all RabbitMQQueueResources in the given root scope +// NewListByScopePager - List RabbitMQQueueResource resources by Scope +// // Generated from API version 2022-03-15-privatepreview -// options - RabbitMqQueuesClientListByRootScopeOptions contains the optional parameters for the RabbitMqQueuesClient.ListByRootScope -// method. -func (client *RabbitMqQueuesClient) NewListByRootScopePager(options *RabbitMqQueuesClientListByRootScopeOptions) (*runtime.Pager[RabbitMqQueuesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[RabbitMqQueuesClientListByRootScopeResponse]{ - More: func(page RabbitMqQueuesClientListByRootScopeResponse) bool { +// - options - RabbitMqQueuesClientListByScopeOptions contains the optional parameters for the RabbitMqQueuesClient.NewListByScopePager +// method. +func (client *RabbitMqQueuesClient) NewListByScopePager(options *RabbitMqQueuesClientListByScopeOptions) (*runtime.Pager[RabbitMqQueuesClientListByScopeResponse]) { + return runtime.NewPager(runtime.PagingHandler[RabbitMqQueuesClientListByScopeResponse]{ + More: func(page RabbitMqQueuesClientListByScopeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *RabbitMqQueuesClientListByRootScopeResponse) (RabbitMqQueuesClientListByRootScopeResponse, error) { + Fetcher: func(ctx context.Context, page *RabbitMqQueuesClientListByScopeResponse) (RabbitMqQueuesClientListByScopeResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) + req, err = client.listByScopeCreateRequest(ctx, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return RabbitMqQueuesClientListByRootScopeResponse{}, err + return RabbitMqQueuesClientListByScopeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return RabbitMqQueuesClientListByRootScopeResponse{}, err + return RabbitMqQueuesClientListByScopeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return RabbitMqQueuesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) + return RabbitMqQueuesClientListByScopeResponse{}, runtime.NewResponseError(resp) } - return client.listByRootScopeHandleResponse(resp) + return client.listByScopeHandleResponse(resp) }, }) } -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *RabbitMqQueuesClient) listByRootScopeCreateRequest(ctx context.Context, options *RabbitMqQueuesClientListByRootScopeOptions) (*policy.Request, error) { +// listByScopeCreateRequest creates the ListByScope request. +func (client *RabbitMqQueuesClient) listByScopeCreateRequest(ctx context.Context, options *RabbitMqQueuesClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -261,45 +272,50 @@ func (client *RabbitMqQueuesClient) listByRootScopeCreateRequest(ctx context.Con return req, nil } -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *RabbitMqQueuesClient) listByRootScopeHandleResponse(resp *http.Response) (RabbitMqQueuesClientListByRootScopeResponse, error) { - result := RabbitMqQueuesClientListByRootScopeResponse{} +// listByScopeHandleResponse handles the ListByScope response. +func (client *RabbitMqQueuesClient) listByScopeHandleResponse(resp *http.Response) (RabbitMqQueuesClientListByScopeResponse, error) { + result := RabbitMqQueuesClientListByScopeResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.RabbitMQQueueResourceListResult); err != nil { - return RabbitMqQueuesClientListByRootScopeResponse{}, err + return RabbitMqQueuesClientListByScopeResponse{}, err } return result, nil } // ListSecrets - Lists secrets values for the specified RabbitMQQueue resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-03-15-privatepreview -// rabbitMQQueueName - The name of the RabbitMQQueue portable resource -// options - RabbitMqQueuesClientListSecretsOptions contains the optional parameters for the RabbitMqQueuesClient.ListSecrets -// method. -func (client *RabbitMqQueuesClient) ListSecrets(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientListSecretsOptions) (RabbitMqQueuesClientListSecretsResponse, error) { - req, err := client.listSecretsCreateRequest(ctx, rabbitMQQueueName, options) +// - rabbitMQQueueName - The name of the RabbitMQQueue portable resource resource +// - body - The content of the action request +// - options - RabbitMqQueuesClientListSecretsOptions contains the optional parameters for the RabbitMqQueuesClient.ListSecrets +// method. +func (client *RabbitMqQueuesClient) ListSecrets(ctx context.Context, rabbitMQQueueName string, body map[string]any, options *RabbitMqQueuesClientListSecretsOptions) (RabbitMqQueuesClientListSecretsResponse, error) { + var err error + req, err := client.listSecretsCreateRequest(ctx, rabbitMQQueueName, body, options) if err != nil { return RabbitMqQueuesClientListSecretsResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RabbitMqQueuesClientListSecretsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RabbitMqQueuesClientListSecretsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RabbitMqQueuesClientListSecretsResponse{}, err } - return client.listSecretsHandleResponse(resp) + resp, err := client.listSecretsHandleResponse(httpResp) + return resp, err } // listSecretsCreateRequest creates the ListSecrets request. -func (client *RabbitMqQueuesClient) listSecretsCreateRequest(ctx context.Context, rabbitMQQueueName string, options *RabbitMqQueuesClientListSecretsOptions) (*policy.Request, error) { +func (client *RabbitMqQueuesClient) listSecretsCreateRequest(ctx context.Context, rabbitMQQueueName string, body map[string]any, options *RabbitMqQueuesClientListSecretsOptions) (*policy.Request, error) { urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}/listSecrets" urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) if rabbitMQQueueName == "" { return nil, errors.New("parameter rabbitMQQueueName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rabbitMQQueueName}", url.PathEscape(rabbitMQQueueName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,6 +323,9 @@ func (client *RabbitMqQueuesClient) listSecretsCreateRequest(ctx context.Context reqQP.Set("api-version", "2022-03-15-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err +} return req, nil } @@ -319,3 +338,69 @@ func (client *RabbitMqQueuesClient) listSecretsHandleResponse(resp *http.Respons return result, nil } +// BeginUpdate - Update a RabbitMQQueueResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +// - rabbitMQQueueName - The name of the RabbitMQQueue portable resource resource +// - properties - The resource properties to be updated. +// - options - RabbitMqQueuesClientBeginUpdateOptions contains the optional parameters for the RabbitMqQueuesClient.BeginUpdate +// method. +func (client *RabbitMqQueuesClient) BeginUpdate(ctx context.Context, rabbitMQQueueName string, properties RabbitMQQueueResourceUpdate, options *RabbitMqQueuesClientBeginUpdateOptions) (*runtime.Poller[RabbitMqQueuesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, rabbitMQQueueName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RabbitMqQueuesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[RabbitMqQueuesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a RabbitMQQueueResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-03-15-privatepreview +func (client *RabbitMqQueuesClient) update(ctx context.Context, rabbitMQQueueName string, properties RabbitMQQueueResourceUpdate, options *RabbitMqQueuesClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, rabbitMQQueueName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *RabbitMqQueuesClient) updateCreateRequest(ctx context.Context, rabbitMQQueueName string, properties RabbitMQQueueResourceUpdate, options *RabbitMqQueuesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}" + urlPath = strings.ReplaceAll(urlPath, "{rootScope}", client.rootScope) + if rabbitMQQueueName == "" { + return nil, errors.New("parameter rabbitMQQueueName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{rabbitMQQueueName}", url.PathEscape(rabbitMQQueueName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-03-15-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_response_types.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_response_types.go index a030141adf..a9996c7a59 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_response_types.go +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_response_types.go @@ -2,42 +2,49 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. OperationListResult } -// RabbitMqQueuesClientCreateOrUpdateResponse contains the response from method RabbitMqQueuesClient.CreateOrUpdate. +// RabbitMqQueuesClientCreateOrUpdateResponse contains the response from method RabbitMqQueuesClient.BeginCreateOrUpdate. type RabbitMqQueuesClientCreateOrUpdateResponse struct { + // RabbitMQQueue portable resource RabbitMQQueueResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// RabbitMqQueuesClientDeleteResponse contains the response from method RabbitMqQueuesClient.Delete. +// RabbitMqQueuesClientDeleteResponse contains the response from method RabbitMqQueuesClient.BeginDelete. type RabbitMqQueuesClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 + // placeholder for future response values } // RabbitMqQueuesClientGetResponse contains the response from method RabbitMqQueuesClient.Get. type RabbitMqQueuesClientGetResponse struct { + // RabbitMQQueue portable resource RabbitMQQueueResource } -// RabbitMqQueuesClientListByRootScopeResponse contains the response from method RabbitMqQueuesClient.ListByRootScope. -type RabbitMqQueuesClientListByRootScopeResponse struct { +// RabbitMqQueuesClientListByScopeResponse contains the response from method RabbitMqQueuesClient.NewListByScopePager. +type RabbitMqQueuesClientListByScopeResponse struct { + // The response of a RabbitMQQueueResource list operation. RabbitMQQueueResourceListResult } // RabbitMqQueuesClientListSecretsResponse contains the response from method RabbitMqQueuesClient.ListSecrets. type RabbitMqQueuesClientListSecretsResponse struct { + // The secret values for the given RabbitMQQueue resource RabbitMQListSecretsResult } +// RabbitMqQueuesClientUpdateResponse contains the response from method RabbitMqQueuesClient.BeginUpdate. +type RabbitMqQueuesClientUpdateResponse struct { + // RabbitMQQueue portable resource + RabbitMQQueueResource +} + diff --git a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go index cea28fe8b6..30ea6fa1d0 100644 --- a/pkg/messagingrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go +++ b/pkg/messagingrp/api/v20220315privatepreview/zz_generated_time_rfc3339.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220315privatepreview @@ -66,7 +65,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/pkg/messagingrp/datamodel/converter/rabbitmq_converter.go b/pkg/messagingrp/datamodel/converter/rabbitmq_converter.go index 21f2d835ea..6eba77b8ac 100644 --- a/pkg/messagingrp/datamodel/converter/rabbitmq_converter.go +++ b/pkg/messagingrp/datamodel/converter/rabbitmq_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/messagingrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/messagingrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/messagingrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/messagingrp/datamodel" ) // RabbitMQQueueDataModelToVersioned converts a version-agnostic datamodel.RabbitMQQueue to a versioned model interface diff --git a/pkg/messagingrp/datamodel/converter/rabbitmq_converter_test.go b/pkg/messagingrp/datamodel/converter/rabbitmq_converter_test.go index b5c6a970d8..1a7b411349 100644 --- a/pkg/messagingrp/datamodel/converter/rabbitmq_converter_test.go +++ b/pkg/messagingrp/datamodel/converter/rabbitmq_converter_test.go @@ -21,10 +21,10 @@ import ( "errors" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - linkrp_util "github.com/project-radius/radius/pkg/linkrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/messagingrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/messagingrp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/messagingrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -52,10 +52,10 @@ func TestRabbitMQQueueDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.RabbitMQQueue{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := RabbitMQQueueDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -92,8 +92,7 @@ func TestRabbitMQQueueDataModelFromVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.versionedModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.versionedModelFile) dm, err := RabbitMQQueueDataModelFromVersioned(c, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) @@ -128,10 +127,10 @@ func TestRabbitMQSecretsDataModelToVersioned(t *testing.T) { for _, tc := range testset { t.Run(tc.apiVersion, func(t *testing.T) { - c, err := linkrp_util.LoadTestData(tc.dataModelFile) - require.NoError(t, err) + c := testutil.ReadFixture("../" + tc.dataModelFile) dm := &datamodel.RabbitMQSecrets{} - _ = json.Unmarshal(c, dm) + err := json.Unmarshal(c, dm) + require.NoError(t, err) am, err := RabbitMQSecretsDataModelToVersioned(dm, tc.apiVersion) if tc.err != nil { require.ErrorAs(t, tc.err, &err) diff --git a/pkg/messagingrp/datamodel/rabbitmq.go b/pkg/messagingrp/datamodel/rabbitmq.go index 30d1ead1c3..cbc8e833e9 100644 --- a/pkg/messagingrp/datamodel/rabbitmq.go +++ b/pkg/messagingrp/datamodel/rabbitmq.go @@ -20,27 +20,26 @@ import ( "fmt" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/linkrp" - linkrp_dm "github.com/project-radius/radius/pkg/linkrp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/portableresources" + pr_dm "github.com/radius-project/radius/pkg/portableresources/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) -// RabbitMQQueue represents RabbitMQQueue link resource. +// RabbitMQQueue represents RabbitMQQueue portable resource. type RabbitMQQueue struct { v1.BaseResource // Properties is the properties of the resource. Properties RabbitMQQueueProperties `json:"properties"` - // LinkMetadata represents internal DataModel properties common to all link types. - linkrp_dm.LinkMetadata + // ResourceMetadata represents internal DataModel properties common to all portable resource types. + pr_dm.PortableResourceMetadata } // ApplyDeploymentOutput updates the RabbitMQQueue instance with the DeployedOutputResources from the // DeploymentOutput object and returns no error. func (r *RabbitMQQueue) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { - r.Properties.Status.OutputResources = do.DeployedOutputResources return nil } @@ -56,22 +55,22 @@ func (r *RabbitMQQueue) ResourceMetadata() *rpv1.BasicResourceProperties { // ResourceTypeName returns the resource type name for RabbitMQ queues. func (rabbitmq *RabbitMQQueue) ResourceTypeName() string { - return linkrp.N_RabbitMQQueuesResourceType + return portableresources.RabbitMQQueuesResourceType } // RabbitMQQueueProperties represents the properties of RabbitMQQueue response resource. type RabbitMQQueueProperties struct { rpv1.BasicResourceProperties - Queue string `json:"queue,omitempty"` - Host string `json:"host,omitempty"` - Port int32 `json:"port,omitempty"` - VHost string `json:"vHost,omitempty"` - Username string `json:"username,omitempty"` - Resources []*linkrp.ResourceReference `json:"resources,omitempty"` - Recipe linkrp.LinkRecipe `json:"recipe,omitempty"` - Secrets RabbitMQSecrets `json:"secrets,omitempty"` - ResourceProvisioning linkrp.ResourceProvisioning `json:"resourceProvisioning,omitempty"` - TLS bool `json:"tls,omitempty"` + Queue string `json:"queue,omitempty"` + Host string `json:"host,omitempty"` + Port int32 `json:"port,omitempty"` + VHost string `json:"vHost,omitempty"` + Username string `json:"username,omitempty"` + Resources []*portableresources.ResourceReference `json:"resources,omitempty"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` + Secrets RabbitMQSecrets `json:"secrets,omitempty"` + ResourceProvisioning portableresources.ResourceProvisioning `json:"resourceProvisioning,omitempty"` + TLS bool `json:"tls,omitempty"` } // Secrets values consisting of secrets provided for the resource @@ -82,13 +81,13 @@ type RabbitMQSecrets struct { // ResourceTypeName returns the resource type name for RabbitMQ queues. func (rabbitmq RabbitMQSecrets) ResourceTypeName() string { - return linkrp.N_RabbitMQQueuesResourceType + return portableresources.RabbitMQQueuesResourceType } -// Recipe returns the recipe for the RabbitMQQueue. It gets the LinkRecipe associated with the RabbitMQQueue instance +// Recipe returns the recipe for the RabbitMQQueue. It gets the ResourceRecipe associated with the RabbitMQQueue instance // if the ResourceProvisioning is not set to Manual, otherwise it returns nil. -func (r *RabbitMQQueue) Recipe() *linkrp.LinkRecipe { - if r.Properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { +func (r *RabbitMQQueue) Recipe() *portableresources.ResourceRecipe { + if r.Properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { return nil } return &r.Properties.Recipe @@ -98,9 +97,9 @@ func (r *RabbitMQQueue) Recipe() *linkrp.LinkRecipe { func (rabbitmq *RabbitMQQueue) VerifyInputs() error { properties := rabbitmq.Properties msgs := []string{} - if properties.ResourceProvisioning != "" && properties.ResourceProvisioning == linkrp.ResourceProvisioningManual { + if properties.ResourceProvisioning != "" && properties.ResourceProvisioning == portableresources.ResourceProvisioningManual { if properties.Queue == "" { - return &v1.ErrClientRP{Code: "Bad Request", Message: fmt.Sprintf("queue is required when resourceProvisioning is %s", linkrp.ResourceProvisioningManual)} + return &v1.ErrClientRP{Code: "Bad Request", Message: fmt.Sprintf("queue is required when resourceProvisioning is %s", portableresources.ResourceProvisioningManual)} } if properties.Host == "" { msgs = append(msgs, "host must be specified when resourceProvisioning is set to manual") diff --git a/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq.go b/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq.go index 80800135fc..f73e4da6ce 100644 --- a/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq.go +++ b/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq.go @@ -20,12 +20,12 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/linkrp/renderers" - msg_dm "github.com/project-radius/radius/pkg/messagingrp/datamodel" - msg_conv "github.com/project-radius/radius/pkg/messagingrp/datamodel/converter" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + msg_dm "github.com/radius-project/radius/pkg/messagingrp/datamodel" + msg_conv "github.com/radius-project/radius/pkg/messagingrp/datamodel/converter" + "github.com/radius-project/radius/pkg/portableresources/renderers" ) var _ ctrl.Controller = (*ListSecretsRabbitMQQueue)(nil) diff --git a/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq_test.go b/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq_test.go index dc7130e104..d96eb40d91 100644 --- a/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq_test.go +++ b/pkg/messagingrp/frontend/controller/rabbitmqqueues/listsecretsrabbitmq_test.go @@ -25,11 +25,11 @@ import ( "testing" "github.com/golang/mock/gomock" - ctrl "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/linkrp/renderers" - "github.com/project-radius/radius/pkg/messagingrp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/ucp/store" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/messagingrp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/portableresources/renderers" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/messagingrp/frontend/controller/rabbitmqqueues/testdata/20220315privatepreview_datamodel.json b/pkg/messagingrp/frontend/controller/rabbitmqqueues/testdata/20220315privatepreview_datamodel.json index 64fde9a2e3..dd945fcb96 100644 --- a/pkg/messagingrp/frontend/controller/rabbitmqqueues/testdata/20220315privatepreview_datamodel.json +++ b/pkg/messagingrp/frontend/controller/rabbitmqqueues/testdata/20220315privatepreview_datamodel.json @@ -1,44 +1,48 @@ { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.messaging/rabbitmqqueues/rabbitmq0", - "name": "rabbitmq0", - "type": "applications.messaging/rabbitmqqueues", - "location": "West US", - "systemData": { - "createdAt": "2022-03-22T18:54:52.6857175Z", - "createdBy": "fake@hotmail.com", - "createdByType": "User", - "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", - "lastModifiedBy": "fake@hotmail.com", - "lastModifiedByType": "User" - }, - "properties": { - "status": { - "outputResources": null - }, - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", - "resourceProvisioning": "manual", - "queue": "testQueue", - "secrets": { - "uri": "connection://string", - "password": "password" + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/applications.messaging/rabbitmqqueues/rabbitmq0", + "name": "rabbitmq0", + "type": "applications.messaging/rabbitmqqueues", + "location": "West US", + "systemData": { + "createdAt": "2022-03-22T18:54:52.6857175Z", + "createdBy": "fake@hotmail.com", + "createdByType": "User", + "lastModifiedAt": "2022-03-22T18:57:52.6857175Z", + "lastModifiedBy": "fake@hotmail.com", + "lastModifiedByType": "User" + }, + "properties": { + "status": { + "outputResources": [ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource" } + ] }, - "computedValues": { - "queue": "testQueue" - }, - "secretValues": { - "uri": { - "value": "connection://string" - }, - "password": { - "value": "password" - } + "provisioningState": "Succeeded", + "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/environments/env0", + "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Core/applications/testApplication", + "resourceProvisioning": "manual", + "queue": "testQueue", + "secrets": { + "uri": "connection://string", + "password": "password" + } + }, + "computedValues": { + "queue": "testQueue" + }, + "secretValues": { + "uri": { + "value": "connection://string" }, - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroup": "radius-test-rg", - "createdApiVersion": "2022-03-15-privatepreview", - "updatedApiVersion": "2022-03-15-privatepreview" + "password": { + "value": "password" + } + }, + "tenantId": "00000000-0000-0000-0000-000000000000", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroup": "radius-test-rg", + "createdApiVersion": "2022-03-15-privatepreview", + "updatedApiVersion": "2022-03-15-privatepreview" } \ No newline at end of file diff --git a/pkg/messagingrp/frontend/controller/rabbitmqqueues/v20220315privatepreview_test.go b/pkg/messagingrp/frontend/controller/rabbitmqqueues/v20220315privatepreview_test.go index ddbddb35f5..f607368d30 100644 --- a/pkg/messagingrp/frontend/controller/rabbitmqqueues/v20220315privatepreview_test.go +++ b/pkg/messagingrp/frontend/controller/rabbitmqqueues/v20220315privatepreview_test.go @@ -19,9 +19,9 @@ package rabbitmqqueues import ( "encoding/json" - "github.com/project-radius/radius/pkg/messagingrp/api/v20220315privatepreview" - msg_dm "github.com/project-radius/radius/pkg/messagingrp/datamodel" - "github.com/project-radius/radius/test/testutil" + "github.com/radius-project/radius/pkg/messagingrp/api/v20220315privatepreview" + msg_dm "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/test/testutil" ) const testHeaderfile = "20220315privatepreview_requestheaders.json" diff --git a/pkg/messagingrp/processors/rabbitmqqueues/processor.go b/pkg/messagingrp/processors/rabbitmqqueues/processor.go index c9ebded77a..093b50f8df 100644 --- a/pkg/messagingrp/processors/rabbitmqqueues/processor.go +++ b/pkg/messagingrp/processors/rabbitmqqueues/processor.go @@ -20,9 +20,9 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/linkrp/renderers" - msg_dm "github.com/project-radius/radius/pkg/messagingrp/datamodel" + msg_dm "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/portableresources/renderers" ) const ( @@ -61,6 +61,11 @@ func (p *Processor) Process(ctx context.Context, resource *msg_dm.RabbitMQQueue, return nil } +// Delete implements the processors.Processor interface for RabbitMQQueue resources. +func (p *Processor) Delete(ctx context.Context, resource *msg_dm.RabbitMQQueue, options processors.Options) error { + return nil +} + func (p *Processor) computeURI(resource *msg_dm.RabbitMQQueue) string { rabbitMQProtocol := "amqp" if resource.Properties.TLS { diff --git a/pkg/messagingrp/processors/rabbitmqqueues/processor_test.go b/pkg/messagingrp/processors/rabbitmqqueues/processor_test.go index a9a7a1c0cf..37a31a4ec1 100644 --- a/pkg/messagingrp/processors/rabbitmqqueues/processor_test.go +++ b/pkg/messagingrp/processors/rabbitmqqueues/processor_test.go @@ -18,10 +18,10 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/messagingrp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/metrics/asyncoperationmetrics.go b/pkg/metrics/asyncoperationmetrics.go index fa048f9f15..0b6e0b986b 100644 --- a/pkg/metrics/asyncoperationmetrics.go +++ b/pkg/metrics/asyncoperationmetrics.go @@ -21,9 +21,9 @@ import ( "strings" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/ucp/resources" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" @@ -138,6 +138,9 @@ func newAsyncOperationCommonAttributes(req *ctrl.Request, res *ctrl.Result) []at if res != nil && res.ProvisioningState() != "" { attrs = append(attrs, OperationStateAttrKey.String(normalizeAttrValue(string(res.ProvisioningState())))) + } + + if res != nil && res.Error != nil && res.Error.Code != "" { attrs = append(attrs, operationErrorCodeAttrKey.String(normalizeAttrValue(string(res.Error.Code)))) } diff --git a/pkg/metrics/recipeenginemetrics.go b/pkg/metrics/recipeenginemetrics.go index ce28a5c047..13b4cf747a 100644 --- a/pkg/metrics/recipeenginemetrics.go +++ b/pkg/metrics/recipeenginemetrics.go @@ -21,7 +21,7 @@ import ( "strings" "time" - "github.com/project-radius/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" diff --git a/pkg/metrics/service/hostoptions.go b/pkg/metrics/service/hostoptions.go index b7f893a968..009d3bea90 100644 --- a/pkg/metrics/service/hostoptions.go +++ b/pkg/metrics/service/hostoptions.go @@ -17,8 +17,8 @@ limitations under the License. package metricsservice import ( - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/metrics/provider" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/metrics/provider" ) // HostOptions defines all of the settings that our metric's execution environment provides. diff --git a/pkg/metrics/service/service.go b/pkg/metrics/service/service.go index 3a614dbe31..915205f22c 100644 --- a/pkg/metrics/service/service.go +++ b/pkg/metrics/service/service.go @@ -24,9 +24,9 @@ import ( "strconv" "time" - "github.com/project-radius/radius/pkg/metrics" - "github.com/project-radius/radius/pkg/metrics/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/metrics" + "github.com/radius-project/radius/pkg/metrics/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" "go.opentelemetry.io/contrib/instrumentation/runtime" ) diff --git a/pkg/middleware/logger.go b/pkg/middleware/logger.go index 4fd71d30b6..ac5e5a9f87 100644 --- a/pkg/middleware/logger.go +++ b/pkg/middleware/logger.go @@ -19,25 +19,21 @@ package middleware import ( "net/http" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // WithLogger adds logger to the context based on the Resource ID (if present). -func WithLogger(serviceName string) func(h http.Handler) http.Handler { - return func(h http.Handler) http.Handler { - fn := func(w http.ResponseWriter, r *http.Request) { - id, err := resources.Parse(r.URL.Path) - if err != nil { - // This just means the request is for an ARM resource. Not an error. - h.ServeHTTP(w, r) - return - } - - ctx := ucplog.WrapLogContext(r.Context(), ucplog.LogFieldResourceID, id.String()) - h.ServeHTTP(w, r.WithContext(ctx)) +func WithLogger(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + id, err := resources.Parse(r.URL.Path) + if err != nil { + // This just means the request is for an ARM resource. Not an error. + h.ServeHTTP(w, r) + return } - return http.HandlerFunc(fn) - } + ctx := ucplog.WrapLogContext(r.Context(), ucplog.LogFieldResourceID, id.String()) + h.ServeHTTP(w, r.WithContext(ctx)) + }) } diff --git a/pkg/middleware/lowercaseurlpath.go b/pkg/middleware/lowercaseurlpath.go index 793c2c7b7a..1cc013f5c8 100644 --- a/pkg/middleware/lowercaseurlpath.go +++ b/pkg/middleware/lowercaseurlpath.go @@ -20,7 +20,7 @@ import ( "net/http" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) // LowercaseURLPath sets the Referer header to the original URL if it is not already set, and then lowercases the URL path diff --git a/pkg/middleware/lowercaseurlpath_test.go b/pkg/middleware/lowercaseurlpath_test.go index f477a159ed..4ad371db16 100644 --- a/pkg/middleware/lowercaseurlpath_test.go +++ b/pkg/middleware/lowercaseurlpath_test.go @@ -24,7 +24,7 @@ import ( "testing" "github.com/go-chi/chi/v5" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/middleware/recoverer.go b/pkg/middleware/recoverer.go index 59c17d9e1c..ea8a20589d 100644 --- a/pkg/middleware/recoverer.go +++ b/pkg/middleware/recoverer.go @@ -21,9 +21,9 @@ import ( "net/http" "runtime/debug" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // Recoverer handles panics and logs the error, returning an Internal Server Error response. diff --git a/pkg/portableresources/api/versions.go b/pkg/portableresources/api/versions.go new file mode 100644 index 0000000000..557058b8ca --- /dev/null +++ b/pkg/portableresources/api/versions.go @@ -0,0 +1,20 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package api + +// V20220315privatepreview represents the api version "2022-03-15-privatepreview". +const V20220315privatepreview = "2022-03-15-privatepreview" diff --git a/pkg/portableresources/backend/controller/createorupdateresource.go b/pkg/portableresources/backend/controller/createorupdateresource.go new file mode 100644 index 0000000000..05aad4e8a4 --- /dev/null +++ b/pkg/portableresources/backend/controller/createorupdateresource.go @@ -0,0 +1,151 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controller + +import ( + "context" + "errors" + + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/portableresources/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/configloader" + "github.com/radius-project/radius/pkg/recipes/engine" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/store" +) + +// CreateOrUpdateResource is the async operation controller to create or update portable resources. +type CreateOrUpdateResource[P interface { + *T + rpv1.RadiusResourceModel +}, T any] struct { + ctrl.BaseController + processor processors.ResourceProcessor[P, T] + engine engine.Engine + client processors.ResourceClient + configurationLoader configloader.ConfigurationLoader +} + +// NewCreateOrUpdateResource creates a new controller for creating or updating a resource with the given processor, engine, +// client, configurationLoader and options. The processor function will be called to process updates to the resource. +func NewCreateOrUpdateResource[P interface { + *T + rpv1.RadiusResourceModel +}, T any](opts ctrl.Options, processor processors.ResourceProcessor[P, T], eng engine.Engine, client processors.ResourceClient, configurationLoader configloader.ConfigurationLoader) (ctrl.Controller, error) { + return &CreateOrUpdateResource[P, T]{ + ctrl.NewBaseAsyncController(opts), + processor, + eng, + client, + configurationLoader, + }, nil +} + +// Run retrieves an existing resource, executes a recipe if needed, loads runtime configuration, +// processes the resource, cleans up any obsolete output resources, and saves the updated resource. +func (c *CreateOrUpdateResource[P, T]) Run(ctx context.Context, req *ctrl.Request) (ctrl.Result, error) { + obj, err := c.StorageClient().Get(ctx, req.ResourceID) + if errors.Is(&store.ErrNotFound{ID: req.ResourceID}, err) { + return ctrl.Result{}, err + } else if err != nil { + return ctrl.Result{}, err + } + + data := P(new(T)) + if err = obj.As(data); err != nil { + return ctrl.Result{}, err + } + + // Clone existing output resources so we can diff them later. + previousOutputResources := c.copyOutputResources(data) + + // Now we're ready to process recipes (if needed). + recipeOutput, err := c.executeRecipeIfNeeded(ctx, data, previousOutputResources) + if err != nil { + if recipeError, ok := err.(*recipes.RecipeError); ok { + return ctrl.NewFailedResult(recipeError.ErrorDetails), nil + } + return ctrl.Result{}, err + } + + // Load details about the runtime for the processor to access. + runtimeConfiguration, err := c.loadRuntimeConfiguration(ctx, data.ResourceMetadata().Environment, data.ResourceMetadata().Application, data.GetBaseResource().ID) + if err != nil { + return ctrl.Result{}, err + } + + // Now we're ready to process the resource. This will handle the updates to any user-visible state. + err = c.processor.Process(ctx, data, processors.Options{RecipeOutput: recipeOutput, RuntimeConfiguration: *runtimeConfiguration}) + if err != nil { + return ctrl.Result{}, err + } + + update := &store.Object{ + Metadata: store.Metadata{ + ID: req.ResourceID, + }, + Data: data, + } + err = c.StorageClient().Save(ctx, update, store.WithETag(obj.ETag)) + if err != nil { + return ctrl.Result{}, err + } + + return ctrl.Result{}, err +} + +func (c *CreateOrUpdateResource[P, T]) copyOutputResources(data P) []string { + previousOutputResources := []string{} + for _, outputResource := range data.OutputResources() { + previousOutputResources = append(previousOutputResources, outputResource.ID.String()) + } + return previousOutputResources +} + +func (c *CreateOrUpdateResource[P, T]) executeRecipeIfNeeded(ctx context.Context, data P, prevState []string) (*recipes.RecipeOutput, error) { + // 'any' is required here to convert to an interface type, only then can we use a type assertion. + recipeDataModel, supportsRecipes := any(data).(datamodel.RecipeDataModel) + if !supportsRecipes { + return nil, nil + } + + input := recipeDataModel.Recipe() + if input == nil { + return nil, nil + } + request := recipes.ResourceMetadata{ + Name: input.Name, + Parameters: input.Parameters, + EnvironmentID: data.ResourceMetadata().Environment, + ApplicationID: data.ResourceMetadata().Application, + ResourceID: data.GetBaseResource().ID, + } + + return c.engine.Execute(ctx, request, prevState) +} + +func (c *CreateOrUpdateResource[P, T]) loadRuntimeConfiguration(ctx context.Context, environmentID string, applicationID string, resourceID string) (*recipes.RuntimeConfiguration, error) { + metadata := recipes.ResourceMetadata{EnvironmentID: environmentID, ApplicationID: applicationID, ResourceID: resourceID} + config, err := c.configurationLoader.LoadConfiguration(ctx, metadata) + if err != nil { + return nil, err + } + + return &config.Runtime, nil +} diff --git a/pkg/portableresources/backend/controller/createorupdateresource_test.go b/pkg/portableresources/backend/controller/createorupdateresource_test.go new file mode 100644 index 0000000000..ea65a55a08 --- /dev/null +++ b/pkg/portableresources/backend/controller/createorupdateresource_test.go @@ -0,0 +1,428 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controller + +import ( + "context" + "errors" + "testing" + + "github.com/golang/mock/gomock" + "github.com/google/uuid" + "github.com/mitchellh/mapstructure" + "github.com/stretchr/testify/require" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/configloader" + "github.com/radius-project/radius/pkg/recipes/controllerconfig" + "github.com/radius-project/radius/pkg/recipes/engine" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" +) + +const ( + TestResourceType = "Applications.Test/testResources" + TestEnvironmentID = "/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Core/environments/test-env" + TestApplicationID = "/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Core/applications/test-app" + TestResourceID = "/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Test/testResources/tr" +) + +type TestResource struct { + v1.BaseResource + + // ResourceMetadata represents internal DataModel properties common to all portable resource types. + datamodel.PortableResourceMetadata + + // Properties is the properties of the resource. + Properties TestResourceProperties `json:"properties"` +} + +// ApplyDeploymentOutput updates the status of the TestResource instance with the DeploymentOutput values. +func (r *TestResource) ApplyDeploymentOutput(do rpv1.DeploymentOutput) error { + r.Properties.Status.OutputResources = do.DeployedOutputResources + r.ComputedValues = do.ComputedValues + r.SecretValues = do.SecretValues + return nil +} + +// OutputResources returns the OutputResources from the Status field of the Properties field of the TestResource instance. +func (r *TestResource) OutputResources() []rpv1.OutputResource { + return r.Properties.Status.OutputResources +} + +// ResourceMetadata returns the BasicResourceProperties of the TestResource instance. +func (r *TestResource) ResourceMetadata() *rpv1.BasicResourceProperties { + return &r.Properties.BasicResourceProperties +} + +// Recipe returns a pointer to the ResourceRecipe stored in the Properties field of the TestResource struct. +func (t *TestResource) Recipe() *portableresources.ResourceRecipe { + return &t.Properties.Recipe +} + +type TestResourceProperties struct { + rpv1.BasicResourceProperties + IsProcessed bool `json:"isProcessed"` + Recipe portableresources.ResourceRecipe `json:"recipe,omitempty"` +} + +type SuccessProcessor struct { +} + +// Process sets a computed value and adds an output resource to the TestResource object, and returns no error. +func (p *SuccessProcessor) Process(ctx context.Context, data *TestResource, options processors.Options) error { + // Simulate setting a computed value and adding an output resource. + data.Properties.IsProcessed = true + data.Properties.Status.OutputResources = []rpv1.OutputResource{ + newOutputResource, + } + return nil +} + +// Delete returns no error. +func (p *SuccessProcessor) Delete(ctx context.Context, data *TestResource, options processors.Options) error { + return nil +} + +var successProcessorReference = processors.ResourceProcessor[*TestResource, TestResource](&SuccessProcessor{}) + +type ErrorProcessor struct { +} + +// Process always returns a processorErr. +func (p *ErrorProcessor) Process(ctx context.Context, data *TestResource, options processors.Options) error { + return errProcessor +} + +func (p *ErrorProcessor) Delete(ctx context.Context, data *TestResource, options processors.Options) error { + return nil +} + +var errorProcessorReference = processors.ResourceProcessor[*TestResource, TestResource](&ErrorProcessor{}) +var errProcessor = errors.New("processor error") +var errConfiguration = errors.New("configuration error") + +var oldOutputResourceResourceID = "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1" + +var newOutputResourceResourceID = "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test2" +var newOutputResource = rpv1.OutputResource{ID: resources.MustParse(newOutputResourceResourceID)} + +func TestCreateOrUpdateResource_Run(t *testing.T) { + setupTest := func(tb testing.TB) (*store.MockStorageClient, *engine.MockEngine, *processors.MockResourceClient, *configloader.MockConfigurationLoader) { + mctrl := gomock.NewController(t) + + msc := store.NewMockStorageClient(mctrl) + eng := engine.NewMockEngine(mctrl) + cfg := configloader.NewMockConfigurationLoader(mctrl) + client := processors.NewMockResourceClient(mctrl) + return msc, eng, client, cfg + } + + cases := []struct { + description string + factory func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) + getErr error + conversionFailure bool + recipeErr error + runtimeConfigurationErr error + processorErr error + resourceClientErr error + saveErr error + expectedErr error + }{ + { + "get-not-found", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, errorProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + &store.ErrNotFound{ID: TestResourceID}, + false, + nil, + nil, + nil, + nil, + nil, + &store.ErrNotFound{ID: TestResourceID}, + }, + { + "get-error", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, errorProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + &store.ErrInvalid{}, + false, + nil, + nil, + nil, + nil, + nil, + &store.ErrInvalid{}, + }, + { + "conversion-failure", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, errorProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + nil, + true, + nil, + nil, + nil, + nil, + nil, + &mapstructure.Error{Errors: []string{"'type' expected type 'string', got unconvertible type 'int', value: '3'"}}, + }, + { + "recipe-err", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, errorProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + nil, + false, + &recipes.ErrRecipeNotFound{}, + nil, + nil, + nil, + nil, + &recipes.ErrRecipeNotFound{}, + }, + { + "runtime-configuration-err", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, errorProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + nil, + false, + nil, + errConfiguration, + nil, + nil, + nil, + errConfiguration, + }, + { + "processor-err", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, errorProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + nil, + false, + nil, + nil, + errProcessor, + nil, + nil, + errProcessor, + }, + { + "save-err", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, successProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + nil, + false, + nil, + nil, + nil, + nil, + errors.New("resource save failed"), + errors.New("resource save failed"), + }, + { + "success", + func(recipeCfg *controllerconfig.RecipeControllerConfig, options ctrl.Options) (ctrl.Controller, error) { + return NewCreateOrUpdateResource(options, successProcessorReference, recipeCfg.Engine, recipeCfg.ResourceClient, recipeCfg.ConfigLoader) + }, + nil, + false, + nil, + nil, + nil, + nil, + nil, + nil, + }, + } + + for _, tt := range cases { + t.Run(tt.description, func(t *testing.T) { + msc, eng, client, cfg := setupTest(t) + + req := &ctrl.Request{ + OperationID: uuid.New(), + OperationType: "APPLICATIONS.TEST/TESTRESOURCES|PUT", // Operation does not affect the behavior of the controller. + ResourceID: TestResourceID, + CorrelationID: uuid.NewString(), + OperationTimeout: &ctrl.DefaultAsyncOperationTimeout, + } + + data := map[string]any{ + "name": "tr", + "type": "Applications.Test/testResources", + "id": TestResourceID, + "location": v1.LocationGlobal, + "properties": map[string]any{ + "application": TestApplicationID, + "environment": TestEnvironmentID, + "provisioningState": "Accepted", + "status": map[string]any{ + "outputResources": []map[string]any{ + { + "id": oldOutputResourceResourceID, + }, + }, + }, + "recipe": map[string]any{ + "name": "test-recipe", + "parameters": map[string]any{ + "p1": "v1", + }, + }, + }, + } + + // Note: this test walks through the mock setup in same order as the controller + // performs these steps. That makes it easier to reason about what to configure + // for the desired test case. + // + // This flag is used to track whether the "current" test will reach the current + // control flow. + stillPassing := true + + if stillPassing && tt.getErr != nil { + stillPassing = false + msc.EXPECT(). + Get(gomock.Any(), TestResourceID). + Return(&store.Object{Data: nil}, tt.getErr). + Times(1) + } else if stillPassing { + msc.EXPECT(). + Get(gomock.Any(), TestResourceID). + Return(&store.Object{Data: data}, nil). + Times(1) + } + + if tt.conversionFailure { + stillPassing = false + data["type"] = 3 // This won't convert to our data model. + } + + recipeMetadata := recipes.ResourceMetadata{ + Name: "test-recipe", + EnvironmentID: TestEnvironmentID, + ApplicationID: TestApplicationID, + ResourceID: TestResourceID, + Parameters: map[string]any{ + "p1": "v1", + }, + } + prevState := []string{ + oldOutputResourceResourceID, + } + + if stillPassing && tt.recipeErr != nil { + stillPassing = false + eng.EXPECT(). + Execute(gomock.Any(), recipeMetadata, prevState). + Return(&recipes.RecipeOutput{}, tt.recipeErr). + Times(1) + } else if stillPassing { + eng.EXPECT(). + Execute(gomock.Any(), recipeMetadata, prevState). + Return(&recipes.RecipeOutput{}, nil). + Times(1) + } + + if stillPassing && tt.runtimeConfigurationErr != nil { + stillPassing = false + cfg.EXPECT(). + LoadConfiguration(gomock.Any(), recipes.ResourceMetadata{ + EnvironmentID: TestEnvironmentID, + ApplicationID: TestApplicationID, + ResourceID: TestResourceID, + }). + Return(nil, tt.runtimeConfigurationErr). + Times(1) + } else if stillPassing { + configuration := &recipes.Configuration{ + Runtime: recipes.RuntimeConfiguration{ + Kubernetes: &recipes.KubernetesRuntime{ + Namespace: "test-namespace", + EnvironmentNamespace: "test-env-namespace", + }, + }, + } + cfg.EXPECT(). + LoadConfiguration(gomock.Any(), recipes.ResourceMetadata{ + EnvironmentID: TestEnvironmentID, + ApplicationID: TestApplicationID, + ResourceID: TestResourceID, + }). + Return(configuration, nil). + Times(1) + } + + // No mock for the processor... + if stillPassing && tt.processorErr != nil { + stillPassing = false + } + + if stillPassing && tt.saveErr != nil { + stillPassing = false + msc.EXPECT(). + Save(gomock.Any(), gomock.Any(), gomock.Any()). + Return(tt.saveErr). + Times(1) + } else if stillPassing && tt.resourceClientErr == nil { + msc.EXPECT(). + Save(gomock.Any(), gomock.Any(), gomock.Any()). + Return(nil). + Times(1) + } + + opts := ctrl.Options{ + StorageClient: msc, + } + + recipeCfg := &controllerconfig.RecipeControllerConfig{ + Engine: eng, + ResourceClient: client, + ConfigLoader: cfg, + } + + genCtrl, err := tt.factory(recipeCfg, opts) + require.NoError(t, err) + + res, err := genCtrl.Run(context.Background(), req) + if tt.expectedErr != nil { + require.False(t, stillPassing) + require.Error(t, err) + require.Equal(t, tt.expectedErr, err) + } else { + require.True(t, stillPassing) + require.NoError(t, err) + require.Equal(t, ctrl.Result{}, res) + } + }) + } +} diff --git a/pkg/portableresources/backend/controller/deleteresource.go b/pkg/portableresources/backend/controller/deleteresource.go new file mode 100644 index 0000000000..67d374b25a --- /dev/null +++ b/pkg/portableresources/backend/controller/deleteresource.go @@ -0,0 +1,124 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controller + +import ( + "context" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/portableresources/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/configloader" + "github.com/radius-project/radius/pkg/recipes/engine" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" +) + +// DeleteResource is the async operation controller to delete a portable resource. +type DeleteResource[P interface { + *T + rpv1.RadiusResourceModel +}, T any] struct { + ctrl.BaseController + processor processors.ResourceProcessor[P, T] + engine engine.Engine + configurationLoader configloader.ConfigurationLoader +} + +// NewDeleteResource creates a new DeleteResource controller which is used to delete resources asynchronously. +func NewDeleteResource[P interface { + *T + rpv1.RadiusResourceModel +}, T any](opts ctrl.Options, processor processors.ResourceProcessor[P, T], eng engine.Engine, configurationLoader configloader.ConfigurationLoader) (ctrl.Controller, error) { + return &DeleteResource[P, T]{ + ctrl.NewBaseAsyncController(opts), + processor, + eng, + configurationLoader, + }, nil +} + +// Run retrieves a resource from storage, parses the resource ID, gets the data model, deletes the output +// resources, and deletes the resource from storage. It returns an error if any of these steps fail. +func (c *DeleteResource[P, T]) Run(ctx context.Context, request *ctrl.Request) (ctrl.Result, error) { + obj, err := c.StorageClient().Get(ctx, request.ResourceID) + if err != nil { + return ctrl.NewFailedResult(v1.ErrorDetails{Message: err.Error()}), err + } + + // This code is general and we might be processing an async job for a resource or a scope, so using the general Parse function. + id, err := resources.Parse(request.ResourceID) + if err != nil { + return ctrl.Result{}, err + } + + data := P(new(T)) + if err = obj.As(data); err != nil { + return ctrl.Result{}, err + } + + recipeDataModel, supportsRecipes := any(data).(datamodel.RecipeDataModel) + if supportsRecipes && recipeDataModel.Recipe() != nil { + recipeData := recipes.ResourceMetadata{ + Name: recipeDataModel.Recipe().Name, + EnvironmentID: data.ResourceMetadata().Environment, + ApplicationID: data.ResourceMetadata().Application, + Parameters: recipeDataModel.Recipe().Parameters, + ResourceID: id.String(), + } + + err = c.engine.Delete(ctx, recipeData, data.OutputResources()) + if err != nil { + if recipeError, ok := err.(*recipes.RecipeError); ok { + return ctrl.NewFailedResult(recipeError.ErrorDetails), nil + } + return ctrl.Result{}, err + } + } + + // Load details about the runtime for the processor to access. + runtimeConfiguration, err := c.loadRuntimeConfiguration(ctx, data.ResourceMetadata().Environment, data.ResourceMetadata().Application, data.GetBaseResource().ID) + if err != nil { + return ctrl.Result{}, err + } + + err = c.processor.Delete(ctx, data, processors.Options{ + RuntimeConfiguration: *runtimeConfiguration, + }) + if err != nil { + return ctrl.Result{}, err + } + + err = c.StorageClient().Delete(ctx, request.ResourceID) + if err != nil { + return ctrl.Result{}, err + } + + return ctrl.Result{}, err +} + +func (c *DeleteResource[P, T]) loadRuntimeConfiguration(ctx context.Context, environmentID string, applicationID string, resourceID string) (*recipes.RuntimeConfiguration, error) { + metadata := recipes.ResourceMetadata{EnvironmentID: environmentID, ApplicationID: applicationID, ResourceID: resourceID} + config, err := c.configurationLoader.LoadConfiguration(ctx, metadata) + if err != nil { + return nil, err + } + + return &config.Runtime, nil +} diff --git a/pkg/portableresources/backend/controller/deleteresource_test.go b/pkg/portableresources/backend/controller/deleteresource_test.go new file mode 100644 index 0000000000..2fc612b3da --- /dev/null +++ b/pkg/portableresources/backend/controller/deleteresource_test.go @@ -0,0 +1,166 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controller + +import ( + "context" + "encoding/json" + "errors" + "testing" + + "github.com/golang/mock/gomock" + "github.com/google/uuid" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/configloader" + "github.com/radius-project/radius/pkg/recipes/engine" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/stretchr/testify/require" +) + +var outputResourceResourceID = "/subscriptions/test-sub/resourceGroups/test-rg/providers/Microsoft.DocumentDB/databaseAccounts/mongoDatabases" +var outputResource = rpv1.OutputResource{ + ID: resources.MustParse(outputResourceResourceID), + RadiusManaged: to.Ptr(true), +} + +func TestDeleteResourceRun_20220315PrivatePreview(t *testing.T) { + resourceID := "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/radius-test-rg/providers/Applications.Datastores/mongoDatabases/mongo0" + setupTest := func(tb testing.TB) (func(tb testing.TB), *store.MockStorageClient, *ctrl.Request, *engine.MockEngine, *configloader.MockConfigurationLoader) { + mctrl := gomock.NewController(t) + msc := store.NewMockStorageClient(mctrl) + eng := engine.NewMockEngine(mctrl) + cfg := configloader.NewMockConfigurationLoader(mctrl) + + req := &ctrl.Request{ + OperationID: uuid.New(), + OperationType: "APPLICATIONS.DATASTORES/MONGODATABASES|DELETE", + ResourceID: resourceID, + CorrelationID: uuid.NewString(), + OperationTimeout: &ctrl.DefaultAsyncOperationTimeout, + } + + return func(tb testing.TB) { + mctrl.Finish() + }, msc, req, eng, cfg + } + + t.Parallel() + + deleteCases := []struct { + desc string + getErr error + engDelErr error + scDelErr error + }{ + {"delete-existing-resource", nil, nil, nil}, + {"delete-non-existing-resource", &store.ErrNotFound{ID: resourceID}, nil, nil}, + {"delete-resource-engine-delete-error", nil, errors.New("engine delete error"), nil}, + {"delete-resource-delete-from-db-error", nil, nil, errors.New("delete from db error")}, + } + + for _, tt := range deleteCases { + t.Run(tt.desc, func(t *testing.T) { + teardownTest, msc, req, eng, configLoader := setupTest(t) + defer teardownTest(t) + + status := rpv1.ResourceStatus{ + OutputResources: []rpv1.OutputResource{ + outputResource, + }, + } + sb, err := json.Marshal(&status) + require.NoError(t, err) + + sm := map[string]interface{}{} + err = json.Unmarshal(sb, &sm) + require.NoError(t, err) + + data := map[string]any{ + "name": "tr", + "type": "Applications.Test/testResources", + "id": TestResourceID, + "location": v1.LocationGlobal, + "properties": map[string]any{ + "application": TestApplicationID, + "environment": TestEnvironmentID, + "provisioningState": "Accepted", + "status": sm, + }, + } + + recipeData := recipes.ResourceMetadata{ + Name: "", + EnvironmentID: TestEnvironmentID, + ApplicationID: TestApplicationID, + Parameters: nil, + ResourceID: resourceID, + } + + msc.EXPECT(). + Get(gomock.Any(), gomock.Any()). + Return(&store.Object{Data: data}, tt.getErr). + Times(1) + + if tt.getErr == nil { + eng.EXPECT(). + Delete(gomock.Any(), recipeData, status.OutputResources). + Return(tt.engDelErr). + Times(1) + if tt.engDelErr == nil { + configLoader.EXPECT(). + LoadConfiguration(gomock.Any(), gomock.Any()). + Return( + &recipes.Configuration{ + Runtime: recipes.RuntimeConfiguration{ + Kubernetes: &recipes.KubernetesRuntime{ + Namespace: "test-namespace", + EnvironmentNamespace: "test-env-namespace", + }, + }, + }, + nil, + ). + Times(1) + + msc.EXPECT(). + Delete(gomock.Any(), gomock.Any()). + Return(tt.scDelErr). + Times(1) + } + } + opts := ctrl.Options{ + StorageClient: msc, + } + + ctrl, err := NewDeleteResource(opts, successProcessorReference, eng, configLoader) + require.NoError(t, err) + + _, err = ctrl.Run(context.Background(), req) + + if tt.getErr != nil || tt.engDelErr != nil || tt.scDelErr != nil { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/pkg/portableresources/backend/service.go b/pkg/portableresources/backend/service.go new file mode 100644 index 0000000000..808fed7e60 --- /dev/null +++ b/pkg/portableresources/backend/service.go @@ -0,0 +1,198 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package backend + +import ( + "context" + "fmt" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + dapr_dm "github.com/radius-project/radius/pkg/daprrp/datamodel" + "github.com/radius-project/radius/pkg/daprrp/processors/pubsubbrokers" + "github.com/radius-project/radius/pkg/daprrp/processors/secretstores" + "github.com/radius-project/radius/pkg/daprrp/processors/statestores" + ds_dm "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + mongo_prc "github.com/radius-project/radius/pkg/datastoresrp/processors/mongodatabases" + redis_prc "github.com/radius-project/radius/pkg/datastoresrp/processors/rediscaches" + sql_prc "github.com/radius-project/radius/pkg/datastoresrp/processors/sqldatabases" + "github.com/radius-project/radius/pkg/kubeutil" + msg_dm "github.com/radius-project/radius/pkg/messagingrp/datamodel" + "github.com/radius-project/radius/pkg/messagingrp/processors/rabbitmqqueues" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/portableresources/frontend/handler" + + "github.com/radius-project/radius/pkg/recipes/controllerconfig" + + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + backend_ctrl "github.com/radius-project/radius/pkg/portableresources/backend/controller" +) + +type Service struct { + worker.Service +} + +// NewService creates a new Service instance with the given options. +func NewService(options hostoptions.HostOptions) *Service { + return &Service{ + worker.Service{ + Options: options, + ProviderName: handler.PortableResourcesNamespace, + }, + } +} + +// Name returns a string containing the namespace of the Resource Provider. +func (s *Service) Name() string { + return fmt.Sprintf("%s async worker", handler.PortableResourcesNamespace) +} + +// Run initializes the service and registers controllers for each resource type to handle create/update/delete operations. +func (s *Service) Run(ctx context.Context) error { + if err := s.Init(ctx); err != nil { + return err + } + + k8s, err := kubeutil.NewClients(s.Options.K8sConfig) + if err != nil { + return fmt.Errorf("failed to initialize kubernetes client: %w", err) + } + + recipeControllerConfig, err := controllerconfig.New(s.Options) + if err != nil { + return err + } + + engine := recipeControllerConfig.Engine + client := recipeControllerConfig.ResourceClient + configLoader := recipeControllerConfig.ConfigLoader + + // resourceTypes is the array that holds resource types that needs async processing. + // We use this array to register backend controllers for each resource. + resourceTypes := []struct { + TypeName string + CreatePutController func(options ctrl.Options) (ctrl.Controller, error) + CreateDeleteController func(options ctrl.Options) (ctrl.Controller, error) + }{ + { + portableresources.RabbitMQQueuesResourceType, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &rabbitmqqueues.Processor{} + return backend_ctrl.NewCreateOrUpdateResource[*msg_dm.RabbitMQQueue, msg_dm.RabbitMQQueue](options, processor, engine, client, configLoader) + }, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &rabbitmqqueues.Processor{} + return backend_ctrl.NewDeleteResource[*msg_dm.RabbitMQQueue, msg_dm.RabbitMQQueue](options, processor, engine, configLoader) + }, + }, + { + portableresources.DaprStateStoresResourceType, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &statestores.Processor{Client: k8s.RuntimeClient} + return backend_ctrl.NewCreateOrUpdateResource[*dapr_dm.DaprStateStore, dapr_dm.DaprStateStore](options, processor, engine, client, configLoader) + }, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &statestores.Processor{Client: k8s.RuntimeClient} + return backend_ctrl.NewDeleteResource[*dapr_dm.DaprStateStore, dapr_dm.DaprStateStore](options, processor, engine, configLoader) + }, + }, + { + portableresources.DaprSecretStoresResourceType, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &secretstores.Processor{Client: k8s.RuntimeClient} + return backend_ctrl.NewCreateOrUpdateResource[*dapr_dm.DaprSecretStore, dapr_dm.DaprSecretStore](options, processor, engine, client, configLoader) + }, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &secretstores.Processor{Client: k8s.RuntimeClient} + return backend_ctrl.NewDeleteResource[*dapr_dm.DaprSecretStore, dapr_dm.DaprSecretStore](options, processor, engine, configLoader) + }, + }, + { + portableresources.DaprPubSubBrokersResourceType, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &pubsubbrokers.Processor{Client: k8s.RuntimeClient} + return backend_ctrl.NewCreateOrUpdateResource[*dapr_dm.DaprPubSubBroker, dapr_dm.DaprPubSubBroker](options, processor, engine, client, configLoader) + }, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &pubsubbrokers.Processor{Client: k8s.RuntimeClient} + return backend_ctrl.NewDeleteResource[*dapr_dm.DaprPubSubBroker, dapr_dm.DaprPubSubBroker](options, processor, engine, configLoader) + }, + }, + { + portableresources.MongoDatabasesResourceType, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &mongo_prc.Processor{} + return backend_ctrl.NewCreateOrUpdateResource[*ds_dm.MongoDatabase, ds_dm.MongoDatabase](options, processor, engine, client, configLoader) + }, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &mongo_prc.Processor{} + return backend_ctrl.NewDeleteResource[*ds_dm.MongoDatabase, ds_dm.MongoDatabase](options, processor, engine, configLoader) + }, + }, + { + portableresources.RedisCachesResourceType, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &redis_prc.Processor{} + return backend_ctrl.NewCreateOrUpdateResource[*ds_dm.RedisCache, ds_dm.RedisCache](options, processor, engine, client, configLoader) + }, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &redis_prc.Processor{} + return backend_ctrl.NewDeleteResource[*ds_dm.RedisCache, ds_dm.RedisCache](options, processor, engine, configLoader) + }, + }, + { + portableresources.SqlDatabasesResourceType, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &sql_prc.Processor{} + return backend_ctrl.NewCreateOrUpdateResource[*ds_dm.SqlDatabase, ds_dm.SqlDatabase](options, processor, engine, client, configLoader) + }, + func(options ctrl.Options) (ctrl.Controller, error) { + processor := &sql_prc.Processor{} + return backend_ctrl.NewDeleteResource[*ds_dm.SqlDatabase, ds_dm.SqlDatabase](options, processor, engine, configLoader) + }, + }, + } + + opts := ctrl.Options{ + DataProvider: s.StorageProvider, + KubeClient: k8s.RuntimeClient, + } + + for _, rt := range resourceTypes { + // Register controllers + err = s.Controllers.Register(ctx, rt.TypeName, v1.OperationDelete, rt.CreateDeleteController, opts) + if err != nil { + return err + } + err = s.Controllers.Register(ctx, rt.TypeName, v1.OperationPut, rt.CreatePutController, opts) + if err != nil { + return err + } + } + workerOpts := worker.Options{} + if s.Options.Config.WorkerServer != nil { + if s.Options.Config.WorkerServer.MaxOperationConcurrency != nil { + workerOpts.MaxOperationConcurrency = *s.Options.Config.WorkerServer.MaxOperationConcurrency + } + if s.Options.Config.WorkerServer.MaxOperationRetryCount != nil { + workerOpts.MaxOperationRetryCount = *s.Options.Config.WorkerServer.MaxOperationRetryCount + } + } + + return s.Start(ctx, workerOpts) +} diff --git a/pkg/portableresources/datamodel/doc.go b/pkg/portableresources/datamodel/doc.go new file mode 100644 index 0000000000..f56e857b98 --- /dev/null +++ b/pkg/portableresources/datamodel/doc.go @@ -0,0 +1,21 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This is the version nuetral data model. Structures present in this package must be used internally. +// API version specific models should be exist under /pkg/portableresources/api. This api package should be able +// to convert among the versions. + +package datamodel diff --git a/pkg/portableresources/datamodel/metadata.go b/pkg/portableresources/datamodel/metadata.go new file mode 100644 index 0000000000..c506915c29 --- /dev/null +++ b/pkg/portableresources/datamodel/metadata.go @@ -0,0 +1,39 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package datamodel + +import ( + "github.com/radius-project/radius/pkg/portableresources" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" +) + +const ( + // RecipeContextParameter is the parameter context for recipe deployment + RecipeContextParameter string = "context" +) + +// PortableResourceMetadata represents internal DataModel properties common to all portable resource types. +type PortableResourceMetadata struct { + // ComputedValues map is any resource values that will be needed for more operations. + // For example; database name to generate secrets for cosmos DB. + ComputedValues map[string]any `json:"computedValues,omitempty"` + + // Stores action to retrieve secret values. For Azure, connectionstring is accessed through cosmos listConnectionString operation, if secrets are not provided as input + SecretValues map[string]rpv1.SecretValueReference `json:"secretValues,omitempty"` + + RecipeData portableresources.RecipeData `json:"recipeData,omitempty"` +} diff --git a/pkg/linkrp/datamodel/recipes.go b/pkg/portableresources/datamodel/recipes.go similarity index 81% rename from pkg/linkrp/datamodel/recipes.go rename to pkg/portableresources/datamodel/recipes.go index 4b1ae33136..a39218fa80 100644 --- a/pkg/linkrp/datamodel/recipes.go +++ b/pkg/portableresources/datamodel/recipes.go @@ -15,17 +15,17 @@ limitations under the License. */ // This is the version nuetral data model. Structures present in this package must be used internally. -// API version specific models should be exist under /pkg/linkrp/api. This api package should be able +// API version specific models should be exist under /pkg/portableresources/api. This api package should be able // to convert among the versions. package datamodel import ( - "github.com/project-radius/radius/pkg/linkrp" + "github.com/radius-project/radius/pkg/portableresources" ) // RecipeDataModel should be implemented on the datamodel of types that support recipes. type RecipeDataModel interface { // Recipe provides access to the user-specified recipe configuration. Can return nil. - Recipe() *linkrp.LinkRecipe + Recipe() *portableresources.ResourceRecipe } diff --git a/pkg/portableresources/frontend/handler/getoperations.go b/pkg/portableresources/frontend/handler/getoperations.go new file mode 100644 index 0000000000..a718422d07 --- /dev/null +++ b/pkg/portableresources/frontend/handler/getoperations.go @@ -0,0 +1,389 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handler + +import ( + "context" + "net/http" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + api_ver "github.com/radius-project/radius/pkg/portableresources/api" +) + +var _ ctrl.Controller = (*GetOperations)(nil) + +// GetOperations is the controller implementation to get arm rpc available operations. +type GetOperations struct { + ctrl.BaseController +} + +// NewGetOperations creates a new GetOperations controller and returns it, or returns an error if one occurs. +func NewGetOperations(opts ctrl.Options) (ctrl.Controller, error) { + return &GetOperations{ctrl.NewBaseController(opts)}, nil +} + +// Run returns the list of available operations/permission for the resource provider at tenant level. +// Spec: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/proxy-api-reference.md#exposing-available-operations +func (opctrl *GetOperations) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (rest.Response, error) { + sCtx := v1.ARMRequestContextFromContext(ctx) + + switch sCtx.APIVersion { + case api_ver.V20220315privatepreview: + return rest.NewOKResponse(opctrl.availableOperationsV1()), nil + } + + return rest.NewNotFoundAPIVersionResponse("operations", PortableResourcesNamespace, sCtx.APIVersion), nil +} + +func (opctrl *GetOperations) availableOperationsV1() *v1.PaginatedList { + return &v1.PaginatedList{ + Value: []any{ + &v1.Operation{ + Name: "Applications.Dapr/operations/read", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "operations", + Operation: "Get operations", + Description: "Get the list of operations.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/operations/read", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "operations", + Operation: "Get operations", + Description: "Get the list of operations.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Messaging/operations/read", + Display: &v1.OperationDisplayProperties{ + Provider: MessagingProviderNamespace, + Resource: "operations", + Operation: "Get operations", + Description: "Get the list of operations.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/mongoDatabases/read", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "mongoDatabases", + Operation: "Get/List mongoDatabases", + Description: "Gets/Lists mongoDatabase resource(s).", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/mongoDatabases/write", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "mongoDatabases", + Operation: "Create/Update mongoDatabases", + Description: "Creates or updates a mongo database resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/mongoDatabases/delete", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "mongoDatabases", + Operation: "Delete mongoDatabase", + Description: "Deletes a mongoDatabase resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/mongoDatabases/listsecrets/action", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "mongoDatabases", + Operation: "List secrets", + Description: "Lists mongoDatabase secrets.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/register/action", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: DatastoresProviderNamespace, + Operation: "Register Applications.Datastores resource provider", + Description: "Registers 'Applications.Datastores' resource provider with a subscription.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/register/action", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: DaprProviderNamespace, + Operation: "Register Applications.Dapr resource provider", + Description: "Registers 'Applications.Dapr' resource provider with a subscription.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Messaging/register/action", + Display: &v1.OperationDisplayProperties{ + Provider: MessagingProviderNamespace, + Resource: MessagingProviderNamespace, + Operation: "Register Applications.Messaging resource provider", + Description: "Registers 'Applications.Messaging' resource provider with a subscription.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/unregister/action", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "Applications.Datastores", + Operation: "Unregister 'Applications.Datastores' resource provider", + Description: "Unregisters 'Applications.Datastores' resource provider with a subscription.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/unregister/action", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "Applications.Datastores", + Operation: "Unregister 'Applications.Dapr' resource provider", + Description: "Unregisters 'Applications.Dapr' resource provider with a subscription.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Messaging/unregister/action", + Display: &v1.OperationDisplayProperties{ + Provider: MessagingProviderNamespace, + Resource: "Applications.Datastores", + Operation: "Unregister 'Applications.Messaging' resource provider", + Description: "Unregisters 'Applications.Messaging' resource provider with a subscription.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/sqlDatabases/read", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "sqlDatabases", + Operation: "Get/List sqlDatabases", + Description: "Gets/Lists sqlDatabase resource(s).", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/sqlDatabases/write", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "sqlDatabases", + Operation: "Create/Update sqlDatabases", + Description: "Creates or updates a sql database resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/sqlDatabases/delete", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "sqlDatabases", + Operation: "Delete sqlDatabase", + Description: "Deletes a sqlDatabase resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/redisCaches/read", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "redisCaches", + Operation: "Get/List redisCaches", + Description: "Gets/Lists redisCache resource(s).", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/redisCaches/write", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "redisCaches", + Operation: "Create/Update redisCaches", + Description: "Creates or updates a redisCache resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/redisCaches/delete", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "redisCaches", + Operation: "Delete redisCache", + Description: "Deletes a redisCache resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Datastores/redisCaches/listsecrets/action", + Display: &v1.OperationDisplayProperties{ + Provider: DatastoresProviderNamespace, + Resource: "redisCaches", + Operation: "List secrets", + Description: "Lists redisCache secrets.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Messaging/rabbitMQQueues/read", + Display: &v1.OperationDisplayProperties{ + Provider: MessagingProviderNamespace, + Resource: "rabbitMQQueues", + Operation: "Get/List rabbitMQQueues", + Description: "Gets/Lists rabbitMQQueue resource(s).", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Messaging/rabbitMQQueues/write", + Display: &v1.OperationDisplayProperties{ + Provider: MessagingProviderNamespace, + Resource: "rabbitMQQueues", + Operation: "Create/Update rabbitMQQueues", + Description: "Creates or updates a rabbitMQQueue resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Messaging/rabbitMQQueues/delete", + Display: &v1.OperationDisplayProperties{ + Provider: MessagingProviderNamespace, + Resource: "rabbitMQQueues", + Operation: "Delete rabbitMQQueue", + Description: "Deletes a rabbitMQQueue resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Messaging/rabbitMQQueues/listsecrets/action", + Display: &v1.OperationDisplayProperties{ + Provider: MessagingProviderNamespace, + Resource: "rabbitMQQueues", + Operation: "List secrets", + Description: "Lists rabbitMQQueue secrets.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/secretStores/read", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprSecretStores", + Operation: "Get/List daprSecretStores", + Description: "Gets/Lists daprSecretStore resource(s).", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/secretStores/write", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprSecretStores", + Operation: "Create/Update daprSecretStores", + Description: "Creates or updates a daprSecretStore resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/secretStores/delete", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprSecretStores", + Operation: "Delete daprSecretStore", + Description: "Deletes a daprSecretStore resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/stateStores/read", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprStateStores", + Operation: "Get/List daprStateStores", + Description: "Gets/Lists daprStateStore resource(s).", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/stateStores/write", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprStateStores", + Operation: "Create/Update daprStateStores", + Description: "Creates or updates a daprStateStore resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/stateStores/delete", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprStateStores", + Operation: "Delete daprStateStore", + Description: "Deletes a daprStateStore resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/pubSubBrokers/read", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprPubSubBrokers", + Operation: "Get/List daprPubSubBrokers", + Description: "Gets/Lists daprPubSubBroker resource(s).", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/pubSubBrokers/write", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprPubSubBrokers", + Operation: "Create/Update daprPubSubBrokers", + Description: "Creates or updates a daprPubSubBroker resource.", + }, + IsDataAction: false, + }, + &v1.Operation{ + Name: "Applications.Dapr/pubSubBrokers/delete", + Display: &v1.OperationDisplayProperties{ + Provider: DaprProviderNamespace, + Resource: "daprPubSubBrokers", + Operation: "Delete daprPubSubBroker", + Description: "Deletes a daprPubSubBroker resource.", + }, + IsDataAction: false, + }, + }, + } +} diff --git a/pkg/portableresources/frontend/handler/getoperations_test.go b/pkg/portableresources/frontend/handler/getoperations_test.go new file mode 100644 index 0000000000..15bbc57b4b --- /dev/null +++ b/pkg/portableresources/frontend/handler/getoperations_test.go @@ -0,0 +1,78 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handler + +import ( + "context" + "net/http/httptest" + "testing" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + api_ver "github.com/radius-project/radius/pkg/portableresources/api" + "github.com/stretchr/testify/require" +) + +func TestRunWith20220315PrivatePreview(t *testing.T) { + // arrange + opts := ctrl.Options{} + op, err := NewGetOperations(opts) + require.NoError(t, err) + ctx := v1.WithARMRequestContext(context.Background(), &v1.ARMRequestContext{ + APIVersion: api_ver.V20220315privatepreview, + }) + w := httptest.NewRecorder() + + // act + resp, err := op.Run(ctx, w, nil) + + // assert + require.NoError(t, err) + switch v := resp.(type) { + case *rest.OKResponse: + pagination, ok := v.Body.(*v1.PaginatedList) + require.True(t, ok) + require.Equal(t, 33, len(pagination.Value)) + default: + require.Truef(t, false, "should not return error") + } +} + +func TestRunWithUnsupportedAPIVersion(t *testing.T) { + // arrange + opts := ctrl.Options{} + op, err := NewGetOperations(opts) + require.NoError(t, err) + ctx := v1.WithARMRequestContext(context.Background(), &v1.ARMRequestContext{ + APIVersion: "unknownversion", + }) + w := httptest.NewRecorder() + + // act + resp, err := op.Run(ctx, w, nil) + + // assert + require.NoError(t, err) + switch v := resp.(type) { + case *rest.NotFoundResponse: + armerr := v.Body + require.Equal(t, v1.CodeInvalidResourceType, armerr.Error.Code) + default: + require.Truef(t, false, "should not return error") + } +} diff --git a/pkg/portableresources/frontend/handler/routes.go b/pkg/portableresources/frontend/handler/routes.go new file mode 100644 index 0000000000..c86134aea8 --- /dev/null +++ b/pkg/portableresources/frontend/handler/routes.go @@ -0,0 +1,909 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handler + +import ( + "context" + "time" + + "github.com/go-chi/chi/v5" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + frontend_ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/portableresources" + rp_frontend "github.com/radius-project/radius/pkg/rp/frontend" + "github.com/radius-project/radius/pkg/validator" + "github.com/radius-project/radius/swagger" + + dapr_dm "github.com/radius-project/radius/pkg/daprrp/datamodel" + dapr_conv "github.com/radius-project/radius/pkg/daprrp/datamodel/converter" + dapr_ctrl "github.com/radius-project/radius/pkg/daprrp/frontend/controller" + ds_dm "github.com/radius-project/radius/pkg/datastoresrp/datamodel" + ds_conv "github.com/radius-project/radius/pkg/datastoresrp/datamodel/converter" + ds_ctrl "github.com/radius-project/radius/pkg/datastoresrp/frontend/controller" + mongo_ctrl "github.com/radius-project/radius/pkg/datastoresrp/frontend/controller/mongodatabases" + redis_ctrl "github.com/radius-project/radius/pkg/datastoresrp/frontend/controller/rediscaches" + sql_ctrl "github.com/radius-project/radius/pkg/datastoresrp/frontend/controller/sqldatabases" + msg_dm "github.com/radius-project/radius/pkg/messagingrp/datamodel" + msg_conv "github.com/radius-project/radius/pkg/messagingrp/datamodel/converter" + msg_ctrl "github.com/radius-project/radius/pkg/messagingrp/frontend/controller" + rmq_ctrl "github.com/radius-project/radius/pkg/messagingrp/frontend/controller/rabbitmqqueues" +) + +const ( + // resourceGroupPath is the path for resource groups. + resourceGroupPath = "/resourcegroups/{resourceGroupName}" + + // PortableResourcesNamespace is the name representing group of portable resource providers. + PortableResourcesNamespace = "Applications.Datastores" + + // DaprProviderNamespace is the namespace for Dapr provider. + DaprProviderNamespace = "Applications.Dapr" + + // DatastoresProviderNamespace is the namespace for Datastores provider. + DatastoresProviderNamespace = "Applications.Datastores" + + // MessagingProviderNamespace is the namespace for Messaging provider. + MessagingProviderNamespace = "Applications.Messaging" + + // AsyncOperationRetryAfter is the polling interval for async create/update or delete resource operations. + AsyncOperationRetryAfter = time.Duration(5) * time.Second +) + +// AddRoutes configures routes and handlers for Datastores, Messaging, Dapr Resource Providers. +func AddRoutes(ctx context.Context, router chi.Router, isARM bool, ctrlOpts frontend_ctrl.Options) error { + rootScopePath := ctrlOpts.PathBase + rootScopePath += getRootScopePath(isARM) + + // URLs may use either the subscription/plane scope or resource group scope. + // These paths are order sensitive and the longer path MUST be registered first. + prefixes := []string{ + rootScopePath + resourceGroupPath, + rootScopePath, + } + + err := AddMessagingRoutes(ctx, router, rootScopePath, prefixes, isARM, ctrlOpts) + if err != nil { + return err + } + + err = AddDaprRoutes(ctx, router, rootScopePath, prefixes, isARM, ctrlOpts) + if err != nil { + return err + } + + err = AddDatastoresRoutes(ctx, router, rootScopePath, prefixes, isARM, ctrlOpts) + if err != nil { + return err + } + + return nil +} + +// AddMessagingRoutes configures the default ARM handlers and registers handlers for the RabbitMQQueue resource type for +// the List, Get, Put, Patch and Delete operations. +func AddMessagingRoutes(ctx context.Context, r chi.Router, rootScopePath string, prefixes []string, isARM bool, ctrlOpts frontend_ctrl.Options) error { + // Configure the default ARM handlers. + err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, MessagingProviderNamespace, NewGetOperations, ctrlOpts) + if err != nil { + return err + } + + specLoader, err := validator.LoadSpec(ctx, MessagingProviderNamespace, swagger.SpecFiles, prefixes, "rootScope") + if err != nil { + return err + } + + validator := validator.APIValidator(validator.Options{ + SpecLoader: specLoader, + ResourceTypeGetter: validator.RadiusResourceTypeGetter, + }) + + // Register resource routers. + // + // Note: We have to follow the below rules to enable API validators: + // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. + // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. + + // rabbitmqqueues router handlers: + rmqPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.messaging/rabbitmqqueues", validator) + rmqResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.messaging/rabbitmqqueues", validator) + rmqResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.messaging/rabbitmqqueues/{rabbitMQQueueName}", validator) + + // Messaging handlers: + handlerOptions := []server.HandlerOptions{ + { + ParentRouter: rmqPlaneRouter, + ResourceType: portableresources.RabbitMQQueuesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ + RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, + ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, + ListRecursiveQuery: true, + }) + }, + }, + { + ParentRouter: rmqResourceGroupRouter, + ResourceType: portableresources.RabbitMQQueuesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ + RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, + ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, + }) + }, + }, + { + ParentRouter: rmqResourceRouter, + ResourceType: portableresources.RabbitMQQueuesResourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, + frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ + RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, + ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, + }) + }, + }, + { + ParentRouter: rmqResourceRouter, + ResourceType: portableresources.RabbitMQQueuesResourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ + RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, + ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[msg_dm.RabbitMQQueue]{ + rp_frontend.PrepareRadiusResource[*msg_dm.RabbitMQQueue], + }, + AsyncOperationTimeout: msg_ctrl.AsyncCreateOrUpdateRabbitMQTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: rmqResourceRouter, + ResourceType: portableresources.RabbitMQQueuesResourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ + RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, + ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[msg_dm.RabbitMQQueue]{ + rp_frontend.PrepareRadiusResource[*msg_dm.RabbitMQQueue], + }, + AsyncOperationTimeout: msg_ctrl.AsyncCreateOrUpdateRabbitMQTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: rmqResourceRouter, + ResourceType: portableresources.RabbitMQQueuesResourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, + frontend_ctrl.ResourceOptions[msg_dm.RabbitMQQueue]{ + RequestConverter: msg_conv.RabbitMQQueueDataModelFromVersioned, + ResponseConverter: msg_conv.RabbitMQQueueDataModelToVersioned, + AsyncOperationTimeout: msg_ctrl.AsyncDeleteRabbitMQTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: rmqResourceRouter, + Path: "/listsecrets", + ResourceType: portableresources.RabbitMQQueuesResourceType, + Method: rmq_ctrl.OperationListSecret, + ControllerFactory: rmq_ctrl.NewListSecretsRabbitMQQueue, + }, + } + + for _, h := range handlerOptions { + if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { + return err + } + } + + return nil +} + +// AddDaprRoutes configures the default ARM handlers and adds handlers for Dapr resources such as Dapr PubSubBroker, +// SecretStore and StateStore. It registers handlers for various operations on these resources. +func AddDaprRoutes(ctx context.Context, r chi.Router, rootScopePath string, prefixes []string, isARM bool, ctrlOpts frontend_ctrl.Options) error { + + // Dapr - Configure the default ARM handlers. + err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, DaprProviderNamespace, NewGetOperations, ctrlOpts) + if err != nil { + return err + } + + specLoader, err := validator.LoadSpec(ctx, DaprProviderNamespace, swagger.SpecFiles, prefixes, "rootScope") + if err != nil { + return err + } + + validator := validator.APIValidator(validator.Options{ + SpecLoader: specLoader, + ResourceTypeGetter: validator.RadiusResourceTypeGetter, + }) + + // Register resource routers. + // + // Note: We have to follow the below rules to enable API validators: + // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. + // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. + + pubsubPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.dapr/pubsubbrokers", validator) + pubsubResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/pubsubbrokers", validator) + pubsubResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/pubsubbrokers/{pubSubBrokerName}", validator) + + handlerOptions := []server.HandlerOptions{ + { + ParentRouter: pubsubPlaneRouter, + ResourceType: portableresources.DaprPubSubBrokersResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ + RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, + ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, + ListRecursiveQuery: true, + }) + }, + }, + { + ParentRouter: pubsubResourceGroupRouter, + ResourceType: portableresources.DaprPubSubBrokersResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ + RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, + ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, + }) + }, + }, + { + ParentRouter: pubsubResourceRouter, + ResourceType: portableresources.DaprPubSubBrokersResourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ + RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, + ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, + }) + }, + }, + { + ParentRouter: pubsubResourceRouter, + ResourceType: portableresources.DaprPubSubBrokersResourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ + RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, + ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprPubSubBroker]{ + rp_frontend.PrepareRadiusResource[*dapr_dm.DaprPubSubBroker], + rp_frontend.PrepareDaprResource[*dapr_dm.DaprPubSubBroker], + }, + AsyncOperationTimeout: dapr_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: pubsubResourceRouter, + ResourceType: portableresources.DaprPubSubBrokersResourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ + RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, + ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprPubSubBroker]{ + rp_frontend.PrepareRadiusResource[*dapr_dm.DaprPubSubBroker], + rp_frontend.PrepareDaprResource[*dapr_dm.DaprPubSubBroker], + }, + AsyncOperationTimeout: dapr_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: pubsubResourceRouter, + ResourceType: portableresources.DaprPubSubBrokersResourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprPubSubBroker]{ + RequestConverter: dapr_conv.PubSubBrokerDataModelFromVersioned, + ResponseConverter: dapr_conv.PubSubBrokerDataModelToVersioned, + AsyncOperationTimeout: dapr_ctrl.AsyncCreateOrUpdateDaprPubSubBrokerTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + } + + secretStorePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.dapr/secretstores", validator) + secretStoreResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/secretstores", validator) + secretStoreResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/secretstores/{secretStoreName}", validator) + + handlerOptions = append(handlerOptions, []server.HandlerOptions{ + { + ParentRouter: secretStorePlaneRouter, + ResourceType: portableresources.DaprSecretStoresResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ + RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, + ListRecursiveQuery: true, + }) + }, + }, + { + ParentRouter: secretStoreResourceGroupRouter, + ResourceType: portableresources.DaprSecretStoresResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ + RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, + }) + }, + }, + { + ParentRouter: secretStoreResourceRouter, + ResourceType: portableresources.DaprSecretStoresResourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ + RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, + }) + }, + }, + { + ParentRouter: secretStoreResourceRouter, + ResourceType: portableresources.DaprSecretStoresResourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ + RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprSecretStore]{ + rp_frontend.PrepareRadiusResource[*dapr_dm.DaprSecretStore], + rp_frontend.PrepareDaprResource[*dapr_dm.DaprSecretStore], + }, + AsyncOperationTimeout: dapr_ctrl.AsyncCreateOrUpdateDaprSecretStoreTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: secretStoreResourceRouter, + ResourceType: portableresources.DaprSecretStoresResourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ + RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprSecretStore]{ + rp_frontend.PrepareRadiusResource[*dapr_dm.DaprSecretStore], + rp_frontend.PrepareDaprResource[*dapr_dm.DaprSecretStore], + }, + AsyncOperationTimeout: dapr_ctrl.AsyncCreateOrUpdateDaprSecretStoreTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: secretStoreResourceRouter, + ResourceType: portableresources.DaprSecretStoresResourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprSecretStore]{ + RequestConverter: dapr_conv.SecretStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.SecretStoreDataModelToVersioned, + AsyncOperationTimeout: dapr_ctrl.AsyncDeleteDaprSecretStoreTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + }...) + + stateStorePlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.dapr/statestores", validator) + stateStoreResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/statestores", validator) + stateStoreResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.dapr/statestores/{stateStoreName}", validator) + + handlerOptions = append(handlerOptions, []server.HandlerOptions{ + { + ParentRouter: stateStorePlaneRouter, + ResourceType: portableresources.DaprStateStoresResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ + RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, + ListRecursiveQuery: true, + }) + }, + }, + { + ParentRouter: stateStoreResourceGroupRouter, + ResourceType: portableresources.DaprStateStoresResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ + RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, + }) + }, + }, + { + ParentRouter: stateStoreResourceRouter, + ResourceType: portableresources.DaprStateStoresResourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ + RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, + }) + }, + }, + { + ParentRouter: stateStoreResourceRouter, + ResourceType: portableresources.DaprStateStoresResourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ + RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprStateStore]{ + rp_frontend.PrepareRadiusResource[*dapr_dm.DaprStateStore], + rp_frontend.PrepareDaprResource[*dapr_dm.DaprStateStore], + }, + AsyncOperationTimeout: dapr_ctrl.AsyncCreateOrUpdateDaprStateStoreTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: stateStoreResourceRouter, + ResourceType: portableresources.DaprStateStoresResourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ + RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[dapr_dm.DaprStateStore]{ + rp_frontend.PrepareRadiusResource[*dapr_dm.DaprStateStore], + rp_frontend.PrepareDaprResource[*dapr_dm.DaprStateStore], + }, + AsyncOperationTimeout: dapr_ctrl.AsyncCreateOrUpdateDaprStateStoreTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: stateStoreResourceRouter, + ResourceType: portableresources.DaprStateStoresResourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, + frontend_ctrl.ResourceOptions[dapr_dm.DaprStateStore]{ + RequestConverter: dapr_conv.StateStoreDataModelFromVersioned, + ResponseConverter: dapr_conv.StateStoreDataModelToVersioned, + AsyncOperationTimeout: dapr_ctrl.AsyncDeleteDaprStateStoreTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + }...) + + for _, h := range handlerOptions { + if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { + return err + } + } + + return nil +} + +// AddDatastoresRoutes configures the routes and handlers for Datastores Resource Provider. It registers handlers for List, Get, Put, +// Patch, and Delete operations for MongoDatabase, RedisCache, and SqlDatabase resources. +func AddDatastoresRoutes(ctx context.Context, r chi.Router, rootScopePath string, prefixes []string, isARM bool, ctrlOpts frontend_ctrl.Options) error { + // Datastores - Configure the default ARM handlers. + err := server.ConfigureDefaultHandlers(ctx, r, rootScopePath, isARM, DatastoresProviderNamespace, NewGetOperations, ctrlOpts) + if err != nil { + return err + } + + specLoader, err := validator.LoadSpec(ctx, DatastoresProviderNamespace, swagger.SpecFiles, prefixes, "rootScope") + if err != nil { + return err + } + + validator := validator.APIValidator(validator.Options{ + SpecLoader: specLoader, + ResourceTypeGetter: validator.RadiusResourceTypeGetter, + }) + + // Register resource routers. + // + // Note: We have to follow the below rules to enable API validators: + // 1. For collection scope routers (xxxPlaneRouter and xxxResourceGroupRouter), register validator at HandlerOptions.Middlewares. + // 2. For resource scopes (xxxResourceRouter), register validator at Subrouter. + + mongoPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.datastores/mongodatabases", validator) + mongoResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/mongodatabases", validator) + mongoResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/mongodatabases/{mongoDatabaseName}", validator) + + // Datastores handlers: + handlerOptions := []server.HandlerOptions{ + { + ParentRouter: mongoPlaneRouter, + ResourceType: portableresources.MongoDatabasesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ + RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, + ListRecursiveQuery: true, + }) + }, + }, + { + ParentRouter: mongoResourceGroupRouter, + ResourceType: portableresources.MongoDatabasesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ + RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, + }) + }, + }, + { + ParentRouter: mongoResourceRouter, + ResourceType: portableresources.MongoDatabasesResourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, + frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ + RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, + }) + }, + }, + { + ParentRouter: mongoResourceRouter, + ResourceType: portableresources.MongoDatabasesResourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ + RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.MongoDatabase]{ + rp_frontend.PrepareRadiusResource[*ds_dm.MongoDatabase], + }, + AsyncOperationTimeout: ds_ctrl.AsyncCreateOrUpdateMongoDatabaseTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: mongoResourceRouter, + ResourceType: portableresources.MongoDatabasesResourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ + RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.MongoDatabase]{ + rp_frontend.PrepareRadiusResource[*ds_dm.MongoDatabase], + }, + AsyncOperationTimeout: ds_ctrl.AsyncCreateOrUpdateMongoDatabaseTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: mongoResourceRouter, + ResourceType: portableresources.MongoDatabasesResourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, + frontend_ctrl.ResourceOptions[ds_dm.MongoDatabase]{ + RequestConverter: ds_conv.MongoDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.MongoDatabaseDataModelToVersioned, + AsyncOperationTimeout: ds_ctrl.AsyncDeleteMongoDatabaseTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: mongoResourceRouter, + Path: "/listsecrets", + ResourceType: portableresources.MongoDatabasesResourceType, + Method: ds_ctrl.OperationListSecret, + ControllerFactory: mongo_ctrl.NewListSecretsMongoDatabase, + }, + } + + redisPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.datastores/rediscaches", validator) + redisResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/rediscaches", validator) + redisResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/rediscaches/{redisCacheName}", validator) + + handlerOptions = append(handlerOptions, []server.HandlerOptions{ + { + ParentRouter: redisPlaneRouter, + ResourceType: portableresources.RedisCachesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ + RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, + ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, + ListRecursiveQuery: true, + }) + }, + }, + { + ParentRouter: redisResourceGroupRouter, + ResourceType: portableresources.RedisCachesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ + RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, + ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, + }) + }, + }, + { + ParentRouter: redisResourceRouter, + ResourceType: portableresources.RedisCachesResourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, + frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ + RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, + ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, + }) + }, + }, + { + ParentRouter: redisResourceRouter, + ResourceType: portableresources.RedisCachesResourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ + RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, + ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.RedisCache]{ + rp_frontend.PrepareRadiusResource[*ds_dm.RedisCache], + }, + AsyncOperationTimeout: ds_ctrl.AsyncCreateOrUpdateRedisCacheTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: redisResourceRouter, + ResourceType: portableresources.RedisCachesResourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ + RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, + ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.RedisCache]{ + rp_frontend.PrepareRadiusResource[*ds_dm.RedisCache], + }, + AsyncOperationTimeout: ds_ctrl.AsyncCreateOrUpdateRedisCacheTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: redisResourceRouter, + ResourceType: portableresources.RedisCachesResourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, + frontend_ctrl.ResourceOptions[ds_dm.RedisCache]{ + RequestConverter: ds_conv.RedisCacheDataModelFromVersioned, + ResponseConverter: ds_conv.RedisCacheDataModelToVersioned, + AsyncOperationTimeout: ds_ctrl.AsyncDeleteRedisCacheTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: redisResourceRouter, + Path: "/listsecrets", + ResourceType: portableresources.RedisCachesResourceType, + Method: ds_ctrl.OperationListSecret, + ControllerFactory: redis_ctrl.NewListSecretsRedisCache, + }, + }...) + + sqlPlaneRouter := server.NewSubrouter(r, rootScopePath+"/providers/applications.datastores/sqldatabases", validator) + sqlResourceGroupRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/sqldatabases", validator) + sqlResourceRouter := server.NewSubrouter(r, rootScopePath+resourceGroupPath+"/providers/applications.datastores/sqldatabases/{sqlDatabaseName}", validator) + + handlerOptions = append(handlerOptions, []server.HandlerOptions{ + { + ParentRouter: sqlPlaneRouter, + ResourceType: portableresources.SqlDatabasesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ + RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, + ListRecursiveQuery: true, + }) + }, + }, + { + ParentRouter: sqlResourceGroupRouter, + ResourceType: portableresources.SqlDatabasesResourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, + frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ + RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, + }) + }, + }, + { + ParentRouter: sqlResourceRouter, + ResourceType: portableresources.SqlDatabasesResourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, + frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ + RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, + }) + }, + }, + { + ParentRouter: sqlResourceRouter, + ResourceType: portableresources.SqlDatabasesResourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ + RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.SqlDatabase]{ + rp_frontend.PrepareRadiusResource[*ds_dm.SqlDatabase], + }, + AsyncOperationTimeout: ds_ctrl.AsyncCreateOrUpdateSqlDatabaseTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: sqlResourceRouter, + ResourceType: portableresources.SqlDatabasesResourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, + frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ + RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, + UpdateFilters: []frontend_ctrl.UpdateFilter[ds_dm.SqlDatabase]{ + rp_frontend.PrepareRadiusResource[*ds_dm.SqlDatabase], + }, + AsyncOperationTimeout: ds_ctrl.AsyncCreateOrUpdateSqlDatabaseTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: sqlResourceRouter, + ResourceType: portableresources.SqlDatabasesResourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, + frontend_ctrl.ResourceOptions[ds_dm.SqlDatabase]{ + RequestConverter: ds_conv.SqlDatabaseDataModelFromVersioned, + ResponseConverter: ds_conv.SqlDatabaseDataModelToVersioned, + AsyncOperationTimeout: ds_ctrl.AsyncDeleteSqlDatabaseTimeout, + AsyncOperationRetryAfter: AsyncOperationRetryAfter, + }, + ) + }, + }, + { + ParentRouter: sqlResourceRouter, + Path: "/listsecrets", + ResourceType: portableresources.SqlDatabasesResourceType, + Method: ds_ctrl.OperationListSecret, + ControllerFactory: sql_ctrl.NewListSecretsSqlDatabase, + }, + }...) + + for _, h := range handlerOptions { + if err := server.RegisterHandler(ctx, h, ctrlOpts); err != nil { + return err + } + } + + return nil +} + +func getRootScopePath(isARM bool) string { + if isARM { + return "/subscriptions/{subscriptionID}" + } + return "/planes/radius/{planeName}" +} diff --git a/pkg/portableresources/frontend/handler/routes_test.go b/pkg/portableresources/frontend/handler/routes_test.go new file mode 100644 index 0000000000..ccc8f96a65 --- /dev/null +++ b/pkg/portableresources/frontend/handler/routes_test.go @@ -0,0 +1,292 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handler + +import ( + "context" + "net/http" + "testing" + + "github.com/go-chi/chi/v5" + "github.com/golang/mock/gomock" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ds_ctrl "github.com/radius-project/radius/pkg/datastoresrp/frontend/controller" + rabbitmq_ctrl "github.com/radius-project/radius/pkg/messagingrp/frontend/controller/rabbitmqqueues" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" +) + +var handlerTests = []rpctest.HandlerTestSpec{ + { + OperationType: v1.OperationType{Type: portableresources.RabbitMQQueuesResourceType, Method: v1.OperationList}, + Path: "/providers/applications.messaging/rabbitmqqueues", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.RabbitMQQueuesResourceType, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.RabbitMQQueuesResourceType, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.RabbitMQQueuesResourceType, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: portableresources.RabbitMQQueuesResourceType, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: portableresources.RabbitMQQueuesResourceType, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: portableresources.RabbitMQQueuesResourceType, Method: rabbitmq_ctrl.OperationListSecret}, + Path: "/resourcegroups/testrg/providers/applications.messaging/rabbitmqqueues/rabbitmq/listsecrets", + Method: http.MethodPost, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprPubSubBrokersResourceType, Method: v1.OperationList}, + Path: "/providers/applications.dapr/pubsubbrokers", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprPubSubBrokersResourceType, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprPubSubBrokersResourceType, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprPubSubBrokersResourceType, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprPubSubBrokersResourceType, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprPubSubBrokersResourceType, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.dapr/pubsubbrokers/daprpubsub", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprSecretStoresResourceType, Method: v1.OperationList}, + Path: "/providers/applications.dapr/secretstores", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprSecretStoresResourceType, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprSecretStoresResourceType, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprSecretStoresResourceType, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprSecretStoresResourceType, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprSecretStoresResourceType, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.dapr/secretstores/daprsecretstore", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprStateStoresResourceType, Method: v1.OperationList}, + Path: "/providers/applications.dapr/statestores", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprStateStoresResourceType, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.dapr/statestores", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprStateStoresResourceType, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprStateStoresResourceType, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprStateStoresResourceType, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: portableresources.DaprStateStoresResourceType, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.dapr/statestores/daprstatestore", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: portableresources.MongoDatabasesResourceType, Method: v1.OperationList}, + Path: "/providers/applications.datastores/mongodatabases", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.MongoDatabasesResourceType, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.MongoDatabasesResourceType, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.MongoDatabasesResourceType, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: portableresources.MongoDatabasesResourceType, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: portableresources.MongoDatabasesResourceType, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: portableresources.MongoDatabasesResourceType, Method: ds_ctrl.OperationListSecret}, + Path: "/resourcegroups/testrg/providers/applications.datastores/mongodatabases/mongo/listsecrets", + Method: http.MethodPost, + }, { + OperationType: v1.OperationType{Type: portableresources.RedisCachesResourceType, Method: v1.OperationList}, + Path: "/providers/applications.datastores/rediscaches", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.RedisCachesResourceType, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.RedisCachesResourceType, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.RedisCachesResourceType, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: portableresources.RedisCachesResourceType, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: portableresources.RedisCachesResourceType, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: portableresources.RedisCachesResourceType, Method: ds_ctrl.OperationListSecret}, + Path: "/resourcegroups/testrg/providers/applications.datastores/rediscaches/redis/listsecrets", + Method: http.MethodPost, + }, { + OperationType: v1.OperationType{Type: portableresources.SqlDatabasesResourceType, Method: v1.OperationList}, + Path: "/providers/applications.datastores/sqldatabases", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.SqlDatabasesResourceType, Method: v1.OperationList}, + Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.SqlDatabasesResourceType, Method: v1.OperationGet}, + Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: portableresources.SqlDatabasesResourceType, Method: v1.OperationPut}, + Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", + Method: http.MethodPut, + }, { + OperationType: v1.OperationType{Type: portableresources.SqlDatabasesResourceType, Method: v1.OperationPatch}, + Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", + Method: http.MethodPatch, + }, { + OperationType: v1.OperationType{Type: portableresources.SqlDatabasesResourceType, Method: v1.OperationDelete}, + Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql", + Method: http.MethodDelete, + }, { + OperationType: v1.OperationType{Type: portableresources.SqlDatabasesResourceType, Method: ds_ctrl.OperationListSecret}, + Path: "/resourcegroups/testrg/providers/applications.datastores/sqldatabases/sql/listsecrets", + Method: http.MethodPost, + }, { + OperationType: v1.OperationType{Type: "Applications.Messaging/operationStatuses", Method: v1.OperationGet}, + Path: "/providers/applications.messaging/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Messaging/operationResults", Method: v1.OperationGet}, + Path: "/providers/applications.messaging/locations/global/operationresults/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, + { + OperationType: v1.OperationType{Type: "Applications.Dapr/operationStatuses", Method: v1.OperationGet}, + Path: "/providers/applications.dapr/locations/global/operationstatuses/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, { + OperationType: v1.OperationType{Type: "Applications.Dapr/operationResults", Method: v1.OperationGet}, + Path: "/providers/applications.dapr/locations/global/operationresults/00000000-0000-0000-0000-000000000000", + Method: http.MethodGet, + }, +} + +func TestHandlers(t *testing.T) { + mctrl := gomock.NewController(t) + defer mctrl.Finish() + + mockSP := dataprovider.NewMockDataStorageProvider(mctrl) + mockSC := store.NewMockStorageClient(mctrl) + + mockSC.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(&store.Object{}, nil).AnyTimes() + mockSC.EXPECT().Save(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + mockSP.EXPECT().GetStorageClient(gomock.Any(), gomock.Any()).Return(store.StorageClient(mockSC), nil).AnyTimes() + + t.Run("UCP", func(t *testing.T) { + // Test handlers for UCP resources. + rpctest.AssertRouters(t, handlerTests, "/api.ucp.dev", "/planes/radius/local", func(ctx context.Context) (chi.Router, error) { + r := chi.NewRouter() + return r, AddRoutes(ctx, r, false, ctrl.Options{PathBase: "/api.ucp.dev", DataProvider: mockSP}) + }) + }) + + t.Run("Azure", func(t *testing.T) { + // Add azure specific handlers. + azureHandlerTests := append(handlerTests, []rpctest.HandlerTestSpec{ + { + OperationType: v1.OperationType{Type: "Applications.Messaging/providers", Method: v1.OperationGet}, + Path: "/providers/applications.messaging/operations", + Method: http.MethodGet, + WithoutRootScope: true, + SkipOperationTypeValidation: true, + }, + { + OperationType: v1.OperationType{Type: "Applications.Dapr/providers", Method: v1.OperationGet}, + Path: "/providers/applications.dapr/operations", + Method: http.MethodGet, + WithoutRootScope: true, + SkipOperationTypeValidation: true, + }, + { + OperationType: v1.OperationType{Type: "Applications.Datastores/providers", Method: v1.OperationGet}, + Path: "/providers/applications.datastores/operations", + Method: http.MethodGet, + WithoutRootScope: true, + SkipOperationTypeValidation: true, + }, + }...) + + // Test handlers for Azure resources + rpctest.AssertRouters(t, azureHandlerTests, "", "/subscriptions/00000000-0000-0000-0000-000000000000", func(ctx context.Context) (chi.Router, error) { + r := chi.NewRouter() + return r, AddRoutes(ctx, r, true, ctrl.Options{PathBase: "", DataProvider: mockSP}) + }) + }) +} diff --git a/pkg/portableresources/frontend/service.go b/pkg/portableresources/frontend/service.go new file mode 100644 index 0000000000..eb35116912 --- /dev/null +++ b/pkg/portableresources/frontend/service.go @@ -0,0 +1,80 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package frontend + +import ( + "context" + "fmt" + + "github.com/go-chi/chi/v5" + ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/portableresources/frontend/handler" +) + +type Service struct { + server.Service +} + +// NewService creates a new Service instance with the given options. +func NewService(options hostoptions.HostOptions) *Service { + return &Service{ + server.Service{ + Options: options, + ProviderName: handler.PortableResourcesNamespace, + }, + } +} + +// Name returns the namespace of the portable resource provider. +func (s *Service) Name() string { + return handler.PortableResourcesNamespace +} + +// Run sets up the server and starts it, returning an error if any. +func (s *Service) Run(ctx context.Context) error { + if err := s.Init(ctx); err != nil { + return err + } + + opts := ctrl.Options{ + Address: fmt.Sprintf("%s:%d", s.Options.Config.Server.Host, s.Options.Config.Server.Port), + PathBase: s.Options.Config.Server.PathBase, + DataProvider: s.StorageProvider, + KubeClient: s.KubeClient, + StatusManager: s.OperationStatusManager, + } + + err := s.Start(ctx, server.Options{ + Address: opts.Address, + ServiceName: s.ProviderName, + Location: s.Options.Config.Env.RoleLocation, + PathBase: s.Options.Config.Server.PathBase, + // set the arm cert manager for managing client certificate + ArmCertMgr: s.ARMCertManager, + EnableArmAuth: s.Options.Config.Server.EnableArmAuth, // when enabled the client cert validation will be done + Configure: func(router chi.Router) error { + err := handler.AddRoutes(ctx, router, !hostoptions.IsSelfHosted(), opts) + if err != nil { + return err + } + return nil + }, + }) + return err +} diff --git a/pkg/portableresources/handlers/util.go b/pkg/portableresources/handlers/util.go new file mode 100644 index 0000000000..a9db93e812 --- /dev/null +++ b/pkg/portableresources/handlers/util.go @@ -0,0 +1,71 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handlers + +import ( + "context" + "fmt" + "strings" + + "github.com/radius-project/radius/pkg/kubernetes" + + k8serrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const daprConflictFmt = "the Dapr component name '%q' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again" + +// CheckDaprResourceNameUniqueness checks if the resource name is unique in the namespace. If the resource name is not unique, it returns an error. +// +// This protects against some of the following scenarios: +// +// - Two Dapr resources with the same component name but different types. +// - Two Dapr resources with different UCP resource names, but the same Dapr component name. +// +// Note: the Dapr component name and UCP resource name are NOT the same thing. Users can override the Dapr component name. +func CheckDaprResourceNameUniqueness(ctx context.Context, k8s client.Client, componentName string, namespace string, resourceName string, resourceType string) error { + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(schema.GroupVersionKind{ + Kind: "Component", + Version: "dapr.io/v1alpha1", + }) + err := k8s.Get(ctx, client.ObjectKey{ + Namespace: namespace, + Name: componentName, + }, u) + if k8serrors.IsNotFound(err) { + // Object with the same name doesn't exist. + return nil + } else if err != nil { + return err + } + + // Object with the same name exists, checking the labels to see if they are 'owned' by the same Radius + // resource. + // + // We also need to handle the case where the component has no Radius labels. + resourceTypeLabel := u.GetLabels()[kubernetes.LabelRadiusResourceType] + resourceNameLabel := u.GetLabels()[kubernetes.LabelRadiusResource] + if strings.EqualFold(resourceNameLabel, resourceName) && + strings.EqualFold(kubernetes.ConvertLabelToResourceType(resourceTypeLabel), resourceType) { + return nil + } + + return fmt.Errorf(daprConflictFmt, componentName) +} diff --git a/pkg/portableresources/handlers/util_test.go b/pkg/portableresources/handlers/util_test.go new file mode 100644 index 0000000000..590c2ac622 --- /dev/null +++ b/pkg/portableresources/handlers/util_test.go @@ -0,0 +1,100 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package handlers + +import ( + "context" + "fmt" + "testing" + + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/test/k8sutil" + "github.com/stretchr/testify/require" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +func Test_CheckDaprResourceNameUniqueness_NotFound(t *testing.T) { + client := k8sutil.NewFakeKubeClient(nil) + + err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", portableresources.DaprStateStoresResourceType) + require.NoError(t, err) +} + +func Test_CheckDaprResourceNameUniqueness_SameRadiusResource(t *testing.T) { + labels := kubernetes.MakeDescriptiveDaprLabels("test-app", "test-resource", portableresources.DaprStateStoresResourceType) + existing := createUnstructuredComponent("test-component", "default", labels) + client := k8sutil.NewFakeKubeClient(nil, existing) + + err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", portableresources.DaprStateStoresResourceType) + require.NoError(t, err) +} + +func Test_CheckDaprResourceNameUniqueness_NoLabels(t *testing.T) { + existing := createUnstructuredComponent("test-component", "default", nil) + client := k8sutil.NewFakeKubeClient(nil, existing) + + err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", portableresources.DaprStateStoresResourceType) + require.Error(t, err) + require.Equal(t, fmt.Sprintf(daprConflictFmt, "test-component"), err.Error()) +} + +func Test_CheckDaprResourceNameUniqueness_DifferentResourceNames(t *testing.T) { + labels := kubernetes.MakeDescriptiveDaprLabels("test-app", "different-resource", portableresources.DaprStateStoresResourceType) + existing := createUnstructuredComponent("test-component", "default", labels) + client := k8sutil.NewFakeKubeClient(nil, existing) + + err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", portableresources.DaprStateStoresResourceType) + require.Error(t, err) + require.Equal(t, fmt.Sprintf(daprConflictFmt, "test-component"), err.Error()) +} + +func Test_CheckDaprResourceNameUniqueness_DifferentResourceTypes(t *testing.T) { + labels := kubernetes.MakeDescriptiveDaprLabels("test-app", "test-resource", portableresources.DaprPubSubBrokersResourceType) + existing := createUnstructuredComponent("test-component", "default", labels) + client := k8sutil.NewFakeKubeClient(nil, existing) + + err := CheckDaprResourceNameUniqueness(context.Background(), client, "test-component", "default", "test-resource", portableresources.DaprStateStoresResourceType) + require.Error(t, err) + require.Equal(t, fmt.Sprintf(daprConflictFmt, "test-component"), err.Error()) +} + +func createUnstructuredComponent(name string, namespace string, labels map[string]any) *unstructured.Unstructured { + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(schema.GroupVersionKind{ + Kind: "Component", + Version: "dapr.io/v1alpha1", + }) + u.SetNamespace(namespace) + u.SetName(name) + + if labels == nil { + return u + } + + // This is (unfortunately) needed, because unstructured wants a map[string]string for labels. However + // some of the fake clients want a map[string]any and WILL NOT work with map[string]string. So our API + // returns map[string]any. + copy := map[string]string{} + for k, v := range labels { + copy[k] = v.(string) + } + + u.SetLabels(copy) + return u +} diff --git a/pkg/portableresources/processors/doc.go b/pkg/portableresources/processors/doc.go new file mode 100644 index 0000000000..92b0d9406b --- /dev/null +++ b/pkg/portableresources/processors/doc.go @@ -0,0 +1,24 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// processors contains the shared logic and interfaces for implementing a resource processor. +// +// Resource processors are responsible for processing the results of recipe execution or any +// other change to the lifecycle of a portable resource. +// +// For example a mongo processor might take the results of executing a recipe and compute +// and store the connection string as part of the resource data model. +package processors diff --git a/pkg/portableresources/processors/mock_resourceclient.go b/pkg/portableresources/processors/mock_resourceclient.go new file mode 100644 index 0000000000..5cbcfcb5d6 --- /dev/null +++ b/pkg/portableresources/processors/mock_resourceclient.go @@ -0,0 +1,49 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/radius-project/radius/pkg/portableresources/processors (interfaces: ResourceClient) + +// Package processors is a generated GoMock package. +package processors + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" +) + +// MockResourceClient is a mock of ResourceClient interface. +type MockResourceClient struct { + ctrl *gomock.Controller + recorder *MockResourceClientMockRecorder +} + +// MockResourceClientMockRecorder is the mock recorder for MockResourceClient. +type MockResourceClientMockRecorder struct { + mock *MockResourceClient +} + +// NewMockResourceClient creates a new mock instance. +func NewMockResourceClient(ctrl *gomock.Controller) *MockResourceClient { + mock := &MockResourceClient{ctrl: ctrl} + mock.recorder = &MockResourceClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockResourceClient) EXPECT() *MockResourceClientMockRecorder { + return m.recorder +} + +// Delete mocks base method. +func (m *MockResourceClient) Delete(arg0 context.Context, arg1 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockResourceClientMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockResourceClient)(nil).Delete), arg0, arg1) +} diff --git a/pkg/linkrp/processors/resourceclient.go b/pkg/portableresources/processors/resourceclient.go similarity index 76% rename from pkg/linkrp/processors/resourceclient.go rename to pkg/portableresources/processors/resourceclient.go index ec7ff5e042..8543a99e86 100644 --- a/pkg/linkrp/processors/resourceclient.go +++ b/pkg/portableresources/processors/resourceclient.go @@ -23,15 +23,16 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - "github.com/project-radius/radius/pkg/azure/armauth" - "github.com/project-radius/radius/pkg/azure/clientv2" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/trace" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/clientv2" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/trace" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/pkg/ucp/ucplog" "go.opentelemetry.io/otel/attribute" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -62,7 +63,7 @@ func NewResourceClient(arm *armauth.ArmConfig, connection sdk.Connection, k8sCli } // Delete attempts to delete a resource, either through UCP, Azure, or Kubernetes, depending on the resource type. -func (c *resourceClient) Delete(ctx context.Context, id string, apiVersion string) error { +func (c *resourceClient) Delete(ctx context.Context, id string) error { parsed, err := resources.ParseResource(id) if err != nil { return err @@ -79,11 +80,11 @@ func (c *resourceClient) Delete(ctx context.Context, id string, apiVersion strin ns := strings.ToLower(parsed.PlaneNamespace()) if !parsed.IsUCPQualfied() || strings.HasPrefix(ns, "azure/") { - return c.wrapError(parsed, c.deleteAzureResource(ctx, parsed, apiVersion)) + return c.wrapError(parsed, c.deleteAzureResource(ctx, parsed)) } else if strings.HasPrefix(ns, "kubernetes/") { - return c.wrapError(parsed, c.deleteKubernetesResource(ctx, parsed, apiVersion)) + return c.wrapError(parsed, c.deleteKubernetesResource(ctx, parsed)) } else { - return c.wrapError(parsed, c.deleteUCPResource(ctx, parsed, apiVersion)) + return c.wrapError(parsed, c.deleteUCPResource(ctx, parsed)) } } @@ -95,23 +96,21 @@ func (c *resourceClient) wrapError(id resources.ID, err error) error { return nil } -func (c *resourceClient) deleteAzureResource(ctx context.Context, id resources.ID, apiVersion string) error { +func (c *resourceClient) deleteAzureResource(ctx context.Context, id resources.ID) error { var err error if id.IsUCPQualfied() { - id, err = resources.ParseResource(resources.MakeRelativeID(id.ScopeSegments()[1:], id.TypeSegments()...)) + id, err = resources.ParseResource(resources.MakeRelativeID(id.ScopeSegments()[1:], id.TypeSegments(), id.ExtensionSegments())) if err != nil { return err } } - if apiVersion == "" || apiVersion == resourcemodel.APIVersionUnknown { - apiVersion, err = c.lookupARMAPIVersion(ctx, id) - if err != nil { - return err - } + apiVersion, err := c.lookupARMAPIVersion(ctx, id) + if err != nil { + return err } - client, err := clientv2.NewGenericResourceClient(id.FindScope(resources.SubscriptionsSegment), &c.arm.ClientOptions, c.armClientOptions) + client, err := clientv2.NewGenericResourceClient(id.FindScope(resources_azure.ScopeSubscriptions), &c.arm.ClientOptions, c.armClientOptions) if err != nil { return err } @@ -130,7 +129,7 @@ func (c *resourceClient) deleteAzureResource(ctx context.Context, id resources.I } func (c *resourceClient) lookupARMAPIVersion(ctx context.Context, id resources.ID) (string, error) { - client, err := clientv2.NewProvidersClient(id.FindScope(resources.SubscriptionsSegment), &c.arm.ClientOptions, c.armClientOptions) + client, err := clientv2.NewProvidersClient(id.FindScope(resources_azure.ScopeSubscriptions), &c.arm.ClientOptions, c.armClientOptions) if err != nil { return "", err } @@ -161,7 +160,7 @@ func (c *resourceClient) lookupARMAPIVersion(ctx context.Context, id resources.I return "", fmt.Errorf("could not find API version for type %q, type was not found", id.Type()) } -func (c *resourceClient) deleteUCPResource(ctx context.Context, id resources.ID, apiVersion string) error { +func (c *resourceClient) deleteUCPResource(ctx context.Context, id resources.ID) error { // NOTE: the API version passed in here is ignored. // // We're using a generated client that understands Radius' currently supported API version. @@ -187,33 +186,29 @@ func (c *resourceClient) deleteUCPResource(ctx context.Context, id resources.ID, return nil } -func (c *resourceClient) deleteKubernetesResource(ctx context.Context, id resources.ID, apiVersion string) error { - if apiVersion == "" || apiVersion == resourcemodel.APIVersionUnknown { - var err error - apiVersion, err = c.lookupKubernetesAPIVersion(ctx, id) - if err != nil { - return err - } - } - - identity := resourcemodel.FromUCPID(id, apiVersion) - gvk, ns, name, err := identity.RequireKubernetes() +func (c *resourceClient) deleteKubernetesResource(ctx context.Context, id resources.ID) error { + apiVersion, err := c.lookupKubernetesAPIVersion(ctx, id) if err != nil { - // We don't expect this to fail, but just in case.... - return fmt.Errorf("could not understand kubernetes resource id %q: %w", id.String(), err) + return err } + group, kind, namespace, name := resources_kubernetes.ToParts(id) + metadata := map[string]any{ "name": name, } - if ns != "" { - metadata["namespace"] = ns + if namespace != "" { + metadata["namespace"] = namespace + } + + if group != "" { + apiVersion = fmt.Sprintf("%s/%s", group, apiVersion) } obj := unstructured.Unstructured{ Object: map[string]interface{}{ - "apiVersion": gvk.GroupVersion().String(), - "kind": gvk.Kind, + "apiVersion": apiVersion, + "kind": kind, "metadata": metadata, }, } @@ -227,14 +222,9 @@ func (c *resourceClient) deleteKubernetesResource(ctx context.Context, id resour } func (c *resourceClient) lookupKubernetesAPIVersion(ctx context.Context, id resources.ID) (string, error) { - identity := resourcemodel.FromUCPID(id, resourcemodel.APIVersionUnknown) - gvk, namespace, _, err := identity.RequireKubernetes() - if err != nil { - // We don't expect this to fail, but just in case.... - return "", fmt.Errorf("could not find API version for type %q: %w", id.Type(), err) - } - + group, kind, namespace, _ := resources_kubernetes.ToParts(id) var resourceLists []*v1.APIResourceList + var err error if namespace == "" { resourceLists, err = c.k8sDiscoveryClient.ServerPreferredResources() if err != nil { @@ -254,12 +244,12 @@ func (c *resourceClient) lookupKubernetesAPIVersion(ctx context.Context, id reso return "", err } - if gvk.Group != gv.Group { + if group != gv.Group { continue } for _, resource := range resourceList.APIResources { - if resource.Kind == gvk.Kind { + if resource.Kind == kind { return gv.Version, nil } } diff --git a/pkg/portableresources/processors/resourceclient_test.go b/pkg/portableresources/processors/resourceclient_test.go new file mode 100644 index 0000000000..bdc9667f9a --- /dev/null +++ b/pkg/portableresources/processors/resourceclient_test.go @@ -0,0 +1,368 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package processors + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/azure/armauth" + "github.com/radius-project/radius/pkg/azure/clientv2" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/test/k8sutil" + "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client/fake" +) + +const ( + ARMResourceID = "/subscriptions/0000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/test-vm" + ARMProviderPath = "/subscriptions/0000/providers/Microsoft.Compute" + AzureUCPResourceID = "/planes/azure/azurecloud/subscriptions/0000/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/test-vm" + ARMAPIVersion = "2020-01-01" + AWSResourceID = "/planes/aws/aws/accounts/0000/regions/us-east-1/providers/AWS.Kinesis/Streams/test-stream" + KubernetesCoreGroupResourceID = "/planes/kubernetes/local/namespaces/test-namespace/providers/core/Secret/test-name" + KubernetesNonCoreGroupResourceID = "/planes/kubernetes/local/namespaces/test-namespace/providers/apps/Deployment/test-name" +) + +func Test_Delete_InvalidResourceID(t *testing.T) { + c := NewResourceClient(nil, nil, nil, nil) + err := c.Delete(context.Background(), "invalid") + require.Error(t, err) +} + +func Test_Delete_ARM(t *testing.T) { + t.Run("failure - delete fails", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(ARMResourceID, handleJSONResponse(t, v1.ErrorResponse{ + Error: v1.ErrorDetails{ + Code: v1.CodeConflict, + }, + }, 409)) + + server := httptest.NewServer(mux) + defer server.Close() + + c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) + c.armClientOptions = newClientOptions(server.Client(), server.URL) + + err := c.Delete(context.Background(), ARMResourceID) + require.Error(t, err) + require.IsType(t, &ResourceError{}, err) + }) + + t.Run("success - lookup API Version (default)", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(ARMResourceID, handleDeleteSuccess(t)) + mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ + Namespace: to.Ptr("Microsoft.Compute"), + ResourceTypes: []*armresources.ProviderResourceType{ + { + ResourceType: to.Ptr("anotherType"), + APIVersions: []*string{}, + }, + { + ResourceType: to.Ptr("virtualMachines"), + DefaultAPIVersion: to.Ptr(ARMAPIVersion), + }, + }, + }, 200)) + + server := httptest.NewServer(mux) + defer server.Close() + + c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) + c.armClientOptions = newClientOptions(server.Client(), server.URL) + + err := c.Delete(context.Background(), ARMResourceID) + require.NoError(t, err) + }) + + t.Run("success - lookup API Version (first available)", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(ARMResourceID, handleDeleteSuccess(t)) + mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ + Namespace: to.Ptr("Microsoft.Compute"), + ResourceTypes: []*armresources.ProviderResourceType{ + { + ResourceType: to.Ptr("virtualMachines"), + APIVersions: []*string{to.Ptr("2020-01-01"), to.Ptr("2020-01-02")}, + }, + }, + }, 200)) + + server := httptest.NewServer(mux) + defer server.Close() + + c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) + c.armClientOptions = newClientOptions(server.Client(), server.URL) + + err := c.Delete(context.Background(), ARMResourceID) + require.NoError(t, err) + }) + + t.Run("failure - lookup API Version - provider not found", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(ARMProviderPath, handleNotFound(t)) + + server := httptest.NewServer(mux) + defer server.Close() + + c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) + c.armClientOptions = newClientOptions(server.Client(), server.URL) + + err := c.Delete(context.Background(), ARMResourceID) + require.Error(t, err) + require.IsType(t, &ResourceError{}, err) + }) + + t.Run("failure - lookup API Version - resource type not found", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ + Namespace: to.Ptr("Microsoft.Compute"), + ResourceTypes: []*armresources.ProviderResourceType{}, + }, 200)) + + server := httptest.NewServer(mux) + defer server.Close() + + c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) + c.armClientOptions = newClientOptions(server.Client(), server.URL) + + err := c.Delete(context.Background(), ARMResourceID) + require.Error(t, err) + require.IsType(t, &ResourceError{}, err) + require.Contains(t, err.Error(), "could not find API version for type \"Microsoft.Compute/virtualMachines\", type was not found") + }) + + t.Run("failure - lookup API Version - no api versions", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(ARMProviderPath, handleJSONResponse(t, armresources.Provider{ + Namespace: to.Ptr("Microsoft.Compute"), + ResourceTypes: []*armresources.ProviderResourceType{ + { + ResourceType: to.Ptr("virtualMachines"), + APIVersions: []*string{}, + }, + }, + }, 200)) + + server := httptest.NewServer(mux) + defer server.Close() + + c := NewResourceClient(newArmOptions(server.URL), nil, nil, nil) + c.armClientOptions = newClientOptions(server.Client(), server.URL) + + err := c.Delete(context.Background(), ARMResourceID) + require.Error(t, err) + require.IsType(t, &ResourceError{}, err) + require.Contains(t, err.Error(), "could not find API version for type \"Microsoft.Compute/virtualMachines\", no supported API versions") + }) +} + +func Test_Delete_Kubernetes(t *testing.T) { + // Note: unfortunately there isn't a great way to test a deletion failure with the runtime client. + + t.Run("success - lookup API Version (preferred namespaced resources)", func(t *testing.T) { + client := fake.NewClientBuilder().WithObjects(&corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-name", + Namespace: "test-namespace", + }, + }).Build() + + dc := &k8sutil.DiscoveryClient{ + Resources: []*metav1.APIResourceList{ + { + GroupVersion: "v1", + APIResources: []metav1.APIResource{ + { + Name: "api1", + Version: "v1", + Kind: "Secret", + }, + }, + }, + }, + } + + c := NewResourceClient(nil, nil, client, dc) + + err := c.Delete(context.Background(), KubernetesCoreGroupResourceID) + require.NoError(t, err) + }) + + t.Run("success - lookup API Version (preferred empty namespace)", func(t *testing.T) { + client := fake.NewClientBuilder().WithObjects(&corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-name", + }, + }).Build() + + dc := &k8sutil.DiscoveryClient{ + Resources: []*metav1.APIResourceList{ + { + GroupVersion: "v1", + APIResources: []metav1.APIResource{ + { + Name: "api1", + Version: "v1", + Kind: "Secret", + }, + }, + }, + }, + } + + c := NewResourceClient(nil, nil, client, dc) + + err := c.Delete(context.Background(), KubernetesCoreGroupResourceID) + require.NoError(t, err) + }) + + t.Run("failure - lookup API Version - resource list not found", func(t *testing.T) { + client := fake.NewClientBuilder().WithObjects(&corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-name", + Namespace: "test-namespace", + }, + }).Build() + + dc := &k8sutil.DiscoveryClient{ + Resources: []*metav1.APIResourceList{}, + } + + c := NewResourceClient(nil, nil, client, dc) + + err := c.Delete(context.Background(), KubernetesCoreGroupResourceID) + require.Error(t, err) + require.Contains(t, err.Error(), "could not find API version for type \"core/Secret\", type was not found") + }) +} + +func Test_Delete_UCP(t *testing.T) { + t.Run("success", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(AWSResourceID, handleDeleteSuccess(t)) + + server := httptest.NewServer(mux) + defer server.Close() + + connection, err := sdk.NewDirectConnection(server.URL) + require.NoError(t, err) + + c := NewResourceClient(nil, connection, nil, nil) + + err = c.Delete(context.Background(), AWSResourceID) + require.NoError(t, err) + }) + + t.Run("failure - delete fails", func(t *testing.T) { + mux := http.NewServeMux() + mux.HandleFunc(AWSResourceID, handleJSONResponse(t, v1.ErrorResponse{ + Error: v1.ErrorDetails{ + Code: v1.CodeConflict, + }, + }, 409)) + + server := httptest.NewServer(mux) + defer server.Close() + + connection, err := sdk.NewDirectConnection(server.URL) + require.NoError(t, err) + + c := NewResourceClient(nil, connection, nil, nil) + + err = c.Delete(context.Background(), AWSResourceID) + require.Error(t, err) + require.IsType(t, &ResourceError{}, err) + }) +} + +func newArmOptions(url string) *armauth.ArmConfig { + return &armauth.ArmConfig{ + ClientOptions: clientv2.Options{ + Cred: &aztoken.AnonymousCredential{}, + BaseURI: url, + }, + } +} + +func newClientOptions(c *http.Client, url string) *arm.ClientOptions { + return &arm.ClientOptions{ + ClientOptions: policy.ClientOptions{ + Transport: &wrapper{Client: c}, + Cloud: cloud.Configuration{ + Services: map[cloud.ServiceName]cloud.ServiceConfiguration{ + cloud.ResourceManager: { + Endpoint: url, + Audience: "https://management.core.windows.net", + }, + }, + }, + }, + } +} + +func handleDeleteSuccess(t *testing.T) func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() + w.WriteHeader(204) + } +} + +func handleJSONResponse(t *testing.T, response any, statusCode int) func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() + b, err := json.Marshal(&response) + require.NoError(t, err) + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(statusCode) + _, err = w.Write(b) + require.NoError(t, err) + } +} + +func handleNotFound(t *testing.T) func(w http.ResponseWriter, r *http.Request) { + return handleJSONResponse(t, v1.ErrorResponse{ + Error: v1.ErrorDetails{ + Code: v1.CodeNotFound, + }, + }, 404) +} + +// wrapper implements the INTERNAL interface that autorest uses for transport :(. +type wrapper struct { + Client *http.Client +} + +// Do is a method that sends an HTTP request and returns an HTTP response and an error if one occurs. +func (w *wrapper) Do(req *http.Request) (*http.Response, error) { + return w.Client.Do(req) +} diff --git a/pkg/portableresources/processors/types.go b/pkg/portableresources/processors/types.go new file mode 100644 index 0000000000..78f9c1cb44 --- /dev/null +++ b/pkg/portableresources/processors/types.go @@ -0,0 +1,85 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package processors + +import ( + "context" + "fmt" + + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" +) + +// ResourceProcessor is responsible for processing the results of recipe execution or any +// other change to the lifecycle of a portable resource. Each resource processor supports a single +// Radius resource type (eg: RedisCache). +type ResourceProcessor[P interface { + *T + rpv1.RadiusResourceModel +}, T any] interface { + // Process is called to process the results of recipe execution or any other changes to the resource + // data model. Process should modify the datamodel in place to perform updates. + Process(ctx context.Context, resource P, options Options) error + + // Delete is called to delete all the resources created by the resource processor. + Delete(ctx context.Context, resource P, options Options) error +} + +// Options defines the options passed to the resource processor. +type Options struct { + // RuntimeConfiguration represents the configuration of the target runtime. + RuntimeConfiguration recipes.RuntimeConfiguration + + // RecipeOutput represents the output of executing a recipe (may be nil). + RecipeOutput *recipes.RecipeOutput +} + +// ValidationError represents a user-facing validation message reported by the processor. +type ValidationError struct { + Message string +} + +// Error returns a string containing the error message for ValidationError. +func (e *ValidationError) Error() string { + return e.Message +} + +//go:generate mockgen -destination=./mock_resourceclient.go -package=processors -self_package github.com/radius-project/radius/pkg/portableresources/processors github.com/radius-project/radius/pkg/portableresources/processors ResourceClient + +// ResourceClient is a client used by resource processors for interacting with UCP resources. +type ResourceClient interface { + // Delete deletes a resource by id. + // + // If the API version is omitted, then an attempt will be made to look up the API version. + Delete(ctx context.Context, id string) error +} + +// ResourceError represents an error that occured while processing a resource. +type ResourceError struct { + ID string + Inner error +} + +// Error returns a string describing the error that occurred when attempting to delete a resource. +func (e *ResourceError) Error() string { + return fmt.Sprintf("failed to delete resource %q: %v", e.ID, e.Inner) +} + +// Unwrap returns the underlying error of ResourceError. +func (e *ResourceError) Unwrap() error { + return e.Inner +} diff --git a/pkg/portableresources/processors/util.go b/pkg/portableresources/processors/util.go new file mode 100644 index 0000000000..cff2fd61ec --- /dev/null +++ b/pkg/portableresources/processors/util.go @@ -0,0 +1,69 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package processors + +import ( + "fmt" + + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" +) + +// GetOutputResourcesFromResourcesField parses a slice of resource references and converts each resource into an OutputResource. +// It returns a slice of output resources and an error if any of the resource references are invalid. This should be used for +// processing the '.properties.resources' field of a resource. +func GetOutputResourcesFromResourcesField(field []*portableresources.ResourceReference) ([]rpv1.OutputResource, error) { + results := []rpv1.OutputResource{} + for _, resource := range field { + id, err := resources.ParseResource(resource.ID) + if err != nil { + return nil, &ValidationError{Message: fmt.Sprintf("resource id %q is invalid", resource.ID)} + } + + result := rpv1.OutputResource{ + ID: id, + RadiusManaged: to.Ptr(false), // Generally when we parse a resource ID from a resource field, it's externally managed. + } + results = append(results, result) + } + + return results, nil +} + +// GetOutputResourcesFromRecipe parses the output resources from a recipe and returns a slice of OutputResource objects, +// returning an error if any of the resources are invalid. +func GetOutputResourcesFromRecipe(output *recipes.RecipeOutput) ([]rpv1.OutputResource, error) { + results := []rpv1.OutputResource{} + for _, resource := range output.Resources { + id, err := resources.ParseResource(resource) + if err != nil { + return nil, &ValidationError{Message: fmt.Sprintf("resource id %q returned by recipe is invalid", resource)} + } + + result := rpv1.OutputResource{ + ID: id, + RadiusManaged: to.Ptr(true), + } + + results = append(results, result) + } + + return results, nil +} diff --git a/pkg/portableresources/processors/util_test.go b/pkg/portableresources/processors/util_test.go new file mode 100644 index 0000000000..7104ce0d59 --- /dev/null +++ b/pkg/portableresources/processors/util_test.go @@ -0,0 +1,104 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package processors + +import ( + "testing" + + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/stretchr/testify/require" +) + +func Test_GetOutputResourcesFromResourcesField(t *testing.T) { + resourcesField := []*portableresources.ResourceReference{ + {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource1"}, + {ID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource2"}, + } + + expected := []rpv1.OutputResource{ + { + LocalID: "", + ID: resources.MustParse(resourcesField[0].ID), + RadiusManaged: to.Ptr(false), + }, + { + LocalID: "", + ID: resources.MustParse(resourcesField[1].ID), + RadiusManaged: to.Ptr(false), + }, + } + + actual, err := GetOutputResourcesFromResourcesField(resourcesField) + require.NoError(t, err) + require.Equal(t, expected, actual) +} + +func Test_GetOutputResourceFromResourceID_Invalid(t *testing.T) { + resourcesField := []*portableresources.ResourceReference{ + {ID: "/////asdf////"}, + } + + actual, err := GetOutputResourcesFromResourcesField(resourcesField) + require.Error(t, err) + require.Empty(t, actual) + require.IsType(t, &ValidationError{}, err) + require.Equal(t, "resource id \"/////asdf////\" is invalid", err.Error()) +} + +func Test_GetOutputResourcesFromRecipe(t *testing.T) { + output := recipes.RecipeOutput{ + Resources: []string{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource1", + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Cache/redis/test-resource2", + }, + } + + expected := []rpv1.OutputResource{ + { + LocalID: "", + ID: resources.MustParse(output.Resources[0]), + RadiusManaged: to.Ptr(true), + }, + { + LocalID: "", + ID: resources.MustParse(output.Resources[1]), + RadiusManaged: to.Ptr(true), + }, + } + + actual, err := GetOutputResourcesFromRecipe(&output) + require.NoError(t, err) + require.Equal(t, expected, actual) +} + +func Test_GetOutputResourcesFromRecipe_Invalid(t *testing.T) { + output := recipes.RecipeOutput{ + Resources: []string{ + "/////asdf////", + }, + } + + actual, err := GetOutputResourcesFromRecipe(&output) + require.Error(t, err) + require.Empty(t, actual) + require.IsType(t, &ValidationError{}, err) + require.Equal(t, "resource id \"/////asdf////\" returned by recipe is invalid", err.Error()) +} diff --git a/pkg/linkrp/processors/validator.go b/pkg/portableresources/processors/validator.go similarity index 97% rename from pkg/linkrp/processors/validator.go rename to pkg/portableresources/processors/validator.go index 623e74c1ba..668980ae54 100644 --- a/pkg/linkrp/processors/validator.go +++ b/pkg/portableresources/processors/validator.go @@ -21,9 +21,9 @@ import ( "reflect" "strings" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) const ( @@ -40,7 +40,7 @@ const ( // - Extract connection values and connection secrets from the recipe output // - Apply values and secrets from the recipe output to the resource data model. type Validator struct { - resourcesField *[]*linkrp.ResourceReference + resourcesField *[]*portableresources.ResourceReference fields []func(output *recipes.RecipeOutput) string computedFields []func(output *recipes.RecipeOutput) string @@ -71,7 +71,7 @@ func NewValidator(connectionValues *map[string]any, connectionSecrets *map[strin } // AddResourceField registers a field containing a resource ID with the validator. -func (v *Validator) AddResourcesField(ref *[]*linkrp.ResourceReference) { +func (v *Validator) AddResourcesField(ref *[]*portableresources.ResourceReference) { v.resourcesField = ref } diff --git a/pkg/linkrp/processors/validator_test.go b/pkg/portableresources/processors/validator_test.go similarity index 96% rename from pkg/linkrp/processors/validator_test.go rename to pkg/portableresources/processors/validator_test.go index 3a7203641f..3eef229781 100644 --- a/pkg/linkrp/processors/validator_test.go +++ b/pkg/portableresources/processors/validator_test.go @@ -19,12 +19,11 @@ package processors import ( "testing" - "github.com/project-radius/radius/pkg/linkrp" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/portableresources" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) @@ -92,7 +91,7 @@ func Test_Validator_SetAndValidate_OutputResources(t *testing.T) { values := map[string]any{} secrets := map[string]rpv1.SecretValueReference{} - var resources *[]*linkrp.ResourceReference + var resources *[]*portableresources.ResourceReference v := NewValidator(&values, &secrets, &outputResources) v.AddResourcesField(resources) @@ -107,7 +106,7 @@ func Test_Validator_SetAndValidate_OutputResources(t *testing.T) { values := map[string]any{} secrets := map[string]rpv1.SecretValueReference{} - resources := []*linkrp.ResourceReference{} + resources := []*portableresources.ResourceReference{} v := NewValidator(&values, &secrets, &outputResources) v.AddResourcesField(&resources) @@ -134,7 +133,7 @@ func Test_Validator_SetAndValidate_OutputResources(t *testing.T) { values := map[string]any{} secrets := map[string]rpv1.SecretValueReference{} - resources := []*linkrp.ResourceReference{{ID: "////invalid//////"}} + resources := []*portableresources.ResourceReference{{ID: "////invalid//////"}} v := NewValidator(&values, &secrets, &outputResources) v.AddResourcesField(&resources) @@ -168,7 +167,7 @@ func Test_Validator_SetAndValidate_OutputResources(t *testing.T) { values := map[string]any{} secrets := map[string]rpv1.SecretValueReference{} - resourcesField := []*linkrp.ResourceReference{ + resourcesField := []*portableresources.ResourceReference{ { ID: "/planes/aws/aws/accounts/1234/regions/us-west-1/providers/AWS.Kinesis/Stream/my-stream1", }, @@ -178,12 +177,6 @@ func Test_Validator_SetAndValidate_OutputResources(t *testing.T) { Resources: []string{"/planes/aws/aws/accounts/1234/regions/us-west-1/providers/AWS.Kinesis/Stream/my-stream2"}, } - mustparse := func(id string) resources.ID { - parsed, err := resources.ParseResource(id) - require.NoError(t, err) - return parsed - } - v := NewValidator(&values, &secrets, &outputResources) v.AddResourcesField(&resourcesField) @@ -192,15 +185,11 @@ func Test_Validator_SetAndValidate_OutputResources(t *testing.T) { expected := []rpv1.OutputResource{ { - LocalID: "RecipeResource0", - Identity: resourcemodel.FromUCPID(mustparse(output.Resources[0]), ""), - ResourceType: *resourcemodel.FromUCPID(mustparse(output.Resources[0]), "").ResourceType, + ID: resources.MustParse(output.Resources[0]), RadiusManaged: to.Ptr(true), }, { - LocalID: "Resource0", - Identity: resourcemodel.FromUCPID(mustparse(resourcesField[0].ID), ""), - ResourceType: *resourcemodel.FromUCPID(mustparse(resourcesField[0].ID), "").ResourceType, + ID: resources.MustParse(resourcesField[0].ID), RadiusManaged: to.Ptr(false), }, } diff --git a/pkg/linkrp/renderers/dapr/generic.go b/pkg/portableresources/renderers/dapr/generic.go similarity index 93% rename from pkg/linkrp/renderers/dapr/generic.go rename to pkg/portableresources/renderers/dapr/generic.go index a4ded7639e..4fe26dbc9c 100644 --- a/pkg/linkrp/renderers/dapr/generic.go +++ b/pkg/portableresources/renderers/dapr/generic.go @@ -19,8 +19,8 @@ package dapr import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/kubernetes" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/kubernetes" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) @@ -66,8 +66,8 @@ func ConstructDaprGeneric(daprGeneric DaprGeneric, namespace string, componentNa // Translate into Dapr State Store schema item := unstructured.Unstructured{ Object: map[string]any{ - "apiVersion": "dapr.io/v1alpha1", - "kind": "Component", + "apiVersion": DaprAPIVersion, + "kind": DaprKind, "metadata": map[string]any{ "namespace": namespace, "name": kubernetes.NormalizeDaprResourceName(componentName), diff --git a/pkg/portableresources/renderers/dapr/types.go b/pkg/portableresources/renderers/dapr/types.go new file mode 100644 index 0000000000..c5819752f7 --- /dev/null +++ b/pkg/portableresources/renderers/dapr/types.go @@ -0,0 +1,22 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package dapr + +const ( + DaprAPIVersion = "dapr.io/v1alpha1" + DaprKind = "Component" +) diff --git a/pkg/linkrp/renderers/types.go b/pkg/portableresources/renderers/types.go similarity index 100% rename from pkg/linkrp/renderers/types.go rename to pkg/portableresources/renderers/types.go diff --git a/pkg/portableresources/types.go b/pkg/portableresources/types.go new file mode 100644 index 0000000000..c77c2c268c --- /dev/null +++ b/pkg/portableresources/types.go @@ -0,0 +1,149 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package portableresources + +import ( + "strings" +) + +const ( + // DaprPubSubBrokersResourceType represents the resource type for Dapr PubSub brokers. + DaprPubSubBrokersResourceType = "Applications.Dapr/pubSubBrokers" + + // DaprSecretStoresResourceType represents the resource type for Dapr Secret stores. + DaprSecretStoresResourceType = "Applications.Dapr/secretStores" + + // DaprStateStoresResourceType represents the resource type for Dapr State stores. + DaprStateStoresResourceType = "Applications.Dapr/stateStores" + + // RabbitMQQueuesResourceType represents the resource type for RabbitMQ queue. + RabbitMQQueuesResourceType = "Applications.Messaging/rabbitMQQueues" + + // MongoDatabasesResourceType represents the resource type for Mongo database. + MongoDatabasesResourceType = "Applications.Datastores/mongoDatabases" + + // RedisCachesResourceType represents the resource type for Redis caches. + RedisCachesResourceType = "Applications.Datastores/redisCaches" + + // SqlDatabasesResourceType represents the resource type for SQL databases. + SqlDatabasesResourceType = "Applications.Datastores/sqlDatabases" + + // ExtendersResourceType represents the resource type for Extenders resource. + ExtendersResourceType = "Applications.Core/extenders" + + // ResourceProvisioningRecipe is the scenario when Radius manages the lifecycle of the resource through a Recipe. + ResourceProvisioningRecipe ResourceProvisioning = "recipe" + + // ResourceProvisioningManual is the scenario where the user manages the resource and provides values. + ResourceProvisioningManual ResourceProvisioning = "manual" + + // DefaultRecipeName represents the default recipe name. + DefaultRecipeName = "default" +) + +type RecipeData struct { + RecipeProperties + + // APIVersion is the API version to use to perform operations on resources. + // For example for Azure resources, every service has different REST API version that must be specified in the request. + APIVersion string + + // Resource ids of the resources deployed by the recipe + Resources []string +} + +// RecipeProperties represents the information needed to deploy a recipe +type RecipeProperties struct { + ResourceRecipe // ResourceRecipe is the recipe of the resource to be deployed + ResourceType string // ResourceType represent the type of the resource + TemplatePath string // TemplatePath represent the recipe location + EnvParameters map[string]any // EnvParameters represents the parameters set by the operator while linking the recipe to an environment +} + +// ResourceRecipe is the recipe details used to automatically deploy underlying infrastructure for a resource. +type ResourceRecipe struct { + // Name of the recipe within the environment to use + Name string `json:"name,omitempty"` + // Parameters are key/value parameters to pass into the recipe at deployment + Parameters map[string]any `json:"parameters,omitempty"` +} + +// ResourceReference represents a reference to a resource that was deployed by the user +// and specified as part of a portable resource. +// +// This type should be used in datamodels for the '.properties.resources' field. +type ResourceReference struct { + ID string `json:"id"` +} + +// RecipeContext Recipe template authors can leverage the RecipeContext parameter to access portable resource properties to +// generate name and properties that are unique for the resource calling the recipe. +type RecipeContext struct { + Resource Resource `json:"resource,omitempty"` + Application ResourceInfo `json:"application,omitempty"` + Environment ResourceInfo `json:"environment,omitempty"` + Runtime Runtime `json:"runtime,omitempty"` +} + +// Resource contains the information needed to deploy a recipe. +// In the case the resource is a portable resource, it represents the resource's id, name and type. +type Resource struct { + ResourceInfo + Type string `json:"type"` +} + +// ResourceInfo name and id of the resource +type ResourceInfo struct { + Name string `json:"name"` + ID string `json:"id"` +} + +type Runtime struct { + Kubernetes Kubernetes `json:"kubernetes,omitempty"` +} + +// ResourceProvisioning specifies how the resource should be managed +type ResourceProvisioning string + +type Kubernetes struct { + // Namespace is set to the applicationNamespace when the portable resource is application-scoped, and set to the environmentNamespace when it is environment scoped + Namespace string `json:"namespace"` + // EnvironmentNamespace is set to environment namespace. + EnvironmentNamespace string `json:"environmentNamespace"` +} + +// IsValidPortableResourceType checks if the provided resource type is a valid portable resource type. +// Returns true if the resource type is valid, false otherwise. +func IsValidPortableResourceType(resourceType string) bool { + portableResourceTypes := []string{ + DaprPubSubBrokersResourceType, + DaprSecretStoresResourceType, + DaprStateStoresResourceType, + RabbitMQQueuesResourceType, + MongoDatabasesResourceType, + RedisCachesResourceType, + SqlDatabasesResourceType, + ExtendersResourceType, + } + for _, s := range portableResourceTypes { + if strings.EqualFold(s, resourceType) { + return true + } + } + + return false +} diff --git a/pkg/portableresources/types_test.go b/pkg/portableresources/types_test.go new file mode 100644 index 0000000000..1a1a0b65ce --- /dev/null +++ b/pkg/portableresources/types_test.go @@ -0,0 +1,33 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package portableresources + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestValidPortableResourceType(t *testing.T) { + isValid := IsValidPortableResourceType("Applications.Datastores/mongoDatabases") + require.Equal(t, true, isValid) +} + +func TestInvalidPortableResourceType(t *testing.T) { + isValid := IsValidPortableResourceType("Applications.Dapr/pubSubBroker") + require.Equal(t, false, isValid) +} diff --git a/pkg/profiler/service/hostoptions.go b/pkg/profiler/service/hostoptions.go index 5947a721f5..795ac7d334 100644 --- a/pkg/profiler/service/hostoptions.go +++ b/pkg/profiler/service/hostoptions.go @@ -17,8 +17,8 @@ limitations under the License. package profilerservice import ( - "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/profiler/provider" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/profiler/provider" ) type HostOptions struct { diff --git a/pkg/profiler/service/service.go b/pkg/profiler/service/service.go index 7b362075fd..96a7668d70 100644 --- a/pkg/profiler/service/service.go +++ b/pkg/profiler/service/service.go @@ -23,7 +23,7 @@ import ( "net/http" "strconv" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) type Service struct { diff --git a/pkg/recipes/configloader/environment.go b/pkg/recipes/configloader/environment.go index 4493d98060..f30b573ee1 100644 --- a/pkg/recipes/configloader/environment.go +++ b/pkg/recipes/configloader/environment.go @@ -22,20 +22,20 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/rp/kube" - "github.com/project-radius/radius/pkg/rp/util" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/rp/kube" + "github.com/radius-project/radius/pkg/rp/util" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" ) var ( ErrUnsupportedComputeKind = errors.New("unsupported compute kind in environment resource") ) -//go:generate mockgen -destination=./mock_config_loader.go -package=configloader -self_package github.com/project-radius/radius/pkg/recipes/configloader github.com/project-radius/radius/pkg/recipes/configloader ConfigurationLoader +//go:generate mockgen -destination=./mock_config_loader.go -package=configloader -self_package github.com/radius-project/radius/pkg/recipes/configloader github.com/radius-project/radius/pkg/recipes/configloader ConfigurationLoader var _ ConfigurationLoader = (*environmentLoader)(nil) @@ -139,10 +139,10 @@ func getRecipeDefinition(environment *v20220315privatepreview.EnvironmentResourc definition := &recipes.EnvironmentDefinition{ Name: recipeName, - Driver: *found.GetEnvironmentRecipeProperties().TemplateKind, + Driver: *found.GetRecipeProperties().TemplateKind, ResourceType: resource.Type(), - Parameters: found.GetEnvironmentRecipeProperties().Parameters, - TemplatePath: *found.GetEnvironmentRecipeProperties().TemplatePath, + Parameters: found.GetRecipeProperties().Parameters, + TemplatePath: *found.GetRecipeProperties().TemplatePath, } switch c := found.(type) { case *v20220315privatepreview.TerraformRecipeProperties: diff --git a/pkg/recipes/configloader/environment_test.go b/pkg/recipes/configloader/environment_test.go index 93889e899d..6e0623eefc 100644 --- a/pkg/recipes/configloader/environment_test.go +++ b/pkg/recipes/configloader/environment_test.go @@ -19,10 +19,10 @@ package configloader import ( "testing" - model "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/to" + model "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/to" "github.com/stretchr/testify/require" ) @@ -34,8 +34,8 @@ const ( appResourceId = "/subscriptions/test-sub/resourceGroups/test-group/providers/Applications.Core/applications/app0" azureScope = "/subscriptions/test-sub/resourceGroups/testRG" awsScope = "/planes/aws/aws/accounts/000/regions/cool-region" - mongoResourceID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0" - redisID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/redisCaches/redis-0" + mongoResourceID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0" + redisID = "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/redisCaches/redis-0" recipeName = "cosmosDB" terraformRecipe = "terraform-cosmosDB" @@ -220,8 +220,8 @@ func TestGetRecipeDefinition(t *testing.T) { Scope: to.Ptr(azureScope), }, }, - Recipes: map[string]map[string]model.EnvironmentRecipePropertiesClassification{ - "Applications.Link/mongoDatabases": { + Recipes: map[string]map[string]model.RecipePropertiesClassification{ + "Applications.Datastores/mongoDatabases": { recipeName: &model.BicepRecipeProperties{ TemplateKind: to.Ptr(recipes.TemplateKindBicep), TemplatePath: to.Ptr("radiusdev.azurecr.io/recipes/mongodatabases/azure:1.0"), @@ -264,7 +264,7 @@ func TestGetRecipeDefinition(t *testing.T) { expected := recipes.EnvironmentDefinition{ Name: recipeName, Driver: recipes.TemplateKindBicep, - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", TemplatePath: "radiusdev.azurecr.io/recipes/mongodatabases/azure:1.0", Parameters: map[string]any{ "foo": "bar", @@ -279,7 +279,7 @@ func TestGetRecipeDefinition(t *testing.T) { expected := recipes.EnvironmentDefinition{ Name: terraformRecipe, Driver: recipes.TemplateKindTerraform, - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", TemplatePath: "Azure/cosmosdb/azurerm", TemplateVersion: "1.1.0", } diff --git a/pkg/recipes/configloader/mock_config_loader.go b/pkg/recipes/configloader/mock_config_loader.go index 32976c77c1..59fcd47027 100644 --- a/pkg/recipes/configloader/mock_config_loader.go +++ b/pkg/recipes/configloader/mock_config_loader.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/recipes/configloader (interfaces: ConfigurationLoader) +// Source: github.com/radius-project/radius/pkg/recipes/configloader (interfaces: ConfigurationLoader) // Package configloader is a generated GoMock package. package configloader @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - recipes "github.com/project-radius/radius/pkg/recipes" + recipes "github.com/radius-project/radius/pkg/recipes" ) // MockConfigurationLoader is a mock of ConfigurationLoader interface. diff --git a/pkg/recipes/configloader/types.go b/pkg/recipes/configloader/types.go index 20ed8e3cb1..861196690d 100644 --- a/pkg/recipes/configloader/types.go +++ b/pkg/recipes/configloader/types.go @@ -19,7 +19,7 @@ package configloader import ( "context" - "github.com/project-radius/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes" ) type ConfigurationLoader interface { diff --git a/pkg/recipes/controllerconfig/config.go b/pkg/recipes/controllerconfig/config.go new file mode 100644 index 0000000000..e40b93cf87 --- /dev/null +++ b/pkg/recipes/controllerconfig/config.go @@ -0,0 +1,85 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controllerconfig + +import ( + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/configloader" + "github.com/radius-project/radius/pkg/recipes/driver" + "github.com/radius-project/radius/pkg/recipes/engine" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/sdk/clients" + "github.com/radius-project/radius/pkg/ucp/secret/provider" +) + +// RecipeControllerConfig is the configuration for the controllers which uses recipe. +type RecipeControllerConfig struct { + // K8sClients is the collections of Kubernetes clients. + K8sClients *kubeutil.Clients + + // ResourceClient is a client used by resource processors for interacting with UCP resources. + ResourceClient processors.ResourceClient + + // ConfigLoader is the configuration loader. + ConfigLoader configloader.ConfigurationLoader + + // DeploymentEngineClient is the client for interacting with the deployment engine. + DeploymentEngineClient *clients.ResourceDeploymentsClient + + // Engine is the engine for executing recipes. + Engine engine.Engine +} + +// New creates a new RecipeControllerConfig instance with the given host options. +func New(options hostoptions.HostOptions) (*RecipeControllerConfig, error) { + cfg := &RecipeControllerConfig{} + var err error + cfg.K8sClients, err = kubeutil.NewClients(options.K8sConfig) + if err != nil { + return nil, err + } + + cfg.ResourceClient = processors.NewResourceClient(options.Arm, options.UCPConnection, cfg.K8sClients.RuntimeClient, cfg.K8sClients.DiscoveryClient) + clientOptions := sdk.NewClientOptions(options.UCPConnection) + + cfg.DeploymentEngineClient, err = clients.NewResourceDeploymentsClient(&clients.Options{ + Cred: &aztoken.AnonymousCredential{}, + BaseURI: options.UCPConnection.Endpoint(), + ARMClientOptions: sdk.NewClientOptions(options.UCPConnection), + }) + if err != nil { + return nil, err + } + + cfg.ConfigLoader = configloader.NewEnvironmentLoader(clientOptions) + cfg.Engine = engine.NewEngine(engine.Options{ + ConfigurationLoader: cfg.ConfigLoader, + Drivers: map[string]driver.Driver{ + recipes.TemplateKindBicep: driver.NewBicepDriver(clientOptions, cfg.DeploymentEngineClient, cfg.ResourceClient), + recipes.TemplateKindTerraform: driver.NewTerraformDriver(options.UCPConnection, provider.NewSecretProvider(options.Config.SecretProvider), + driver.TerraformOptions{ + Path: options.Config.Terraform.Path, + }, cfg.K8sClients.ClientSet), + }, + }) + + return cfg, nil +} diff --git a/pkg/recipes/driver/bicep.go b/pkg/recipes/driver/bicep.go index 151cbe2a7e..45fde7c048 100644 --- a/pkg/recipes/driver/bicep.go +++ b/pkg/recipes/driver/bicep.go @@ -27,22 +27,22 @@ import ( deployments "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/go-logr/logr" - "github.com/project-radius/radius/pkg/linkrp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/metrics" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/recipecontext" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/rp/util" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - clients "github.com/project-radius/radius/pkg/sdk/clients" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" - - coredm "github.com/project-radius/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/metrics" + "github.com/radius-project/radius/pkg/portableresources/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/recipecontext" + "github.com/radius-project/radius/pkg/rp/util" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + clients "github.com/radius-project/radius/pkg/sdk/clients" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" + "github.com/radius-project/radius/pkg/ucp/ucplog" + + coredm "github.com/radius-project/radius/pkg/corerp/datamodel" ) -//go:generate mockgen -destination=./mock_driver.go -package=driver -self_package github.com/project-radius/radius/pkg/recipes/driver github.com/project-radius/radius/pkg/recipes/driver Driver +//go:generate mockgen -destination=./mock_driver.go -package=driver -self_package github.com/radius-project/radius/pkg/recipes/driver github.com/radius-project/radius/pkg/recipes/driver Driver const ( deploymentPrefix = "recipe" pollFrequency = time.Second * 5 @@ -53,7 +53,11 @@ var _ Driver = (*bicepDriver)(nil) // NewBicepDriver creates a new bicep driver instance with the given ARM client options, deployment client and resource client. func NewBicepDriver(armOptions *arm.ClientOptions, deploymentClient *clients.ResourceDeploymentsClient, client processors.ResourceClient) Driver { - return &bicepDriver{ArmClientOptions: armOptions, DeploymentClient: deploymentClient, ResourceClient: client} + return &bicepDriver{ + ArmClientOptions: armOptions, + DeploymentClient: deploymentClient, + ResourceClient: client, + } } type bicepDriver struct { @@ -65,40 +69,40 @@ type bicepDriver struct { // Execute fetches recipe contents from container registry, creates a deployment ID, a recipe context parameter, recipe parameters, // a provider config, and deploys a bicep template for the recipe using UCP deployment client, then polls until the deployment // is done and prepares the recipe response. -func (d *bicepDriver) Execute(ctx context.Context, configuration recipes.Configuration, recipe recipes.ResourceMetadata, definition recipes.EnvironmentDefinition) (*recipes.RecipeOutput, error) { +func (d *bicepDriver) Execute(ctx context.Context, opts ExecuteOptions) (*recipes.RecipeOutput, error) { logger := logr.FromContextOrDiscard(ctx) - logger.Info(fmt.Sprintf("Deploying recipe: %q, template: %q", definition.Name, definition.TemplatePath)) + logger.Info(fmt.Sprintf("Deploying recipe: %q, template: %q", opts.Definition.Name, opts.Definition.TemplatePath)) recipeData := make(map[string]any) downloadStartTime := time.Now() - err := util.ReadFromRegistry(ctx, definition.TemplatePath, &recipeData) + err := util.ReadFromRegistry(ctx, opts.Definition.TemplatePath, &recipeData) if err != nil { metrics.DefaultRecipeEngineMetrics.RecordRecipeDownloadDuration(ctx, downloadStartTime, - metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, recipe.Name, &definition, metrics.FailedOperationState)) - return nil, err + metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, opts.Recipe.Name, &opts.Definition, recipes.RecipeDownloadFailed)) + return nil, recipes.NewRecipeError(recipes.RecipeDownloadFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } metrics.DefaultRecipeEngineMetrics.RecordRecipeDownloadDuration(ctx, downloadStartTime, - metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, recipe.Name, &definition, metrics.SuccessfulOperationState)) + metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, opts.Recipe.Name, &opts.Definition, metrics.SuccessfulOperationState)) // create the context object to be passed to the recipe deployment - recipeContext, err := recipecontext.New(&recipe, &configuration) + recipeContext, err := recipecontext.New(&opts.Recipe, &opts.Configuration) if err != nil { - return nil, err + return nil, recipes.NewRecipeError(recipes.RecipeDeploymentFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } // get the parameters after resolving the conflict between developer and operator parameters // if the recipe template also has the context parameter defined then add it to the parameter for deployment isContextParameterDefined := hasContextParameter(recipeData) - parameters := createRecipeParameters(recipe.Parameters, definition.Parameters, isContextParameterDefined, recipeContext) + parameters := createRecipeParameters(opts.Recipe.Parameters, opts.Definition.Parameters, isContextParameterDefined, recipeContext) deploymentName := deploymentPrefix + strconv.FormatInt(time.Now().UnixNano(), 10) deploymentID, err := createDeploymentID(recipeContext.Resource.ID, deploymentName) if err != nil { - return nil, err + return nil, recipes.NewRecipeError(recipes.RecipeDeploymentFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } // Provider config will specify the Azure and AWS scopes (if provided). - providerConfig := newProviderConfig(deploymentID.FindScope(resources.ResourceGroupsSegment), configuration.Providers) + providerConfig := newProviderConfig(deploymentID.FindScope(resources_radius.ScopeResourceGroups), opts.Configuration.Providers) logger.Info("deploying bicep template for recipe", "deploymentID", deploymentID) if providerConfig.AWS != nil { @@ -122,17 +126,29 @@ func (d *bicepDriver) Execute(ctx context.Context, configuration recipes.Configu clients.DeploymentsClientAPIVersion, ) if err != nil { - return nil, err + return nil, recipes.NewRecipeError(recipes.RecipeDeploymentFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } resp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{Frequency: pollFrequency}) if err != nil { - return nil, err + return nil, recipes.NewRecipeError(recipes.RecipeDeploymentFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } recipeResponse, err := d.prepareRecipeResponse(resp.Properties.Outputs, resp.Properties.OutputResources) if err != nil { - return nil, fmt.Errorf("failed to read the recipe output %q: %w", recipes.ResultPropertyName, err) + return nil, recipes.NewRecipeError(recipes.InvalidRecipeOutputs, fmt.Sprintf("failed to read the recipe output %q: %s", recipes.ResultPropertyName, err.Error()), recipes.GetRecipeErrorDetails(err)) + } + + // When a Radius portable resource consuming a recipe is redeployed, Garbage collection of the recipe resources that aren't included + // in the currently deployed resources compared to the list of resources from the previous deployment needs to be deleted + // as bicep does not take care of automatically deleting the unused resources. + // Identify the output resources that are no longer relevant to the recipe. + diff := d.getGCOutputResources(recipeResponse.Resources, opts.PrevState) + + // Deleting obsolete output resources. + err = d.deleteGCOutputResources(ctx, diff) + if err != nil { + return nil, recipes.NewRecipeError(recipes.RecipeGarbageCollectionFailed, err.Error(), nil) } return recipeResponse, nil @@ -140,37 +156,63 @@ func (d *bicepDriver) Execute(ctx context.Context, configuration recipes.Configu // Delete deletes output resources in reverse dependency order, logging each resource deleted and skipping any // resources that are not managed by Radius. It returns an error if any of the resources fail to delete. -func (d *bicepDriver) Delete(ctx context.Context, outputResources []rpv1.OutputResource) error { +func (d *bicepDriver) Delete(ctx context.Context, opts DeleteOptions) error { logger := ucplog.FromContextOrDiscard(ctx) - orderedOutputResources, err := rpv1.OrderOutputResources(outputResources) + orderedOutputResources, err := rpv1.OrderOutputResources(opts.OutputResources) if err != nil { - return err + return recipes.NewRecipeError(recipes.RecipeDeletionFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } // Loop over each output resource and delete in reverse dependency order for i := len(orderedOutputResources) - 1; i >= 0; i-- { outputResource := orderedOutputResources[i] - id := outputResource.Identity.GetID() - if err != nil { - return err - } - logger.Info(fmt.Sprintf("Deleting output resource: %v, LocalID: %s, resource type: %s\n", outputResource.Identity, outputResource.LocalID, outputResource.ResourceType.Type)) + + resourceType := outputResource.GetResourceType() + logger.Info(fmt.Sprintf("Deleting output resource: %v, LocalID: %s, resource type: %s\n", outputResource.ID.String(), outputResource.LocalID, resourceType.Type)) if outputResource.RadiusManaged == nil || !*outputResource.RadiusManaged { continue } - err = d.ResourceClient.Delete(ctx, id, resourcemodel.APIVersionUnknown) + err = d.ResourceClient.Delete(ctx, outputResource.ID.String()) if err != nil { - return err + return recipes.NewRecipeError(recipes.RecipeDeletionFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } - logger.Info(fmt.Sprintf("Deleted output resource: %q", id), ucplog.LogFieldTargetResourceID, id) + logger.Info(fmt.Sprintf("Deleted output resource: %q", outputResource.ID.String()), ucplog.LogFieldTargetResourceID, outputResource.ID.String()) } return nil } +// GetRecipeMetadata gets the Bicep recipe parameters information from the container registry +func (d *bicepDriver) GetRecipeMetadata(ctx context.Context, opts BaseOptions) (map[string]any, error) { + // Recipe parameters can be found in the recipe data pulled from the registry in the following format: + // { + // "parameters": { + // : { + // : + // } + // } + // } + // For example: + // { + // "parameters": { + // "location": { + // "type": "string", + // "defaultValue" : "[resourceGroup().location]" + // } + // } + // } + recipeData := make(map[string]any) + err := util.ReadFromRegistry(ctx, opts.Definition.TemplatePath, &recipeData) + if err != nil { + return nil, err + } + + return recipeData, nil +} + func hasContextParameter(recipeData map[string]any) bool { parametersAny, ok := recipeData[recipeParameters] if !ok { @@ -214,7 +256,7 @@ func createDeploymentID(resourceID string, deploymentName string) (resources.ID, return resources.ID{}, err } - resourceGroup := parsed.FindScope(resources.ResourceGroupsSegment) + resourceGroup := parsed.FindScope(resources_radius.ScopeResourceGroups) return resources.ParseResource(fmt.Sprintf("/planes/radius/local/resourceGroups/%s/providers/Microsoft.Resources/deployments/%s", resourceGroup, deploymentName)) } @@ -274,3 +316,40 @@ func (d *bicepDriver) prepareRecipeResponse(outputs any, resources []*deployment return recipeResponse, nil } + +// getGCOutputResources [GC stands for Garbage Collection] compares two slices of resource ids and +// returns a slice of resource ids that contains the elements that are in the "previous" slice but not in the "current". +func (d *bicepDriver) getGCOutputResources(current []string, previous []string) []string { + // We can easily determine which resources have changed via a brute-force search comparing IDs. + // The lists of resources we work with are small, so this is fine. + diff := []string{} + for _, prevResource := range previous { + found := false + for _, currentResource := range current { + if prevResource == currentResource { + found = true + break + } + } + + if !found { + diff = append(diff, prevResource) + } + } + + return diff +} + +func (d *bicepDriver) deleteGCOutputResources(ctx context.Context, diff []string) error { + logger := ucplog.FromContextOrDiscard(ctx) + for _, resource := range diff { + logger.Info(fmt.Sprintf("Deleting output resource: %s", resource), ucplog.LogFieldTargetResourceID, resource) + err := d.ResourceClient.Delete(ctx, resource) + if err != nil { + return err + } + logger.Info(fmt.Sprintf("Deleted output resource: %s", resource), ucplog.LogFieldTargetResourceID, resource) + } + + return nil +} diff --git a/pkg/recipes/driver/bicep_test.go b/pkg/recipes/driver/bicep_test.go index 36e9a09921..d950813d03 100644 --- a/pkg/recipes/driver/bicep_test.go +++ b/pkg/recipes/driver/bicep_test.go @@ -17,21 +17,23 @@ limitations under the License. package driver import ( + "errors" "fmt" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" gomock "github.com/golang/mock/gomock" - corerp_datamodel "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/linkrp/processors" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/recipecontext" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - clients "github.com/project-radius/radius/pkg/sdk/clients" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/testcontext" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + corerp_datamodel "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/portableresources/processors" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/recipecontext" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + clients "github.com/radius-project/radius/pkg/sdk/clients" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) @@ -83,10 +85,10 @@ func Test_CreateRecipeParameters_WithContextParameter(t *testing.T) { recipeContext := recipecontext.Context{ Resource: recipecontext.Resource{ ResourceInfo: recipecontext.ResourceInfo{ - ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", Name: "mongo0", }, - Type: "Applications.Link/mongoDatabases", + Type: "Applications.Datastores/mongoDatabases", }, Application: recipecontext.ResourceInfo{ ID: "/subscriptions/test-sub/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", @@ -131,10 +133,10 @@ func Test_CreateRecipeParameters_EmptyResourceParameters(t *testing.T) { recipeContext := recipecontext.Context{ Resource: recipecontext.Resource{ ResourceInfo: recipecontext.ResourceInfo{ - ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", Name: "mongo0", }, - Type: "Applications.Link/mongoDatabases", + Type: "Applications.Datastores/mongoDatabases", }, Application: recipecontext.ResourceInfo{ ID: "/subscriptions/test-sub/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", @@ -183,10 +185,10 @@ func Test_CreateRecipeParameters_ResourceAndEnvParameters(t *testing.T) { recipeContext := recipecontext.Context{ Resource: recipecontext.Resource{ ResourceInfo: recipecontext.ResourceInfo{ - ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", Name: "mongo0", }, - Type: "Applications.Link/mongoDatabases", + Type: "Applications.Datastores/mongoDatabases", }, Application: recipecontext.ResourceInfo{ ID: "/subscriptions/test-sub/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", @@ -226,7 +228,7 @@ func Test_createDeploymentID(t *testing.T) { expected, err := resources.ParseResource("/planes/radius/local/resourceGroups/cool-group/providers/Microsoft.Resources/deployments/test-deployment") require.NoError(t, err) - actual, err := createDeploymentID("/planes/radius/local/resourceGroups/cool-group/providers/Applications.Link/mongoDatabases/test-db", "test-deployment") + actual, err := createDeploymentID("/planes/radius/local/resourceGroups/cool-group/providers/Applications.Datastores/mongoDatabases/test-db", "test-deployment") require.NoError(t, err) require.Equal(t, expected, actual) } @@ -368,41 +370,31 @@ func Test_Bicep_Delete_Success(t *testing.T) { outputResources := []rpv1.OutputResource{ { LocalID: "RecipeResource0", - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: "Service", - Provider: "kubernetes", - }, - Data: map[string]any{ - "apiVersion": "apps/unknown", - "kind": "Deployment", - "name": "redis", - "namespace": "recipe-app", - }, - }, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "apps", + "Deployment", + "recipe-app", + "redis"), RadiusManaged: to.Ptr(true), }, { LocalID: "RecipeResource1", - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: "Service", - Provider: "kubernetes", - }, - Data: map[string]any{ - "apiVersion": "apps/unknown", - "kind": "Deployment", - "name": "redis", - "namespace": "recipe-app", - }, - }, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "", + "Service", + "recipe-app", + "redis"), // We don't expect a call to delete to be made when RadiusManaged is false. RadiusManaged: to.Ptr(false), }, } - client.EXPECT().Delete(ctx, "/planes/kubernetes/local/namespaces/recipe-app/providers/apps/Deployment/redis", resourcemodel.APIVersionUnknown).Times(1).Return(nil) + client.EXPECT().Delete(ctx, "/planes/kubernetes/local/namespaces/recipe-app/providers/apps/Deployment/redis").Times(1).Return(nil) - err := driver.Delete(ctx, outputResources) + err := driver.Delete(ctx, DeleteOptions{ + OutputResources: outputResources, + }) require.NoError(t, err) } @@ -411,24 +403,137 @@ func Test_Bicep_Delete_Error(t *testing.T) { driver, client := setupDeleteInputs(t) outputResources := []rpv1.OutputResource{ { - LocalID: "RecipeResource0", - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: "KubernetesService", - Provider: "kubernetes", - }, - Data: map[string]any{ - "apiVersion": "invalid api versionn", - "kind": "Deployment", - "name": "redis", - "namespace": "recipe-app", - }, - }, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "core", + "Deployment", + "recipe-app", + "redis"), RadiusManaged: to.Ptr(true), }, } - client.EXPECT().Delete(ctx, "/planes/kubernetes/local/namespaces/recipe-app/providers/core/Deployment/redis", resourcemodel.APIVersionUnknown).Times(1).Return(fmt.Errorf("could not find API version for type %q, no supported API versions", outputResources[0].Identity.ResourceType.Type)) + recipeError := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.RecipeDeletionFailed, + Message: fmt.Sprintf("could not find API version for type %q, no supported API versions", outputResources[0].GetResourceType().Type), + }, + } + client.EXPECT(). + Delete(ctx, "/planes/kubernetes/local/namespaces/recipe-app/providers/core/Deployment/redis"). + Return(fmt.Errorf("could not find API version for type %q, no supported API versions", outputResources[0].GetResourceType().Type)). + Times(1) + + err := driver.Delete(ctx, DeleteOptions{ + OutputResources: outputResources, + }) + require.Error(t, err) + require.Equal(t, err, &recipeError) +} + +func Test_Bicep_GetRecipeMetadata_Success(t *testing.T) { + ctx := testcontext.New(t) + driver := bicepDriver{} + recipeDefinition := recipes.EnvironmentDefinition{ + Name: "mongo-azure", + Driver: recipes.TemplateKindBicep, + TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/parameters/mongodatabases/azure:1.0", + ResourceType: "Applications.Datastores/mongoDatabases", + } + + expectedOutput := map[string]any{ + "documentdbName": map[string]any{"type": "string"}, + "location": map[string]any{"defaultValue": "[resourceGroup().location]", "type": "string"}, + "mongodbName": map[string]any{"type": "string"}, + } + + recipeData, err := driver.GetRecipeMetadata(ctx, BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: recipeDefinition, + }) + + require.NoError(t, err) + require.Equal(t, expectedOutput, recipeData["parameters"]) +} + +func Test_Bicep_GetRecipeMetadata_Error(t *testing.T) { + ctx := testcontext.New(t) + driver := bicepDriver{} + recipeDefinition := recipes.EnvironmentDefinition{ + Name: "mongo-azure", + Driver: recipes.TemplateKindBicep, + TemplatePath: "radiusdev.azurecr.io/test-non-existent-recipe", + ResourceType: "Applications.Datastores/mongoDatabases", + } + + _, err := driver.GetRecipeMetadata(ctx, BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: recipeDefinition, + }) + expErr := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.RecipeLanguageFailure, + Message: "failed to fetch repository from the path \"radiusdev.azurecr.io/test-non-existent-recipe\": radiusdev.azurecr.io/test-non-existent-recipe:latest: not found", + }, + } - err := driver.Delete(ctx, outputResources) require.Error(t, err) + require.Equal(t, err, &expErr) +} + +func Test_GetGCOutputResources(t *testing.T) { + d := &bicepDriver{} + before := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource1", + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource2", + } + after := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource1", + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource3", + } + exp := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource2", + } + res := d.getGCOutputResources(after, before) + require.Equal(t, exp, res) +} + +func Test_DeleteGCOutputResources(t *testing.T) { + ctx := testcontext.New(t) + driver, client := setupDeleteInputs(t) + tests := []struct { + desc string + err error + gcOutputResources []string + }{ + { + desc: "success", + err: nil, + gcOutputResources: []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource1", + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource2", + }, + }, + { + desc: "deletion failed", + err: errors.New("test-error"), + gcOutputResources: []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/resource1", + }, + }, + } + for _, tt := range tests { + for _, resource := range tt.gcOutputResources { + client.EXPECT(). + Delete(ctx, resource). + Return(tt.err). + Times(1) + } + err := driver.deleteGCOutputResources(ctx, tt.gcOutputResources) + if tt.err != nil { + require.Equal(t, err, tt.err) + } else { + require.NoError(t, err) + } + } + } diff --git a/pkg/recipes/driver/mock_driver.go b/pkg/recipes/driver/mock_driver.go index 459b97e431..4eb4ca869b 100644 --- a/pkg/recipes/driver/mock_driver.go +++ b/pkg/recipes/driver/mock_driver.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/recipes/driver (interfaces: Driver) +// Source: github.com/radius-project/radius/pkg/recipes/driver (interfaces: Driver) // Package driver is a generated GoMock package. package driver @@ -9,8 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - recipes "github.com/project-radius/radius/pkg/recipes" - v1 "github.com/project-radius/radius/pkg/rp/v1" + recipes "github.com/radius-project/radius/pkg/recipes" ) // MockDriver is a mock of Driver interface. @@ -37,7 +36,7 @@ func (m *MockDriver) EXPECT() *MockDriverMockRecorder { } // Delete mocks base method. -func (m *MockDriver) Delete(arg0 context.Context, arg1 []v1.OutputResource) error { +func (m *MockDriver) Delete(arg0 context.Context, arg1 DeleteOptions) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", arg0, arg1) ret0, _ := ret[0].(error) @@ -51,16 +50,31 @@ func (mr *MockDriverMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { } // Execute mocks base method. -func (m *MockDriver) Execute(arg0 context.Context, arg1 recipes.Configuration, arg2 recipes.ResourceMetadata, arg3 recipes.EnvironmentDefinition) (*recipes.RecipeOutput, error) { +func (m *MockDriver) Execute(arg0 context.Context, arg1 ExecuteOptions) (*recipes.RecipeOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Execute", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "Execute", arg0, arg1) ret0, _ := ret[0].(*recipes.RecipeOutput) ret1, _ := ret[1].(error) return ret0, ret1 } // Execute indicates an expected call of Execute. -func (mr *MockDriverMockRecorder) Execute(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockDriverMockRecorder) Execute(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Execute", reflect.TypeOf((*MockDriver)(nil).Execute), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Execute", reflect.TypeOf((*MockDriver)(nil).Execute), arg0, arg1) +} + +// GetRecipeMetadata mocks base method. +func (m *MockDriver) GetRecipeMetadata(arg0 context.Context, arg1 BaseOptions) (map[string]interface{}, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetRecipeMetadata", arg0, arg1) + ret0, _ := ret[0].(map[string]interface{}) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRecipeMetadata indicates an expected call of GetRecipeMetadata. +func (mr *MockDriverMockRecorder) GetRecipeMetadata(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRecipeMetadata", reflect.TypeOf((*MockDriver)(nil).GetRecipeMetadata), arg0, arg1) } diff --git a/pkg/recipes/driver/terraform.go b/pkg/recipes/driver/terraform.go index a95445943f..cc0cbb6639 100644 --- a/pkg/recipes/driver/terraform.go +++ b/pkg/recipes/driver/terraform.go @@ -24,15 +24,14 @@ import ( "path/filepath" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/recipes" - - "github.com/project-radius/radius/pkg/recipes/terraform" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/sdk" - ucp_provider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "github.com/project-radius/radius/pkg/ucp/util" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/recipes" + + "github.com/radius-project/radius/pkg/recipes/terraform" + "github.com/radius-project/radius/pkg/sdk" + ucp_provider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/util" "k8s.io/client-go/kubernetes" tfjson "github.com/hashicorp/terraform-json" @@ -42,7 +41,10 @@ var _ Driver = (*terraformDriver)(nil) // NewTerraformDriver creates a new instance of driver to execute a Terraform recipe. func NewTerraformDriver(ucpConn sdk.Connection, secretProvider *ucp_provider.SecretProvider, options TerraformOptions, k8sClientSet kubernetes.Interface) Driver { - return &terraformDriver{terraformExecutor: terraform.NewExecutor(ucpConn, secretProvider, k8sClientSet), options: options} + return &terraformDriver{ + terraformExecutor: terraform.NewExecutor(ucpConn, secretProvider, k8sClientSet), + options: options, + } } // Options represents the options required for execution of Terraform driver. @@ -62,30 +64,12 @@ type terraformDriver struct { // Execute creates a unique directory for each execution of terraform and deploys the recipe using the // the Terraform CLI through terraform-exec. It returns a RecipeOutput or an error if the deployment fails. -func (d *terraformDriver) Execute(ctx context.Context, configuration recipes.Configuration, recipe recipes.ResourceMetadata, definition recipes.EnvironmentDefinition) (*recipes.RecipeOutput, error) { +func (d *terraformDriver) Execute(ctx context.Context, opts ExecuteOptions) (*recipes.RecipeOutput, error) { logger := ucplog.FromContextOrDiscard(ctx) - if d.options.Path == "" { - return nil, errors.New("path is a required option for Terraform driver") - } - - // We need a unique directory per execution of terraform. We generate this using the unique operation id of the async request so that names are always unique, - // but we can also trace them to the resource we were working on through operationID. - dirID := "" - armCtx := v1.ARMRequestContextFromContext(ctx) - if armCtx.OperationID != uuid.Nil { - dirID = armCtx.OperationID.String() - } else { - // If the operationID is nil, we generate a new UUID for unique directory name combined with resource id so that we can trace it to the resource. - // Ideally operationID should not be nil. - logger.Info("Empty operation ID provided in the request context, using uuid to generate a unique directory name") - dirID = util.NormalizeStringToLower(recipe.ResourceID) + "/" + uuid.NewString() - } - requestDirPath := filepath.Join(d.options.Path, dirID) - - logger.Info(fmt.Sprintf("Deploying terraform recipe: %q, template: %q, execution directory: %q", recipe.Name, definition.TemplatePath, requestDirPath)) - if err := os.MkdirAll(requestDirPath, 0755); err != nil { - return nil, fmt.Errorf("failed to create directory %q to execute terraform: %w", requestDirPath, err) + requestDirPath, err := d.createExecutionDirectory(ctx, opts.Recipe, opts.Definition) + if err != nil { + return nil, recipes.NewRecipeError(recipes.RecipeDeploymentFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } defer func() { if err := os.RemoveAll(requestDirPath); err != nil { @@ -95,26 +79,47 @@ func (d *terraformDriver) Execute(ctx context.Context, configuration recipes.Con tfState, err := d.terraformExecutor.Deploy(ctx, terraform.Options{ RootDir: requestDirPath, - EnvConfig: &configuration, - ResourceRecipe: &recipe, - EnvRecipe: &definition, + EnvConfig: &opts.Configuration, + ResourceRecipe: &opts.Recipe, + EnvRecipe: &opts.Definition, }) if err != nil { - return nil, err + return nil, recipes.NewRecipeError(recipes.RecipeDeploymentFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) } recipeOutputs, err := d.prepareRecipeResponse(tfState) if err != nil { - return nil, err + return nil, recipes.NewRecipeError(recipes.InvalidRecipeOutputs, fmt.Sprintf("failed to read the recipe output %q: %s", recipes.ResultPropertyName, err.Error()), recipes.GetRecipeErrorDetails(err)) } return recipeOutputs, nil } // Delete returns an error if called as it is not yet implemented. -func (d *terraformDriver) Delete(ctx context.Context, outputResources []rpv1.OutputResource) error { - // TODO: to be implemented in follow up PR - return errors.New("terraform delete support is not implemented yet") +func (d *terraformDriver) Delete(ctx context.Context, opts DeleteOptions) error { + logger := ucplog.FromContextOrDiscard(ctx) + + requestDirPath, err := d.createExecutionDirectory(ctx, opts.Recipe, opts.Definition) + if err != nil { + return recipes.NewRecipeError(recipes.RecipeDeletionFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) + } + defer func() { + if err := os.RemoveAll(requestDirPath); err != nil { + logger.Info(fmt.Sprintf("Failed to cleanup Terraform execution directory %q. Err: %s", requestDirPath, err.Error())) + } + }() + + err = d.terraformExecutor.Delete(ctx, terraform.Options{ + RootDir: requestDirPath, + EnvConfig: &opts.Configuration, + ResourceRecipe: &opts.Recipe, + EnvRecipe: &opts.Definition, + }) + if err != nil { + return recipes.NewRecipeError(recipes.RecipeDeletionFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) + } + + return nil } // prepareRecipeResponse populates the recipe response from the module output named "result" and the @@ -138,3 +143,59 @@ func (d *terraformDriver) prepareRecipeResponse(tfState *tfjson.State) (*recipes return recipeResponse, nil } + +// createExecutionDirectory creates a unique directory for each execution of terraform. +func (d *terraformDriver) createExecutionDirectory(ctx context.Context, recipe recipes.ResourceMetadata, definition recipes.EnvironmentDefinition) (string, error) { + logger := ucplog.FromContextOrDiscard(ctx) + + if d.options.Path == "" { + return "", fmt.Errorf("path is a required option for Terraform driver") + } + + // We need a unique directory per execution of terraform. We generate this using the unique operation id of the async request so that names are always unique, + // but we can also trace them to the resource we were working on through operationID. + dirID := "" + armCtx := v1.ARMRequestContextFromContext(ctx) + if armCtx.OperationID != uuid.Nil { + dirID = armCtx.OperationID.String() + } else { + // If the operationID is nil, we generate a new UUID for unique directory name combined with resource id so that we can trace it to the resource. + // Ideally operationID should not be nil. + logger.Info("Empty operation ID provided in the request context, using uuid to generate a unique directory name") + dirID = util.NormalizeStringToLower(recipe.ResourceID) + "/" + uuid.NewString() + } + requestDirPath := filepath.Join(d.options.Path, dirID) + + logger.Info(fmt.Sprintf("Deploying terraform recipe: %q, template: %q, execution directory: %q", recipe.Name, definition.TemplatePath, requestDirPath)) + if err := os.MkdirAll(requestDirPath, 0755); err != nil { + return "", fmt.Errorf("failed to create directory %q to execute terraform: %s", requestDirPath, err.Error()) + } + + return requestDirPath, nil +} + +// GetRecipeMetadata returns the Terraform Recipe parameters by downloading the module and retrieving variable information +func (d *terraformDriver) GetRecipeMetadata(ctx context.Context, opts BaseOptions) (map[string]any, error) { + logger := ucplog.FromContextOrDiscard(ctx) + + requestDirPath, err := d.createExecutionDirectory(ctx, opts.Recipe, opts.Definition) + if err != nil { + return nil, recipes.NewRecipeError(recipes.RecipeGetMetadataFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) + } + defer func() { + if err := os.RemoveAll(requestDirPath); err != nil { + logger.Info(fmt.Sprintf("Failed to cleanup Terraform execution directory %q. Err: %s", requestDirPath, err.Error())) + } + }() + + recipeData, err := d.terraformExecutor.GetRecipeMetadata(ctx, terraform.Options{ + RootDir: requestDirPath, + ResourceRecipe: &opts.Recipe, + EnvRecipe: &opts.Definition, + }) + if err != nil { + return nil, err + } + + return recipeData, nil +} diff --git a/pkg/recipes/driver/terraform_test.go b/pkg/recipes/driver/terraform_test.go index b23ddb6f41..7e1184ef9a 100644 --- a/pkg/recipes/driver/terraform_test.go +++ b/pkg/recipes/driver/terraform_test.go @@ -26,13 +26,13 @@ import ( gomock "github.com/golang/mock/gomock" "github.com/google/uuid" tfjson "github.com/hashicorp/terraform-json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/recipes/terraform" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/recipes/terraform" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) @@ -58,16 +58,17 @@ func buildTestInputs() (recipes.Configuration, recipes.ResourceMetadata, recipes Name: "redis-azure", ApplicationID: "/planes/radius/local/resourcegroups/test-rg/providers/applications.core/applications/app1", EnvironmentID: "/planes/radius/local/resourcegroups/test-rg/providers/applications.core/environments/env1", - ResourceID: "/planes/radius/local/resourceGroups/test-rg/providers/applications.link/rediscaches/test-redis-recipe", + ResourceID: "/planes/radius/local/resourceGroups/test-rg/providers/applications.datastores/rediscaches/test-redis-recipe", Parameters: map[string]any{ "redis_cache_name": "redis-test", }, } envRecipe := recipes.EnvironmentDefinition{ + Name: "redis-azure", Driver: recipes.TemplateKindBicep, TemplatePath: "Azure/redis/azurerm", - ResourceType: "Applications.Link/redisCaches", + ResourceType: "Applications.Datastores/redisCaches", } return envConfig, recipeMetadata, envRecipe @@ -115,7 +116,13 @@ func Test_Terraform_Execute_Success(t *testing.T) { tfExecutor.EXPECT().Deploy(ctx, options).Times(1).Return(expectedTFState, nil) - recipeOutput, err := driver.Execute(ctx, envConfig, recipeMetadata, envRecipe) + recipeOutput, err := driver.Execute(ctx, ExecuteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + }) require.NoError(t, err) require.Equal(t, expectedOutput, recipeOutput) // Verify directory cleanup @@ -139,12 +146,23 @@ func Test_Terraform_Execute_DeploymentFailure(t *testing.T) { ResourceRecipe: &recipeMetadata, EnvRecipe: &envRecipe, } - + recipeError := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.RecipeDeploymentFailed, + Message: "Failed to deploy terraform module", + }, + } tfExecutor.EXPECT().Deploy(ctx, options).Times(1).Return(nil, errors.New("Failed to deploy terraform module")) - _, err := driver.Execute(ctx, envConfig, recipeMetadata, envRecipe) + _, err := driver.Execute(ctx, ExecuteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + }) require.Error(t, err) - require.Equal(t, "Failed to deploy terraform module", err.Error()) + require.Equal(t, err, &recipeError) // Verify directory cleanup _, err = os.Stat(tfDir) require.True(t, os.IsNotExist(err), "Expected directory %s to be removed, but it still exists", tfDir) @@ -182,12 +200,23 @@ func Test_Terraform_Execute_OutputsFailure(t *testing.T) { }, }, } - + recipeError := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.InvalidRecipeOutputs, + Message: "failed to read the recipe output \"result\": json: unknown field \"invalid\"", + }, + } tfExecutor.EXPECT().Deploy(ctx, options).Times(1).Return(expectedTFState, nil) - _, err := driver.Execute(ctx, envConfig, recipeMetadata, envRecipe) + _, err := driver.Execute(ctx, ExecuteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + }) require.Error(t, err) - require.Equal(t, "json: unknown field \"invalid\"", err.Error()) + require.Equal(t, err, &recipeError) // Verify directory cleanup _, err = os.Stat(tfDir) require.True(t, os.IsNotExist(err), "Expected directory %s to be removed, but it still exists", tfDir) @@ -197,10 +226,22 @@ func Test_Terraform_Execute_EmptyPath(t *testing.T) { _, driver := setup(t) driver.options.Path = "" envConfig, recipeMetadata, envRecipe := buildTestInputs() - - _, err := driver.Execute(testcontext.New(t), envConfig, recipeMetadata, envRecipe) + expErr := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.RecipeDeploymentFailed, + Message: "path is a required option for Terraform driver", + }, + } + _, err := driver.Execute(testcontext.New(t), ExecuteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + }) require.Error(t, err) - require.Equal(t, "path is a required option for Terraform driver", err.Error()) + require.Equal(t, err, &expErr) + } func Test_Terraform_Execute_EmptyOperationID_Success(t *testing.T) { @@ -233,9 +274,18 @@ func Test_Terraform_Execute_EmptyOperationID_Success(t *testing.T) { }, } - tfExecutor.EXPECT().Deploy(ctx, gomock.Any()).Times(1).Return(expectedTFState, nil) + tfExecutor.EXPECT(). + Deploy(ctx, gomock.Any()). + Times(1). + Return(expectedTFState, nil) - recipeOutput, err := driver.Execute(ctx, envConfig, recipeMetadata, envRecipe) + recipeOutput, err := driver.Execute(ctx, ExecuteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + }) require.NoError(t, err) require.Equal(t, expectedOutput, recipeOutput) } @@ -248,18 +298,174 @@ func Test_Terraform_Execute_MissingARMRequestContext_Panics(t *testing.T) { envConfig, recipeMetadata, envRecipe := buildTestInputs() require.Panics(t, func() { - _, _ = driver.Execute(ctx, envConfig, recipeMetadata, envRecipe) + _, _ = driver.Execute(ctx, ExecuteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + }) + }) +} + +func TestTerraformDriver_GetRecipeMetadata_Success(t *testing.T) { + ctx := testcontext.New(t) + armCtx := &v1.ARMRequestContext{ + OperationID: uuid.New(), + } + ctx = v1.WithARMRequestContext(ctx, armCtx) + + tfExecutor, driver := setup(t) + _, _, envRecipe := buildTestInputs() + + tfDir := filepath.Join(driver.options.Path, armCtx.OperationID.String()) + expectedOutput := map[string]any{ + "parameters": map[string]any{ + "redis_cache_name": "redis-test", + }, + } + options := terraform.Options{ + RootDir: tfDir, + ResourceRecipe: &recipes.ResourceMetadata{}, + EnvRecipe: &envRecipe, + } + tfExecutor.EXPECT().GetRecipeMetadata(ctx, options).Times(1).Return(expectedOutput, nil) + + recipeData, err := driver.GetRecipeMetadata(ctx, BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: envRecipe, }) + require.NoError(t, err) + require.Equal(t, expectedOutput, recipeData) + // Verify directory cleanup + _, err = os.Stat(tfDir) + require.True(t, os.IsNotExist(err), "Expected directory %s to be removed, but it still exists", tfDir) +} + +func Test_Terraform_GetRecipeMetadata_EmptyPath(t *testing.T) { + _, driver := setup(t) + driver.options.Path = "" + _, _, envRecipe := buildTestInputs() + + expErr := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.RecipeGetMetadataFailed, + Message: "path is a required option for Terraform driver", + }, + } + + _, err := driver.GetRecipeMetadata(testcontext.New(t), BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: envRecipe, + }) + require.Error(t, err) + require.Equal(t, err, &expErr) +} + +func TestTerraformDriver_GetRecipeMetadata_Failure(t *testing.T) { + ctx := testcontext.New(t) + armCtx := &v1.ARMRequestContext{ + OperationID: uuid.New(), + } + ctx = v1.WithARMRequestContext(ctx, armCtx) + + tfExecutor, driver := setup(t) + _, _, envRecipe := buildTestInputs() + + tfDir := filepath.Join(driver.options.Path, armCtx.OperationID.String()) + options := terraform.Options{ + RootDir: tfDir, + ResourceRecipe: &recipes.ResourceMetadata{}, + EnvRecipe: &envRecipe, + } + + expErr := errors.New("Failed to download module") + tfExecutor.EXPECT().GetRecipeMetadata(ctx, options).Times(1).Return(nil, expErr) + + _, err := driver.GetRecipeMetadata(ctx, BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: envRecipe, + }) + require.Error(t, err) + require.Equal(t, expErr, err) } func Test_Terraform_Delete_Success(t *testing.T) { ctx := testcontext.New(t) + ctx = v1.WithARMRequestContext(ctx, &v1.ARMRequestContext{}) + + tfExecutor, driver := setup(t) + envConfig, recipeMetadata, envRecipe := buildTestInputs() + + tfExecutor.EXPECT(). + Delete(ctx, gomock.Any()). + Times(1). + Return(nil) + err := driver.Delete(ctx, DeleteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + OutputResources: []rpv1.OutputResource{}, + }) + require.NoError(t, err) +} + +func Test_Terraform_Delete_EmptyPath(t *testing.T) { _, driver := setup(t) + driver.options.Path = "" + envConfig, recipeMetadata, envRecipe := buildTestInputs() + + expErr := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.RecipeDeletionFailed, + Message: "path is a required option for Terraform driver", + }, + } + + err := driver.Delete(testcontext.New(t), DeleteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + OutputResources: []rpv1.OutputResource{}, + }) + require.Error(t, err) + require.Equal(t, err, &expErr) +} + +func Test_Terraform_Delete_Failure(t *testing.T) { + ctx := testcontext.New(t) + ctx = v1.WithARMRequestContext(ctx, &v1.ARMRequestContext{}) + + tfExecutor, driver := setup(t) + envConfig, recipeMetadata, envRecipe := buildTestInputs() - err := driver.Delete(ctx, []rpv1.OutputResource{}) + tfExecutor.EXPECT(). + Delete(ctx, gomock.Any()). + Times(1). + Return(errors.New("Failed to delete terraform module")) + + expErr := recipes.RecipeError{ + ErrorDetails: v1.ErrorDetails{ + Code: recipes.RecipeDeletionFailed, + Message: "Failed to delete terraform module", + }, + } + + err := driver.Delete(ctx, DeleteOptions{ + BaseOptions: BaseOptions{ + Configuration: envConfig, + Recipe: recipeMetadata, + Definition: envRecipe, + }, + OutputResources: []rpv1.OutputResource{}, + }) require.Error(t, err) - require.Equal(t, "terraform delete support is not implemented yet", err.Error()) + require.Equal(t, &expErr, err) } func Test_Terraform_PrepareRecipeResponse(t *testing.T) { diff --git a/pkg/recipes/driver/types.go b/pkg/recipes/driver/types.go index 51b48a3b26..bd64199ca2 100644 --- a/pkg/recipes/driver/types.go +++ b/pkg/recipes/driver/types.go @@ -19,15 +19,45 @@ package driver import ( "context" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // Driver is an interface to implement recipe deployment and recipe resources deletion. type Driver interface { // Execute fetches the recipe contents and deploys the recipe and returns deployed resources, secrets and values. - Execute(ctx context.Context, configuration recipes.Configuration, recipe recipes.ResourceMetadata, definition recipes.EnvironmentDefinition) (*recipes.RecipeOutput, error) + Execute(ctx context.Context, opts ExecuteOptions) (*recipes.RecipeOutput, error) // Delete handles deletion of output resources for the recipe deployment. - Delete(ctx context.Context, outputResources []rpv1.OutputResource) error + Delete(ctx context.Context, opts DeleteOptions) error + + // Gets the Recipe metadata and parameters from Recipe's template path + GetRecipeMetadata(ctx context.Context, opts BaseOptions) (map[string]any, error) +} + +// BaseOptions is the base options for the driver operations. +type BaseOptions struct { + // Configuration is the configuration for the recipe. + Configuration recipes.Configuration + + // Recipe is the recipe metadata. + Recipe recipes.ResourceMetadata + + // Definition is the environment definition for the recipe. + Definition recipes.EnvironmentDefinition +} + +// ExecuteOptions is the options for the Execute method. +type ExecuteOptions struct { + BaseOptions + // Previously deployed state of output resource IDs. + PrevState []string +} + +// DeleteOptions is the options for the Delete method. +type DeleteOptions struct { + BaseOptions + + // OutputResources is the list of output resources for the recipe. + OutputResources []rpv1.OutputResource } diff --git a/pkg/recipes/engine/engine.go b/pkg/recipes/engine/engine.go index 6ac8f9ec49..100b58b7bd 100644 --- a/pkg/recipes/engine/engine.go +++ b/pkg/recipes/engine/engine.go @@ -21,11 +21,11 @@ import ( "fmt" "time" - "github.com/project-radius/radius/pkg/metrics" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/configloader" - "github.com/project-radius/radius/pkg/recipes/driver" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/metrics" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/configloader" + recipedriver "github.com/radius-project/radius/pkg/recipes/driver" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // NewEngine creates a new Engine to deploy recipe. @@ -38,7 +38,7 @@ var _ Engine = (*engine)(nil) // Options represents the configuration loader and type of driver used to deploy recipe. type Options struct { ConfigurationLoader configloader.ConfigurationLoader - Drivers map[string]driver.Driver + Drivers map[string]recipedriver.Driver } type engine struct { @@ -48,13 +48,16 @@ type engine struct { // Execute loads the recipe definition from the environment, finds the driver associated with the recipe, loads the // configuration associated with the recipe, and then executes the recipe using the driver. It returns a RecipeOutput and // an error if one occurs. -func (e *engine) Execute(ctx context.Context, recipe recipes.ResourceMetadata) (*recipes.RecipeOutput, error) { +func (e *engine) Execute(ctx context.Context, recipe recipes.ResourceMetadata, prevState []string) (*recipes.RecipeOutput, error) { executionStart := time.Now() result := metrics.SuccessfulOperationState - recipeOutput, definition, err := e.executeCore(ctx, recipe) + recipeOutput, definition, err := e.executeCore(ctx, recipe, prevState) if err != nil { result = metrics.FailedOperationState + if recipes.GetRecipeErrorDetails(err) != nil { + result = recipes.GetRecipeErrorDetails(err).Code + } } metrics.DefaultRecipeEngineMetrics.RecordRecipeOperationDuration(ctx, executionStart, @@ -66,24 +69,25 @@ func (e *engine) Execute(ctx context.Context, recipe recipes.ResourceMetadata) ( // executeCore function is the core logic of the Execute function. // Any changes to the core logic of the Execute function should be made here. -func (e *engine) executeCore(ctx context.Context, recipe recipes.ResourceMetadata) (*recipes.RecipeOutput, *recipes.EnvironmentDefinition, error) { - // Load Recipe Definition from the environment. - definition, err := e.options.ConfigurationLoader.LoadRecipe(ctx, &recipe) +func (e *engine) executeCore(ctx context.Context, recipe recipes.ResourceMetadata, prevState []string) (*recipes.RecipeOutput, *recipes.EnvironmentDefinition, error) { + definition, driver, err := e.getDriver(ctx, recipe) if err != nil { return nil, nil, err } - driver, ok := e.options.Drivers[definition.Driver] - if !ok { - return nil, definition, fmt.Errorf("could not find driver %s", definition.Driver) - } - configuration, err := e.options.ConfigurationLoader.LoadConfiguration(ctx, recipe) if err != nil { return nil, definition, err } - res, err := driver.Execute(ctx, *configuration, recipe, *definition) + res, err := driver.Execute(ctx, recipedriver.ExecuteOptions{ + BaseOptions: recipedriver.BaseOptions{ + Configuration: *configuration, + Recipe: recipe, + Definition: *definition, + }, + PrevState: prevState, + }) if err != nil { return nil, definition, err } @@ -99,6 +103,9 @@ func (e *engine) Delete(ctx context.Context, recipe recipes.ResourceMetadata, ou definition, err := e.deleteCore(ctx, recipe, outputResources) if err != nil { result = metrics.FailedOperationState + if recipes.GetRecipeErrorDetails(err) != nil { + result = recipes.GetRecipeErrorDetails(err).Code + } } metrics.DefaultRecipeEngineMetrics.RecordRecipeOperationDuration(ctx, deletionStart, @@ -111,22 +118,67 @@ func (e *engine) Delete(ctx context.Context, recipe recipes.ResourceMetadata, ou // deleteCore function is the core logic of the Delete function. // Any changes to the core logic of the Delete function should be made here. func (e *engine) deleteCore(ctx context.Context, recipe recipes.ResourceMetadata, outputResources []rpv1.OutputResource) (*recipes.EnvironmentDefinition, error) { - // Load Recipe Definition from the environment. - definition, err := e.options.ConfigurationLoader.LoadRecipe(ctx, &recipe) + definition, driver, err := e.getDriver(ctx, recipe) if err != nil { return nil, err } - // Determine Recipe driver type - driver, ok := e.options.Drivers[definition.Driver] - if !ok { - return definition, fmt.Errorf("could not find driver %s", definition.Driver) + configuration, err := e.options.ConfigurationLoader.LoadConfiguration(ctx, recipe) + if err != nil { + return definition, err } - err = driver.Delete(ctx, outputResources) + err = driver.Delete(ctx, recipedriver.DeleteOptions{ + BaseOptions: recipedriver.BaseOptions{ + Configuration: *configuration, + Recipe: recipe, + Definition: *definition, + }, + OutputResources: outputResources, + }) if err != nil { return definition, err } return definition, nil } + +// Gets the Recipe metadata and parameters from Recipe's template path. +func (e *engine) GetRecipeMetadata(ctx context.Context, recipeDefinition recipes.EnvironmentDefinition) (map[string]any, error) { + recipeData, err := e.getRecipeMetadataCore(ctx, recipeDefinition) + if err != nil { + return nil, err + } + + return recipeData, nil +} + +// getRecipeMetadataCore function is the core logic of the GetRecipeMetadata function. +// Any changes to the core logic of the GetRecipeMetadata function should be made here. +func (e *engine) getRecipeMetadataCore(ctx context.Context, recipeDefinition recipes.EnvironmentDefinition) (map[string]any, error) { + // Determine Recipe driver type + driver, ok := e.options.Drivers[recipeDefinition.Driver] + if !ok { + return nil, fmt.Errorf("could not find driver %s", recipeDefinition.Driver) + } + + return driver.GetRecipeMetadata(ctx, recipedriver.BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: recipeDefinition, + }) +} + +func (e *engine) getDriver(ctx context.Context, recipeMetadata recipes.ResourceMetadata) (*recipes.EnvironmentDefinition, recipedriver.Driver, error) { + // Load Recipe Definition from the environment. + definition, err := e.options.ConfigurationLoader.LoadRecipe(ctx, &recipeMetadata) + if err != nil { + return nil, nil, err + } + + // Determine Recipe driver type + driver, ok := e.options.Drivers[definition.Driver] + if !ok { + return nil, nil, fmt.Errorf("could not find driver %s", definition.Driver) + } + return definition, driver, nil +} diff --git a/pkg/recipes/engine/engine_test.go b/pkg/recipes/engine/engine_test.go index 781e0c5b77..ccf6805939 100644 --- a/pkg/recipes/engine/engine_test.go +++ b/pkg/recipes/engine/engine_test.go @@ -22,23 +22,23 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/configloader" - "github.com/project-radius/radius/pkg/recipes/driver" - "github.com/project-radius/radius/pkg/resourcemodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/configloader" + recipedriver "github.com/radius-project/radius/pkg/recipes/driver" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) -func setup(t *testing.T) (engine, configloader.MockConfigurationLoader, driver.MockDriver) { +func setup(t *testing.T) (engine, configloader.MockConfigurationLoader, recipedriver.MockDriver) { ctrl := gomock.NewController(t) configLoader := configloader.NewMockConfigurationLoader(ctrl) - mDriver := driver.NewMockDriver(ctrl) + mDriver := recipedriver.NewMockDriver(ctrl) options := Options{ ConfigurationLoader: configLoader, - Drivers: map[string]driver.Driver{ + Drivers: map[string]recipedriver.Driver{ recipes.TemplateKindBicep: mDriver, recipes.TemplateKindTerraform: mDriver, }, @@ -59,6 +59,9 @@ func Test_Engine_Execute_Success(t *testing.T) { "resourceName": "resource1", }, } + prevState := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1", + } envConfig := &recipes.Configuration{ Runtime: recipes.RuntimeConfiguration{ Kubernetes: &recipes.KubernetesRuntime{ @@ -84,16 +87,32 @@ func Test_Engine_Execute_Success(t *testing.T) { recipeDefinition := &recipes.EnvironmentDefinition{ Driver: recipes.TemplateKindBicep, TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/basic/mongodatabases/azure:1.0", - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } ctx := testcontext.New(t) engine, configLoader, driver := setup(t) - configLoader.EXPECT().LoadConfiguration(gomock.Any(), gomock.Any()).Times(1).Return(envConfig, nil) - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(recipeDefinition, nil) - driver.EXPECT().Execute(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Times(1).Return(recipeResult, nil) + configLoader.EXPECT(). + LoadConfiguration(ctx, recipeMetadata). + Times(1). + Return(envConfig, nil) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(recipeDefinition, nil) + driver.EXPECT(). + Execute(ctx, recipedriver.ExecuteOptions{ + BaseOptions: recipedriver.BaseOptions{ + Configuration: *envConfig, + Recipe: recipeMetadata, + Definition: *recipeDefinition, + }, + PrevState: prevState, + }). + Times(1). + Return(recipeResult, nil) - result, err := engine.Execute(ctx, recipeMetadata) + result, err := engine.Execute(ctx, recipeMetadata, prevState) require.NoError(t, err) require.Equal(t, result, recipeResult) } @@ -108,6 +127,9 @@ func Test_Engine_Execute_Failure(t *testing.T) { "resourceName": "resource1", }, } + prevState := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1", + } envConfig := &recipes.Configuration{ Runtime: recipes.RuntimeConfiguration{ Kubernetes: &recipes.KubernetesRuntime{ @@ -123,16 +145,32 @@ func Test_Engine_Execute_Failure(t *testing.T) { recipeDefinition := &recipes.EnvironmentDefinition{ Driver: recipes.TemplateKindBicep, TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/basic/mongodatabases/azure:1.0", - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } ctx := testcontext.New(t) engine, configLoader, driver := setup(t) - configLoader.EXPECT().LoadConfiguration(gomock.Any(), gomock.Any()).Times(1).Return(envConfig, nil) - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(recipeDefinition, nil) - driver.EXPECT().Execute(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Times(1).Return(nil, errors.New("failed to execute recipe")) + configLoader.EXPECT(). + LoadConfiguration(ctx, recipeMetadata). + Times(1). + Return(envConfig, nil) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(recipeDefinition, nil) + driver.EXPECT(). + Execute(ctx, recipedriver.ExecuteOptions{ + BaseOptions: recipedriver.BaseOptions{ + Configuration: *envConfig, + Recipe: recipeMetadata, + Definition: *recipeDefinition, + }, + PrevState: prevState, + }). + Times(1). + Return(nil, errors.New("failed to execute recipe")) - result, err := engine.Execute(ctx, recipeMetadata) + result, err := engine.Execute(ctx, recipeMetadata, prevState) require.Nil(t, result) require.Error(t, err) require.Equal(t, err.Error(), "failed to execute recipe") @@ -148,6 +186,9 @@ func Test_Engine_Terraform_Success(t *testing.T) { "resourceName": "resource1", }, } + prevState := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1", + } envConfig := &recipes.Configuration{ Runtime: recipes.RuntimeConfiguration{ Kubernetes: &recipes.KubernetesRuntime{ @@ -174,16 +215,32 @@ func Test_Engine_Terraform_Success(t *testing.T) { Driver: recipes.TemplateKindTerraform, TemplatePath: "Azure/redis/azurerm", TemplateVersion: "1.1.0", - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } ctx := testcontext.New(t) engine, configLoader, driver := setup(t) - configLoader.EXPECT().LoadConfiguration(gomock.Any(), gomock.Any()).Times(1).Return(envConfig, nil) - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(recipeDefinition, nil) - driver.EXPECT().Execute(ctx, gomock.Any(), gomock.Any(), gomock.Any()).Times(1).Return(recipeResult, nil) + configLoader.EXPECT(). + LoadConfiguration(ctx, recipeMetadata). + Times(1). + Return(envConfig, nil) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(recipeDefinition, nil) + driver.EXPECT(). + Execute(ctx, recipedriver.ExecuteOptions{ + BaseOptions: recipedriver.BaseOptions{ + Configuration: *envConfig, + Recipe: recipeMetadata, + Definition: *recipeDefinition, + }, + PrevState: prevState, + }). + Times(1). + Return(recipeResult, nil) - result, err := engine.Execute(ctx, recipeMetadata) + result, err := engine.Execute(ctx, recipeMetadata, prevState) require.NoError(t, err) require.Equal(t, result, recipeResult) } @@ -195,7 +252,7 @@ func Test_Engine_InvalidDriver(t *testing.T) { recipeDefinition := &recipes.EnvironmentDefinition{ Driver: "invalid", TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/basic/mongodatabases/azure:1.0", - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } recipeMetadata := recipes.ResourceMetadata{ @@ -207,9 +264,14 @@ func Test_Engine_InvalidDriver(t *testing.T) { "resourceName": "resource1", }, } - - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(recipeDefinition, nil) - _, err := engine.Execute(ctx, recipeMetadata) + prevState := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1", + } + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(recipeDefinition, nil) + _, err := engine.Execute(ctx, recipeMetadata, prevState) require.Error(t, err) require.Equal(t, err.Error(), "could not find driver invalid") } @@ -226,8 +288,14 @@ func Test_Engine_Lookup_Error(t *testing.T) { "resourceName": "resource1", }, } - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(nil, errors.New("could not find recipe mongo-azure in environment env1")) - _, err := engine.Execute(ctx, recipeMetadata) + prevState := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1", + } + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(nil, errors.New("could not find recipe mongo-azure in environment env1")) + _, err := engine.Execute(ctx, recipeMetadata, prevState) require.Error(t, err) } @@ -243,51 +311,128 @@ func Test_Engine_Load_Error(t *testing.T) { "resourceName": "resource1", }, } + prevState := []string{ + "/subscriptions/test-sub/resourceGroups/test-rg/providers/System.Test/testResources/test1", + } recipeDefinition := &recipes.EnvironmentDefinition{ Driver: recipes.TemplateKindBicep, TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/basic/mongodatabases/azure:1.0", - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(recipeDefinition, nil) - configLoader.EXPECT().LoadConfiguration(gomock.Any(), gomock.Any()).Times(1).Return(nil, errors.New("unable to fetch namespace information")) - _, err := engine.Execute(ctx, recipeMetadata) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(recipeDefinition, nil) + configLoader.EXPECT(). + LoadConfiguration(ctx, recipeMetadata). + Times(1). + Return(nil, errors.New("unable to fetch namespace information")) + _, err := engine.Execute(ctx, recipeMetadata, prevState) require.Error(t, err) } func Test_Engine_Delete_Success(t *testing.T) { - recipeMetadata, recipeDefinition, outputResources := getDeleteInputs() + recipeMetadata, recipeDefinition, outputResources := getRecipeInputs() + + envConfig := &recipes.Configuration{ + Runtime: recipes.RuntimeConfiguration{ + Kubernetes: &recipes.KubernetesRuntime{ + Namespace: "default", + }, + }, + Providers: datamodel.Providers{ + Azure: datamodel.ProvidersAzure{ + Scope: "scope", + }, + }, + } ctx := testcontext.New(t) engine, configLoader, driver := setup(t) - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(&recipeDefinition, nil) - driver.EXPECT().Delete(ctx, outputResources).Times(1).Return(nil) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(&recipeDefinition, nil) + + configLoader.EXPECT(). + LoadConfiguration(ctx, recipeMetadata). + Times(1). + Return(envConfig, nil) + + driver.EXPECT(). + Delete(ctx, recipedriver.DeleteOptions{ + BaseOptions: recipedriver.BaseOptions{ + Configuration: *envConfig, + Recipe: recipeMetadata, + Definition: recipeDefinition, + }, + OutputResources: outputResources, + }). + Times(1). + Return(nil) err := engine.Delete(ctx, recipeMetadata, outputResources) require.NoError(t, err) } func Test_Engine_Delete_Error(t *testing.T) { - recipeMetadata, recipeDefinition, outputResources := getDeleteInputs() + recipeMetadata, recipeDefinition, outputResources := getRecipeInputs() + + envConfig := &recipes.Configuration{ + Runtime: recipes.RuntimeConfiguration{ + Kubernetes: &recipes.KubernetesRuntime{ + Namespace: "default", + }, + }, + Providers: datamodel.Providers{ + Azure: datamodel.ProvidersAzure{ + Scope: "scope", + }, + }, + } ctx := testcontext.New(t) engine, configLoader, driver := setup(t) - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(&recipeDefinition, nil) - driver.EXPECT().Delete(ctx, outputResources).Times(1).Return(fmt.Errorf("could not find API version for type %q, no supported API versions", outputResources[0].Identity.ResourceType.Type)) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(&recipeDefinition, nil) + + configLoader.EXPECT(). + LoadConfiguration(ctx, recipeMetadata). + Times(1). + Return(envConfig, nil) + + driver.EXPECT(). + Delete(ctx, recipedriver.DeleteOptions{ + BaseOptions: recipedriver.BaseOptions{ + Configuration: *envConfig, + Recipe: recipeMetadata, + Definition: recipeDefinition, + }, + OutputResources: outputResources, + }). + Times(1). + Return(fmt.Errorf("could not find API version for type %q, no supported API versions", + outputResources[0].ID)) err := engine.Delete(ctx, recipeMetadata, outputResources) require.Error(t, err) } func Test_Delete_InvalidDriver(t *testing.T) { - recipeMetadata, recipeDefinition, outputResources := getDeleteInputs() + recipeMetadata, recipeDefinition, outputResources := getRecipeInputs() recipeDefinition.Driver = "invalid" ctx := testcontext.New(t) engine, configLoader, _ := setup(t) - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(&recipeDefinition, nil) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(&recipeDefinition, nil) err := engine.Delete(ctx, recipeMetadata, outputResources) require.Error(t, err) require.Equal(t, err.Error(), "could not find driver invalid") @@ -296,19 +441,67 @@ func Test_Delete_InvalidDriver(t *testing.T) { func Test_Delete_Lookup_Error(t *testing.T) { ctx := testcontext.New(t) engine, configLoader, _ := setup(t) - recipeMetadata, _, outputResources := getDeleteInputs() + recipeMetadata, _, outputResources := getRecipeInputs() - configLoader.EXPECT().LoadRecipe(gomock.Any(), gomock.Any()).Times(1).Return(nil, errors.New("could not find recipe mongo-azure in environment env1")) + configLoader.EXPECT(). + LoadRecipe(ctx, &recipeMetadata). + Times(1). + Return(nil, errors.New("could not find recipe mongo-azure in environment env1")) err := engine.Delete(ctx, recipeMetadata, outputResources) require.Error(t, err) } -func getDeleteInputs() (recipes.ResourceMetadata, recipes.EnvironmentDefinition, []rpv1.OutputResource) { +func Test_Engine_GetRecipeMetadata_Success(t *testing.T) { + _, recipeDefinition, _ := getRecipeInputs() + + ctx := testcontext.New(t) + engine, _, driver := setup(t) + outputParams := map[string]any{"parameters": recipeDefinition.Parameters} + + driver.EXPECT().GetRecipeMetadata(ctx, recipedriver.BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: recipeDefinition, + }).Times(1).Return(outputParams, nil) + + recipeData, err := engine.GetRecipeMetadata(ctx, recipeDefinition) + require.NoError(t, err) + require.Equal(t, outputParams, recipeData) +} + +func Test_GetRecipeMetadata_Driver_Error(t *testing.T) { + _, recipeDefinition, _ := getRecipeInputs() + + ctx := testcontext.New(t) + engine, _, driver := setup(t) + + driver.EXPECT().GetRecipeMetadata(ctx, recipedriver.BaseOptions{ + Recipe: recipes.ResourceMetadata{}, + Definition: recipeDefinition, + }).Times(1).Return(nil, errors.New("driver failure")) + + _, err := engine.GetRecipeMetadata(ctx, recipeDefinition) + require.Error(t, err) + require.Contains(t, err.Error(), "driver failure") +} + +func Test_GetRecipeMetadata_Driver_InvalidDriver(t *testing.T) { + _, recipeDefinition, _ := getRecipeInputs() + recipeDefinition.Driver = "invalid" + + ctx := testcontext.New(t) + engine, _, _ := setup(t) + + _, err := engine.GetRecipeMetadata(ctx, recipeDefinition) + require.Error(t, err) + require.Contains(t, err.Error(), "could not find driver invalid") +} + +func getRecipeInputs() (recipes.ResourceMetadata, recipes.EnvironmentDefinition, []rpv1.OutputResource) { recipeMetadata := recipes.ResourceMetadata{ Name: "mongo-azure", ApplicationID: "/planes/radius/local/resourcegroups/test-rg/providers/applications.core/applications/app1", EnvironmentID: "/planes/radius/local/resourcegroups/test-rg/providers/applications.core/environments/env1", - ResourceID: "/planes/deployments/local/resourceGroups/test-rg/providers/Microsoft.Resources/deployments/recipe", + ResourceID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/test-db", Parameters: map[string]any{ "resourceName": "resource1", }, @@ -317,18 +510,12 @@ func getDeleteInputs() (recipes.ResourceMetadata, recipes.EnvironmentDefinition, recipeDefinition := recipes.EnvironmentDefinition{ Driver: recipes.TemplateKindBicep, TemplatePath: "radiusdev.azurecr.io/recipes/functionaltest/basic/mongodatabases/azure:1.0", - ResourceType: "Applications.Link/mongoDatabases", + ResourceType: "Applications.Datastores/mongoDatabases", } outputResources := []rpv1.OutputResource{ { - LocalID: "/planes/deployments/local/resourceGroups/test-rg/providers/Microsoft.Resources/deployments/recipe", - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: "Microsoft.Resources/deployments", - Provider: "azure", - }, - }, + ID: resources.MustParse("/subscriptions/test-sub/resourcegroups/test-rg/providers/Microsoft.DocumentDB/accounts/test-account"), }, } return recipeMetadata, recipeDefinition, outputResources diff --git a/pkg/recipes/engine/mock_engine.go b/pkg/recipes/engine/mock_engine.go index 65456bd714..cf1c1da32a 100644 --- a/pkg/recipes/engine/mock_engine.go +++ b/pkg/recipes/engine/mock_engine.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/recipes/engine (interfaces: Engine) +// Source: github.com/radius-project/radius/pkg/recipes/engine (interfaces: Engine) // Package engine is a generated GoMock package. package engine @@ -9,8 +9,8 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - recipes "github.com/project-radius/radius/pkg/recipes" - v1 "github.com/project-radius/radius/pkg/rp/v1" + recipes "github.com/radius-project/radius/pkg/recipes" + v1 "github.com/radius-project/radius/pkg/rp/v1" ) // MockEngine is a mock of Engine interface. @@ -51,16 +51,31 @@ func (mr *MockEngineMockRecorder) Delete(arg0, arg1, arg2 interface{}) *gomock.C } // Execute mocks base method. -func (m *MockEngine) Execute(arg0 context.Context, arg1 recipes.ResourceMetadata) (*recipes.RecipeOutput, error) { +func (m *MockEngine) Execute(arg0 context.Context, arg1 recipes.ResourceMetadata, arg2 []string) (*recipes.RecipeOutput, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Execute", arg0, arg1) + ret := m.ctrl.Call(m, "Execute", arg0, arg1, arg2) ret0, _ := ret[0].(*recipes.RecipeOutput) ret1, _ := ret[1].(error) return ret0, ret1 } // Execute indicates an expected call of Execute. -func (mr *MockEngineMockRecorder) Execute(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockEngineMockRecorder) Execute(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Execute", reflect.TypeOf((*MockEngine)(nil).Execute), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Execute", reflect.TypeOf((*MockEngine)(nil).Execute), arg0, arg1, arg2) +} + +// GetRecipeMetadata mocks base method. +func (m *MockEngine) GetRecipeMetadata(arg0 context.Context, arg1 recipes.EnvironmentDefinition) (map[string]interface{}, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetRecipeMetadata", arg0, arg1) + ret0, _ := ret[0].(map[string]interface{}) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRecipeMetadata indicates an expected call of GetRecipeMetadata. +func (mr *MockEngineMockRecorder) GetRecipeMetadata(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRecipeMetadata", reflect.TypeOf((*MockEngine)(nil).GetRecipeMetadata), arg0, arg1) } diff --git a/pkg/recipes/engine/types.go b/pkg/recipes/engine/types.go index 386e7bb02b..3079e015a1 100644 --- a/pkg/recipes/engine/types.go +++ b/pkg/recipes/engine/types.go @@ -19,15 +19,20 @@ package engine import ( "context" - "github.com/project-radius/radius/pkg/recipes" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/recipes" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) -//go:generate mockgen -destination=./mock_engine.go -package=engine -self_package github.com/project-radius/radius/pkg/recipes/engine github.com/project-radius/radius/pkg/recipes/engine Engine +//go:generate mockgen -destination=./mock_engine.go -package=engine -self_package github.com/radius-project/radius/pkg/recipes/engine github.com/radius-project/radius/pkg/recipes/engine Engine type Engine interface { - // Execute gathers environment configuration and recipe definition and calls the driver to deploy the recipe. - Execute(ctx context.Context, recipe recipes.ResourceMetadata) (*recipes.RecipeOutput, error) + // Execute gathers environment configuration, recipe definition and calls the driver to deploy the recipe. + // prevState is added to the driver execute options, which is used to get the obsolete resources for cleanup. It consists list of recipe output resource IDs that were created in the previous deployment. + Execute(ctx context.Context, recipe recipes.ResourceMetadata, prevState []string) (*recipes.RecipeOutput, error) + // Delete handles deletion of output resources for the recipe deployment. Delete(ctx context.Context, recipe recipes.ResourceMetadata, outputResources []rpv1.OutputResource) error + + // Gets the Recipe metadata and parameters from Recipe's template path + GetRecipeMetadata(ctx context.Context, recipeDefinition recipes.EnvironmentDefinition) (map[string]any, error) } diff --git a/pkg/recipes/error.go b/pkg/recipes/error.go new file mode 100644 index 0000000000..b03b7f373f --- /dev/null +++ b/pkg/recipes/error.go @@ -0,0 +1,58 @@ +/* +Copyright 2023 The Radius Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package recipes + +import ( + "fmt" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" +) + +type RecipeError struct { + ErrorDetails v1.ErrorDetails +} + +// Error returns an error string describing the error code and message. +func (r *RecipeError) Error() string { + return fmt.Sprintf("code %v: err %v", r.ErrorDetails.Code, r.ErrorDetails.Message) +} + +func (e *RecipeError) Is(target error) bool { + _, ok := target.(*RecipeError) + return ok +} + +// NewRecipeError creates a new RecipeError error with a given code, message and error details. +func NewRecipeError(code string, message string, details ...*v1.ErrorDetails) *RecipeError { + err := new(RecipeError) + err.ErrorDetails.Message = message + err.ErrorDetails.Code = code + for _, val := range details { + if val != nil { + err.ErrorDetails.Details = append(err.ErrorDetails.Details, *val) + } + } + + return err +} + +// GetRecipeErrorDetails is used to get ErrorDetails if error is of type RecipeError else returns nil. +func GetRecipeErrorDetails(err error) *v1.ErrorDetails { + recipeError, _ := err.(*RecipeError) + if recipeError != nil { + return &recipeError.ErrorDetails + } + + return nil +} diff --git a/pkg/recipes/error_test.go b/pkg/recipes/error_test.go new file mode 100644 index 0000000000..a9f888a61c --- /dev/null +++ b/pkg/recipes/error_test.go @@ -0,0 +1,104 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package recipes + +import ( + "errors" + "testing" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/stretchr/testify/require" +) + +func TestNewRecipeError(t *testing.T) { + errorTests := []struct { + name string + errorCode string + errorMessage string + errorDetails *v1.ErrorDetails + expectedErr RecipeError + }{ + { + name: "error with details", + errorCode: RecipeDeploymentFailed, + errorMessage: "test-recipe-deployment-failed-message", + errorDetails: &v1.ErrorDetails{ + Code: RecipeLanguageFailure, + Message: "test-recipe-language-failure-message", + }, + expectedErr: RecipeError{ + v1.ErrorDetails{ + Code: RecipeDeploymentFailed, + Message: "test-recipe-deployment-failed-message", + Details: []v1.ErrorDetails{ + { + Code: RecipeLanguageFailure, + Message: "test-recipe-language-failure-message", + }, + }, + }, + }, + }, + { + name: "error without details", + errorCode: RecipeDeploymentFailed, + errorMessage: "test-recipe-deployment-failed-message", + errorDetails: nil, + expectedErr: RecipeError{ + v1.ErrorDetails{ + Code: RecipeDeploymentFailed, + Message: "test-recipe-deployment-failed-message", + }, + }, + }, + } + for _, tc := range errorTests { + err := NewRecipeError(tc.errorCode, tc.errorMessage, tc.errorDetails) + require.Equal(t, err, &tc.expectedErr) + } +} + +func TestGetRecipeErrorDetails(t *testing.T) { + errorTests := []struct { + name string + err error + expErrorDetails *v1.ErrorDetails + }{ + { + name: "", + err: errors.New("test-error"), + expErrorDetails: nil, + }, + { + name: "", + err: &RecipeError{ + v1.ErrorDetails{ + Code: RecipeDeploymentFailed, + Message: "test-recipe-deployment-failed-message", + }, + }, + expErrorDetails: &v1.ErrorDetails{ + Code: RecipeDeploymentFailed, + Message: "test-recipe-deployment-failed-message", + }, + }, + } + for _, tc := range errorTests { + details := GetRecipeErrorDetails(tc.err) + require.Equal(t, details, tc.expErrorDetails) + } +} diff --git a/pkg/recipes/errorcodes.go b/pkg/recipes/errorcodes.go new file mode 100644 index 0000000000..d5c53c1d90 --- /dev/null +++ b/pkg/recipes/errorcodes.go @@ -0,0 +1,37 @@ +/* +Copyright 2023 The Radius Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package recipes + +const ( + // Used for recipe download failures. + RecipeDownloadFailed = "RecipeDownloadFailed" + + // Used for recipe deployment failures. + RecipeDeploymentFailed = "RecipeDeploymentFailed" + + // Used for recipe deletion failures. + RecipeDeletionFailed = "RecipeDeletionFailed" + + // Used for errors encountered during processing recipe outputs. + InvalidRecipeOutputs = "InvalidRecipeOutputs" + + // Used for errors encountered while reading a recipe from registry. + RecipeLanguageFailure = "RecipeLanguageFailure" + + // Used for errors encountered while cleaning up of obsolete resources during patch operation. + RecipeGarbageCollectionFailed = "RecipeGarbageCollectionFailed" + + // Used for errors encountered when getting recipe parameters. + RecipeGetMetadataFailed = "RecipeGetMetadataFailed" +) diff --git a/pkg/recipes/recipecontext/context.go b/pkg/recipes/recipecontext/context.go index 3ae3d42c84..2e9fdea37e 100644 --- a/pkg/recipes/recipecontext/context.go +++ b/pkg/recipes/recipecontext/context.go @@ -19,16 +19,18 @@ package recipecontext import ( "fmt" - coredm "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/ucp/resources" + coredm "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_aws "github.com/radius-project/radius/pkg/ucp/resources/aws" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" ) var ( ErrParseFormat = "failed to parse %s: %q while building the recipe context parameter %w" ) -// New creates the context parameter for the recipe with the link, environment and application info +// New creates the context parameter for the recipe with the portable resource, environment, and application info func New(metadata *recipes.ResourceMetadata, config *recipes.Configuration) (*Context, error) { parsedResource, err := resources.ParseResource(metadata.ResourceID) if err != nil { @@ -78,8 +80,8 @@ func New(metadata *recipes.ResourceMetadata, config *recipes.Configuration) (*Co return nil, fmt.Errorf(ErrParseFormat, "Azure scope", providers.Azure.Scope, err) } - subID := p.FindScope(resources.SubscriptionsSegment) - rgName := p.FindScope(resources.ResourceGroupsSegment) + subID := p.FindScope(resources_azure.ScopeSubscriptions) + rgName := p.FindScope(resources_azure.ScopeResourceGroups) recipeContext.Azure = &ProviderAzure{ ResourceGroup: AzureResourceGroup{ Name: rgName, @@ -98,8 +100,8 @@ func New(metadata *recipes.ResourceMetadata, config *recipes.Configuration) (*Co return nil, fmt.Errorf(ErrParseFormat, "AWS scope", providers.AWS.Scope, err) } recipeContext.AWS = &ProviderAWS{ - Region: p.FindScope(resources.RegionsSegment), - Account: p.FindScope(resources.AccountsSegment), + Region: p.FindScope(resources_aws.ScopeRegions), + Account: p.FindScope(resources_aws.ScopeAccounts), } } diff --git a/pkg/recipes/recipecontext/context_test.go b/pkg/recipes/recipecontext/context_test.go index 46aa81fa9a..b7b88b540a 100644 --- a/pkg/recipes/recipecontext/context_test.go +++ b/pkg/recipes/recipecontext/context_test.go @@ -19,15 +19,15 @@ package recipecontext import ( "testing" - coredm "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" + coredm "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" "github.com/stretchr/testify/require" ) func TestNewContext(t *testing.T) { testMetadata := &recipes.ResourceMetadata{ - ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", EnvironmentID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/environments/env0", ApplicationID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", } @@ -60,10 +60,10 @@ func TestNewContext(t *testing.T) { out: &Context{ Resource: Resource{ ResourceInfo: ResourceInfo{ - ID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", Name: "mongo0", }, - Type: "applications.link/mongodatabases", + Type: "applications.datastores/mongodatabases", }, Application: ResourceInfo{ Name: "testApplication", @@ -110,10 +110,10 @@ func TestNewContext(t *testing.T) { out: &Context{ Resource: Resource{ ResourceInfo: ResourceInfo{ - ID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", Name: "mongo0", }, - Type: "applications.link/mongodatabases", + Type: "applications.datastores/mongodatabases", }, Application: ResourceInfo{ Name: "testApplication", @@ -150,10 +150,10 @@ func TestNewContext(t *testing.T) { out: &Context{ Resource: Resource{ ResourceInfo: ResourceInfo{ - ID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", Name: "mongo0", }, - Type: "applications.link/mongodatabases", + Type: "applications.datastores/mongodatabases", }, Application: ResourceInfo{ Name: "testApplication", @@ -220,7 +220,7 @@ func TestNewContext_failures(t *testing.T) { { name: "invalid env id", metadata: &recipes.ResourceMetadata{ - ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", EnvironmentID: "invalid-env", ApplicationID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", }, @@ -230,7 +230,7 @@ func TestNewContext_failures(t *testing.T) { { name: "invalid app id", metadata: &recipes.ResourceMetadata{ - ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", EnvironmentID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/environments/env0", ApplicationID: "invalid-app", }, @@ -240,7 +240,7 @@ func TestNewContext_failures(t *testing.T) { { name: "invalid azure scope", metadata: &recipes.ResourceMetadata{ - ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", EnvironmentID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/environments/env0", ApplicationID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", }, @@ -265,7 +265,7 @@ func TestNewContext_failures(t *testing.T) { { name: "invalid aws scope", metadata: &recipes.ResourceMetadata{ - ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ResourceID: "/planes/radius/local/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", EnvironmentID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/environments/env0", ApplicationID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/applications/testApplication", }, diff --git a/pkg/recipes/recipecontext/types.go b/pkg/recipes/recipecontext/types.go index ed051bc6f5..f905fbcb89 100644 --- a/pkg/recipes/recipecontext/types.go +++ b/pkg/recipes/recipecontext/types.go @@ -17,7 +17,7 @@ limitations under the License. package recipecontext import ( - "github.com/project-radius/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes" ) const ( @@ -25,9 +25,9 @@ const ( RecipeContextParamKey = "context" ) -// Context represents the context information which accesses Link properties. Recipe template authors -// can leverage the RecipeContext parameter to access Link properties to generate name and properties -// that are unique for the Link calling the recipe. +// Context represents the context information which accesses portable resource properties. Recipe template authors +// can leverage the RecipeContext parameter to access portable resource properties to generate name and properties +// that are unique for the portable resource calling the recipe. type Context struct { // Resource represents the resource information of the deploying recipe resource. Resource Resource `json:"resource,omitempty"` @@ -44,7 +44,7 @@ type Context struct { } // Resource contains the information needed to deploy a recipe. -// In the case the resource is a Link, it represents the Link's id, name and type. +// In the case the resource is a portable resource, it represents the resource's id, name and type. type Resource struct { // ResourceInfo represents name and id of the resource ResourceInfo diff --git a/pkg/recipes/terraform/config/backends/kubernetes.go b/pkg/recipes/terraform/config/backends/kubernetes.go index bd6d8767c6..e91de84c80 100644 --- a/pkg/recipes/terraform/config/backends/kubernetes.go +++ b/pkg/recipes/terraform/config/backends/kubernetes.go @@ -22,8 +22,8 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/ucp/resources" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" ) diff --git a/pkg/recipes/terraform/config/backends/kubernetes_test.go b/pkg/recipes/terraform/config/backends/kubernetes_test.go index 3c16b08c91..0ad6be122f 100644 --- a/pkg/recipes/terraform/config/backends/kubernetes_test.go +++ b/pkg/recipes/terraform/config/backends/kubernetes_test.go @@ -22,7 +22,7 @@ import ( "strings" "testing" - "github.com/project-radius/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes" "github.com/stretchr/testify/require" "k8s.io/client-go/tools/clientcmd" ) diff --git a/pkg/recipes/terraform/config/backends/mock_backend.go b/pkg/recipes/terraform/config/backends/mock_backend.go index f9486ac932..df8df9a02c 100644 --- a/pkg/recipes/terraform/config/backends/mock_backend.go +++ b/pkg/recipes/terraform/config/backends/mock_backend.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/recipes/terraform/config/backends (interfaces: Backend) +// Source: github.com/radius-project/radius/pkg/recipes/terraform/config/backends (interfaces: Backend) // Package backends is a generated GoMock package. package backends @@ -8,7 +8,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - recipes "github.com/project-radius/radius/pkg/recipes" + recipes "github.com/radius-project/radius/pkg/recipes" ) // MockBackend is a mock of Backend interface. diff --git a/pkg/recipes/terraform/config/backends/types.go b/pkg/recipes/terraform/config/backends/types.go index 5a8e18fb0d..6e27b9c65a 100644 --- a/pkg/recipes/terraform/config/backends/types.go +++ b/pkg/recipes/terraform/config/backends/types.go @@ -17,10 +17,10 @@ limitations under the License. package backends import ( - "github.com/project-radius/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes" ) -//go:generate mockgen -destination=./mock_backend.go -package=backends -self_package github.com/project-radius/radius/pkg/recipes/terraform/config/backends github.com/project-radius/radius/pkg/recipes/terraform/config/backends Backend +//go:generate mockgen -destination=./mock_backend.go -package=backends -self_package github.com/radius-project/radius/pkg/recipes/terraform/config/backends github.com/radius-project/radius/pkg/recipes/terraform/config/backends Backend // Backend is an interface for generating Terraform backend configurations. type Backend interface { diff --git a/pkg/recipes/terraform/config/config.go b/pkg/recipes/terraform/config/config.go index 416f34a034..e123029722 100644 --- a/pkg/recipes/terraform/config/config.go +++ b/pkg/recipes/terraform/config/config.go @@ -24,11 +24,11 @@ import ( "io/fs" "os" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/recipecontext" - "github.com/project-radius/radius/pkg/recipes/terraform/config/backends" - "github.com/project-radius/radius/pkg/recipes/terraform/config/providers" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/recipecontext" + "github.com/radius-project/radius/pkg/recipes/terraform/config/backends" + "github.com/radius-project/radius/pkg/recipes/terraform/config/providers" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) const ( diff --git a/pkg/recipes/terraform/config/config_test.go b/pkg/recipes/terraform/config/config_test.go index 6cf072feed..0f43323e33 100644 --- a/pkg/recipes/terraform/config/config_test.go +++ b/pkg/recipes/terraform/config/config_test.go @@ -26,12 +26,12 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/recipecontext" - "github.com/project-radius/radius/pkg/recipes/terraform/config/backends" - "github.com/project-radius/radius/pkg/recipes/terraform/config/providers" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/recipecontext" + "github.com/radius-project/radius/pkg/recipes/terraform/config/backends" + "github.com/radius-project/radius/pkg/recipes/terraform/config/providers" + "github.com/radius-project/radius/test/testcontext" ) const ( @@ -69,10 +69,10 @@ func getTestRecipeContext() *recipecontext.Context { return &recipecontext.Context{ Resource: recipecontext.Resource{ ResourceInfo: recipecontext.ResourceInfo{ - ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", + ID: "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", Name: "mongo0", }, - Type: "applications.link/mongodatabases", + Type: "applications.datastores/mongodatabases", }, Application: recipecontext.ResourceInfo{ Name: "testApplication", @@ -158,6 +158,17 @@ func Test_AddRecipeContext(t *testing.T) { recipeContext: getTestRecipeContext(), expectedConfigFile: "testdata/main-noparams.tf.json", }, + { + name: "recipe context with empty resource metadata", + envdef: &recipes.EnvironmentDefinition{ + Name: testRecipeName, + TemplatePath: testTemplatePath, + TemplateVersion: testTemplateVersion, + }, + metadata: &recipes.ResourceMetadata{}, + recipeContext: getTestRecipeContext(), + expectedConfigFile: "testdata/main-noparams.tf.json", + }, { name: "recipe context and env params are given", envdef: &recipes.EnvironmentDefinition{ diff --git a/pkg/recipes/terraform/config/providers/aws.go b/pkg/recipes/terraform/config/providers/aws.go index d67c7d8684..e00418e733 100644 --- a/pkg/recipes/terraform/config/providers/aws.go +++ b/pkg/recipes/terraform/config/providers/aws.go @@ -21,15 +21,16 @@ import ( "errors" "fmt" - "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/ucp/credentials" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/secret" - ucp_provider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_aws "github.com/radius-project/radius/pkg/ucp/resources/aws" + "github.com/radius-project/radius/pkg/ucp/secret" + ucp_provider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // Provider's config parameters need to match the values expected by Terraform @@ -92,7 +93,7 @@ func (p *awsProvider) parseScope(ctx context.Context, envConfig *recipes.Configu return "", fmt.Errorf("invalid AWS provider scope %q is configured on the Environment, error parsing: %s", scope, err.Error()) } - region := parsedScope.FindScope(resources.RegionsSegment) + region := parsedScope.FindScope(resources_aws.ScopeRegions) if region == "" { return "", fmt.Errorf("invalid AWS provider scope %q is configured on the Environment, region is required in the scope", scope) } diff --git a/pkg/recipes/terraform/config/providers/aws_test.go b/pkg/recipes/terraform/config/providers/aws_test.go index ae1c5ebb3d..965f3d7113 100644 --- a/pkg/recipes/terraform/config/providers/aws_test.go +++ b/pkg/recipes/terraform/config/providers/aws_test.go @@ -21,12 +21,12 @@ import ( "errors" "testing" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/sdk" - ucp_credentials "github.com/project-radius/radius/pkg/ucp/credentials" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/sdk" + ucp_credentials "github.com/radius-project/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) diff --git a/pkg/recipes/terraform/config/providers/azure.go b/pkg/recipes/terraform/config/providers/azure.go index ab83e63c9c..6880fe339d 100644 --- a/pkg/recipes/terraform/config/providers/azure.go +++ b/pkg/recipes/terraform/config/providers/azure.go @@ -21,15 +21,16 @@ import ( "errors" "fmt" - "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/ucp/credentials" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/secret" - ucp_provider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + "github.com/radius-project/radius/pkg/ucp/secret" + ucp_provider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // Provider's config parameters need to match the values expected by Terraform @@ -100,7 +101,7 @@ func (p *azureProvider) parseScope(ctx context.Context, envConfig *recipes.Confi return "", fmt.Errorf("invalid Azure provider scope %q is configured on the Environment, error parsing: %s", scope, err.Error()) } - subscription := parsedScope.FindScope(resources.SubscriptionsSegment) + subscription := parsedScope.FindScope(resources_azure.ScopeSubscriptions) if subscription == "" { return "", fmt.Errorf("invalid Azure provider scope %q is configured on the Environment, subscription is required in the scope", scope) } diff --git a/pkg/recipes/terraform/config/providers/azure_test.go b/pkg/recipes/terraform/config/providers/azure_test.go index be16f8f42d..9ba20ddc91 100644 --- a/pkg/recipes/terraform/config/providers/azure_test.go +++ b/pkg/recipes/terraform/config/providers/azure_test.go @@ -21,12 +21,12 @@ import ( "errors" "testing" - "github.com/project-radius/radius/pkg/corerp/datamodel" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/sdk" - ucp_credentials "github.com/project-radius/radius/pkg/ucp/credentials" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/sdk" + ucp_credentials "github.com/radius-project/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) diff --git a/pkg/recipes/terraform/config/providers/kubernetes.go b/pkg/recipes/terraform/config/providers/kubernetes.go index 8ee8309299..e7708d4563 100644 --- a/pkg/recipes/terraform/config/providers/kubernetes.go +++ b/pkg/recipes/terraform/config/providers/kubernetes.go @@ -20,7 +20,7 @@ import ( "context" "errors" - "github.com/project-radius/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" ) diff --git a/pkg/recipes/terraform/config/providers/kubernetes_test.go b/pkg/recipes/terraform/config/providers/kubernetes_test.go index f321b87580..5c292a7cf9 100644 --- a/pkg/recipes/terraform/config/providers/kubernetes_test.go +++ b/pkg/recipes/terraform/config/providers/kubernetes_test.go @@ -19,7 +19,7 @@ package providers import ( "testing" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" "k8s.io/client-go/tools/clientcmd" ) diff --git a/pkg/recipes/terraform/config/providers/mock_provider.go b/pkg/recipes/terraform/config/providers/mock_provider.go index f45154e3bc..4934f2523b 100644 --- a/pkg/recipes/terraform/config/providers/mock_provider.go +++ b/pkg/recipes/terraform/config/providers/mock_provider.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/recipes/terraform/config/providers (interfaces: Provider) +// Source: github.com/radius-project/radius/pkg/recipes/terraform/config/providers (interfaces: Provider) // Package providers is a generated GoMock package. package providers @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - recipes "github.com/project-radius/radius/pkg/recipes" + recipes "github.com/radius-project/radius/pkg/recipes" ) // MockProvider is a mock of Provider interface. diff --git a/pkg/recipes/terraform/config/providers/types.go b/pkg/recipes/terraform/config/providers/types.go index dcee1f07ce..7a12fec82c 100644 --- a/pkg/recipes/terraform/config/providers/types.go +++ b/pkg/recipes/terraform/config/providers/types.go @@ -19,12 +19,12 @@ package providers import ( "context" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/sdk" - ucp_provider "github.com/project-radius/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/sdk" + ucp_provider "github.com/radius-project/radius/pkg/ucp/secret/provider" ) -//go:generate mockgen -destination=./mock_provider.go -package=providers -self_package github.com/project-radius/radius/pkg/recipes/terraform/config/providers github.com/project-radius/radius/pkg/recipes/terraform/config/providers Provider +//go:generate mockgen -destination=./mock_provider.go -package=providers -self_package github.com/radius-project/radius/pkg/recipes/terraform/config/providers github.com/radius-project/radius/pkg/recipes/terraform/config/providers Provider // Provider is an interface for generating Terraform provider configurations. type Provider interface { diff --git a/pkg/recipes/terraform/config/testdata/main-all.tf.json b/pkg/recipes/terraform/config/testdata/main-all.tf.json index 9a9dfbb069..bf8750972b 100644 --- a/pkg/recipes/terraform/config/testdata/main-all.tf.json +++ b/pkg/recipes/terraform/config/testdata/main-all.tf.json @@ -13,8 +13,8 @@ "context": { "resource": { "name": "mongo0", - "id": "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", - "type": "applications.link/mongodatabases" + "id": "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", + "type": "applications.datastores/mongodatabases" }, "application": { "name": "testApplication", diff --git a/pkg/recipes/terraform/config/testdata/main-noparams.tf.json b/pkg/recipes/terraform/config/testdata/main-noparams.tf.json index db8378f73a..5a051f97aa 100644 --- a/pkg/recipes/terraform/config/testdata/main-noparams.tf.json +++ b/pkg/recipes/terraform/config/testdata/main-noparams.tf.json @@ -13,8 +13,8 @@ "context": { "resource": { "name": "mongo0", - "id": "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", - "type": "applications.link/mongodatabases" + "id": "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", + "type": "applications.datastores/mongodatabases" }, "application": { "name": "testApplication", diff --git a/pkg/recipes/terraform/config/testdata/main-noresourceparam.tf.json b/pkg/recipes/terraform/config/testdata/main-noresourceparam.tf.json index e29a625a49..9069bfcd54 100644 --- a/pkg/recipes/terraform/config/testdata/main-noresourceparam.tf.json +++ b/pkg/recipes/terraform/config/testdata/main-noresourceparam.tf.json @@ -13,8 +13,8 @@ "context": { "resource": { "name": "mongo0", - "id": "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.link/mongodatabases/mongo0", - "type": "applications.link/mongodatabases" + "id": "/subscriptions/testSub/resourceGroups/testGroup/providers/applications.datastores/mongodatabases/mongo0", + "type": "applications.datastores/mongodatabases" }, "application": { "name": "testApplication", diff --git a/pkg/recipes/terraform/execute.go b/pkg/recipes/terraform/execute.go index a124f4f75b..234df5ee71 100644 --- a/pkg/recipes/terraform/execute.go +++ b/pkg/recipes/terraform/execute.go @@ -27,14 +27,15 @@ import ( install "github.com/hashicorp/hc-install" tfjson "github.com/hashicorp/terraform-json" - "github.com/project-radius/radius/pkg/metrics" - "github.com/project-radius/radius/pkg/recipes/recipecontext" - "github.com/project-radius/radius/pkg/recipes/terraform/config" - "github.com/project-radius/radius/pkg/recipes/terraform/config/backends" - "github.com/project-radius/radius/pkg/recipes/terraform/config/providers" - "github.com/project-radius/radius/pkg/sdk" - ucp_provider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/metrics" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/recipecontext" + "github.com/radius-project/radius/pkg/recipes/terraform/config" + "github.com/radius-project/radius/pkg/recipes/terraform/config/backends" + "github.com/radius-project/radius/pkg/recipes/terraform/config/providers" + "github.com/radius-project/radius/pkg/sdk" + ucp_provider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" "go.opentelemetry.io/otel/attribute" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -108,6 +109,7 @@ func (e *executor) Deploy(ctx context.Context, options Options) (*tfjson.State, if err != nil { return nil, err } + // verifying if kubernetes secret is created as part of terraform init // this is valid only for the backend of type kubernetes err = verifyKubernetesSecret(ctx, options, e.k8sClientSet, secretSuffix) @@ -121,6 +123,87 @@ func (e *executor) Deploy(ctx context.Context, options Options) (*tfjson.State, return state, nil } +// Delete installs Terraform, creates a working directory, generates a config, and runs Terraform destroy +// in the working directory, returning an error if any of these steps fail. +func (e *executor) Delete(ctx context.Context, options Options) error { + logger := ucplog.FromContextOrDiscard(ctx) + + // Install Terraform + i := install.NewInstaller() + execPath, err := Install(ctx, i, options.RootDir) + // The terraform zip for installation is downloaded in a location outside of the install directory and is only accessible through the installer.Remove function - + // stored in latestVersion.pathsToRemove. So this needs to be called for complete cleanup even if the root terraform directory is deleted. + defer func() { + if err := i.Remove(ctx); err != nil { + logger.Info(fmt.Sprintf("Failed to cleanup Terraform installation: %s", err.Error())) + } + }() + if err != nil { + return err + } + + // Create Working Directory + workingDir, err := createWorkingDir(ctx, options.RootDir) + if err != nil { + return err + } + + // Create Terraform config in the working directory + secretSuffix, err := e.generateConfig(ctx, workingDir, execPath, options) + if err != nil { + return err + } + + // Run TF Destroy in the working directory + err = initAndDestroy(ctx, workingDir, execPath) + if err != nil { + return err + } + + // Delete the kubernetes secret created as part of `terraform apply` in the execute flow. + return e.k8sClientSet.CoreV1(). + Secrets(backends.RadiusNamespace). + Delete(ctx, terraformStateKubernetesPrefix+secretSuffix, metav1.DeleteOptions{}) +} + +func (e *executor) GetRecipeMetadata(ctx context.Context, options Options) (map[string]any, error) { + logger := ucplog.FromContextOrDiscard(ctx) + + // Install Terraform + i := install.NewInstaller() + execPath, err := Install(ctx, i, options.RootDir) + // The terraform zip for installation is downloaded in a location outside of the install directory and is only accessible through the installer.Remove function - + // stored in latestVersion.pathsToRemove. So this needs to be called for complete cleanup even if the root terraform directory is deleted. + defer func() { + if err := i.Remove(ctx); err != nil { + logger.Info(fmt.Sprintf("Failed to cleanup Terraform installation: %s", err.Error())) + } + }() + if err != nil { + return nil, err + } + + // Create Working Directory + workingDir, err := createWorkingDir(ctx, options.RootDir) + if err != nil { + return nil, err + } + + _, err = getTerraformConfig(ctx, workingDir, options) + if err != nil { + return nil, err + } + + result, err := downloadAndInspect(ctx, workingDir, execPath, options) + if err != nil { + return nil, err + } + + return map[string]any{ + "parameters": result.Parameters, + }, nil +} + func createWorkingDir(ctx context.Context, tfDir string) (string, error) { logger := ucplog.FromContextOrDiscard(ctx) @@ -137,42 +220,12 @@ func createWorkingDir(ctx context.Context, tfDir string) (string, error) { func (e *executor) generateConfig(ctx context.Context, workingDir, execPath string, options Options) (string, error) { logger := ucplog.FromContextOrDiscard(ctx) - // Generate Terraform json config in the working directory - // Use recipe name as a local reference to the module. - // Modules are downloaded in a subdirectory in the working directory. Name of the module specified in the - // configuration is used as subdirectory name under .terraform/modules directory. - // https://developer.hashicorp.com/terraform/tutorials/modules/module-use#understand-how-modules-work - localModuleName := options.EnvRecipe.Name - if localModuleName == "" { - return "", ErrRecipeNameEmpty - } - - // Create Terraform configuration containing module information with the given recipe parameters. - tfConfig := config.New(localModuleName, options.EnvRecipe, options.ResourceRecipe) - - // Before downloading the module, Teraform configuration needs to be persisted in the working directory. - // Terraform Get command uses this config file to download module from the source specified in the config. - if err := tfConfig.Save(ctx, workingDir); err != nil { - return "", err - } - - // Download the Terraform module to the working directory. - logger.Info(fmt.Sprintf("Downloading Terraform module: %s", options.EnvRecipe.TemplatePath)) - downloadStartTime := time.Now() - if err := downloadModule(ctx, workingDir, execPath); err != nil { - metrics.DefaultRecipeEngineMetrics.RecordRecipeDownloadDuration(ctx, downloadStartTime, - metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, options.EnvRecipe.Name, - options.EnvRecipe, metrics.FailedOperationState)) + tfConfig, err := getTerraformConfig(ctx, workingDir, options) + if err != nil { return "", err } - metrics.DefaultRecipeEngineMetrics.RecordRecipeDownloadDuration(ctx, downloadStartTime, - metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, options.EnvRecipe.Name, - options.EnvRecipe, metrics.SuccessfulOperationState)) - // Load the downloaded module to retrieve providers and variables required by the module. - // This is needed to add the appropriate providers config and populate the value of recipe context variable. - logger.Info(fmt.Sprintf("Inspecting the downloaded Terraform module: %s", options.EnvRecipe.TemplatePath)) - loadedModule, err := inspectModule(workingDir, localModuleName) + loadedModule, err := downloadAndInspect(ctx, workingDir, execPath, options) if err != nil { return "", err } @@ -209,12 +262,12 @@ func (e *executor) generateConfig(ctx context.Context, workingDir, execPath stri return "", err } - if err = tfConfig.AddRecipeContext(ctx, localModuleName, recipectx); err != nil { + if err = tfConfig.AddRecipeContext(ctx, options.EnvRecipe.Name, recipectx); err != nil { return "", err } } if loadedModule.ResultOutputExists { - if err = tfConfig.AddOutputs(localModuleName); err != nil { + if err = tfConfig.AddOutputs(options.EnvRecipe.Name); err != nil { return "", err } } @@ -229,6 +282,57 @@ func (e *executor) generateConfig(ctx context.Context, workingDir, execPath stri return secretSuffix, nil } +// downloadAndInspect handles downloading the TF module and retrieving the necessary information +func downloadAndInspect(ctx context.Context, workingDir string, execPath string, options Options) (*moduleInspectResult, error) { + logger := ucplog.FromContextOrDiscard(ctx) + + // Download the Terraform module to the working directory. + logger.Info(fmt.Sprintf("Downloading Terraform module: %s", options.EnvRecipe.TemplatePath)) + downloadStartTime := time.Now() + if err := downloadModule(ctx, workingDir, execPath); err != nil { + metrics.DefaultRecipeEngineMetrics.RecordRecipeDownloadDuration(ctx, downloadStartTime, + metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, options.EnvRecipe.Name, + options.EnvRecipe, recipes.RecipeDownloadFailed)) + return nil, recipes.NewRecipeError(recipes.RecipeDownloadFailed, err.Error(), recipes.GetRecipeErrorDetails(err)) + } + metrics.DefaultRecipeEngineMetrics.RecordRecipeDownloadDuration(ctx, downloadStartTime, + metrics.NewRecipeAttributes(metrics.RecipeEngineOperationDownloadRecipe, options.EnvRecipe.Name, + options.EnvRecipe, metrics.SuccessfulOperationState)) + + // Load the downloaded module to retrieve providers and variables required by the module. + // This is needed to add the appropriate providers config and populate the value of recipe context variable. + logger.Info(fmt.Sprintf("Inspecting the downloaded Terraform module: %s", options.EnvRecipe.TemplatePath)) + loadedModule, err := inspectModule(workingDir, options.EnvRecipe.Name) + if err != nil { + return nil, err + } + + return loadedModule, nil +} + +// getTerraformConfig generates the Terraform json config and saves it +func getTerraformConfig(ctx context.Context, workingDir string, options Options) (*config.TerraformConfig, error) { + // Generate Terraform json config in the working directory + // Use recipe name as a local reference to the module. + // Modules are downloaded in a subdirectory in the working directory. Name of the module specified in the + // configuration is used as subdirectory name under .terraform/modules directory. + // https://developer.hashicorp.com/terraform/tutorials/modules/module-use#understand-how-modules-work + localModuleName := options.EnvRecipe.Name + if localModuleName == "" { + return nil, ErrRecipeNameEmpty + } + + // Create Terraform configuration containing module information with the given recipe parameters. + tfConfig := config.New(localModuleName, options.EnvRecipe, options.ResourceRecipe) + + // Before downloading the module, Teraform configuration needs to be persisted in the working directory. + // Terraform Get command uses this config file to download module from the source specified in the config. + if err := tfConfig.Save(ctx, workingDir); err != nil { + return nil, err + } + return tfConfig, nil +} + // initAndApply runs Terraform init and apply in the provided working directory. func initAndApply(ctx context.Context, workingDir, execPath string) (*tfjson.State, error) { logger := ucplog.FromContextOrDiscard(ctx) @@ -271,3 +375,30 @@ func verifyKubernetesSecret(ctx context.Context, options Options, k8s kubernetes return nil } + +// initAndDestroy runs Terraform init and destroy in the provided working directory. +func initAndDestroy(ctx context.Context, workingDir, execPath string) error { + logger := ucplog.FromContextOrDiscard(ctx) + + tf, err := NewTerraform(ctx, workingDir, execPath) + if err != nil { + return err + } + + // Initialize Terraform + logger.Info("Initializing Terraform") + + terraformInitStartTime := time.Now() + if err := tf.Init(ctx); err != nil { + return fmt.Errorf("terraform init failure: %w", err) + } + metrics.DefaultRecipeEngineMetrics.RecordTerraformInitializationDuration(ctx, terraformInitStartTime, nil) + + // Destroy Terraform configuration + logger.Info("Running Terraform destroy") + if err := tf.Destroy(ctx); err != nil { + return fmt.Errorf("terraform destroy failure: %w", err) + } + + return nil +} diff --git a/pkg/recipes/terraform/execute_test.go b/pkg/recipes/terraform/execute_test.go index 72093d28b6..c38c8d939f 100644 --- a/pkg/recipes/terraform/execute_test.go +++ b/pkg/recipes/terraform/execute_test.go @@ -21,8 +21,9 @@ import ( "path/filepath" "testing" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/terraform/config" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) @@ -119,3 +120,61 @@ func TestGeneratedConfig(t *testing.T) { }) } } + +func Test_GetTerraformConfig(t *testing.T) { + // Create a temporary directory for testing. + testDir := t.TempDir() + + workingDir, err := createWorkingDir(testcontext.New(t), testDir) + require.NoError(t, err) + options := Options{ + EnvRecipe: &recipes.EnvironmentDefinition{ + Name: "test-recipe", + TemplatePath: "test/module/source", + }, + ResourceRecipe: &recipes.ResourceMetadata{}, + } + + expectedConfig := config.TerraformConfig{ + Module: map[string]config.TFModuleConfig{ + "test-recipe": {"source": "test/module/source"}}, + } + tfConfig, err := getTerraformConfig(testcontext.New(t), workingDir, options) + require.NoError(t, err) + require.Equal(t, &expectedConfig, tfConfig) +} + +func Test_GetTerraformConfig_EmptyRecipeName(t *testing.T) { + // Create a temporary directory for testing. + testDir := t.TempDir() + + workingDir, err := createWorkingDir(testcontext.New(t), testDir) + require.NoError(t, err) + options := Options{ + EnvRecipe: &recipes.EnvironmentDefinition{ + Name: "", + TemplatePath: "test/module/source", + }, + ResourceRecipe: &recipes.ResourceMetadata{}, + } + + _, err = getTerraformConfig(testcontext.New(t), workingDir, options) + require.Error(t, err) + require.Equal(t, err, ErrRecipeNameEmpty) +} + +func Test_GetTerraformConfig_InvalidDirectory(t *testing.T) { + // Create a temporary directory for testing. + workingDir := "invalid directory" + options := Options{ + EnvRecipe: &recipes.EnvironmentDefinition{ + Name: "test-recipe", + TemplatePath: "test/module/source", + }, + ResourceRecipe: &recipes.ResourceMetadata{}, + } + + _, err := getTerraformConfig(testcontext.New(t), workingDir, options) + require.Error(t, err) + require.Contains(t, err.Error(), "error creating file: open invalid directory/main.tf.json: no such file or directory") +} diff --git a/pkg/recipes/terraform/install.go b/pkg/recipes/terraform/install.go index 31fe1a68b4..03bd561fd4 100644 --- a/pkg/recipes/terraform/install.go +++ b/pkg/recipes/terraform/install.go @@ -27,8 +27,8 @@ import ( "github.com/hashicorp/hc-install/product" "github.com/hashicorp/hc-install/releases" "github.com/hashicorp/hc-install/src" - "github.com/project-radius/radius/pkg/metrics" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/metrics" + "github.com/radius-project/radius/pkg/ucp/ucplog" "go.opentelemetry.io/otel/attribute" ) @@ -51,7 +51,6 @@ func Install(ctx context.Context, installer *install.Installer, tfDir string) (s logger.Info(fmt.Sprintf("Installing Terraform in the directory: %q", installDir)) installStartTime := time.Now() - result := metrics.SuccessfulOperationState // Re-visit this: consider checking if an existing installation of same version of Terraform is available. // For initial iteration we will always install Terraform for every execution of the recipe driver. execPath, err := installer.Ensure(ctx, []src.Source{ @@ -61,18 +60,23 @@ func Install(ctx context.Context, installer *install.Installer, tfDir string) (s }, }) if err != nil { - result = metrics.FailedOperationState + metrics.DefaultRecipeEngineMetrics.RecordTerraformInstallationDuration(ctx, installStartTime, + []attribute.KeyValue{ + metrics.TerraformVersionAttrKey.String("latest"), + metrics.OperationStateAttrKey.String(metrics.FailedOperationState), + }, + ) + return "", err } - // TODO: Update the metric to record the TF version when we start using a versioned TF installation. metrics.DefaultRecipeEngineMetrics.RecordTerraformInstallationDuration(ctx, installStartTime, []attribute.KeyValue{ metrics.TerraformVersionAttrKey.String("latest"), - metrics.OperationStateAttrKey.String(result), + metrics.OperationStateAttrKey.String(metrics.SuccessfulOperationState), }, ) logger.Info(fmt.Sprintf("Terraform latest version installed to: %q", execPath)) - return execPath, err + return execPath, nil } diff --git a/pkg/recipes/terraform/mock_executor.go b/pkg/recipes/terraform/mock_executor.go index 9d6527a40e..0203850e60 100644 --- a/pkg/recipes/terraform/mock_executor.go +++ b/pkg/recipes/terraform/mock_executor.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/recipes/terraform (interfaces: TerraformExecutor) +// Source: github.com/radius-project/radius/pkg/recipes/terraform (interfaces: TerraformExecutor) // Package terraform is a generated GoMock package. package terraform @@ -35,6 +35,20 @@ func (m *MockTerraformExecutor) EXPECT() *MockTerraformExecutorMockRecorder { return m.recorder } +// Delete mocks base method. +func (m *MockTerraformExecutor) Delete(arg0 context.Context, arg1 Options) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockTerraformExecutorMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockTerraformExecutor)(nil).Delete), arg0, arg1) +} + // Deploy mocks base method. func (m *MockTerraformExecutor) Deploy(arg0 context.Context, arg1 Options) (*terraform_json.State, error) { m.ctrl.T.Helper() @@ -49,3 +63,18 @@ func (mr *MockTerraformExecutorMockRecorder) Deploy(arg0, arg1 interface{}) *gom mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deploy", reflect.TypeOf((*MockTerraformExecutor)(nil).Deploy), arg0, arg1) } + +// GetRecipeMetadata mocks base method. +func (m *MockTerraformExecutor) GetRecipeMetadata(arg0 context.Context, arg1 Options) (map[string]interface{}, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetRecipeMetadata", arg0, arg1) + ret0, _ := ret[0].(map[string]interface{}) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetRecipeMetadata indicates an expected call of GetRecipeMetadata. +func (mr *MockTerraformExecutorMockRecorder) GetRecipeMetadata(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRecipeMetadata", reflect.TypeOf((*MockTerraformExecutor)(nil).GetRecipeMetadata), arg0, arg1) +} diff --git a/pkg/recipes/terraform/module.go b/pkg/recipes/terraform/module.go index dc3fef0f09..b3de1a8969 100644 --- a/pkg/recipes/terraform/module.go +++ b/pkg/recipes/terraform/module.go @@ -22,8 +22,8 @@ import ( "path/filepath" "github.com/hashicorp/terraform-config-inspect/tfconfig" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/recipes/recipecontext" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/recipes/recipecontext" ) const ( @@ -41,6 +41,9 @@ type moduleInspectResult struct { // ResultOutputExists is true if the module contains an output named "result". ResultOutputExists bool + // The parameter variables defined by the recipe + Parameters map[string]any + // Any other module information required in the future can be added here. } @@ -50,7 +53,7 @@ type moduleInspectResult struct { // It uses terraform-config-inspect to load the module from the directory. An error is returned if the module // could not be loaded. func inspectModule(workingDir, localModuleName string) (*moduleInspectResult, error) { - result := &moduleInspectResult{ContextVarExists: false, RequiredProviders: []string{}, ResultOutputExists: false} + result := &moduleInspectResult{ContextVarExists: false, RequiredProviders: []string{}, ResultOutputExists: false, Parameters: map[string]any{}} // Modules are downloaded in a subdirectory in the working directory. // Name of the module specified in the configuration is used as subdirectory name. @@ -75,6 +78,20 @@ func inspectModule(workingDir, localModuleName string) (*moduleInspectResult, er result.ResultOutputExists = true } + // Extract the list of parameters. + for variable, value := range mod.Variables { + tfVar := map[string]any{ + "name": value.Name, + "type": value.Type, + "description": value.Description, + "defaultValue": value.Default, + "required": value.Required, + "sensitive": value.Sensitive, + "pos": value.Pos, + } + result.Parameters[variable] = tfVar + } + return result, nil } diff --git a/pkg/recipes/terraform/module_test.go b/pkg/recipes/terraform/module_test.go index acf987feda..8688059ef3 100644 --- a/pkg/recipes/terraform/module_test.go +++ b/pkg/recipes/terraform/module_test.go @@ -20,7 +20,8 @@ import ( "path/filepath" "testing" - "github.com/project-radius/radius/test/testcontext" + "github.com/hashicorp/terraform-config-inspect/tfconfig" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) @@ -40,17 +41,34 @@ func Test_InspectTFModuleConfig(t *testing.T) { ContextVarExists: false, RequiredProviders: []string{"aws"}, ResultOutputExists: false, + Parameters: map[string]any{}, }, - }, { - name: "aws provider with recipe context variable and output", + }, + { + name: "aws provider with recipe context variable, output and parameters", workingDir: "testdata", moduleName: "test-module-recipe-context-outputs", result: &moduleInspectResult{ ContextVarExists: true, RequiredProviders: []string{"aws"}, ResultOutputExists: true, + Parameters: map[string]any{ + "context": map[string]any{ + "name": "context", + "type": "object({\n resource = object({\n name = string\n id = string\n type = string\n })\n\n application = object({\n name = string\n id = string\n })\n\n environment = object({\n name = string\n id = string\n })\n\n runtime = object({\n kubernetes = optional(object({\n namespace = string\n environmentNamespace = string\n }))\n })\n\n azure = optional(object({\n resourceGroup = object({\n name = string\n id = string\n })\n subscription = object({\n subscriptionId = string\n id = string\n })\n }))\n \n aws = optional(object({\n region = string\n account = string\n }))\n })", + "description": "This variable contains Radius recipe context.", + "defaultValue": nil, + "required": true, + "sensitive": false, + "pos": tfconfig.SourcePos{ + Filename: "testdata/.terraform/modules/test-module-recipe-context-outputs/variables.tf", + Line: 1, + }, + }, + }, }, - }, { + }, + { name: "invalid module name - non existent module directory", workingDir: "testdata", moduleName: "invalid-module", diff --git a/pkg/recipes/terraform/types.go b/pkg/recipes/terraform/types.go index 641a27a3f1..7753caef3d 100644 --- a/pkg/recipes/terraform/types.go +++ b/pkg/recipes/terraform/types.go @@ -22,15 +22,22 @@ import ( "github.com/go-logr/logr" "github.com/hashicorp/terraform-exec/tfexec" tfjson "github.com/hashicorp/terraform-json" - "github.com/project-radius/radius/pkg/recipes" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) -//go:generate mockgen -destination=./mock_executor.go -package=terraform -self_package github.com/project-radius/radius/pkg/recipes/terraform github.com/project-radius/radius/pkg/recipes/terraform TerraformExecutor +//go:generate mockgen -destination=./mock_executor.go -package=terraform -self_package github.com/radius-project/radius/pkg/recipes/terraform github.com/radius-project/radius/pkg/recipes/terraform TerraformExecutor type TerraformExecutor interface { // Deploy installs terraform and runs terraform init and apply on the terraform module referenced by the recipe using terraform-exec. Deploy(ctx context.Context, options Options) (*tfjson.State, error) + + // Delete installs terraform and runs terraform destroy on the terraform module referenced by the recipe using terraform-exec, + // and deletes the Kubernetes secret created for terraform state store. + Delete(ctx context.Context, options Options) error + + // GetRecipeMetadata installs terraform and runs terraform get to retrieve information on the terraform module + GetRecipeMetadata(ctx context.Context, options Options) (map[string]any, error) } // Options represents the options required to build inputs to interact with Terraform. diff --git a/pkg/recipes/types.go b/pkg/recipes/types.go index 446a5943fc..2e0831ab35 100644 --- a/pkg/recipes/types.go +++ b/pkg/recipes/types.go @@ -21,7 +21,7 @@ import ( "encoding/json" "fmt" - "github.com/project-radius/radius/pkg/corerp/datamodel" + "github.com/radius-project/radius/pkg/corerp/datamodel" ) // Configuration represents kubernetes runtime and cloud provider configuration, which is used by the driver while deploying recipes. @@ -39,7 +39,7 @@ type RuntimeConfiguration struct { // KubernetesRuntime represents application and environment namespaces. type KubernetesRuntime struct { - // Namespace is set to the application namespace when the Link is application-scoped, and set to the environment namespace when the Link is environment scoped + // Namespace is set to the application namespace when the portable resource is application-scoped, and set to the environment namespace when it is environment scoped Namespace string `json:"namespace,omitempty"` // EnvironmentNamespace is set to environment namespace. EnvironmentNamespace string `json:"environmentNamespace"` @@ -51,7 +51,7 @@ type EnvironmentDefinition struct { Name string // Driver represents the kind of infrastructure language used to define recipe. Driver string - // ResourceType represents the type of the link this recipe can be consumed by. + // ResourceType represents the type of the portable resource this recipe can be consumed by. ResourceType string // Parameters represents key/value pairs to pass into the recipe template for every resource using this recipe. Specified during recipe registration to environment. Can be overridden by the radius resource consuming this recipe. Parameters map[string]any @@ -61,13 +61,13 @@ type EnvironmentDefinition struct { TemplateVersion string } -// ResourceMetadata represents recipe details provided while creating a Link resource. +// ResourceMetadata represents recipe details provided while creating a portable resource. type ResourceMetadata struct { // Name represents the name of the recipe within the environment Name string - // ApplicationID represents fully qualified resource ID for the application that the link is consumed by + // ApplicationID represents fully qualified resource ID for the application that the portable resource is consumed by ApplicationID string - // EnvironmentID represents fully qualified resource ID for the environment that the link is linked to + // EnvironmentID represents fully qualified resource ID for the environment that the portable resource is linked to EnvironmentID string // ResourceID represents fully qualified resource ID for the resource the recipe is deploying ResourceID string diff --git a/pkg/resourcekinds/resource_kinds.go b/pkg/resourcekinds/resource_kinds.go deleted file mode 100644 index e90f027395..0000000000 --- a/pkg/resourcekinds/resource_kinds.go +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resourcekinds - -// ResourceKinds supported. The RP determines how these are created/deleted and the HealthService determines how -// health checks are handled for these -const ( - Azure = "azure" - Kubernetes = "kubernetes" - Deployment = "Deployment" - Service = "Service" - ServiceAccount = "ServiceAccount" - Secret = "Secret" - Gateway = "Gateway" - Volume = "Volume" - KubernetesRole = "KubernetesRole" - KubernetesRoleBinding = "KubernetesRoleBinding" - KubernetesHTTPRoute = "HTTPRoute" // For httproutes.networking.x-k8s.io - RadiusHttpRoute = "HttpRoute" // For httproutes.radius.dev - StatefulSet = "StatefulSet" - SecretProviderClass = "SecretProviderClass" - DaprStateStoreAzureStorage = "dapr.statestore.azurestorage" - DaprStateStoreAzureTableService = "dapr.statestore.azuretableservice" - DaprStateStoreAzureTable = "dapr.statestore.azuretable" - DaprStateStoreAzureTableStorage = "state.azure.tablestorage" - DaprGeneric = "generic" - DaprComponent = "dapr.io.component" - DaprPubSubTopicAzureServiceBus = "pubsub.azure.servicebus" - AzureCosmosAccount = "azure.cosmosdb.account" - AzureCosmosDBMongo = "azure.cosmosdb.mongo" - AzureCosmosDBSQL = "azure.cosmosdb.sql" - AzureSqlServer = "azure.sql" - AzureSqlServerDatabase = "azure.sql.database" - AzureUserAssignedManagedIdentity = "azure.userassignedmanagedidentity" - AzureFederatedIdentity = "azure.federatedidentity" - AzureRoleAssignment = "azure.roleassignment" - AzureRedis = "azure.redis" - AzureFileShare = "azure.fileshare" - AzureFileShareStorageAccount = "azure.fileshare.account" - - // AnyResourceType is used to designate a resource handler that can handle any type that belongs to a provider. AnyResourceType - // should only be used to register handlers, and not as part of an output resource. - AnyResourceType = "*" -) diff --git a/pkg/resourcemodel/identity.go b/pkg/resourcemodel/identity.go index ee7600e144..9306c18cf0 100644 --- a/pkg/resourcemodel/identity.go +++ b/pkg/resourcemodel/identity.go @@ -17,19 +17,7 @@ limitations under the License. package resourcemodel import ( - "encoding/json" "fmt" - "strings" - - "github.com/project-radius/radius/pkg/logging" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "go.mongodb.org/mongo-driver/bson" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" ) // Providers supported by Radius @@ -39,11 +27,6 @@ const ( ProviderAWS = "aws" ProviderRadius = "radius" ProviderKubernetes = "kubernetes" - - // APIVersionUnknown encodes an "unknown" API version. Including API version in resource identity is - // a design mistake because an API version is not part of the identity of a resource. We use this - // value as a sentinel for the cases where we don't have a preferred API version. - APIVersionUnknown = "unknown" ) // ResourceType determines the type of the resource and the provider domain for the resource @@ -56,485 +39,3 @@ type ResourceType struct { func (r ResourceType) String() string { return fmt.Sprintf("Provider: %s, Type: %s", r.Provider, r.Type) } - -// ResourceIdentity represents the identity of a resource in the underlying system. -// - eg: For ARM this a Resource ID + API Version -// - eg: For Kubernetes this a GroupVersionKind + Namespace + Name -// -// This type supports safe serialization to/from JSON & BSON. -type ResourceIdentity struct { - ResourceType *ResourceType `json:"resourceType"` - // A polymorphic payload. The fields in this data structure are determined by the provider field in the ResourceType - Data any `json:"data"` -} - -// We just need custom Unmarshaling, default Marshaling is fine. -var _ json.Unmarshaler = (*ResourceIdentity)(nil) - -// ARMIdentity uniquely identifies an ARM resource -type ARMIdentity struct { - ID string `json:"id"` - APIVersion string `json:"apiVersion"` -} - -// UCPIdentity uniquely identifies a UCP resource -type UCPIdentity struct { - ID string `json:"id"` -} - -// KubernetesIdentity uniquely identifies a Kubernetes resource -type KubernetesIdentity struct { - Kind string `json:"kind"` - APIVersion string `json:"apiVersion"` - Name string `json:"name"` - Namespace string `json:"namespace"` -} - -// AzureFederatedIdentity represents the federated identity for OIDC issuer. -type AzureFederatedIdentity struct { - // Name represents the name of federeated identity. - Name string `json:"name"` - // Resource represents the associated identity resource. - Resource string `json:"resource"` - // OIDCIssuer represents the OIDC issuer. - OIDCIssuer string `json:"oidcIssuer"` - // Audience represents the client ID of Resource - Audience string `json:"audience"` - // Subejct represents the subject of Identity - Subject string `json:"subject"` -} - -// NewARMIdentity creates a new ResourceIdentity object from a ResourceType, an ID and an API version. -func NewARMIdentity(resourceType *ResourceType, id string, apiVersion string) ResourceIdentity { - return ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourceType.Type, - Provider: resourceType.Provider, - }, - Data: ARMIdentity{ - ID: id, - APIVersion: apiVersion, - }, - } -} - -// NewUCPIdentity creates a new ResourceIdentity with the given ResourceType and ID. -func NewUCPIdentity(resourceType *ResourceType, id string) ResourceIdentity { - return ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourceType.Type, - Provider: resourceType.Provider, - }, - Data: UCPIdentity{ - ID: id, - }, - } -} - -// NewKubernetesIdentity creates a ResourceIdentity object from a ResourceType, runtime.Object and metav1.ObjectMeta. -func NewKubernetesIdentity(resourceType *ResourceType, obj runtime.Object, objectMeta metav1.ObjectMeta) ResourceIdentity { - return ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourceType.Type, - Provider: resourceType.Provider, - }, - Data: KubernetesIdentity{ - Kind: obj.GetObjectKind().GroupVersionKind().Kind, - APIVersion: obj.GetObjectKind().GroupVersionKind().GroupVersion().String(), - Name: objectMeta.Name, - Namespace: objectMeta.Namespace, - }, - } -} - -// GetID constructs a UCP resource ID from the ResourceIdentity. -func (r ResourceIdentity) GetID() string { - if r.ResourceType == nil { - return "" // For a default-initialized identity we can't do anything smart. - } - - switch r.ResourceType.Provider { - case ProviderAzure: - id, _, _ := r.RequireARM() - return id - case ProviderAWS: - id, _ := r.RequireAWS() - return id - case ProviderRadius: - id, _ := r.RequireRadius() - return id - case ProviderKubernetes: - gvk, namespace, name, _ := r.RequireKubernetes() - group := gvk.Group - if group == "" { - group = "core" - } - if namespace == "" { - return fmt.Sprintf("/planes/kubernetes/local/providers/%s/%s/%s", group, gvk.Kind, name) - } else { - return fmt.Sprintf("/planes/kubernetes/local/namespaces/%s/providers/%s/%s/%s", namespace, group, gvk.Kind, name) - } - default: - return "" - } -} - -// RequireARM checks if the ResourceType provider is Azure and returns the ID and API version of the ARMIdentity, or an -// error if the provider is not Azure. -func (r ResourceIdentity) RequireARM() (string, string, error) { - if r.ResourceType.Provider == ProviderAzure { - data, ok := r.Data.(ARMIdentity) - if !ok { - data = ARMIdentity{} - if err := store.DecodeMap(r.Data, &data); err != nil { - return "", "", err - } - } - return data.ID, data.APIVersion, nil - } - - return "", "", fmt.Errorf("expected an %q provider, was %q", ProviderAzure, r.ResourceType.Provider) -} - -// RequireAWS checks if the ResourceIdentity is an AWS provider and returns the ID or an error if not. -func (r ResourceIdentity) RequireAWS() (string, error) { - if r.ResourceType.Provider == ProviderAWS { - data, ok := r.Data.(UCPIdentity) - if !ok { - data = UCPIdentity{} - if err := store.DecodeMap(r.Data, &data); err != nil { - return "", err - } - } - return data.ID, nil - } - - return "", fmt.Errorf("expected an %q provider, was %q", ProviderAWS, r.ResourceType.Provider) -} - -// RequireRadius checks if the ResourceIdentity is an Radius ID and returns the ID or an error if not. -func (r ResourceIdentity) RequireRadius() (string, error) { - if r.ResourceType.Provider == ProviderRadius { - data, ok := r.Data.(UCPIdentity) - if !ok { - data = UCPIdentity{} - if err := store.DecodeMap(r.Data, &data); err != nil { - return "", err - } - } - return data.ID, nil - } - - return "", fmt.Errorf("expected an %q provider, was %q", ProviderRadius, r.ResourceType.Provider) -} - -// RequireKubernetes checks if the ResourceType.Provider is Kubernetes and returns the GroupVersionKind, Namespace, Name -// and an error if the Provider is not Kubernetes. -func (r ResourceIdentity) RequireKubernetes() (schema.GroupVersionKind, string, string, error) { - if r.ResourceType.Provider == ProviderKubernetes { - data, ok := r.Data.(KubernetesIdentity) - if !ok { - data = KubernetesIdentity{} - if err := store.DecodeMap(r.Data, &data); err != nil { - return schema.GroupVersionKind{}, "", "", err - } - } - return schema.FromAPIVersionAndKind(data.APIVersion, data.Kind), data.Namespace, data.Name, nil - } - - return schema.GroupVersionKind{}, "", "", fmt.Errorf("expected an %q provider, was %q", ProviderKubernetes, r.ResourceType.Provider) -} - -// IsSameResource compares two ResourceIdentity objects and returns a boolean indicating whether they are the same resource or not. -func (r ResourceIdentity) IsSameResource(other ResourceIdentity) bool { - if r.ResourceType.Provider != other.ResourceType.Provider { - return false - } - - switch r.ResourceType.Provider { - case ProviderAzure: - a, _ := r.Data.(ARMIdentity) - b, _ := other.Data.(ARMIdentity) - return a == b - - case ProviderAWS: - a, _ := r.Data.(UCPIdentity) - b, _ := other.Data.(UCPIdentity) - return a == b - - case ProviderRadius: - a, _ := r.Data.(UCPIdentity) - b, _ := other.Data.(UCPIdentity) - return a == b - - case ProviderKubernetes: - a, _ := r.Data.(KubernetesIdentity) - b, _ := other.Data.(KubernetesIdentity) - return a == b - - } - // An identity without a valid kind is not the same as any resource. - return false -} - -// AsLogValues returns a slice of any type based on the provider type of the ResourceIdentity struct. If the provider is -// Azure, it returns the ResourceID, SubscriptionID, ResourceGroup, ResourceType and ResourceName. If the provider is AWS, -// it returns the ResourceID, ResourceType and ResourceName. If the provider is Kubernetes, it returns the ResourceName, -// Namespace, Kind and ResourceKind. If the provider is none of the above, it returns nil. -func (r ResourceIdentity) AsLogValues() []any { - if r.ResourceType == nil { - return nil - } - switch r.ResourceType.Provider { - case ProviderAzure: - // We can't report an error here so this is best-effort. - data := r.Data.(ARMIdentity) - id, err := resources.ParseResource(data.ID) - if err != nil { - return []any{ucplog.LogFieldResourceID, data.ID} - } - - return []any{ - logging.LogFieldResourceID, data.ID, - logging.LogFieldSubscriptionID, id.FindScope(resources.SubscriptionsSegment), - logging.LogFieldResourceGroup, id.FindScope(resources.ResourceGroupsSegment), - logging.LogFieldResourceType, id.Type(), - logging.LogFieldResourceName, id.QualifiedName(), - } - - case ProviderAWS: - // We can't report an error here so this is best-effort. - data := r.Data.(UCPIdentity) - id, err := resources.ParseResource(data.ID) - if err != nil { - return []any{ucplog.LogFieldResourceID, data.ID} - } - - return []any{ - logging.LogFieldResourceID, data.ID, - logging.LogFieldResourceType, id.Type(), - logging.LogFieldResourceName, id.QualifiedName(), - } - - case ProviderRadius: - // We can't report an error here so this is best-effort. - data := r.Data.(UCPIdentity) - id, err := resources.ParseResource(data.ID) - if err != nil { - return []any{ucplog.LogFieldResourceID, data.ID} - } - - return []any{ - logging.LogFieldResourceID, data.ID, - logging.LogFieldResourceType, id.Type(), - logging.LogFieldResourceName, id.QualifiedName(), - } - - case ProviderKubernetes: - data := r.Data.(KubernetesIdentity) - return []any{ - logging.LogFieldResourceName, data.Name, - logging.LogFieldNamespace, data.Namespace, - logging.LogFieldKind, data.Kind, - logging.LogFieldResourceKind, resourcekinds.Kubernetes, - } - - default: - return nil - } -} - -// UnmarshalJSON unmarshals a JSON byte slice into a ResourceIdentity struct based on the provider type. -func (r *ResourceIdentity) UnmarshalJSON(b []byte) error { - type intermediate struct { - ResourceType *ResourceType `json:"resourceType"` - Data json.RawMessage `json:"data"` - } - - data := intermediate{} - err := json.Unmarshal(b, &data) - if err != nil { - return err - } - - r.ResourceType = data.ResourceType - - // Make sure not to crash for a default-initialized identity. - if r.ResourceType == nil { - return nil - } - - switch r.ResourceType.Provider { - case ProviderAzure: - identity := ARMIdentity{} - err = json.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - - case ProviderAWS: - identity := UCPIdentity{} - err = json.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - - case ProviderRadius: - identity := UCPIdentity{} - err = json.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - - case ProviderKubernetes: - identity := KubernetesIdentity{} - err = json.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - } - - err = json.Unmarshal(data.Data, &r.Data) - if err != nil { - return err - } - - return nil -} - -// UnmarshalBSON unmarshals a BSON byte slice into a ResourceIdentity, depending on the provider type. It returns an error -// if the provider type is unknown or if the BSON unmarshalling fails. -func (r *ResourceIdentity) UnmarshalBSON(b []byte) error { - type intermediate struct { - ResourceType *ResourceType `json:"resourceType"` - Data bson.Raw `bson:"data"` - } - - data := intermediate{} - err := bson.Unmarshal(b, &data) - if err != nil { - return err - } - - r.ResourceType = data.ResourceType - - // Make sure not to crash for a default-initialized identity. - if r.ResourceType == nil { - return nil - } - - switch r.ResourceType.Provider { - case ProviderAzure: - identity := ARMIdentity{} - err = bson.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - - case ProviderAWS: - identity := UCPIdentity{} - err = bson.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - - case ProviderRadius: - identity := UCPIdentity{} - err = bson.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - - case ProviderKubernetes: - identity := KubernetesIdentity{} - err = bson.Unmarshal(data.Data, &identity) - if err != nil { - return err - } - r.Data = identity - return nil - - default: - return fmt.Errorf("unknown provider: %q", r.ResourceType.Provider) - } -} - -// FromUCPID translates a UCP resource ID into a ResourceIdentity. -// -// TODO: This is transitional while we're refactoring to get rid of ResourceIdentity. UCP resource IDs are a more -// complete and flexible way of identitying resources. -func FromUCPID(id resources.ID, preferredAPIVersion string) ResourceIdentity { - // Blank resource id => blank identity - if len(id.ScopeSegments()) == 0 { - return ResourceIdentity{} - } - - firstScope := id.ScopeSegments()[0].Type - if preferredAPIVersion == "" { - preferredAPIVersion = APIVersionUnknown - } - - // If this starts with a subscription ID then it's an Azure resource - // - // case: /subscriptions/.../resourceGroups/.../...... - if strings.EqualFold(resources.SubscriptionsSegment, firstScope) { - return NewARMIdentity(&ResourceType{Type: id.Type(), Provider: ProviderAzure}, id.String(), preferredAPIVersion) - } - - // case: /planes/azure/azurecloud/subscriptions/.../resourceGroups/.../...... - if strings.EqualFold("azure", firstScope) { - return NewARMIdentity(&ResourceType{Type: id.Type(), Provider: ProviderAzure}, id.String(), preferredAPIVersion) - } - - // case: /planes/aws/aws/accounts/.../regions/.../...... - if strings.EqualFold("aws", firstScope) { - return NewUCPIdentity(&ResourceType{Type: id.Type(), Provider: ProviderAWS}, id.String()) - } - - // case: /planes/radius/local/... - if strings.EqualFold("radius", firstScope) { - return NewUCPIdentity(&ResourceType{Type: id.Type(), Provider: ProviderRadius}, id.String()) - } - - // case: /planes/kubernetes/local/namespaces/.../...... - if strings.EqualFold("kubernetes", firstScope) { - // Kubernetes has some quirks because API groups were added after the initial release. - // We encode the "unnamed" group as "core". - group, kind, _ := strings.Cut(id.Type(), "/") - resourceType := id.Type() - apiVersion := group + "/" + preferredAPIVersion - if strings.EqualFold(group, "core") { - resourceType = kind - apiVersion = preferredAPIVersion - } - - return ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourceType, - Provider: ProviderKubernetes, - }, - Data: KubernetesIdentity{ - Kind: kind, - APIVersion: apiVersion, - Namespace: id.FindScope("namespaces"), - Name: id.Name(), - }, - } - } - - return ResourceIdentity{} -} diff --git a/pkg/resourcemodel/identity_test.go b/pkg/resourcemodel/identity_test.go deleted file mode 100644 index c76feceb9a..0000000000 --- a/pkg/resourcemodel/identity_test.go +++ /dev/null @@ -1,170 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resourcemodel - -import ( - "encoding/json" - "testing" - - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/stretchr/testify/require" - "go.mongodb.org/mongo-driver/bson" -) - -var values = []struct { - Description string - ExpectedID string - Identity ResourceIdentity -}{ - { - // Ensure that default-initialized identity does not panic. - Description: "empty", - ExpectedID: "", - Identity: ResourceIdentity{}, - }, - { - Description: "Azure", - ExpectedID: "/subscriptions/0000/resourceGroups/mygroup/providers/Microsoft.DocumentDB/accounts/someaccount", - Identity: ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourcekinds.AzureCosmosAccount, - Provider: ProviderAzure, - }, - Data: ARMIdentity{ - ID: "/subscriptions/0000/resourceGroups/mygroup/providers/Microsoft.DocumentDB/accounts/someaccount", - APIVersion: "2020-01-01", - }, - }, - }, - { - // "core" group - Description: "Kubernetes (core)", - ExpectedID: "/planes/kubernetes/local/namespaces/test-namespace/providers/core/Secret/test-name", - Identity: ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourcekinds.Secret, - Provider: ProviderKubernetes, - }, - Data: KubernetesIdentity{ - Kind: "Secret", - APIVersion: "v1", - Name: "test-name", - Namespace: "test-namespace", - }, - }, - }, - { - // Cluster-scoped resource - Description: "Kubernetes (cluster-scoped)", - ExpectedID: "/planes/kubernetes/local/providers/secrets/SecretProviderClass/test-name", - Identity: ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourcekinds.SecretProviderClass, - Provider: ProviderKubernetes, - }, - Data: KubernetesIdentity{ - Kind: "SecretProviderClass", - APIVersion: "secrets/v1", - Name: "test-name", - }, - }, - }, - { - // Namespaced non-core group - Description: "Kubernetes (non-core)", - ExpectedID: "/planes/kubernetes/local/namespaces/test-namespace/providers/apps/Deployment/test-name", - Identity: ResourceIdentity{ - ResourceType: &ResourceType{ - Type: resourcekinds.Deployment, - Provider: ProviderKubernetes, - }, - Data: KubernetesIdentity{ - Kind: "Deployment", - APIVersion: "apps/v1", - Name: "test-name", - Namespace: "test-namespace", - }, - }, - }, - { - Description: "AWS", - ExpectedID: "/planes/aws/aws/accounts/0000/regions/us-west-2/providers/AWS.Kinesis/Stream/mystream", - Identity: ResourceIdentity{ - ResourceType: &ResourceType{ - Type: "AWS.Kinesis/Stream", - Provider: ProviderAWS, - }, - Data: UCPIdentity{ - ID: "/planes/aws/aws/accounts/0000/regions/us-west-2/providers/AWS.Kinesis/Stream/mystream", - }, - }, - }, - { - Description: "Radius", - ExpectedID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/applications/myapp", - Identity: ResourceIdentity{ - ResourceType: &ResourceType{ - Type: "Applications.Core/applications", - Provider: ProviderRadius, - }, - Data: UCPIdentity{ - ID: "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/applications/myapp", - }, - }, - }, -} - -// Test that all formats of ResourceIdentifier round-trip with BSON -func Test_ResourceIdentifier_BSONRoundTrip(t *testing.T) { - for _, input := range values { - t.Run(input.Description, func(t *testing.T) { - b, err := bson.Marshal(&input.Identity) - require.NoError(t, err) - - output := ResourceIdentity{} - err = bson.Unmarshal(b, &output) - require.NoError(t, err) - - require.Equal(t, input.Identity, output) - }) - } -} - -// Test that all formats of ResourceIdentifier round-trip with JSON -func Test_ResourceIdentifier_JSONRoundTrip(t *testing.T) { - for _, input := range values { - t.Run(input.Description, func(t *testing.T) { - b, err := json.Marshal(&input.Identity) - require.NoError(t, err) - - output := ResourceIdentity{} - err = json.Unmarshal(b, &output) - require.NoError(t, err) - - require.Equal(t, input.Identity, output) - }) - } -} - -func Test_GetID(t *testing.T) { - for _, input := range values { - t.Run(input.Description, func(t *testing.T) { - id := input.Identity.GetID() - require.Equal(t, input.ExpectedID, id) - }) - } -} diff --git a/pkg/rp/doc.go b/pkg/rp/doc.go index 3cd006fe3c..9caafd8a16 100644 --- a/pkg/rp/doc.go +++ b/pkg/rp/doc.go @@ -14,5 +14,5 @@ See the License for the specific language governing permissions and limitations under the License. */ -// rp package includes common packages which are shared by corerp and linkrp. +// rp package includes common packages which are shared by corerp and portable resources rps (datastoresrp, messagingrp, daprrp). package rp diff --git a/pkg/rp/frontend/resource_test.go b/pkg/rp/frontend/resource_test.go index 9f086ff48e..9c0e6dd66e 100644 --- a/pkg/rp/frontend/resource_test.go +++ b/pkg/rp/frontend/resource_test.go @@ -17,9 +17,9 @@ limitations under the License. package frontend import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" ) const ( diff --git a/pkg/rp/frontend/validator.go b/pkg/rp/frontend/validator.go index 57e6315abf..27f89fa2a6 100644 --- a/pkg/rp/frontend/validator.go +++ b/pkg/rp/frontend/validator.go @@ -19,10 +19,11 @@ package frontend import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" ) // PrepareRadiusResource validates the Radius resource and prepare new resource data. @@ -47,3 +48,19 @@ func PrepareRadiusResource[P interface { return nil, nil } + +// PrepareDaprResource validates if the cluster has Dapr installed. +func PrepareDaprResource[P interface { + *T + rpv1.RadiusResourceModel +}, T any](ctx context.Context, newResource *T, oldResource *T, options *controller.Options) (rest.Response, error) { + isDaprSupported, err := datamodel.IsDaprInstalled(ctx, options.KubeClient) + if err != nil { + return nil, err + } + if !isDaprSupported { + return rest.NewDependencyMissingResponse(datamodel.DaprMissingError), nil + } + + return nil, nil +} diff --git a/pkg/rp/frontend/validator_test.go b/pkg/rp/frontend/validator_test.go index d9860f4a1d..b660e56634 100644 --- a/pkg/rp/frontend/validator_test.go +++ b/pkg/rp/frontend/validator_test.go @@ -20,10 +20,15 @@ import ( "context" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/daprrp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/require" + apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apimachinery/pkg/runtime" ) func newTestARMContext() context.Context { @@ -88,3 +93,38 @@ func TestPrepareRadiusResource_DeepCopy(t *testing.T) { require.Nil(t, resp) require.Equal(t, "testID", newResource.Properties.BasicResourceProperties.Status.OutputResources[0].LocalID) } + +// TestPrepareDaprResource tests the PrepareDaprResource function. +// At present we have only a negative test, due to the challenge of receiving a different result for test purposes from fakekubeclient, which is called by datamodel.IsDaprInstalled. +// For positive case (dapr is installed), we have several E2E tests to make sure the functionality works. +func TestPrepareDaprResource(t *testing.T) { + crdScheme := runtime.NewScheme() + err := apiextv1.AddToScheme(crdScheme) + require.NoError(t, err) + + client := k8sutil.NewFakeKubeClient(crdScheme) + oldResource := &TestResourceDataModel{Properties: &TestResourceDataModelProperties{ + BasicResourceProperties: rpv1.BasicResourceProperties{ + Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + Status: rpv1.ResourceStatus{ + OutputResources: []rpv1.OutputResource{ + { + LocalID: "testID", + }, + }, + }, + }, + }} + newResource := &TestResourceDataModel{Properties: &TestResourceDataModelProperties{ + BasicResourceProperties: rpv1.BasicResourceProperties{ + Environment: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + Application: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + }, + }} + expectedResp := rest.NewDependencyMissingResponse(datamodel.DaprMissingError) + resp, err := PrepareDaprResource(newTestARMContext(), newResource, oldResource, &controller.Options{KubeClient: client}) + require.NoError(t, err) + require.Equal(t, expectedResp, resp) + +} diff --git a/pkg/rp/kube/kubernetesmetadata.go b/pkg/rp/kube/kubernetesmetadata.go index 9c324d1ca8..e36e584fe7 100644 --- a/pkg/rp/kube/kubernetesmetadata.go +++ b/pkg/rp/kube/kubernetesmetadata.go @@ -17,11 +17,9 @@ limitations under the License. package kube import ( - "context" "strings" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/kubernetes" "k8s.io/apimachinery/pkg/labels" ) @@ -39,7 +37,7 @@ type Metadata struct { // More info: // ObjectMeta: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata // Spec: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status -func (km *Metadata) Merge(ctx context.Context) (map[string]string, map[string]string) { +func (km *Metadata) Merge() (map[string]string, map[string]string) { mergedDataMap := map[string]string{} if km.EnvData != nil { @@ -51,8 +49,8 @@ func (km *Metadata) Merge(ctx context.Context) (map[string]string, map[string]st } // Reject custom user entries that may affect Radius reserved keys. - mergedDataMap = rejectReservedEntries(ctx, mergedDataMap) - km.Input = rejectReservedEntries(ctx, km.Input) + mergedDataMap = rejectReservedEntries(mergedDataMap) + km.Input = rejectReservedEntries(km.Input) // Cumulative Env+App Labels (mergeMap) is now merged with new input map. Existing metaLabels and specLabels are subsequently merged with the result map. mergedDataMap = labels.Merge(mergedDataMap, km.Input) @@ -63,12 +61,9 @@ func (km *Metadata) Merge(ctx context.Context) (map[string]string, map[string]st } // rejectReservedEntries rejects custom user entries that would affect Radius reserved keys -func rejectReservedEntries(ctx context.Context, inputMap map[string]string) map[string]string { - logger := ucplog.FromContextOrDiscard(ctx) - +func rejectReservedEntries(inputMap map[string]string) map[string]string { for k := range inputMap { if strings.HasPrefix(k, kubernetes.RadiusDevPrefix) { - logger.Info("User provided label/annotation key starts with 'radius.dev/' and is not being applied", "key", k) delete(inputMap, k) } } diff --git a/pkg/rp/kube/kubernetesmetadata_test.go b/pkg/rp/kube/kubernetesmetadata_test.go index f11c984bda..42b6dccdaf 100644 --- a/pkg/rp/kube/kubernetesmetadata_test.go +++ b/pkg/rp/kube/kubernetesmetadata_test.go @@ -17,7 +17,6 @@ limitations under the License. package kube import ( - "context" "testing" "github.com/stretchr/testify/require" @@ -80,7 +79,7 @@ func Test_Render_WithEnvironment_KubernetesMetadata(t *testing.T) { } // Testing for cascading, overriding, and reserved keys - metaMap, specMap := input.Merge(context.Background()) + metaMap, specMap := input.Merge() // Verify require.Equal(t, metaMap, expectedMetadataMap) diff --git a/pkg/rp/kube/resources.go b/pkg/rp/kube/resources.go index c2bdc989ae..59c418a6df 100644 --- a/pkg/rp/kube/resources.go +++ b/pkg/rp/kube/resources.go @@ -21,12 +21,12 @@ import ( "errors" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - cdm "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + cdm "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/resources" ) // FindNamespaceByEnvID finds the environment-scope Kubernetes namespace. If the environment ID is invalid or the environment is not a Kubernetes diff --git a/pkg/rp/kube/resources_test.go b/pkg/rp/kube/resources_test.go index 7eb582dc40..d6c3f10d0b 100644 --- a/pkg/rp/kube/resources_test.go +++ b/pkg/rp/kube/resources_test.go @@ -22,13 +22,13 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - model "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + model "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/rp/util/application.go b/pkg/rp/util/application.go index f9f40d86a1..db0feefa85 100644 --- a/pkg/rp/util/application.go +++ b/pkg/rp/util/application.go @@ -20,9 +20,9 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - resources "github.com/project-radius/radius/pkg/ucp/resources" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + resources "github.com/radius-project/radius/pkg/ucp/resources" ) // FetchApplication fetches an application resource from the Azure Resource Manager using the given application ID and diff --git a/pkg/rp/util/datastore.go b/pkg/rp/util/datastore.go index 83c30cad58..5aa2306221 100644 --- a/pkg/rp/util/datastore.go +++ b/pkg/rp/util/datastore.go @@ -22,10 +22,10 @@ import ( "fmt" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - resources "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + resources "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" ) // FetchScopeResource checks if the given scopeID is a valid resource ID for the given resource type, fetches the resource diff --git a/pkg/rp/util/environment.go b/pkg/rp/util/environment.go index 9a663125dd..00bec92f23 100644 --- a/pkg/rp/util/environment.go +++ b/pkg/rp/util/environment.go @@ -20,9 +20,9 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - resources "github.com/project-radius/radius/pkg/ucp/resources" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + resources "github.com/radius-project/radius/pkg/ucp/resources" ) // FetchEnvironment fetches an environment resource using the provided environmentID and ClientOptions, diff --git a/pkg/rp/util/registry.go b/pkg/rp/util/registry.go index 57010104e7..a7886708bd 100644 --- a/pkg/rp/util/registry.go +++ b/pkg/rp/util/registry.go @@ -22,7 +22,8 @@ import ( "fmt" dockerParser "github.com/novln/docker-parser" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/recipes" "oras.land/oras-go/v2/content" "oras.land/oras-go/v2/registry/remote" ) @@ -45,12 +46,12 @@ func ReadFromRegistry(ctx context.Context, path string, data *map[string]any) er digest, err := getDigestFromManifest(ctx, repo, tag) if err != nil { - return v1.NewClientErrInvalidRequest(fmt.Sprintf("failed to fetch repository from the path %q: %s", path, err.Error())) + return recipes.NewRecipeError(recipes.RecipeLanguageFailure, fmt.Sprintf("failed to fetch repository from the path %q: %s", path, err.Error()), nil) } bytes, err := getBytes(ctx, repo, digest) if err != nil { - return v1.NewClientErrInvalidRequest(fmt.Sprintf("failed to fetch repository from the path %q: %s", path, err.Error())) + return recipes.NewRecipeError(recipes.RecipeLanguageFailure, fmt.Sprintf("failed to fetch repository from the path %q: %s", path, err.Error()), nil) } err = json.Unmarshal(bytes, data) diff --git a/pkg/rp/v1/local_ids.go b/pkg/rp/v1/local_ids.go deleted file mode 100644 index 1095d799af..0000000000 --- a/pkg/rp/v1/local_ids.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - "encoding/base64" - "encoding/binary" - "hash/fnv" -) - -// About LocalIDs -// -// The LocalID concept exists to give each 'output resource' a *logical* name that is a unique and stable per-Radius-resource. -// This means that given the same inputs to a renderer, the outputs will contain the same set of LocalIDs. The LocalIDs are -// *not* randomly generated, they must be stable and predictable given the same input. -// -// Physical names (think resource ID) *must* be decoupled from our business logic, because they almost always have to be generated -// with a non-idempotent process due to uniqueness requirements. Consider the physical name of a resource to be a side-effect of creating -// it. -// -// Since we can't use physical names, LocalIDs exist to give us an identifier we *can* use. -// -// This is needed for a few reasons: -// -// This allows renderers to refer to and create dependencies between resources without *knowing* the physical names of those resources. -// The capability to refer to logical names is critical when multiple resources have a contract with each other (eg. a KeyVault) -// creates a KeyVault resource, and the container needs a role assignment to access it.) -// -// This allows diffing of expected state vs actual state. We can tell when a physical resource has disappeared. We can tell when a logical -// resource *should* disappear. This allows the renders a degree of control when the user-provided definition of a Radius resource changes. - -// Represents local IDs used for output resources -const ( - LocalIDAzureCosmosAccount = "AzureCosmosAccount" - LocalIDAzureCosmosDBMongo = "AzureCosmosDBMongo" - LocalIDAzureCosmosDBSQL = "AzureCosmosDBSQL" - LocalIDAzureFileShare = "AzureFileShare" - LocalIDAzureFileShareStorageAccount = "AzureFileShareStorageAccount" - LocalIDAzureRedis = "AzureRedis" - LocalIDAzureServiceBusNamespace = "AzureServiceBusNamespace" - LocalIDAzureServiceBusQueue = "AzureServiceBusQueue" - LocalIDAzureSqlServer = "AzureSqlServer" - LocalIDAzureSqlServerDatabase = "AzureSqlServerDatabase" - LocalIDExtender = "Extender" - LocalIDDaprStateStoreAzureStorage = "DaprStateStoreAzureStorage" - LocalIDAzureStorageTableService = "AzureStorageTableService" - LocalIDAzureStorageTable = "AzureStorageTable" - LocalIDDaprStateStoreComponent = "DaprStateStoreComponent" - LocalIDDaprStateStoreSQLServer = "DaprStateStoreSQLServer" - LocalIDDaprComponent = "DaprComponent" - LocalIDDeployment = "Deployment" - LocalIDGateway = "Gateway" - LocalIDHttpRoute = "HttpRoute" - LocalIDKeyVault = "KeyVault" - LocalIDRabbitMQDeployment = "KubernetesRabbitMQDeployment" - LocalIDRabbitMQSecret = "KubernetesRabbitMQSecret" - LocalIDRabbitMQService = "KubernetesRabbitMQService" - LocalIDRedisDeployment = "KubernetesRedisDeployment" - LocalIDRedisService = "KubernetesRedisService" - LocalIDScrapedSecret = "KubernetesScrapedSecret" - LocalIDSecret = "Secret" - LocalIDSecretProviderClass = "SecretProviderClass" - LocalIDServiceAccount = "ServiceAccount" - LocalIDKubernetesRole = "KubernetesRole" - LocalIDKubernetesRoleBinding = "KubernetesRoleBinding" - LocalIDService = "Service" - LocalIDStatefulSet = "StatefulSet" - LocalIDUserAssignedManagedIdentity = "UserAssignedManagedIdentity" - LocalIDFederatedIdentity = "FederatedIdentity" - - // Obsolete when we remove AppModelV1 - LocalIDRoleAssignmentKVKeys = "RoleAssignment-KVKeys" - LocalIDRoleAssignmentKVSecretsCerts = "RoleAssignment-KVSecretsCerts" - LocalIDKeyVaultSecret = "KeyVaultSecret" -) - -// GenerateLocalIDForRoleAssignment generates a unique string based on the input parameters id and roleName -// -// using a stable hashing algorithm. -// -// Most LocalIDs are a 1:1 mapping with Radius resource. This is a little tricky for role assignments -// because we need to key them on the resource ID of the target resource X the role being assigned. -// For example if the user switches their keyvault 'a' for a different instance 'b' we want to delete -// the original role assignments and create new ones. -func GenerateLocalIDForRoleAssignment(id string, roleName string) string { - base := "RoleAssignment-" - - // The technique here uses a stable hashing algorithm with 32 bits of entropy. These values - // only need to be unique within a *single* Radius resource. - h := fnv.New32a() - _, _ = h.Write([]byte(id)) - _, _ = h.Write([]byte(roleName)) - - hash := [4]byte{} - binary.BigEndian.PutUint32(hash[:], h.Sum32()) - return base + base64.StdEncoding.EncodeToString(hash[:]) -} diff --git a/pkg/rp/v1/localids.go b/pkg/rp/v1/localids.go new file mode 100644 index 0000000000..1d0507bbe0 --- /dev/null +++ b/pkg/rp/v1/localids.go @@ -0,0 +1,90 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "encoding/base64" + "encoding/binary" + "hash/fnv" +) + +// About LocalIDs +// +// The LocalID concept exists to give each 'output resource' a *logical* name that is a unique and stable per-Radius-resource. +// This means that given the same inputs to a renderer, the outputs will contain the same set of LocalIDs. The LocalIDs are +// *not* randomly generated, they must be stable and predictable given the same input. +// +// Physical names (think resource ID) *must* be decoupled from our business logic, because they almost always have to be generated +// with a non-idempotent process due to uniqueness requirements. Consider the physical name of a resource to be a side-effect of creating +// it. +// +// Since we can't use physical names, LocalIDs exist to give us an identifier we *can* use. +// +// This is needed for a few reasons: +// +// This allows renderers to refer to and create dependencies between resources without *knowing* the physical names of those resources. +// The capability to refer to logical names is critical when multiple resources have a contract with each other (eg. a KeyVault) +// creates a KeyVault resource, and the container needs a role assignment to access it.) +// +// This allows diffing of expected state vs actual state. We can tell when a physical resource has disappeared. We can tell when a logical +// resource *should* disappear. This allows the renders a degree of control when the user-provided definition of a Radius resource changes. + +// Represents local IDs used for output resources +const ( + LocalIDAzureCosmosAccount = "AzureCosmosAccount" + LocalIDAzureCosmosDBMongo = "AzureCosmosDBMongo" + LocalIDAzureFileShareStorageAccount = "AzureFileShareStorageAccount" + LocalIDDaprStateStoreAzureStorage = "DaprStateStoreAzureStorage" + LocalIDDaprSecretStoreAzureKeyVault = "DaprSecretStoreAzureKeyVault" + LocalIDDaprPubSubBrokerKafka = "DaprPubSubBrokerKafka" + LocalIDDeployment = "Deployment" + LocalIDGateway = "Gateway" + LocalIDHttpRoute = "HttpRoute" + LocalIDKeyVault = "KeyVault" + LocalIDSecret = "Secret" + LocalIDConfigMap = "ConfigMap" + LocalIDSecretProviderClass = "SecretProviderClass" + LocalIDServiceAccount = "ServiceAccount" + LocalIDKubernetesRole = "KubernetesRole" + LocalIDKubernetesRoleBinding = "KubernetesRoleBinding" + LocalIDService = "Service" + LocalIDUserAssignedManagedIdentity = "UserAssignedManagedIdentity" + LocalIDFederatedIdentity = "FederatedIdentity" + LocalIDRoleAssignmentPrefix = "RoleAssignment" + + // Obsolete when we remove AppModelV1 + LocalIDRoleAssignmentKVKeys = "RoleAssignment-KVKeys" +) + +// NewLocalID generates a unique string based on the input parameter ids using a stable hashing algorithm. +// +// Most LocalIDs are a 1:1 mapping with Radius resource. This is a little tricky for role assignments +// because we need to key them on the resource ID of the target resource X the role being assigned. +// For example if the user switches their keyvault 'a' for a different instance 'b' we want to delete +// the original role assignments and create new ones. +func NewLocalID(prefix string, ids ...string) string { + // The technique here uses a stable hashing algorithm with 32 bits of entropy. These values + // only need to be unique within a *single* Radius resource. + h := fnv.New32a() + for _, id := range ids { + _, _ = h.Write([]byte(id)) + } + + hash := [4]byte{} + binary.BigEndian.PutUint32(hash[:], h.Sum32()) + return prefix + "-" + base64.StdEncoding.EncodeToString(hash[:]) +} diff --git a/pkg/rp/v1/localids_test.go b/pkg/rp/v1/localids_test.go new file mode 100644 index 0000000000..e55c245433 --- /dev/null +++ b/pkg/rp/v1/localids_test.go @@ -0,0 +1,28 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestNewLocalID(t *testing.T) { + require.Equal(t, "foo-drd9Gg==", NewLocalID("foo", "bar")) + require.Equal(t, "foo-6WF5Aw==", NewLocalID("foo", "bar", "baz")) +} diff --git a/pkg/rp/v1/outputresource.go b/pkg/rp/v1/outputresource.go index 82a51bdc36..695a8a19e7 100644 --- a/pkg/rp/v1/outputresource.go +++ b/pkg/rp/v1/outputresource.go @@ -19,42 +19,75 @@ package v1 import ( "errors" - "github.com/project-radius/radius/pkg/algorithm/graph" - "github.com/project-radius/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/algorithm/graph" + "github.com/radius-project/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) // OutputResource represents the output of rendering a resource type OutputResource struct { - // LocalID is a logical identifier scoped to the owning Radius resource. + // LocalID is a logical identifier scoped to the owning Radius resource. This is only needed or used + // when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning + // beyond being compared to determine dependency relationships. LocalID string `json:"localID"` - // Identity uniquely identifies the underlying resource within its platform.. - Identity resourcemodel.ResourceIdentity `json:"identity"` + // ID is the UCP resource ID of the underlying resource. + ID resources.ID `json:"id"` - // Resource type specifies the 'provider' and 'kind' used to look up the resource handler for processing - ResourceType resourcemodel.ResourceType `json:"resourceType"` + // RadiusManaged determines whether Radius manages the lifecycle of the underlying resource. + RadiusManaged *bool `json:"radiusManaged"` - // Resource type defined by the provider for this resource. Example for Azure, a resource type is of the format: Microsoft.DocumentDB/databaseAccounts - ProviderResourceType string `json:"providerResourceType"` + // CreateResource describes data that will be used to create a resource. This is never saved to the database. + CreateResource *Resource `json:"-"` +} - RadiusManaged *bool `json:"radiusManaged"` - Deployed bool `json:"deployed"` - Resource any `json:"resource,omitempty"` - Dependencies []Dependency // resources that are required to be deployed before this resource can be deployed - used for parent/child resources. - Status OutputResourceStatus `json:"status,omitempty"` +// Resource describes data that will be used to create a resource. This data is not saved to the database. +type Resource struct { + // Data is the arbitrary data that will be passed to the handler. + Data any + // ResourceType is the type of resource that will be created. This is used for dispatching to the correct handler. + ResourceType resourcemodel.ResourceType + // Dependencies is the set of LocalIDs of the resources that are required to be deployed before this resource can be deployed. + Dependencies []string } -type Dependency struct { - // LocalID is the LocalID of the dependency. - LocalID string +// ExistDependency checks if the given id is in the Dependencies of the Resource and returns true if it is, false otherwise. +func (r Resource) ExistDependency(localID string) bool { + for _, dependency := range r.Dependencies { + if dependency == localID { + return true + } + } + return false } -// OutputResourceStatus represents the status of the Output Resource -type OutputResourceStatus struct { - ProvisioningState string `json:"provisioningState"` - ProvisioningErrorDetails string `json:"provisioningErrorDetails"` +// GetResourceType returns the ResourceType of the OutputResource. +func (or OutputResource) GetResourceType() resourcemodel.ResourceType { + // There are two possible states: + // + // 1) The resource already exists in which case we have a resource ID. + // 2) The resource will be created, in which case we know the resource type, but don't have an ID. + if or.CreateResource != nil { + return or.CreateResource.ResourceType + } + + if or.ID.IsUCPQualfied() && len(or.ID.ScopeSegments()) > 0 { + return resourcemodel.ResourceType{ + Provider: or.ID.ScopeSegments()[0].Type, + Type: or.ID.Type(), + } + } else if len(or.ID.ScopeSegments()) > 0 { + // Legacy ARM case + return resourcemodel.ResourceType{ + Provider: resourcemodel.ProviderAzure, + Type: or.ID.Type(), + } + } + + return resourcemodel.ResourceType{} } // Key localID of the output resource is used as the key in DependencyItem for output resources. @@ -65,12 +98,16 @@ func (resource OutputResource) Key() string { // GetDependencies returns a slice of strings containing the LocalIDs of the OutputResource's dependencies, or an error if // any of the dependencies are missing a LocalID. func (resource OutputResource) GetDependencies() ([]string, error) { + if resource.CreateResource == nil { + return nil, nil + } + dependencies := []string{} - for _, dependency := range resource.Dependencies { - if dependency.LocalID == "" { + for _, dependency := range resource.CreateResource.Dependencies { + if dependency == "" { return dependencies, errors.New("missing localID for outputresource") } - dependencies = append(dependencies, dependency.LocalID) + dependencies = append(dependencies, dependency) } return dependencies, nil } @@ -111,66 +148,38 @@ func OrderOutputResources(outputResources []OutputResource) ([]OutputResource, e } // NewKubernetesOutputResource creates an OutputResource object with the given resourceType, localID, obj and objectMeta. -func NewKubernetesOutputResource(resourceType string, localID string, obj runtime.Object, objectMeta metav1.ObjectMeta) OutputResource { - rt := resourcemodel.ResourceType{ - Type: resourceType, - Provider: resourcemodel.ProviderKubernetes, - } +func NewKubernetesOutputResource(localID string, obj runtime.Object, objectMeta metav1.ObjectMeta) OutputResource { + gvk := obj.GetObjectKind().GroupVersionKind() return OutputResource{ - LocalID: localID, - Deployed: false, - ResourceType: rt, - Identity: resourcemodel.NewKubernetesIdentity(&rt, obj, objectMeta), - Resource: obj, - Dependencies: []Dependency{}, + LocalID: localID, + ID: resources_kubernetes.IDFromMeta(resources_kubernetes.PlaneNameTODO, gvk, objectMeta), + CreateResource: &Resource{ + ResourceType: resourcemodel.ResourceType{ + Type: resources_kubernetes.ResourceTypeFromGVK(gvk), + Provider: resourcemodel.ProviderKubernetes, + }, + Data: obj, + }, } } // GetGCOutputResources [GC stands for Garbage Collection] compares two slices of OutputResource and // returns a slice of OutputResource that contains the elements that are in the "before" slice but not in the "after". func GetGCOutputResources(after []OutputResource, before []OutputResource) []OutputResource { - afterMap := map[string][]OutputResource{} - - for _, outputResource := range after { - id := outputResource.LocalID - orArr := []OutputResource{} - - if arr, ok := afterMap[id]; ok { - orArr = arr - } - - orArr = append(orArr, outputResource) - afterMap[id] = orArr - } - + // We can easily determine which resources have changed via a brute-force search comparing IDs. + // The lists of resources we work with are small, so this is fine. diff := []OutputResource{} - for _, outputResource := range before { - id := outputResource.LocalID - - // If there is a resource or a group of resources in before(old) outputResources - // array with a LocalID that is not in the after(new) outputResources array, then - // we have to to delete those resources. - if _, found := afterMap[id]; !found { - diff = append(diff, outputResource) - continue - } - - // Otherwise we have to check each resource for their equivalence on the type and ID. - // - // If there is no match, we have to delete that resource. Meaning that new outputResources - // doesn't have that resource in the old array. + for _, beforeResource := range before { found := false - for _, innerOutputResource := range afterMap[id] { - if outputResource.ResourceType.Type == innerOutputResource.ResourceType.Type && - outputResource.ResourceType.Provider == innerOutputResource.ResourceType.Provider && - outputResource.Identity.GetID() == innerOutputResource.Identity.GetID() { + for _, afterResource := range after { + if resources.IDEquals(beforeResource.ID, afterResource.ID) { found = true break } } if !found { - diff = append(diff, outputResource) + diff = append(diff, beforeResource) } } diff --git a/pkg/rp/v1/outputresource_test.go b/pkg/rp/v1/outputresource_test.go index 52cfeb5a7f..bba4876936 100644 --- a/pkg/rp/v1/outputresource_test.go +++ b/pkg/rp/v1/outputresource_test.go @@ -19,8 +19,8 @@ package v1 import ( "testing" - "github.com/project-radius/radius/pkg/resourcekinds" - "github.com/project-radius/radius/pkg/resourcemodel" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_kubernetes "github.com/radius-project/radius/pkg/ucp/resources/kubernetes" "github.com/stretchr/testify/require" ) @@ -29,25 +29,26 @@ func TestGetDependencies(t *testing.T) { dependencies, err := outputResource.GetDependencies() require.NoError(t, err) - require.Equal(t, []string{LocalIDUserAssignedManagedIdentity, LocalIDRoleAssignmentKVKeys}, - dependencies) + require.Equal(t, []string{LocalIDUserAssignedManagedIdentity, LocalIDRoleAssignmentKVKeys}, dependencies) } -func TestGetDependencies_MissingLocalID(t *testing.T) { - testResource1 := OutputResource{ - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, +func TestExistDependency(t *testing.T) { + testResource := &Resource{ + Dependencies: []string{LocalIDSecret}, } + require.True(t, testResource.ExistDependency(LocalIDSecret)) + require.False(t, testResource.ExistDependency(LocalIDDeployment)) +} + +func TestGetDependencies_MissingLocalID(t *testing.T) { + testResource1 := OutputResource{} + testResource2 := OutputResource{ LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, + CreateResource: &Resource{ + Dependencies: []string{testResource1.LocalID}, }, - Dependencies: []Dependency{{LocalID: testResource1.LocalID}}, } _, err := testResource2.GetDependencies() @@ -58,10 +59,6 @@ func TestGetDependencies_MissingLocalID(t *testing.T) { func TestGetDependencies_Empty(t *testing.T) { testOutputResource := OutputResource{ LocalID: LocalIDUserAssignedManagedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, } dependencies, err := testOutputResource.GetDependencies() @@ -87,30 +84,19 @@ func TestOrderOutputResources(t *testing.T) { func getTestOutputResourceWithDependencies() (OutputResource, map[string]OutputResource) { managedIdentity := OutputResource{ LocalID: LocalIDUserAssignedManagedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, } roleAssignmentKeys := OutputResource{ LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, + CreateResource: &Resource{ + Dependencies: []string{managedIdentity.LocalID}, }, - Dependencies: []Dependency{{LocalID: managedIdentity.LocalID}}, } federatedIdentity := OutputResource{ LocalID: LocalIDFederatedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{ - {LocalID: managedIdentity.LocalID}, - {LocalID: roleAssignmentKeys.LocalID}, + CreateResource: &Resource{ + Dependencies: []string{managedIdentity.LocalID, roleAssignmentKeys.LocalID}, }, } @@ -129,36 +115,19 @@ func TestGetGCOutputResources_Same(t *testing.T) { managedIdentity := OutputResource{ LocalID: LocalIDUserAssignedManagedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi"), } roleAssignmentKeys := OutputResource{ LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - Identity: resourcemodel.NewARMIdentity(&resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, "/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi", "2020-01-01"), - Dependencies: []Dependency{{LocalID: managedIdentity.LocalID}}, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.Authorization/roleAssignments/test-ra"), } federatedIdentity := OutputResource{ LocalID: LocalIDFederatedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{ - {LocalID: managedIdentity.LocalID}, - {LocalID: roleAssignmentKeys.LocalID}, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi/federatedIdentities/test-fi"), } + after = append(after, managedIdentity) after = append(after, roleAssignmentKeys) after = append(after, federatedIdentity) @@ -176,27 +145,13 @@ func TestGetGCOutputResources_ResourceDiffersByID(t *testing.T) { after := []OutputResource{ { LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - Identity: resourcemodel.NewARMIdentity(&resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, "/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/after", "2020-01-01"), + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/after"), }, } before := []OutputResource{ { LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - Identity: resourcemodel.NewARMIdentity(&resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, "/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/before", "2020-01-01"), + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/before"), }, } @@ -210,31 +165,17 @@ func TestGetGCOutputResources_SameWithAdditionalOutputResource(t *testing.T) { managedIdentity := OutputResource{ LocalID: LocalIDUserAssignedManagedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi"), } roleAssignmentKeys := OutputResource{ LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{{LocalID: managedIdentity.LocalID}}, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.Authorization/roleAssignments/test-ra"), } federatedIdentity := OutputResource{ LocalID: LocalIDFederatedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{ - {LocalID: managedIdentity.LocalID}, - {LocalID: roleAssignmentKeys.LocalID}, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi/federatedIdentities/test-fi"), } after = append(after, managedIdentity) @@ -255,31 +196,17 @@ func TestGetGCOutputResources_ManagedIdentityShouldBeDeleted(t *testing.T) { managedIdentity := OutputResource{ LocalID: LocalIDUserAssignedManagedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi"), } roleAssignmentKeys := OutputResource{ LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{{LocalID: managedIdentity.LocalID}}, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.Authorization/roleAssignments/test-ra"), } federatedIdentity := OutputResource{ LocalID: LocalIDFederatedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{ - {LocalID: managedIdentity.LocalID}, - {LocalID: roleAssignmentKeys.LocalID}, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi/federatedIdentities/test-fi"), } after = append(after, roleAssignmentKeys) @@ -300,40 +227,22 @@ func TestGetGCOutputResources_ALotOfResources(t *testing.T) { managedIdentity1 := OutputResource{ LocalID: LocalIDUserAssignedManagedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - Provider: resourcemodel.ProviderAzure, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi1"), } managedIdentity2 := OutputResource{ LocalID: LocalIDUserAssignedManagedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureUserAssignedManagedIdentity, - // Fixme: Kubernetes is not possible? - Provider: resourcemodel.ProviderKubernetes, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi2"), } roleAssignmentKeys := OutputResource{ LocalID: LocalIDRoleAssignmentKVKeys, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureRoleAssignment, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{{LocalID: managedIdentity1.LocalID}}, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.Authorization/roleAssignments/test-ra"), } federatedIdentity := OutputResource{ LocalID: LocalIDFederatedIdentity, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.AzureFederatedIdentity, - Provider: resourcemodel.ProviderAzure, - }, - Dependencies: []Dependency{ - {LocalID: managedIdentity1.LocalID}, - {LocalID: roleAssignmentKeys.LocalID}, - }, + ID: resources.MustParse("/subscriptions/test-subscription/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi/federatedIdentities/test-fi"), } after = append(after, managedIdentity1) @@ -350,38 +259,28 @@ func TestGetGCOutputResources_ALotOfResources(t *testing.T) { require.Equal(t, []OutputResource{managedIdentity2}, diff) } -func TestGetGCOutputResources_Secret(t *testing.T) { +func TestGetGCOutputResources_ResourceRemoved(t *testing.T) { after := []OutputResource{} before := []OutputResource{} deployment := OutputResource{ LocalID: LocalIDDeployment, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.Deployment, - Provider: resourcemodel.ProviderKubernetes, - }, - }, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Deployment, - Provider: resourcemodel.ProviderKubernetes, - }, - Dependencies: nil, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "", + resources_kubernetes.KindDeployment, + "test-namespace", + "test-deployment"), } secret := OutputResource{ LocalID: LocalIDSecret, - Identity: resourcemodel.ResourceIdentity{ - ResourceType: &resourcemodel.ResourceType{ - Type: resourcekinds.Secret, - Provider: resourcemodel.ProviderKubernetes, - }, - }, - ResourceType: resourcemodel.ResourceType{ - Type: resourcekinds.Secret, - Provider: resourcemodel.ProviderKubernetes, - }, - Dependencies: nil, + ID: resources_kubernetes.IDFromParts( + resources_kubernetes.PlaneNameTODO, + "", + resources_kubernetes.KindSecret, + "test-namespace", + "test-secret"), } after = append(after, deployment) diff --git a/pkg/rp/v1/types.go b/pkg/rp/v1/types.go index d384a7c45b..b801e2e342 100644 --- a/pkg/rp/v1/types.go +++ b/pkg/rp/v1/types.go @@ -19,7 +19,7 @@ package v1 import ( "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) // EnvironmentComputeKind is the type of compute resource. @@ -123,10 +123,13 @@ func BuildExternalOutputResources(outputResources []OutputResource) []map[string var externalOutputResources []map[string]any for _, or := range outputResources { externalOutput := map[string]any{ - "LocalID": or.LocalID, - "Provider": or.ResourceType.Provider, - "Identity": or.Identity.Data, + "id": or.ID.String(), } + + if or.LocalID != "" { + externalOutput["LocalID"] = or.LocalID + } + externalOutputResources = append(externalOutputResources, externalOutput) } diff --git a/pkg/sdk/clients/resourcedeploymentoperationsclient.go b/pkg/sdk/clients/resourcedeploymentoperationsclient.go index dd3d8ccc46..ac838dfd40 100644 --- a/pkg/sdk/clients/resourcedeploymentoperationsclient.go +++ b/pkg/sdk/clients/resourcedeploymentoperationsclient.go @@ -22,7 +22,7 @@ import ( "net/http" "strconv" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/to" armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" diff --git a/pkg/sdk/clients/resourcedeploymentsclient.go b/pkg/sdk/clients/resourcedeploymentsclient.go index 81f4a0aacb..11a3a2b72a 100644 --- a/pkg/sdk/clients/resourcedeploymentsclient.go +++ b/pkg/sdk/clients/resourcedeploymentsclient.go @@ -27,7 +27,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/resources" ) type Deployment struct { diff --git a/pkg/server/apiservice.go b/pkg/server/apiservice.go new file mode 100644 index 0000000000..b92d6fe2f2 --- /dev/null +++ b/pkg/server/apiservice.go @@ -0,0 +1,89 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package server + +import ( + "context" + "fmt" + + "github.com/go-chi/chi/v5" + + "github.com/radius-project/radius/pkg/armrpc/builder" + apictrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" +) + +// APIService is the restful API server for Radius Resource Provider. +type APIService struct { + server.Service + + handlerBuilder []builder.Builder +} + +// NewAPIService creates a new instance of APIService. +func NewAPIService(options hostoptions.HostOptions, builder []builder.Builder) *APIService { + return &APIService{ + Service: server.Service{ + ProviderName: "radius", + Options: options, + }, + handlerBuilder: builder, + } +} + +// Name returns the name of the service. +func (s *APIService) Name() string { + return "radiusapi" +} + +// Run starts the service. +func (s *APIService) Run(ctx context.Context) error { + if err := s.Init(ctx); err != nil { + return err + } + + address := fmt.Sprintf("%s:%d", s.Options.Config.Server.Host, s.Options.Config.Server.Port) + return s.Start(ctx, server.Options{ + Location: s.Options.Config.Env.RoleLocation, + Address: address, + PathBase: s.Options.Config.Server.PathBase, + Configure: func(r chi.Router) error { + for _, b := range s.handlerBuilder { + opts := apictrl.Options{ + PathBase: s.Options.Config.Server.PathBase, + DataProvider: s.StorageProvider, + KubeClient: s.KubeClient, + StatusManager: s.OperationStatusManager, + } + + validator, err := builder.NewOpenAPIValidator(ctx, opts.PathBase, b.Namespace()) + if err != nil { + panic(err) + } + + if err := b.ApplyAPIHandlers(ctx, r, opts, validator); err != nil { + panic(err) + } + } + return nil + }, + // set the arm cert manager for managing client certificate + ArmCertMgr: s.ARMCertManager, + EnableArmAuth: s.Options.Config.Server.EnableArmAuth, // when enabled the client cert validation will be done + }) +} diff --git a/pkg/server/asyncworker.go b/pkg/server/asyncworker.go new file mode 100644 index 0000000000..15dfb3850d --- /dev/null +++ b/pkg/server/asyncworker.go @@ -0,0 +1,97 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package server + +import ( + "context" + "fmt" + + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + "github.com/radius-project/radius/pkg/armrpc/builder" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/corerp/backend/deployment" + "github.com/radius-project/radius/pkg/corerp/model" + "github.com/radius-project/radius/pkg/kubeutil" +) + +// AsyncWorker is a service to run AsyncReqeustProcessWorker. +type AsyncWorker struct { + worker.Service + + handlerBuilder []builder.Builder +} + +// NewAsyncWorker creates new service instance to run AsyncReqeustProcessWorker. +func NewAsyncWorker(options hostoptions.HostOptions, builder []builder.Builder) *AsyncWorker { + return &AsyncWorker{ + Service: worker.Service{ + ProviderName: "radius", + Options: options, + }, + handlerBuilder: builder, + } +} + +// Name represents the service name. +func (w *AsyncWorker) Name() string { + return "radiusasyncworker" +} + +// Run starts the service and worker. +func (w *AsyncWorker) Run(ctx context.Context) error { + if err := w.Init(ctx); err != nil { + return err + } + + k8s, err := kubeutil.NewClients(w.Options.K8sConfig) + if err != nil { + return fmt.Errorf("failed to initialize kubernetes clients: %w", err) + } + + appModel, err := model.NewApplicationModel(w.Options.Arm, k8s.RuntimeClient, k8s.ClientSet, k8s.DiscoveryClient, k8s.DynamicClient) + if err != nil { + return fmt.Errorf("failed to initialize application model: %w", err) + } + + for _, b := range w.handlerBuilder { + opts := ctrl.Options{ + DataProvider: w.StorageProvider, + KubeClient: k8s.RuntimeClient, + GetDeploymentProcessor: func() deployment.DeploymentProcessor { + return deployment.NewDeploymentProcessor(appModel, w.StorageProvider, k8s.RuntimeClient, k8s.ClientSet) + }, + } + + err := b.ApplyAsyncHandler(ctx, w.Controllers, opts) + if err != nil { + panic(err) + } + } + + workerOpts := worker.Options{} + if w.Options.Config.WorkerServer != nil { + if w.Options.Config.WorkerServer.MaxOperationConcurrency != nil { + workerOpts.MaxOperationConcurrency = *w.Options.Config.WorkerServer.MaxOperationConcurrency + } + if w.Options.Config.WorkerServer.MaxOperationRetryCount != nil { + workerOpts.MaxOperationRetryCount = *w.Options.Config.WorkerServer.MaxOperationRetryCount + } + } + + return w.Start(ctx, workerOpts) +} diff --git a/pkg/trace/util.go b/pkg/trace/util.go index eb49cc56ae..f2add31453 100644 --- a/pkg/trace/util.go +++ b/pkg/trace/util.go @@ -18,7 +18,7 @@ package trace import ( "context" - ctrl "github.com/project-radius/radius/pkg/armrpc/asyncoperation/controller" + ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" otelcodes "go.opentelemetry.io/otel/codes" diff --git a/pkg/ucp/api/README.md b/pkg/ucp/api/README.md index 1f554f6660..a862f353ad 100644 --- a/pkg/ucp/api/README.md +++ b/pkg/ucp/api/README.md @@ -45,7 +45,7 @@ The following configuration generates track2 go models and client. ```yaml $(tag) != '' version: 3.*.* -use: "@autorest/go@4.0.0-preview.44" +use: "@autorest/go@4.0.0-preview.55" module-version: 0.0.1 file-prefix: zz_generated_ license-header: "Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information.\nCode generated by Microsoft (R) AutoRest Code Generator.\nChanges may cause incorrect behavior and will be lost if the code is regenerated." diff --git a/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion.go b/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion.go index 0ae71d435f..6f1fdfeeeb 100644 --- a/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion.go +++ b/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion.go @@ -19,10 +19,9 @@ package v20220901privatepreview import ( "fmt" - azto "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/go-autorest/autorest/to" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) const ( @@ -31,7 +30,7 @@ const ( ) // ConvertTo converts from the versioned Credential resource to version-agnostic datamodel. -func (cr *AWSCredentialResource) ConvertTo() (v1.DataModelInterface, error) { +func (cr *AwsCredentialResource) ConvertTo() (v1.DataModelInterface, error) { prop, err := cr.getDataModelCredentialProperties() if err != nil { return nil, err @@ -56,13 +55,13 @@ func (cr *AWSCredentialResource) ConvertTo() (v1.DataModelInterface, error) { return converted, nil } -func (cr *AWSCredentialResource) getDataModelCredentialProperties() (*datamodel.AWSCredentialResourceProperties, error) { +func (cr *AwsCredentialResource) getDataModelCredentialProperties() (*datamodel.AWSCredentialResourceProperties, error) { if cr.Properties == nil { return nil, &v1.ErrModelConversion{PropertyName: "$.properties", ValidValue: "not nil"} } switch p := cr.Properties.(type) { - case *AWSAccessKeyCredentialProperties: + case *AwsAccessKeyCredentialProperties: var storage *datamodel.CredentialStorageProperties switch c := p.Storage.(type) { @@ -96,7 +95,7 @@ func (cr *AWSCredentialResource) getDataModelCredentialProperties() (*datamodel. } // ConvertFrom converts from version-agnostic datamodel to the versioned Credential resource. -func (dst *AWSCredentialResource) ConvertFrom(src v1.DataModelInterface) error { +func (dst *AwsCredentialResource) ConvertFrom(src v1.DataModelInterface) error { dm, ok := src.(*datamodel.AWSCredential) if !ok { return v1.ErrInvalidModelConversion @@ -112,8 +111,8 @@ func (dst *AWSCredentialResource) ConvertFrom(src v1.DataModelInterface) error { switch dm.Properties.Storage.Kind { case datamodel.InternalStorageKind: storage = &InternalCredentialStorageProperties{ - Kind: azto.Ptr(string(CredentialStorageKindInternal)), - SecretName: azto.Ptr(dm.Properties.Storage.InternalCredential.SecretName), + Kind: to.Ptr(CredentialStorageKindInternal), + SecretName: to.Ptr(dm.Properties.Storage.InternalCredential.SecretName), } default: return v1.ErrInvalidModelConversion @@ -122,9 +121,9 @@ func (dst *AWSCredentialResource) ConvertFrom(src v1.DataModelInterface) error { // DO NOT convert any secret values to versioned model. switch dm.Properties.Kind { case datamodel.AWSCredentialKind: - dst.Properties = &AWSAccessKeyCredentialProperties{ - Kind: azto.Ptr(dm.Properties.Kind), - AccessKeyID: azto.Ptr(dm.Properties.AWSCredential.AccessKeyID), + dst.Properties = &AwsAccessKeyCredentialProperties{ + Kind: to.Ptr(AWSCredentialKind(dm.Properties.Kind)), + AccessKeyID: to.Ptr(dm.Properties.AWSCredential.AccessKeyID), Storage: storage, } default: diff --git a/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion_test.go b/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion_test.go index 2e34c110e2..d8a0ab8dfd 100644 --- a/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion_test.go +++ b/pkg/ucp/api/v20220901privatepreview/aws_credential_conversion_test.go @@ -21,9 +21,9 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/stretchr/testify/require" @@ -89,7 +89,7 @@ func TestAWSCredentialConvertVersionedToDataModel(t *testing.T) { for _, tt := range conversionTests { t.Run(tt.filename, func(t *testing.T) { rawPayload := testutil.ReadFixture(tt.filename) - r := &AWSCredentialResource{} + r := &AwsCredentialResource{} err := json.Unmarshal(rawPayload, r) require.NoError(t, err) @@ -109,12 +109,12 @@ func TestAWSCredentialConvertVersionedToDataModel(t *testing.T) { func TestAWSCredentialConvertDataModelToVersioned(t *testing.T) { conversionTests := []struct { filename string - expected *AWSCredentialResource + expected *AwsCredentialResource err error }{ { filename: "credentialresourcedatamodel-aws.json", - expected: &AWSCredentialResource{ + expected: &AwsCredentialResource{ ID: to.Ptr("/planes/aws/aws/providers/System.AWS/credentials/default"), Name: to.Ptr("default"), Type: to.Ptr("System.AWS/credentials"), @@ -122,11 +122,11 @@ func TestAWSCredentialConvertDataModelToVersioned(t *testing.T) { Tags: map[string]*string{ "env": to.Ptr("dev"), }, - Properties: &AWSAccessKeyCredentialProperties{ - Kind: to.Ptr("AccessKey"), + Properties: &AwsAccessKeyCredentialProperties{ + Kind: to.Ptr(AWSCredentialKindAccessKey), AccessKeyID: to.Ptr("00000000-0000-0000-0000-000000000000"), Storage: &InternalCredentialStorageProperties{ - Kind: to.Ptr(string(CredentialStorageKindInternal)), + Kind: to.Ptr(CredentialStorageKindInternal), SecretName: to.Ptr("aws-awscloud-default"), }, }, @@ -144,7 +144,7 @@ func TestAWSCredentialConvertDataModelToVersioned(t *testing.T) { err := json.Unmarshal(rawPayload, r) require.NoError(t, err) - versioned := &AWSCredentialResource{} + versioned := &AwsCredentialResource{} err = versioned.ConvertFrom(r) if tt.err != nil { diff --git a/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion.go b/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion.go index 635622b7e8..78f7b09d2b 100644 --- a/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion.go +++ b/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion.go @@ -19,9 +19,9 @@ package v20220901privatepreview import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) const ( @@ -112,7 +112,7 @@ func (dst *AzureCredentialResource) ConvertFrom(src v1.DataModelInterface) error switch dm.Properties.Storage.Kind { case datamodel.InternalStorageKind: storage = &InternalCredentialStorageProperties{ - Kind: to.Ptr(string(CredentialStorageKindInternal)), + Kind: to.Ptr(CredentialStorageKindInternal), SecretName: to.Ptr(dm.Properties.Storage.InternalCredential.SecretName), } default: @@ -123,7 +123,7 @@ func (dst *AzureCredentialResource) ConvertFrom(src v1.DataModelInterface) error switch dm.Properties.Kind { case datamodel.AzureCredentialKind: dst.Properties = &AzureServicePrincipalProperties{ - Kind: to.Ptr(dm.Properties.Kind), + Kind: to.Ptr(AzureCredentialKind(dm.Properties.Kind)), ClientID: to.Ptr(dm.Properties.AzureCredential.ClientID), TenantID: to.Ptr(dm.Properties.AzureCredential.TenantID), Storage: storage, diff --git a/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion_test.go b/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion_test.go index c623108063..f5e32bc9fe 100644 --- a/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion_test.go +++ b/pkg/ucp/api/v20220901privatepreview/azure_credential_conversion_test.go @@ -21,10 +21,10 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/test/testutil" "github.com/stretchr/testify/require" ) @@ -124,11 +124,11 @@ func TestAzureCredentialConvertDataModelToVersioned(t *testing.T) { "env": to.Ptr("dev"), }, Properties: &AzureServicePrincipalProperties{ - Kind: to.Ptr("ServicePrincipal"), + Kind: to.Ptr(AzureCredentialKindServicePrincipal), ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), Storage: &InternalCredentialStorageProperties{ - Kind: to.Ptr(string(CredentialStorageKindInternal)), + Kind: to.Ptr(CredentialStorageKindInternal), SecretName: to.Ptr("azure-azurecloud-default"), }, }, diff --git a/pkg/ucp/api/v20220901privatepreview/genericresource_conversion.go b/pkg/ucp/api/v20220901privatepreview/genericresource_conversion.go new file mode 100644 index 0000000000..089cbaade7 --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/genericresource_conversion.go @@ -0,0 +1,49 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v20220901privatepreview + +import ( + "errors" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/datamodel" +) + +const ( + ResourceType = "System.Resources/resources" +) + +// ConvertTo converts from the versioned GenericResource resource to version-agnostic datamodel. +func (src *GenericResource) ConvertTo() (v1.DataModelInterface, error) { + return nil, errors.New("the GenericResource type does not support conversion from versioned models") +} + +// ConvertFrom converts from version-agnostic datamodel to the versioned GenericResource resource. +func (dst *GenericResource) ConvertFrom(src v1.DataModelInterface) error { + entry, ok := src.(*datamodel.GenericResource) + if !ok { + return v1.ErrInvalidModelConversion + } + + // The properties are used to store the data of the "tracked" resource. + dst.ID = to.Ptr(entry.Properties.ID) + dst.Name = to.Ptr(entry.Properties.Name) + dst.Type = to.Ptr(entry.Properties.Type) + + return nil +} diff --git a/pkg/ucp/api/v20220901privatepreview/genericresource_conversion_test.go b/pkg/ucp/api/v20220901privatepreview/genericresource_conversion_test.go new file mode 100644 index 0000000000..e1a93743ff --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/genericresource_conversion_test.go @@ -0,0 +1,73 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v20220901privatepreview + +import ( + "encoding/json" + "errors" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/test/testutil" + + "github.com/stretchr/testify/require" +) + +func Test_GenericResource_VersionedToDataModel(t *testing.T) { + versioned := &GenericResource{} + dm, err := versioned.ConvertTo() + require.Equal(t, errors.New("the GenericResource type does not support conversion from versioned models"), err) + require.Nil(t, dm) +} + +func Test_GenericResource_DataModelToVersioned(t *testing.T) { + conversionTests := []struct { + filename string + expected *GenericResource + err error + }{ + { + filename: "genericresource_datamodel.json", + expected: &GenericResource{ + ID: to.Ptr("/planes/radius/local/resourcegroups/rg1/providers/Applications.Core/applications/test-app"), + Type: to.Ptr("Applications.Core/applications"), + Name: to.Ptr("test-app"), + }, + }, + } + + for _, tt := range conversionTests { + t.Run(tt.filename, func(t *testing.T) { + rawPayload := testutil.ReadFixture(tt.filename) + data := &datamodel.GenericResource{} + err := json.Unmarshal(rawPayload, data) + require.NoError(t, err) + + versioned := &GenericResource{} + + err = versioned.ConvertFrom(data) + + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + } else { + require.NoError(t, err) + require.Equal(t, tt.expected, versioned) + } + }) + } +} diff --git a/pkg/ucp/api/v20220901privatepreview/plane_conversion.go b/pkg/ucp/api/v20220901privatepreview/plane_conversion.go index b20f65d829..443f0743a0 100644 --- a/pkg/ucp/api/v20220901privatepreview/plane_conversion.go +++ b/pkg/ucp/api/v20220901privatepreview/plane_conversion.go @@ -19,10 +19,10 @@ package v20220901privatepreview import ( "fmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) // ConvertTo converts from the versioned Plane resource to version-agnostic datamodel. diff --git a/pkg/ucp/api/v20220901privatepreview/plane_conversion_test.go b/pkg/ucp/api/v20220901privatepreview/plane_conversion_test.go index 4e208186ac..d2c7ba8037 100644 --- a/pkg/ucp/api/v20220901privatepreview/plane_conversion_test.go +++ b/pkg/ucp/api/v20220901privatepreview/plane_conversion_test.go @@ -21,10 +21,11 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -112,19 +113,12 @@ func TestPlaneConvertDataModelToVersioned(t *testing.T) { require.Equal(t, "https://applications.core.radius.azure.com", *r.Properties.ResourceProviders["Applications.Core"]) } -type fakeResource struct{} - -// FakeResource's ResourceTypeName function returns a string "FakeResource" when called. -func (f *fakeResource) ResourceTypeName() string { - return "FakeResource" -} - func TestPlaneConvertFromValidation(t *testing.T) { validationTests := []struct { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion.go b/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion.go index 3faf7e4481..c240115bd1 100644 --- a/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion.go +++ b/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion.go @@ -17,9 +17,9 @@ limitations under the License. package v20220901privatepreview import ( - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) const ( diff --git a/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion_test.go b/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion_test.go index 8334fc4b2d..1ff898a1ce 100644 --- a/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion_test.go +++ b/pkg/ucp/api/v20220901privatepreview/resourcegroup_conversion_test.go @@ -20,10 +20,11 @@ import ( "encoding/json" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/test/testutil" + "github.com/radius-project/radius/test/testutil/resourcetypeutil" "github.com/stretchr/testify/require" ) @@ -95,7 +96,7 @@ func TestResourceGroupConvertFromValidation(t *testing.T) { src v1.DataModelInterface err error }{ - {&fakeResource{}, v1.ErrInvalidModelConversion}, + {&resourcetypeutil.FakeResource{}, v1.ErrInvalidModelConversion}, {nil, v1.ErrInvalidModelConversion}, } diff --git a/pkg/ucp/api/v20220901privatepreview/testdata/genericresource_datamodel.json b/pkg/ucp/api/v20220901privatepreview/testdata/genericresource_datamodel.json new file mode 100644 index 0000000000..c8fabfc130 --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/testdata/genericresource_datamodel.json @@ -0,0 +1,22 @@ +{ + "id": "/planes/radius/local/providers/System.Resources/resources/asdf", + "name": "asdf", + "type": "System.Resources/resources", + "location": "global", + "systemData": { + "createdBy": "fakeid@live.com", + "createdByType": "User", + "createdAt": "2021-09-24T19:09:54.2403864Z", + "lastModifiedBy": "fakeid@live.com", + "lastModifiedByType": "User", + "lastModifiedAt": "2021-09-24T20:09:54.2403864Z" + }, + "tags": { + "env": "dev" + }, + "properties": { + "id": "/planes/radius/local/resourcegroups/rg1/providers/Applications.Core/applications/test-app", + "type": "Applications.Core/applications", + "name": "test-app" + } +} \ No newline at end of file diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_awscredential_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_awscredential_client.go deleted file mode 100644 index 27ef27fe17..0000000000 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_awscredential_client.go +++ /dev/null @@ -1,273 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220901privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// AwsCredentialClient contains the methods for the AwsCredential group. -// Don't use this type directly, use NewAwsCredentialClient() instead. -type AwsCredentialClient struct { - host string - pl runtime.Pipeline -} - -// NewAwsCredentialClient creates a new instance of AwsCredentialClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewAwsCredentialClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AwsCredentialClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &AwsCredentialClient{ - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a AWSCredentialResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// credentialName - The AWS credential name. -// resource - Resource create parameters. -// options - AwsCredentialClientCreateOrUpdateOptions contains the optional parameters for the AwsCredentialClient.CreateOrUpdate -// method. -func (client *AwsCredentialClient) CreateOrUpdate(ctx context.Context, planeName string, credentialName string, resource AWSCredentialResource, options *AwsCredentialClientCreateOrUpdateOptions) (AwsCredentialClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, planeName, credentialName, resource, options) - if err != nil { - return AwsCredentialClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AwsCredentialClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return AwsCredentialClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *AwsCredentialClient) createOrUpdateCreateRequest(ctx context.Context, planeName string, credentialName string, resource AWSCredentialResource, options *AwsCredentialClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - if credentialName == "" { - return nil, errors.New("parameter credentialName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *AwsCredentialClient) createOrUpdateHandleResponse(resp *http.Response) (AwsCredentialClientCreateOrUpdateResponse, error) { - result := AwsCredentialClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return AwsCredentialClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.AWSCredentialResource); err != nil { - return AwsCredentialClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing AWSCredentialResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// credentialName - The AWS credential name. -// options - AwsCredentialClientDeleteOptions contains the optional parameters for the AwsCredentialClient.Delete method. -func (client *AwsCredentialClient) Delete(ctx context.Context, planeName string, credentialName string, options *AwsCredentialClientDeleteOptions) (AwsCredentialClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, planeName, credentialName, options) - if err != nil { - return AwsCredentialClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AwsCredentialClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return AwsCredentialClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return client.deleteHandleResponse(resp) -} - -// deleteCreateRequest creates the Delete request. -func (client *AwsCredentialClient) deleteCreateRequest(ctx context.Context, planeName string, credentialName string, options *AwsCredentialClientDeleteOptions) (*policy.Request, error) { - urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - if credentialName == "" { - return nil, errors.New("parameter credentialName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteHandleResponse handles the Delete response. -func (client *AwsCredentialClient) deleteHandleResponse(resp *http.Response) (AwsCredentialClientDeleteResponse, error) { - result := AwsCredentialClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return AwsCredentialClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a AWSCredentialResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// credentialName - The AWS credential name. -// options - AwsCredentialClientGetOptions contains the optional parameters for the AwsCredentialClient.Get method. -func (client *AwsCredentialClient) Get(ctx context.Context, planeName string, credentialName string, options *AwsCredentialClientGetOptions) (AwsCredentialClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, planeName, credentialName, options) - if err != nil { - return AwsCredentialClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AwsCredentialClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AwsCredentialClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *AwsCredentialClient) getCreateRequest(ctx context.Context, planeName string, credentialName string, options *AwsCredentialClientGetOptions) (*policy.Request, error) { - urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - if credentialName == "" { - return nil, errors.New("parameter credentialName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *AwsCredentialClient) getHandleResponse(resp *http.Response) (AwsCredentialClientGetResponse, error) { - result := AwsCredentialClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.AWSCredentialResource); err != nil { - return AwsCredentialClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all AWSCredentialResource -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// options - AwsCredentialClientListByRootScopeOptions contains the optional parameters for the AwsCredentialClient.ListByRootScope -// method. -func (client *AwsCredentialClient) NewListByRootScopePager(planeName string, options *AwsCredentialClientListByRootScopeOptions) (*runtime.Pager[AwsCredentialClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[AwsCredentialClientListByRootScopeResponse]{ - More: func(page AwsCredentialClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *AwsCredentialClientListByRootScopeResponse) (AwsCredentialClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, planeName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return AwsCredentialClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AwsCredentialClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AwsCredentialClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *AwsCredentialClient) listByRootScopeCreateRequest(ctx context.Context, planeName string, options *AwsCredentialClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *AwsCredentialClient) listByRootScopeHandleResponse(resp *http.Response) (AwsCredentialClientListByRootScopeResponse, error) { - result := AwsCredentialClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.AWSCredentialResourceListResult); err != nil { - return AwsCredentialClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_awscredentials_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_awscredentials_client.go new file mode 100644 index 0000000000..0f506fe5fc --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_awscredentials_client.go @@ -0,0 +1,309 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220901privatepreview + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AwsCredentialsClient contains the methods for the AwsCredentials group. +// Don't use this type directly, use NewAwsCredentialsClient() instead. +type AwsCredentialsClient struct { + internal *arm.Client +} + +// NewAwsCredentialsClient creates a new instance of AwsCredentialsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAwsCredentialsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AwsCredentialsClient, error) { + cl, err := arm.NewClient(moduleName+".AwsCredentialsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AwsCredentialsClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create or update an AWS credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of AWS plane +// - credentialName - The AWS credential name. +// - resource - Resource create parameters. +// - options - AwsCredentialsClientCreateOrUpdateOptions contains the optional parameters for the AwsCredentialsClient.CreateOrUpdate +// method. +func (client *AwsCredentialsClient) CreateOrUpdate(ctx context.Context, planeName string, credentialName string, resource AwsCredentialResource, options *AwsCredentialsClientCreateOrUpdateOptions) (AwsCredentialsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, planeName, credentialName, resource, options) + if err != nil { + return AwsCredentialsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AwsCredentialsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return AwsCredentialsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AwsCredentialsClient) createOrUpdateCreateRequest(ctx context.Context, planeName string, credentialName string, resource AwsCredentialResource, options *AwsCredentialsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AwsCredentialsClient) createOrUpdateHandleResponse(resp *http.Response) (AwsCredentialsClientCreateOrUpdateResponse, error) { + result := AwsCredentialsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AwsCredentialResource); err != nil { + return AwsCredentialsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete an AWS credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of AWS plane +// - credentialName - The AWS credential name. +// - options - AwsCredentialsClientDeleteOptions contains the optional parameters for the AwsCredentialsClient.Delete method. +func (client *AwsCredentialsClient) Delete(ctx context.Context, planeName string, credentialName string, options *AwsCredentialsClientDeleteOptions) (AwsCredentialsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, planeName, credentialName, options) + if err != nil { + return AwsCredentialsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AwsCredentialsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return AwsCredentialsClientDeleteResponse{}, err + } + return AwsCredentialsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AwsCredentialsClient) deleteCreateRequest(ctx context.Context, planeName string, credentialName string, options *AwsCredentialsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get an AWS credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of AWS plane +// - credentialName - The AWS credential name. +// - options - AwsCredentialsClientGetOptions contains the optional parameters for the AwsCredentialsClient.Get method. +func (client *AwsCredentialsClient) Get(ctx context.Context, planeName string, credentialName string, options *AwsCredentialsClientGetOptions) (AwsCredentialsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, planeName, credentialName, options) + if err != nil { + return AwsCredentialsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AwsCredentialsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AwsCredentialsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AwsCredentialsClient) getCreateRequest(ctx context.Context, planeName string, credentialName string, options *AwsCredentialsClientGetOptions) (*policy.Request, error) { + urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AwsCredentialsClient) getHandleResponse(resp *http.Response) (AwsCredentialsClientGetResponse, error) { + result := AwsCredentialsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AwsCredentialResource); err != nil { + return AwsCredentialsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List AWS credentials +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of AWS plane +// - options - AwsCredentialsClientListOptions contains the optional parameters for the AwsCredentialsClient.NewListPager method. +func (client *AwsCredentialsClient) NewListPager(planeName string, options *AwsCredentialsClientListOptions) (*runtime.Pager[AwsCredentialsClientListResponse]) { + return runtime.NewPager(runtime.PagingHandler[AwsCredentialsClientListResponse]{ + More: func(page AwsCredentialsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AwsCredentialsClientListResponse) (AwsCredentialsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, planeName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AwsCredentialsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AwsCredentialsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AwsCredentialsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *AwsCredentialsClient) listCreateRequest(ctx context.Context, planeName string, options *AwsCredentialsClientListOptions) (*policy.Request, error) { + urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AwsCredentialsClient) listHandleResponse(resp *http.Response) (AwsCredentialsClientListResponse, error) { + result := AwsCredentialsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AwsCredentialResourceListResult); err != nil { + return AwsCredentialsClientListResponse{}, err + } + return result, nil +} + +// Update - Update an AWS credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of AWS plane +// - credentialName - The AWS credential name. +// - properties - The resource properties to be updated. +// - options - AwsCredentialsClientUpdateOptions contains the optional parameters for the AwsCredentialsClient.Update method. +func (client *AwsCredentialsClient) Update(ctx context.Context, planeName string, credentialName string, properties AwsCredentialResourceTagsUpdate, options *AwsCredentialsClientUpdateOptions) (AwsCredentialsClientUpdateResponse, error) { + var err error + req, err := client.updateCreateRequest(ctx, planeName, credentialName, properties, options) + if err != nil { + return AwsCredentialsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AwsCredentialsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AwsCredentialsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *AwsCredentialsClient) updateCreateRequest(ctx context.Context, planeName string, credentialName string, properties AwsCredentialResourceTagsUpdate, options *AwsCredentialsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *AwsCredentialsClient) updateHandleResponse(resp *http.Response) (AwsCredentialsClientUpdateResponse, error) { + result := AwsCredentialsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AwsCredentialResource); err != nil { + return AwsCredentialsClientUpdateResponse{}, err + } + return result, nil +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_azurecredential_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_azurecredential_client.go deleted file mode 100644 index 4dc395e4d5..0000000000 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_azurecredential_client.go +++ /dev/null @@ -1,273 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220901privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// AzureCredentialClient contains the methods for the AzureCredential group. -// Don't use this type directly, use NewAzureCredentialClient() instead. -type AzureCredentialClient struct { - host string - pl runtime.Pipeline -} - -// NewAzureCredentialClient creates a new instance of AzureCredentialClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewAzureCredentialClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureCredentialClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &AzureCredentialClient{ - host: ep, -pl: pl, - } - return client, nil -} - -// CreateOrUpdate - Creates or updates a AzureCredentialResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// credentialName - The Azure credential name. -// resource - Resource create parameters. -// options - AzureCredentialClientCreateOrUpdateOptions contains the optional parameters for the AzureCredentialClient.CreateOrUpdate -// method. -func (client *AzureCredentialClient) CreateOrUpdate(ctx context.Context, planeName string, credentialName string, resource AzureCredentialResource, options *AzureCredentialClientCreateOrUpdateOptions) (AzureCredentialClientCreateOrUpdateResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, planeName, credentialName, resource, options) - if err != nil { - return AzureCredentialClientCreateOrUpdateResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AzureCredentialClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return AzureCredentialClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *AzureCredentialClient) createOrUpdateCreateRequest(ctx context.Context, planeName string, credentialName string, resource AzureCredentialResource, options *AzureCredentialClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - if credentialName == "" { - return nil, errors.New("parameter credentialName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *AzureCredentialClient) createOrUpdateHandleResponse(resp *http.Response) (AzureCredentialClientCreateOrUpdateResponse, error) { - result := AzureCredentialClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return AzureCredentialClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } - if err := runtime.UnmarshalAsJSON(resp, &result.AzureCredentialResource); err != nil { - return AzureCredentialClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Deletes an existing AzureCredentialResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// credentialName - The Azure credential name. -// options - AzureCredentialClientDeleteOptions contains the optional parameters for the AzureCredentialClient.Delete method. -func (client *AzureCredentialClient) Delete(ctx context.Context, planeName string, credentialName string, options *AzureCredentialClientDeleteOptions) (AzureCredentialClientDeleteResponse, error) { - req, err := client.deleteCreateRequest(ctx, planeName, credentialName, options) - if err != nil { - return AzureCredentialClientDeleteResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AzureCredentialClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return AzureCredentialClientDeleteResponse{}, runtime.NewResponseError(resp) - } - return client.deleteHandleResponse(resp) -} - -// deleteCreateRequest creates the Delete request. -func (client *AzureCredentialClient) deleteCreateRequest(ctx context.Context, planeName string, credentialName string, options *AzureCredentialClientDeleteOptions) (*policy.Request, error) { - urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - if credentialName == "" { - return nil, errors.New("parameter credentialName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// deleteHandleResponse handles the Delete response. -func (client *AzureCredentialClient) deleteHandleResponse(resp *http.Response) (AzureCredentialClientDeleteResponse, error) { - result := AzureCredentialClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return AzureCredentialClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a AzureCredentialResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// credentialName - The Azure credential name. -// options - AzureCredentialClientGetOptions contains the optional parameters for the AzureCredentialClient.Get method. -func (client *AzureCredentialClient) Get(ctx context.Context, planeName string, credentialName string, options *AzureCredentialClientGetOptions) (AzureCredentialClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, planeName, credentialName, options) - if err != nil { - return AzureCredentialClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AzureCredentialClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AzureCredentialClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *AzureCredentialClient) getCreateRequest(ctx context.Context, planeName string, credentialName string, options *AzureCredentialClientGetOptions) (*policy.Request, error) { - urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - if credentialName == "" { - return nil, errors.New("parameter credentialName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *AzureCredentialClient) getHandleResponse(resp *http.Response) (AzureCredentialClientGetResponse, error) { - result := AzureCredentialClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.AzureCredentialResource); err != nil { - return AzureCredentialClientGetResponse{}, err - } - return result, nil -} - -// NewListByRootScopePager - Lists information about all AzureCredentialResource -// Generated from API version 2022-09-01-privatepreview -// planeName - The name of the plane -// options - AzureCredentialClientListByRootScopeOptions contains the optional parameters for the AzureCredentialClient.ListByRootScope -// method. -func (client *AzureCredentialClient) NewListByRootScopePager(planeName string, options *AzureCredentialClientListByRootScopeOptions) (*runtime.Pager[AzureCredentialClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[AzureCredentialClientListByRootScopeResponse]{ - More: func(page AzureCredentialClientListByRootScopeResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *AzureCredentialClientListByRootScopeResponse) (AzureCredentialClientListByRootScopeResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, planeName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return AzureCredentialClientListByRootScopeResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AzureCredentialClientListByRootScopeResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AzureCredentialClientListByRootScopeResponse{}, runtime.NewResponseError(resp) - } - return client.listByRootScopeHandleResponse(resp) - }, - }) -} - -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *AzureCredentialClient) listByRootScopeCreateRequest(ctx context.Context, planeName string, options *AzureCredentialClientListByRootScopeOptions) (*policy.Request, error) { - urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials" - urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *AzureCredentialClient) listByRootScopeHandleResponse(resp *http.Response) (AzureCredentialClientListByRootScopeResponse, error) { - result := AzureCredentialClientListByRootScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.AzureCredentialResourceListResult); err != nil { - return AzureCredentialClientListByRootScopeResponse{}, err - } - return result, nil -} - diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_azurecredentials_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_azurecredentials_client.go new file mode 100644 index 0000000000..5a281825cc --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_azurecredentials_client.go @@ -0,0 +1,310 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220901privatepreview + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AzureCredentialsClient contains the methods for the AzureCredentials group. +// Don't use this type directly, use NewAzureCredentialsClient() instead. +type AzureCredentialsClient struct { + internal *arm.Client +} + +// NewAzureCredentialsClient creates a new instance of AzureCredentialsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAzureCredentialsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureCredentialsClient, error) { + cl, err := arm.NewClient(moduleName+".AzureCredentialsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AzureCredentialsClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create or update an Azure credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of the plane +// - credentialName - The Azure credential name. +// - resource - Resource create parameters. +// - options - AzureCredentialsClientCreateOrUpdateOptions contains the optional parameters for the AzureCredentialsClient.CreateOrUpdate +// method. +func (client *AzureCredentialsClient) CreateOrUpdate(ctx context.Context, planeName string, credentialName string, resource AzureCredentialResource, options *AzureCredentialsClientCreateOrUpdateOptions) (AzureCredentialsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, planeName, credentialName, resource, options) + if err != nil { + return AzureCredentialsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureCredentialsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return AzureCredentialsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AzureCredentialsClient) createOrUpdateCreateRequest(ctx context.Context, planeName string, credentialName string, resource AzureCredentialResource, options *AzureCredentialsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AzureCredentialsClient) createOrUpdateHandleResponse(resp *http.Response) (AzureCredentialsClientCreateOrUpdateResponse, error) { + result := AzureCredentialsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureCredentialResource); err != nil { + return AzureCredentialsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete an Azure credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of the plane +// - credentialName - The Azure credential name. +// - options - AzureCredentialsClientDeleteOptions contains the optional parameters for the AzureCredentialsClient.Delete method. +func (client *AzureCredentialsClient) Delete(ctx context.Context, planeName string, credentialName string, options *AzureCredentialsClientDeleteOptions) (AzureCredentialsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, planeName, credentialName, options) + if err != nil { + return AzureCredentialsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureCredentialsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return AzureCredentialsClientDeleteResponse{}, err + } + return AzureCredentialsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AzureCredentialsClient) deleteCreateRequest(ctx context.Context, planeName string, credentialName string, options *AzureCredentialsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get an Azure credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of the plane +// - credentialName - The Azure credential name. +// - options - AzureCredentialsClientGetOptions contains the optional parameters for the AzureCredentialsClient.Get method. +func (client *AzureCredentialsClient) Get(ctx context.Context, planeName string, credentialName string, options *AzureCredentialsClientGetOptions) (AzureCredentialsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, planeName, credentialName, options) + if err != nil { + return AzureCredentialsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureCredentialsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureCredentialsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AzureCredentialsClient) getCreateRequest(ctx context.Context, planeName string, credentialName string, options *AzureCredentialsClientGetOptions) (*policy.Request, error) { + urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AzureCredentialsClient) getHandleResponse(resp *http.Response) (AzureCredentialsClientGetResponse, error) { + result := AzureCredentialsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureCredentialResource); err != nil { + return AzureCredentialsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - List Azure credentials +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of the plane +// - options - AzureCredentialsClientListOptions contains the optional parameters for the AzureCredentialsClient.NewListPager +// method. +func (client *AzureCredentialsClient) NewListPager(planeName string, options *AzureCredentialsClientListOptions) (*runtime.Pager[AzureCredentialsClientListResponse]) { + return runtime.NewPager(runtime.PagingHandler[AzureCredentialsClientListResponse]{ + More: func(page AzureCredentialsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AzureCredentialsClientListResponse) (AzureCredentialsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, planeName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AzureCredentialsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureCredentialsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AzureCredentialsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *AzureCredentialsClient) listCreateRequest(ctx context.Context, planeName string, options *AzureCredentialsClientListOptions) (*policy.Request, error) { + urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AzureCredentialsClient) listHandleResponse(resp *http.Response) (AzureCredentialsClientListResponse, error) { + result := AzureCredentialsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureCredentialResourceListResult); err != nil { + return AzureCredentialsClientListResponse{}, err + } + return result, nil +} + +// Update - Update an Azure credential +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeName - The name of the plane +// - credentialName - The Azure credential name. +// - properties - The resource properties to be updated. +// - options - AzureCredentialsClientUpdateOptions contains the optional parameters for the AzureCredentialsClient.Update method. +func (client *AzureCredentialsClient) Update(ctx context.Context, planeName string, credentialName string, properties AzureCredentialResourceTagsUpdate, options *AzureCredentialsClientUpdateOptions) (AzureCredentialsClientUpdateResponse, error) { + var err error + req, err := client.updateCreateRequest(ctx, planeName, credentialName, properties, options) + if err != nil { + return AzureCredentialsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureCredentialsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureCredentialsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *AzureCredentialsClient) updateCreateRequest(ctx context.Context, planeName string, credentialName string, properties AzureCredentialResourceTagsUpdate, options *AzureCredentialsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}" + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if credentialName == "" { + return nil, errors.New("parameter credentialName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{credentialName}", url.PathEscape(credentialName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *AzureCredentialsClient) updateHandleResponse(resp *http.Response) (AzureCredentialsClientUpdateResponse, error) { + result := AzureCredentialsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureCredentialResource); err != nil { + return AzureCredentialsClientUpdateResponse{}, err + } + return result, nil +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_client_factory.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_client_factory.go new file mode 100644 index 0000000000..c88e54ed34 --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_client_factory.go @@ -0,0 +1,61 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220901privatepreview + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory( credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAwsCredentialsClient() *AwsCredentialsClient { + subClient, _ := NewAwsCredentialsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAzureCredentialsClient() *AzureCredentialsClient { + subClient, _ := NewAzureCredentialsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPlanesClient() *PlanesClient { + subClient, _ := NewPlanesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourceGroupsClient() *ResourceGroupsClient { + subClient, _ := NewResourceGroupsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourcesClient() *ResourcesClient { + subClient, _ := NewResourcesClient(c.credential, c.options) + return subClient +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_constants.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_constants.go index 571aa684d2..0ee33593c4 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_constants.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_constants.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview @@ -13,10 +12,11 @@ const ( moduleVersion = "v0.0.1" ) -// AWSCredentialKind - AWS credential kinds supported. +// AWSCredentialKind - AWS credential kind type AWSCredentialKind string const ( + // AWSCredentialKindAccessKey - The AWS Access Key credential AWSCredentialKindAccessKey AWSCredentialKind = "AccessKey" ) @@ -31,6 +31,7 @@ func PossibleAWSCredentialKindValues() []AWSCredentialKind { type AzureCredentialKind string const ( + // AzureCredentialKindServicePrincipal - The Service Principal Credential AzureCredentialKindServicePrincipal AzureCredentialKind = "ServicePrincipal" ) @@ -65,6 +66,7 @@ func PossibleCreatedByTypeValues() []CreatedByType { type CredentialStorageKind string const ( + // CredentialStorageKindInternal - Internal credential storage CredentialStorageKindInternal CredentialStorageKind = "Internal" ) @@ -79,8 +81,11 @@ func PossibleCredentialStorageKindValues() []CredentialStorageKind { type PlaneKind string const ( + // PlaneKindAWS - AWS Plane PlaneKindAWS PlaneKind = "AWS" + // PlaneKindAzure - Azure Plane PlaneKindAzure PlaneKind = "Azure" + // PlaneKindUCPNative - UCP Native Plane PlaneKindUCPNative PlaneKind = "UCPNative" ) @@ -93,16 +98,23 @@ func PossiblePlaneKindValues() []PlaneKind { } } -// ProvisioningState - Provisioning state of the link at the time the operation was called +// ProvisioningState - Provisioning state of the portable resource at the time the operation was called type ProvisioningState string const ( + // ProvisioningStateAccepted - The resource create request has been accepted ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - The resource is being deleted ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - The resource is being provisioned ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - The resource is updating ProvisioningStateUpdating ProvisioningState = "Updating" ) @@ -119,3 +131,18 @@ func PossibleProvisioningStateValues() []ProvisioningState { } } +// Versions - Supported API versions for Universal Control Plane resource provider. +type Versions string + +const ( + // VersionsV20220901Privatepreview - 2022-09-01-privatepreview + VersionsV20220901Privatepreview Versions = "2022-09-01-privatepreview" +) + +// PossibleVersionsValues returns the possible values for the Versions const type. +func PossibleVersionsValues() []Versions { + return []Versions{ + VersionsV20220901Privatepreview, + } +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_interfaces.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_interfaces.go new file mode 100644 index 0000000000..3bbf9848c0 --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_interfaces.go @@ -0,0 +1,36 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220901privatepreview + +// AwsCredentialPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetAwsCredentialProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AwsAccessKeyCredentialProperties, *AwsCredentialProperties +type AwsCredentialPropertiesClassification interface { + // GetAwsCredentialProperties returns the AwsCredentialProperties content of the underlying type. + GetAwsCredentialProperties() *AwsCredentialProperties +} + +// AzureCredentialPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetAzureCredentialProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureCredentialProperties, *AzureServicePrincipalProperties +type AzureCredentialPropertiesClassification interface { + // GetAzureCredentialProperties returns the AzureCredentialProperties content of the underlying type. + GetAzureCredentialProperties() *AzureCredentialProperties +} + +// CredentialStoragePropertiesClassification provides polymorphic access to related types. +// Call the interface's GetCredentialStorageProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *CredentialStorageProperties, *InternalCredentialStorageProperties +type CredentialStoragePropertiesClassification interface { + // GetCredentialStorageProperties returns the CredentialStorageProperties content of the underlying type. + GetCredentialStorageProperties() *CredentialStorageProperties +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_models.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_models.go index e737c80f87..0a2ddfb425 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_models.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_models.go @@ -2,212 +2,161 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview import "time" -// AWSAccessKeyCredentialProperties - AWS credential storage properties -type AWSAccessKeyCredentialProperties struct { +// AwsAccessKeyCredentialProperties - AWS credential storage properties +type AwsAccessKeyCredentialProperties struct { // REQUIRED; Access key ID for AWS identity - AccessKeyID *string `json:"accessKeyId,omitempty"` + AccessKeyID *string - // REQUIRED; Discriminator property for AWSCredentialProperties. - Kind *string `json:"kind,omitempty"` + // REQUIRED; The AWS credential kind + Kind *AWSCredentialKind // REQUIRED; Secret Access Key for AWS identity - SecretAccessKey *string `json:"secretAccessKey,omitempty"` + SecretAccessKey *string // REQUIRED; The storage properties - Storage CredentialStoragePropertiesClassification `json:"storage,omitempty"` + Storage CredentialStoragePropertiesClassification - // READ-ONLY; Provisioning state of the resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState } -// GetAWSCredentialProperties implements the AWSCredentialPropertiesClassification interface for type AWSAccessKeyCredentialProperties. -func (a *AWSAccessKeyCredentialProperties) GetAWSCredentialProperties() *AWSCredentialProperties { - return &AWSCredentialProperties{ +// GetAwsCredentialProperties implements the AwsCredentialPropertiesClassification interface for type AwsAccessKeyCredentialProperties. +func (a *AwsAccessKeyCredentialProperties) GetAwsCredentialProperties() *AwsCredentialProperties { + return &AwsCredentialProperties{ Kind: a.Kind, ProvisioningState: a.ProvisioningState, } } -// AWSCredentialPropertiesClassification provides polymorphic access to related types. -// Call the interface's GetAWSCredentialProperties() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AWSAccessKeyCredentialProperties, *AWSCredentialProperties -type AWSCredentialPropertiesClassification interface { - // GetAWSCredentialProperties returns the AWSCredentialProperties content of the underlying type. - GetAWSCredentialProperties() *AWSCredentialProperties -} - -// AWSCredentialProperties - AWS Credential properties -type AWSCredentialProperties struct { - // REQUIRED; Discriminator property for AWSCredentialProperties. - Kind *string `json:"kind,omitempty"` +// AwsCredentialProperties - AWS Credential properties +type AwsCredentialProperties struct { + // REQUIRED; The AWS credential kind + Kind *AWSCredentialKind - // READ-ONLY; Provisioning state of the resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState } -// GetAWSCredentialProperties implements the AWSCredentialPropertiesClassification interface for type AWSCredentialProperties. -func (a *AWSCredentialProperties) GetAWSCredentialProperties() *AWSCredentialProperties { return a } +// GetAwsCredentialProperties implements the AwsCredentialPropertiesClassification interface for type AwsCredentialProperties. +func (a *AwsCredentialProperties) GetAwsCredentialProperties() *AwsCredentialProperties { return a } -// AWSCredentialResource - Concrete tracked resource types can be created by aliasing this type using a specific property +// AwsCredentialResource - Concrete tracked resource types can be created by aliasing this type using a specific property // type. -type AWSCredentialResource struct { +type AwsCredentialResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties AWSCredentialPropertiesClassification `json:"properties,omitempty"` + Properties AwsCredentialPropertiesClassification // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } -// AWSCredentialResourceListResult - The response of a AWSCredentialResource list operation. -type AWSCredentialResourceListResult struct { - // REQUIRED; The AWSCredentialResource items on this page - Value []*AWSCredentialResource `json:"value,omitempty"` +// AwsCredentialResourceListResult - The response of a AwsCredentialResource list operation. +type AwsCredentialResourceListResult struct { + // REQUIRED; The AwsCredentialResource items on this page + Value []*AwsCredentialResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` -} - -// AwsCredentialClientCreateOrUpdateOptions contains the optional parameters for the AwsCredentialClient.CreateOrUpdate method. -type AwsCredentialClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// AwsCredentialClientDeleteOptions contains the optional parameters for the AwsCredentialClient.Delete method. -type AwsCredentialClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// AwsCredentialClientGetOptions contains the optional parameters for the AwsCredentialClient.Get method. -type AwsCredentialClientGetOptions struct { - // placeholder for future optional parameters -} - -// AwsCredentialClientListByRootScopeOptions contains the optional parameters for the AwsCredentialClient.ListByRootScope -// method. -type AwsCredentialClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// AzureCredentialClientCreateOrUpdateOptions contains the optional parameters for the AzureCredentialClient.CreateOrUpdate -// method. -type AzureCredentialClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// AzureCredentialClientDeleteOptions contains the optional parameters for the AzureCredentialClient.Delete method. -type AzureCredentialClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// AzureCredentialClientGetOptions contains the optional parameters for the AzureCredentialClient.Get method. -type AzureCredentialClientGetOptions struct { - // placeholder for future optional parameters + NextLink *string } -// AzureCredentialClientListByRootScopeOptions contains the optional parameters for the AzureCredentialClient.ListByRootScope -// method. -type AzureCredentialClientListByRootScopeOptions struct { - // placeholder for future optional parameters -} - -// AzureCredentialPropertiesClassification provides polymorphic access to related types. -// Call the interface's GetAzureCredentialProperties() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AzureCredentialProperties, *AzureServicePrincipalProperties -type AzureCredentialPropertiesClassification interface { - // GetAzureCredentialProperties returns the AzureCredentialProperties content of the underlying type. - GetAzureCredentialProperties() *AzureCredentialProperties +// AwsCredentialResourceTagsUpdate - The type used for updating tags in AwsCredentialResource resources. +type AwsCredentialResourceTagsUpdate struct { + // Resource tags. + Tags map[string]*string } -// AzureCredentialProperties - Azure Credential properties +// AzureCredentialProperties - The base properties of Azure Credential type AzureCredentialProperties struct { - // REQUIRED; Discriminator property for AzureCredentialProperties. - Kind *string `json:"kind,omitempty"` + // REQUIRED; The kind of Azure credential + Kind *AzureCredentialKind - // READ-ONLY; Provisioning state of the resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState } // GetAzureCredentialProperties implements the AzureCredentialPropertiesClassification interface for type AzureCredentialProperties. func (a *AzureCredentialProperties) GetAzureCredentialProperties() *AzureCredentialProperties { return a } -// AzureCredentialResource - Concrete tracked resource types can be created by aliasing this type using a specific property -// type. +// AzureCredentialResource - Represents Azure Credential Resource type AzureCredentialResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties AzureCredentialPropertiesClassification `json:"properties,omitempty"` + Properties AzureCredentialPropertiesClassification // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // AzureCredentialResourceListResult - The response of a AzureCredentialResource list operation. type AzureCredentialResourceListResult struct { // REQUIRED; The AzureCredentialResource items on this page - Value []*AzureCredentialResource `json:"value,omitempty"` + Value []*AzureCredentialResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// AzureServicePrincipalProperties - Service Principal credential storage properties +// AzureCredentialResourceTagsUpdate - The type used for updating tags in AzureCredentialResource resources. +type AzureCredentialResourceTagsUpdate struct { + // Resource tags. + Tags map[string]*string +} + +// AzureServicePrincipalProperties - The properties of Service Principal credential storage type AzureServicePrincipalProperties struct { // REQUIRED; clientId for ServicePrincipal - ClientID *string `json:"clientId,omitempty"` + ClientID *string // REQUIRED; secret for ServicePrincipal - ClientSecret *string `json:"clientSecret,omitempty"` + ClientSecret *string - // REQUIRED; Discriminator property for AzureCredentialProperties. - Kind *string `json:"kind,omitempty"` + // REQUIRED; The kind of Azure credential + Kind *AzureCredentialKind // REQUIRED; The storage properties - Storage CredentialStoragePropertiesClassification `json:"storage,omitempty"` + Storage CredentialStoragePropertiesClassification // REQUIRED; tenantId for ServicePrincipal - TenantID *string `json:"tenantId,omitempty"` + TenantID *string - // READ-ONLY; Provisioning state of the resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState } // GetAzureCredentialProperties implements the AzureCredentialPropertiesClassification interface for type AzureServicePrincipalProperties. @@ -218,25 +167,29 @@ func (a *AzureServicePrincipalProperties) GetAzureCredentialProperties() *AzureC } } -// BasicResourceProperties - Basic properties of a UCP resource. -type BasicResourceProperties struct { - // READ-ONLY; Provisioning state of the resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` -} +// ComponentsKhmx01SchemasGenericresourceAllof0 - Concrete proxy resource types can be created by aliasing this type using +// a specific property type. +type ComponentsKhmx01SchemasGenericresourceAllof0 struct { + // The resource-specific properties for this resource. + Properties map[string]any + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData -// CredentialStoragePropertiesClassification provides polymorphic access to related types. -// Call the interface's GetCredentialStorageProperties() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *CredentialStorageProperties, *InternalCredentialStorageProperties -type CredentialStoragePropertiesClassification interface { - // GetCredentialStorageProperties returns the CredentialStorageProperties content of the underlying type. - GetCredentialStorageProperties() *CredentialStorageProperties + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } -// CredentialStorageProperties - Credential storage properties +// CredentialStorageProperties - The base credential storage properties type CredentialStorageProperties struct { - // REQUIRED; Discriminator property for CredentialStorageProperties. - Kind *string `json:"kind,omitempty"` + // REQUIRED; The kind of credential storage + Kind *CredentialStorageKind } // GetCredentialStorageProperties implements the CredentialStoragePropertiesClassification interface for type CredentialStorageProperties. @@ -245,44 +198,71 @@ func (c *CredentialStorageProperties) GetCredentialStorageProperties() *Credenti // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + Info map[string]any // READ-ONLY; The additional info type. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ErrorDetail - The error detail. type ErrorDetail struct { // READ-ONLY; The error additional info. - AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + AdditionalInfo []*ErrorAdditionalInfo // READ-ONLY; The error code. - Code *string `json:"code,omitempty" azure:"ro"` + Code *string // READ-ONLY; The error details. - Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + Details []*ErrorDetail // READ-ONLY; The error message. - Message *string `json:"message,omitempty" azure:"ro"` + Message *string // READ-ONLY; The error target. - Target *string `json:"target,omitempty" azure:"ro"` + Target *string } // ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. // (This also follows the OData error response format.). type ErrorResponse struct { // The error object. - Error *ErrorDetail `json:"error,omitempty"` + Error *ErrorDetail +} + +// GenericResource - Represents resource data. +type GenericResource struct { + // The resource-specific properties for this resource. + Properties map[string]any + + // READ-ONLY; The name of resource + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// GenericResourceListResult - The response of a GenericResource list operation. +type GenericResourceListResult struct { + // REQUIRED; The GenericResource items on this page + Value []*GenericResource + + // The link to the next page of items + NextLink *string } // InternalCredentialStorageProperties - Internal credential storage properties type InternalCredentialStorageProperties struct { - // REQUIRED; Discriminator property for CredentialStorageProperties. - Kind *string `json:"kind,omitempty"` + // REQUIRED; The kind of credential storage + Kind *CredentialStorageKind // READ-ONLY; The name of secret stored. - SecretName *string `json:"secretName,omitempty" azure:"ro"` + SecretName *string } // GetCredentialStorageProperties implements the CredentialStoragePropertiesClassification interface for type InternalCredentialStorageProperties. @@ -292,189 +272,176 @@ func (i *InternalCredentialStorageProperties) GetCredentialStorageProperties() * } } -// PlaneResource - UCP PlaneResource. +// PlaneResource - The plane resource type PlaneResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *PlaneResourceProperties `json:"properties,omitempty"` + Properties *PlaneResourceProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // PlaneResourceListResult - The response of a PlaneResource list operation. type PlaneResourceListResult struct { // REQUIRED; The PlaneResource items on this page - Value []*PlaneResource `json:"value,omitempty"` + Value []*PlaneResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// PlaneResourceProperties - Plane properties. +// PlaneResourceProperties - The Plane properties. type PlaneResourceProperties struct { // REQUIRED; The kind of plane - Kind *PlaneKind `json:"kind,omitempty"` + Kind *PlaneKind // Resource Providers for UCP Native Plane - ResourceProviders map[string]*string `json:"resourceProviders,omitempty"` + ResourceProviders map[string]*string // URL to forward requests to for non UCP Native Plane - URL *string `json:"url,omitempty"` + URL *string - // READ-ONLY; Provisioning state of the resource at the time the operation was called - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState } -// PlaneTypesClientGetOptions contains the optional parameters for the PlaneTypesClient.Get method. -type PlaneTypesClientGetOptions struct { - // placeholder for future optional parameters +// PlaneResourceTagsUpdate - The type used for updating tags in PlaneResource resources. +type PlaneResourceTagsUpdate struct { + // Resource tags. + Tags map[string]*string } -// PlanesClientCreateOrUpdateOptions contains the optional parameters for the PlanesClient.CreateOrUpdate method. -type PlanesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string -// PlanesClientDeleteOptions contains the optional parameters for the PlanesClient.Delete method. -type PlanesClientDeleteOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; The name of the resource + Name *string -// PlanesClientGetOptions contains the optional parameters for the PlanesClient.Get method. -type PlanesClientGetOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData -// PlanesClientListByRootScopeOptions contains the optional parameters for the PlanesClient.ListByRootScope method. -type PlanesClientListByRootScopeOptions struct { - // placeholder for future optional parameters + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string +} + +// ResourceGroupProperties - The resource group resource properties +type ResourceGroupProperties struct { + // READ-ONLY; The status of the asynchronous operation. + ProvisioningState *ProvisioningState } -// ResourceGroupResource - UCP ResourceGroup. +// ResourceGroupResource - The resource group resource type ResourceGroupResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The resource-specific properties for this resource. - Properties *BasicResourceProperties `json:"properties,omitempty"` + Properties *ResourceGroupProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ResourceGroupResourceListResult - The response of a ResourceGroupResource list operation. type ResourceGroupResourceListResult struct { // REQUIRED; The ResourceGroupResource items on this page - Value []*ResourceGroupResource `json:"value,omitempty"` + Value []*ResourceGroupResource // The link to the next page of items - NextLink *string `json:"nextLink,omitempty"` + NextLink *string } -// ResourceGroupsClientCreateOrUpdateOptions contains the optional parameters for the ResourceGroupsClient.CreateOrUpdate -// method. -type ResourceGroupsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ResourceGroupsClientDeleteOptions contains the optional parameters for the ResourceGroupsClient.Delete method. -type ResourceGroupsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ResourceGroupsClientGetOptions contains the optional parameters for the ResourceGroupsClient.Get method. -type ResourceGroupsClientGetOptions struct { - // placeholder for future optional parameters -} - -// ResourceGroupsClientListByRootScopeOptions contains the optional parameters for the ResourceGroupsClient.ListByRootScope -// method. -type ResourceGroupsClientListByRootScopeOptions struct { - // placeholder for future optional parameters +// ResourceGroupResourceTagsUpdate - The type used for updating tags in ResourceGroupResource resources. +type ResourceGroupResourceTagsUpdate struct { + // Resource tags. + Tags map[string]*string } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAt *time.Time // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` + CreatedBy *string // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAt *time.Time // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedBy *string // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *CreatedByType } // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' // and a 'location' type TrackedResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_models_serde.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_models_serde.go index 509be1052d..ac9308dbde 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_models_serde.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_models_serde.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview @@ -15,19 +14,19 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type AWSAccessKeyCredentialProperties. -func (a AWSAccessKeyCredentialProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) +// MarshalJSON implements the json.Marshaller interface for type AwsAccessKeyCredentialProperties. +func (a AwsAccessKeyCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) populate(objectMap, "accessKeyId", a.AccessKeyID) - objectMap["kind"] = "AccessKey" + objectMap["kind"] = AWSCredentialKindAccessKey populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "secretAccessKey", a.SecretAccessKey) populate(objectMap, "storage", a.Storage) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AWSAccessKeyCredentialProperties. -func (a *AWSAccessKeyCredentialProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AwsAccessKeyCredentialProperties. +func (a *AwsAccessKeyCredentialProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -37,19 +36,19 @@ func (a *AWSAccessKeyCredentialProperties) UnmarshalJSON(data []byte) error { switch key { case "accessKeyId": err = unpopulate(val, "AccessKeyID", &a.AccessKeyID) - delete(rawMsg, key) + delete(rawMsg, key) case "kind": err = unpopulate(val, "Kind", &a.Kind) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "secretAccessKey": err = unpopulate(val, "SecretAccessKey", &a.SecretAccessKey) - delete(rawMsg, key) + delete(rawMsg, key) case "storage": - a.Storage, err = unmarshalCredentialStoragePropertiesClassification(val) - delete(rawMsg, key) + a.Storage, err = unmarshalCredentialStoragePropertiesClassification(val) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -58,16 +57,16 @@ func (a *AWSAccessKeyCredentialProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AWSCredentialProperties. -func (a AWSCredentialProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) +// MarshalJSON implements the json.Marshaller interface for type AwsCredentialProperties. +func (a AwsCredentialProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) objectMap["kind"] = a.Kind populate(objectMap, "provisioningState", a.ProvisioningState) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AWSCredentialProperties. -func (a *AWSCredentialProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AwsCredentialProperties. +func (a *AwsCredentialProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -77,10 +76,10 @@ func (a *AWSCredentialProperties) UnmarshalJSON(data []byte) error { switch key { case "kind": err = unpopulate(val, "Kind", &a.Kind) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -89,9 +88,9 @@ func (a *AWSCredentialProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AWSCredentialResource. -func (a AWSCredentialResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) +// MarshalJSON implements the json.Marshaller interface for type AwsCredentialResource. +func (a AwsCredentialResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) populate(objectMap, "name", a.Name) @@ -102,8 +101,8 @@ func (a AWSCredentialResource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AWSCredentialResource. -func (a *AWSCredentialResource) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AwsCredentialResource. +func (a *AwsCredentialResource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -113,25 +112,25 @@ func (a *AWSCredentialResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &a.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &a.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": - a.Properties, err = unmarshalAWSCredentialPropertiesClassification(val) - delete(rawMsg, key) + a.Properties, err = unmarshalAwsCredentialPropertiesClassification(val) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &a.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &a.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -140,16 +139,16 @@ func (a *AWSCredentialResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AWSCredentialResourceListResult. -func (a AWSCredentialResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) +// MarshalJSON implements the json.Marshaller interface for type AwsCredentialResourceListResult. +func (a AwsCredentialResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type AWSCredentialResourceListResult. -func (a *AWSCredentialResourceListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type AwsCredentialResourceListResult. +func (a *AwsCredentialResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -159,10 +158,37 @@ func (a *AWSCredentialResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &a.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &a.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AwsCredentialResourceTagsUpdate. +func (a AwsCredentialResourceTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AwsCredentialResourceTagsUpdate. +func (a *AwsCredentialResourceTagsUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -173,7 +199,7 @@ func (a *AWSCredentialResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureCredentialProperties. func (a AzureCredentialProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["kind"] = a.Kind populate(objectMap, "provisioningState", a.ProvisioningState) return json.Marshal(objectMap) @@ -190,10 +216,10 @@ func (a *AzureCredentialProperties) UnmarshalJSON(data []byte) error { switch key { case "kind": err = unpopulate(val, "Kind", &a.Kind) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -204,7 +230,7 @@ func (a *AzureCredentialProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureCredentialResource. func (a AzureCredentialResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "location", a.Location) populate(objectMap, "name", a.Name) @@ -226,25 +252,25 @@ func (a *AzureCredentialResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &a.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &a.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": - a.Properties, err = unmarshalAzureCredentialPropertiesClassification(val) - delete(rawMsg, key) + a.Properties, err = unmarshalAzureCredentialPropertiesClassification(val) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &a.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &a.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -255,7 +281,7 @@ func (a *AzureCredentialResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureCredentialResourceListResult. func (a AzureCredentialResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -272,10 +298,37 @@ func (a *AzureCredentialResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &a.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &a.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureCredentialResourceTagsUpdate. +func (a AzureCredentialResourceTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureCredentialResourceTagsUpdate. +func (a *AzureCredentialResourceTagsUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -286,10 +339,10 @@ func (a *AzureCredentialResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureServicePrincipalProperties. func (a AzureServicePrincipalProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", a.ClientID) populate(objectMap, "clientSecret", a.ClientSecret) - objectMap["kind"] = "ServicePrincipal" + objectMap["kind"] = AzureCredentialKindServicePrincipal populate(objectMap, "provisioningState", a.ProvisioningState) populate(objectMap, "storage", a.Storage) populate(objectMap, "tenantId", a.TenantID) @@ -307,22 +360,22 @@ func (a *AzureServicePrincipalProperties) UnmarshalJSON(data []byte) error { switch key { case "clientId": err = unpopulate(val, "ClientID", &a.ClientID) - delete(rawMsg, key) + delete(rawMsg, key) case "clientSecret": err = unpopulate(val, "ClientSecret", &a.ClientSecret) - delete(rawMsg, key) + delete(rawMsg, key) case "kind": err = unpopulate(val, "Kind", &a.Kind) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "storage": - a.Storage, err = unmarshalCredentialStoragePropertiesClassification(val) - delete(rawMsg, key) + a.Storage, err = unmarshalCredentialStoragePropertiesClassification(val) + delete(rawMsg, key) case "tenantId": err = unpopulate(val, "TenantID", &a.TenantID) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) @@ -331,28 +384,44 @@ func (a *AzureServicePrincipalProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type BasicResourceProperties. -func (b BasicResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "provisioningState", b.ProvisioningState) +// MarshalJSON implements the json.Marshaller interface for type ComponentsKhmx01SchemasGenericresourceAllof0. +func (c ComponentsKhmx01SchemasGenericresourceAllof0) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type BasicResourceProperties. -func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentsKhmx01SchemasGenericresourceAllof0. +func (c *ComponentsKhmx01SchemasGenericresourceAllof0) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &b.ProvisioningState) - delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil @@ -360,7 +429,7 @@ func (b *BasicResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CredentialStorageProperties. func (c CredentialStorageProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["kind"] = c.Kind return json.Marshal(objectMap) } @@ -376,7 +445,7 @@ func (c *CredentialStorageProperties) UnmarshalJSON(data []byte) error { switch key { case "kind": err = unpopulate(val, "Kind", &c.Kind) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -387,7 +456,7 @@ func (c *CredentialStorageProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -404,10 +473,10 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { switch key { case "info": err = unpopulate(val, "Info", &e.Info) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -418,7 +487,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -438,19 +507,19 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { switch key { case "additionalInfo": err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) - delete(rawMsg, key) + delete(rawMsg, key) case "code": err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) + delete(rawMsg, key) case "details": err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) + delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) + delete(rawMsg, key) case "target": err = unpopulate(val, "Target", &e.Target) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -461,7 +530,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -477,7 +546,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { switch key { case "error": err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -486,10 +555,84 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type GenericResource. +func (g GenericResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResource. +func (g *GenericResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenericResourceListResult. +func (g GenericResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenericResourceListResult. +func (g *GenericResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type InternalCredentialStorageProperties. func (i InternalCredentialStorageProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = "Internal" + objectMap := make(map[string]any) + objectMap["kind"] = CredentialStorageKindInternal populate(objectMap, "secretName", i.SecretName) return json.Marshal(objectMap) } @@ -505,10 +648,10 @@ func (i *InternalCredentialStorageProperties) UnmarshalJSON(data []byte) error { switch key { case "kind": err = unpopulate(val, "Kind", &i.Kind) - delete(rawMsg, key) + delete(rawMsg, key) case "secretName": err = unpopulate(val, "SecretName", &i.SecretName) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) @@ -519,7 +662,7 @@ func (i *InternalCredentialStorageProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PlaneResource. func (p PlaneResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "location", p.Location) populate(objectMap, "name", p.Name) @@ -541,25 +684,25 @@ func (p *PlaneResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &p.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &p.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &p.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &p.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &p.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &p.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &p.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -570,7 +713,7 @@ func (p *PlaneResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PlaneResourceListResult. func (p PlaneResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", p.NextLink) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) @@ -587,10 +730,10 @@ func (p *PlaneResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &p.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &p.Value) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -601,7 +744,7 @@ func (p *PlaneResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PlaneResourceProperties. func (p PlaneResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "kind", p.Kind) populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "resourceProviders", p.ResourceProviders) @@ -620,16 +763,82 @@ func (p *PlaneResourceProperties) UnmarshalJSON(data []byte) error { switch key { case "kind": err = unpopulate(val, "Kind", &p.Kind) - delete(rawMsg, key) + delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) - delete(rawMsg, key) + delete(rawMsg, key) case "resourceProviders": err = unpopulate(val, "ResourceProviders", &p.ResourceProviders) - delete(rawMsg, key) + delete(rawMsg, key) case "url": err = unpopulate(val, "URL", &p.URL) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlaneResourceTagsUpdate. +func (p PlaneResourceTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlaneResourceTagsUpdate. +func (p *PlaneResourceTagsUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -640,7 +849,7 @@ func (p *PlaneResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "systemData", r.SystemData) @@ -659,16 +868,43 @@ func (r *Resource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceGroupProperties. +func (r ResourceGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", r.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceGroupProperties. +func (r *ResourceGroupProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -679,7 +915,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceGroupResource. func (r ResourceGroupResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "location", r.Location) populate(objectMap, "name", r.Name) @@ -701,25 +937,25 @@ func (r *ResourceGroupResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &r.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &r.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &r.Properties) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &r.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &r.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -730,7 +966,7 @@ func (r *ResourceGroupResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceGroupResourceListResult. func (r ResourceGroupResourceListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -747,10 +983,37 @@ func (r *ResourceGroupResourceListResult) UnmarshalJSON(data []byte) error { switch key { case "nextLink": err = unpopulate(val, "NextLink", &r.NextLink) - delete(rawMsg, key) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &r.Value) - delete(rawMsg, key) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceGroupResourceTagsUpdate. +func (r ResourceGroupResourceTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceGroupResourceTagsUpdate. +func (r *ResourceGroupResourceTagsUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -761,7 +1024,7 @@ func (r *ResourceGroupResourceListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -782,22 +1045,22 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { switch key { case "createdAt": err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "createdByType": err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedAt": err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) + delete(rawMsg, key) case "lastModifiedByType": err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -808,7 +1071,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -829,22 +1092,22 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { switch key { case "id": err = unpopulate(val, "ID", &t.ID) - delete(rawMsg, key) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &t.Location) - delete(rawMsg, key) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) - delete(rawMsg, key) + delete(rawMsg, key) case "systemData": err = unpopulate(val, "SystemData", &t.SystemData) - delete(rawMsg, key) + delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &t.Tags) - delete(rawMsg, key) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &t.Type) - delete(rawMsg, key) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) @@ -853,7 +1116,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -863,7 +1126,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_options.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_options.go new file mode 100644 index 0000000000..92d7c3ec05 --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_options.go @@ -0,0 +1,125 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220901privatepreview + +// AwsCredentialsClientCreateOrUpdateOptions contains the optional parameters for the AwsCredentialsClient.CreateOrUpdate +// method. +type AwsCredentialsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AwsCredentialsClientDeleteOptions contains the optional parameters for the AwsCredentialsClient.Delete method. +type AwsCredentialsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// AwsCredentialsClientGetOptions contains the optional parameters for the AwsCredentialsClient.Get method. +type AwsCredentialsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AwsCredentialsClientListOptions contains the optional parameters for the AwsCredentialsClient.NewListPager method. +type AwsCredentialsClientListOptions struct { + // placeholder for future optional parameters +} + +// AwsCredentialsClientUpdateOptions contains the optional parameters for the AwsCredentialsClient.Update method. +type AwsCredentialsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// AzureCredentialsClientCreateOrUpdateOptions contains the optional parameters for the AzureCredentialsClient.CreateOrUpdate +// method. +type AzureCredentialsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AzureCredentialsClientDeleteOptions contains the optional parameters for the AzureCredentialsClient.Delete method. +type AzureCredentialsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// AzureCredentialsClientGetOptions contains the optional parameters for the AzureCredentialsClient.Get method. +type AzureCredentialsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AzureCredentialsClientListOptions contains the optional parameters for the AzureCredentialsClient.NewListPager method. +type AzureCredentialsClientListOptions struct { + // placeholder for future optional parameters +} + +// AzureCredentialsClientUpdateOptions contains the optional parameters for the AzureCredentialsClient.Update method. +type AzureCredentialsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// PlanesClientBeginCreateOrUpdateOptions contains the optional parameters for the PlanesClient.BeginCreateOrUpdate method. +type PlanesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PlanesClientBeginDeleteOptions contains the optional parameters for the PlanesClient.BeginDelete method. +type PlanesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PlanesClientBeginUpdateOptions contains the optional parameters for the PlanesClient.BeginUpdate method. +type PlanesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PlanesClientGetOptions contains the optional parameters for the PlanesClient.Get method. +type PlanesClientGetOptions struct { + // placeholder for future optional parameters +} + +// PlanesClientListByTypeOptions contains the optional parameters for the PlanesClient.NewListByTypePager method. +type PlanesClientListByTypeOptions struct { + // placeholder for future optional parameters +} + +// PlanesClientListPlanesOptions contains the optional parameters for the PlanesClient.NewListPlanesPager method. +type PlanesClientListPlanesOptions struct { + // placeholder for future optional parameters +} + +// ResourceGroupsClientCreateOrUpdateOptions contains the optional parameters for the ResourceGroupsClient.CreateOrUpdate +// method. +type ResourceGroupsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ResourceGroupsClientDeleteOptions contains the optional parameters for the ResourceGroupsClient.Delete method. +type ResourceGroupsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ResourceGroupsClientGetOptions contains the optional parameters for the ResourceGroupsClient.Get method. +type ResourceGroupsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ResourceGroupsClientListOptions contains the optional parameters for the ResourceGroupsClient.NewListPager method. +type ResourceGroupsClientListOptions struct { + // placeholder for future optional parameters +} + +// ResourceGroupsClientUpdateOptions contains the optional parameters for the ResourceGroupsClient.Update method. +type ResourceGroupsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// ResourcesClientListOptions contains the optional parameters for the ResourcesClient.NewListPager method. +type ResourcesClientListOptions struct { + // placeholder for future optional parameters +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_planes_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_planes_client.go index 4c91db0eb3..24588b12a3 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_planes_client.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_planes_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview @@ -13,76 +12,87 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) // PlanesClient contains the methods for the Planes group. // Don't use this type directly, use NewPlanesClient() instead. type PlanesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewPlanesClient creates a new instance of PlanesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPlanesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PlanesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PlanesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PlanesClient{ - host: ep, -pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or updates a PlaneResource +// BeginCreateOrUpdate - Create or update a plane // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// planeName - The name of the plane -// resource - Resource create parameters. -// options - PlanesClientCreateOrUpdateOptions contains the optional parameters for the PlanesClient.CreateOrUpdate method. -func (client *PlanesClient) CreateOrUpdate(ctx context.Context, planeType string, planeName string, resource PlaneResource, options *PlanesClientCreateOrUpdateOptions) (PlanesClientCreateOrUpdateResponse, error) { +// - planeType - The plane type. +// - planeName - The name of the plane +// - resource - Resource create parameters. +// - options - PlanesClientBeginCreateOrUpdateOptions contains the optional parameters for the PlanesClient.BeginCreateOrUpdate +// method. +func (client *PlanesClient) BeginCreateOrUpdate(ctx context.Context, planeType string, planeName string, resource PlaneResource, options *PlanesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PlanesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, planeType, planeName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PlanesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PlanesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Create or update a plane +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +func (client *PlanesClient) createOrUpdate(ctx context.Context, planeType string, planeName string, resource PlaneResource, options *PlanesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, planeType, planeName, resource, options) if err != nil { - return PlanesClientCreateOrUpdateResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return PlanesClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return PlanesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.createOrUpdateHandleResponse(resp) + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *PlanesClient) createOrUpdateCreateRequest(ctx context.Context, planeType string, planeName string, resource PlaneResource, options *PlanesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *PlanesClient) createOrUpdateCreateRequest(ctx context.Context, planeType string, planeName string, resource PlaneResource, options *PlanesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/planes/{planeType}/{planeName}" if planeType == "" { return nil, errors.New("parameter planeType cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -90,56 +100,64 @@ func (client *PlanesClient) createOrUpdateCreateRequest(ctx context.Context, pla reqQP.Set("api-version", "2022-09-01-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *PlanesClient) createOrUpdateHandleResponse(resp *http.Response) (PlanesClientCreateOrUpdateResponse, error) { - result := PlanesClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) +// BeginDelete - Delete a plane +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeType - The plane type. +// - planeName - The name of the plane +// - options - PlanesClientBeginDeleteOptions contains the optional parameters for the PlanesClient.BeginDelete method. +func (client *PlanesClient) BeginDelete(ctx context.Context, planeType string, planeName string, options *PlanesClientBeginDeleteOptions) (*runtime.Poller[PlanesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, planeType, planeName, options) if err != nil { - return PlanesClientCreateOrUpdateResponse{}, err + return nil, err } - result.RetryAfter = &retryAfter + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PlanesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PlanesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } - if err := runtime.UnmarshalAsJSON(resp, &result.PlaneResource); err != nil { - return PlanesClientCreateOrUpdateResponse{}, err - } - return result, nil } -// Delete - Deletes an existing PlaneResource +// Delete - Delete a plane // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// planeName - The name of the plane -// options - PlanesClientDeleteOptions contains the optional parameters for the PlanesClient.Delete method. -func (client *PlanesClient) Delete(ctx context.Context, planeType string, planeName string, options *PlanesClientDeleteOptions) (PlanesClientDeleteResponse, error) { +func (client *PlanesClient) deleteOperation(ctx context.Context, planeType string, planeName string, options *PlanesClientBeginDeleteOptions) (*http.Response, error) { + var err error req, err := client.deleteCreateRequest(ctx, planeType, planeName, options) if err != nil { - return PlanesClientDeleteResponse{}, err + return nil, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return PlanesClientDeleteResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return PlanesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return client.deleteHandleResponse(resp) + return httpResp, nil } // deleteCreateRequest creates the Delete request. -func (client *PlanesClient) deleteCreateRequest(ctx context.Context, planeType string, planeName string, options *PlanesClientDeleteOptions) (*policy.Request, error) { +func (client *PlanesClient) deleteCreateRequest(ctx context.Context, planeType string, planeName string, options *PlanesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/planes/{planeType}/{planeName}" if planeType == "" { return nil, errors.New("parameter planeType cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -150,39 +168,29 @@ func (client *PlanesClient) deleteCreateRequest(ctx context.Context, planeType s return req, nil } -// deleteHandleResponse handles the Delete response. -func (client *PlanesClient) deleteHandleResponse(resp *http.Response) (PlanesClientDeleteResponse, error) { - result := PlanesClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return PlanesClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a PlaneResource +// Get - Get a plane by name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// planeName - The name of the plane -// options - PlanesClientGetOptions contains the optional parameters for the PlanesClient.Get method. +// - planeType - The plane type. +// - planeName - The name of the plane +// - options - PlanesClientGetOptions contains the optional parameters for the PlanesClient.Get method. func (client *PlanesClient) Get(ctx context.Context, planeType string, planeName string, options *PlanesClientGetOptions) (PlanesClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, planeType, planeName, options) if err != nil { return PlanesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PlanesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PlanesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PlanesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -193,7 +201,7 @@ func (client *PlanesClient) getCreateRequest(ctx context.Context, planeType stri } urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -213,41 +221,102 @@ func (client *PlanesClient) getHandleResponse(resp *http.Response) (PlanesClient return result, nil } -// NewListByRootScopePager - Lists information about all PlaneResources in the given plane +// NewListByTypePager - List planes by type +// // Generated from API version 2022-09-01-privatepreview -// options - PlanesClientListByRootScopeOptions contains the optional parameters for the PlanesClient.ListByRootScope method. -func (client *PlanesClient) NewListByRootScopePager(options *PlanesClientListByRootScopeOptions) (*runtime.Pager[PlanesClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[PlanesClientListByRootScopeResponse]{ - More: func(page PlanesClientListByRootScopeResponse) bool { +// - planeType - The plane type. +// - options - PlanesClientListByTypeOptions contains the optional parameters for the PlanesClient.NewListByTypePager method. +func (client *PlanesClient) NewListByTypePager(planeType string, options *PlanesClientListByTypeOptions) (*runtime.Pager[PlanesClientListByTypeResponse]) { + return runtime.NewPager(runtime.PagingHandler[PlanesClientListByTypeResponse]{ + More: func(page PlanesClientListByTypeResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *PlanesClientListByRootScopeResponse) (PlanesClientListByRootScopeResponse, error) { + Fetcher: func(ctx context.Context, page *PlanesClientListByTypeResponse) (PlanesClientListByTypeResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, options) + req, err = client.listByTypeCreateRequest(ctx, planeType, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return PlanesClientListByRootScopeResponse{}, err + return PlanesClientListByTypeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return PlanesClientListByRootScopeResponse{}, err + return PlanesClientListByTypeResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return PlanesClientListByRootScopeResponse{}, runtime.NewResponseError(resp) + return PlanesClientListByTypeResponse{}, runtime.NewResponseError(resp) } - return client.listByRootScopeHandleResponse(resp) + return client.listByTypeHandleResponse(resp) }, }) } -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *PlanesClient) listByRootScopeCreateRequest(ctx context.Context, options *PlanesClientListByRootScopeOptions) (*policy.Request, error) { +// listByTypeCreateRequest creates the ListByType request. +func (client *PlanesClient) listByTypeCreateRequest(ctx context.Context, planeType string, options *PlanesClientListByTypeOptions) (*policy.Request, error) { + urlPath := "/planes/{planeType}" + if planeType == "" { + return nil, errors.New("parameter planeType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByTypeHandleResponse handles the ListByType response. +func (client *PlanesClient) listByTypeHandleResponse(resp *http.Response) (PlanesClientListByTypeResponse, error) { + result := PlanesClientListByTypeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PlaneResourceListResult); err != nil { + return PlanesClientListByTypeResponse{}, err + } + return result, nil +} + +// NewListPlanesPager - List all planes +// +// Generated from API version 2022-09-01-privatepreview +// - options - PlanesClientListPlanesOptions contains the optional parameters for the PlanesClient.NewListPlanesPager method. +func (client *PlanesClient) NewListPlanesPager(options *PlanesClientListPlanesOptions) (*runtime.Pager[PlanesClientListPlanesResponse]) { + return runtime.NewPager(runtime.PagingHandler[PlanesClientListPlanesResponse]{ + More: func(page PlanesClientListPlanesResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PlanesClientListPlanesResponse) (PlanesClientListPlanesResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listPlanesCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return PlanesClientListPlanesResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PlanesClientListPlanesResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PlanesClientListPlanesResponse{}, runtime.NewResponseError(resp) + } + return client.listPlanesHandleResponse(resp) + }, + }) +} + +// listPlanesCreateRequest creates the ListPlanes request. +func (client *PlanesClient) listPlanesCreateRequest(ctx context.Context, options *PlanesClientListPlanesOptions) (*policy.Request, error) { urlPath := "/planes" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,12 +327,78 @@ func (client *PlanesClient) listByRootScopeCreateRequest(ctx context.Context, op return req, nil } -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *PlanesClient) listByRootScopeHandleResponse(resp *http.Response) (PlanesClientListByRootScopeResponse, error) { - result := PlanesClientListByRootScopeResponse{} +// listPlanesHandleResponse handles the ListPlanes response. +func (client *PlanesClient) listPlanesHandleResponse(resp *http.Response) (PlanesClientListPlanesResponse, error) { + result := PlanesClientListPlanesResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.PlaneResourceListResult); err != nil { - return PlanesClientListByRootScopeResponse{}, err + return PlanesClientListPlanesResponse{}, err } return result, nil } +// BeginUpdate - Update a plane +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeType - The plane type. +// - planeName - The name of the plane +// - properties - The resource properties to be updated. +// - options - PlanesClientBeginUpdateOptions contains the optional parameters for the PlanesClient.BeginUpdate method. +func (client *PlanesClient) BeginUpdate(ctx context.Context, planeType string, planeName string, properties PlaneResourceTagsUpdate, options *PlanesClientBeginUpdateOptions) (*runtime.Poller[PlanesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, planeType, planeName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PlanesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PlanesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Update a plane +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +func (client *PlanesClient) update(ctx context.Context, planeType string, planeName string, properties PlaneResourceTagsUpdate, options *PlanesClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, planeType, planeName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *PlanesClient) updateCreateRequest(ctx context.Context, planeType string, planeName string, properties PlaneResourceTagsUpdate, options *PlanesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/planes/{planeType}/{planeName}" + if planeType == "" { + return nil, errors.New("parameter planeType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_planetypes_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_planetypes_client.go deleted file mode 100644 index e02755f5ed..0000000000 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_planetypes_client.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package v20220901privatepreview - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// PlaneTypesClient contains the methods for the PlaneTypes group. -// Don't use this type directly, use NewPlaneTypesClient() instead. -type PlaneTypesClient struct { - host string - pl runtime.Pipeline -} - -// NewPlaneTypesClient creates a new instance of PlaneTypesClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewPlaneTypesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PlaneTypesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &PlaneTypesClient{ - host: ep, -pl: pl, - } - return client, nil -} - -// Get - Retrieves information about a PlaneResource -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// options - PlaneTypesClientGetOptions contains the optional parameters for the PlaneTypesClient.Get method. -func (client *PlaneTypesClient) Get(ctx context.Context, planeType string, options *PlaneTypesClientGetOptions) (PlaneTypesClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, planeType, options) - if err != nil { - return PlaneTypesClientGetResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return PlaneTypesClientGetResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PlaneTypesClientGetResponse{}, runtime.NewResponseError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *PlaneTypesClient) getCreateRequest(ctx context.Context, planeType string, options *PlaneTypesClientGetOptions) (*policy.Request, error) { - urlPath := "/planes/{planeType}" - if planeType == "" { - return nil, errors.New("parameter planeType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-09-01-privatepreview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *PlaneTypesClient) getHandleResponse(resp *http.Response) (PlaneTypesClientGetResponse, error) { - result := PlaneTypesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.PlaneResource); err != nil { - return PlaneTypesClientGetResponse{}, err - } - return result, nil -} - diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_polymorphic_helpers.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_polymorphic_helpers.go index 31f7f6d40b..60dcc7c4fc 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_polymorphic_helpers.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_polymorphic_helpers.go @@ -2,65 +2,73 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview import "encoding/json" -func unmarshalAWSCredentialPropertiesClassification(rawMsg json.RawMessage) (AWSCredentialPropertiesClassification, error) { +func unmarshalAwsCredentialPropertiesClassification(rawMsg json.RawMessage) (AwsCredentialPropertiesClassification, error) { if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } - var b AWSCredentialPropertiesClassification + var b AwsCredentialPropertiesClassification switch m["kind"] { - case "AccessKey": - b = &AWSAccessKeyCredentialProperties{} + case string(AWSCredentialKindAccessKey): + b = &AwsAccessKeyCredentialProperties{} default: - b = &AWSCredentialProperties{} + b = &AwsCredentialProperties{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalAzureCredentialPropertiesClassification(rawMsg json.RawMessage) (AzureCredentialPropertiesClassification, error) { if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } var b AzureCredentialPropertiesClassification switch m["kind"] { - case "ServicePrincipal": + case string(AzureCredentialKindServicePrincipal): b = &AzureServicePrincipalProperties{} default: b = &AzureCredentialProperties{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalCredentialStoragePropertiesClassification(rawMsg json.RawMessage) (CredentialStoragePropertiesClassification, error) { if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } var b CredentialStoragePropertiesClassification switch m["kind"] { - case "Internal": + case string(CredentialStorageKindInternal): b = &InternalCredentialStorageProperties{} default: b = &CredentialStorageProperties{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_resourcegroups_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_resourcegroups_client.go index eea99477d9..f4bb8885b4 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_resourcegroups_client.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_resourcegroups_client.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview @@ -13,67 +12,59 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" - "strconv" "strings" ) // ResourceGroupsClient contains the methods for the ResourceGroups group. // Don't use this type directly, use NewResourceGroupsClient() instead. type ResourceGroupsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewResourceGroupsClient creates a new instance of ResourceGroupsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewResourceGroupsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceGroupsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ResourceGroupsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourceGroupsClient{ - host: ep, -pl: pl, + internal: cl, } return client, nil } -// CreateOrUpdate - Creates or updates a ResourceGroupResource +// CreateOrUpdate - Create or update a resource group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// planeName - The name of the plane -// resourceGroupName - UCP resourcegroup name -// resource - Resource create parameters. -// options - ResourceGroupsClientCreateOrUpdateOptions contains the optional parameters for the ResourceGroupsClient.CreateOrUpdate -// method. +// - planeType - The plane type. +// - planeName - The name of the plane +// - resourceGroupName - The name of resource group +// - resource - Resource create parameters. +// - options - ResourceGroupsClientCreateOrUpdateOptions contains the optional parameters for the ResourceGroupsClient.CreateOrUpdate +// method. func (client *ResourceGroupsClient) CreateOrUpdate(ctx context.Context, planeType string, planeName string, resourceGroupName string, resource ResourceGroupResource, options *ResourceGroupsClientCreateOrUpdateOptions) (ResourceGroupsClientCreateOrUpdateResponse, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, planeType, planeName, resourceGroupName, resource, options) if err != nil { return ResourceGroupsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGroupsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ResourceGroupsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ResourceGroupsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -88,7 +79,7 @@ func (client *ResourceGroupsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -96,46 +87,44 @@ func (client *ResourceGroupsClient) createOrUpdateCreateRequest(ctx context.Cont reqQP.Set("api-version", "2022-09-01-privatepreview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err +} + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. func (client *ResourceGroupsClient) createOrUpdateHandleResponse(resp *http.Response) (ResourceGroupsClientCreateOrUpdateResponse, error) { result := ResourceGroupsClientCreateOrUpdateResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return ResourceGroupsClientCreateOrUpdateResponse{}, err - } - result.RetryAfter = &retryAfter - } if err := runtime.UnmarshalAsJSON(resp, &result.ResourceGroupResource); err != nil { return ResourceGroupsClientCreateOrUpdateResponse{}, err } return result, nil } -// Delete - Deletes an existing ResourceGroupResource +// Delete - Delete a resource group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// planeName - The name of the plane -// resourceGroupName - UCP resourcegroup name -// options - ResourceGroupsClientDeleteOptions contains the optional parameters for the ResourceGroupsClient.Delete method. +// - planeType - The plane type. +// - planeName - The name of the plane +// - resourceGroupName - The name of resource group +// - options - ResourceGroupsClientDeleteOptions contains the optional parameters for the ResourceGroupsClient.Delete method. func (client *ResourceGroupsClient) Delete(ctx context.Context, planeType string, planeName string, resourceGroupName string, options *ResourceGroupsClientDeleteOptions) (ResourceGroupsClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, planeType, planeName, resourceGroupName, options) if err != nil { return ResourceGroupsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGroupsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return ResourceGroupsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ResourceGroupsClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + return ResourceGroupsClientDeleteResponse{}, nil } // deleteCreateRequest creates the Delete request. @@ -150,7 +139,7 @@ func (client *ResourceGroupsClient) deleteCreateRequest(ctx context.Context, pla return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -161,40 +150,30 @@ func (client *ResourceGroupsClient) deleteCreateRequest(ctx context.Context, pla return req, nil } -// deleteHandleResponse handles the Delete response. -func (client *ResourceGroupsClient) deleteHandleResponse(resp *http.Response) (ResourceGroupsClientDeleteResponse, error) { - result := ResourceGroupsClientDeleteResponse{} - if val := resp.Header.Get("Retry-After"); val != "" { - retryAfter32, err := strconv.ParseInt(val, 10, 32) - retryAfter := int32(retryAfter32) - if err != nil { - return ResourceGroupsClientDeleteResponse{}, err - } - result.RetryAfter = &retryAfter - } - return result, nil -} - -// Get - Retrieves information about a ResourceGroupResource +// Get - Get a resource group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// planeName - The name of the plane -// resourceGroupName - UCP resourcegroup name -// options - ResourceGroupsClientGetOptions contains the optional parameters for the ResourceGroupsClient.Get method. +// - planeType - The plane type. +// - planeName - The name of the plane +// - resourceGroupName - The name of resource group +// - options - ResourceGroupsClientGetOptions contains the optional parameters for the ResourceGroupsClient.Get method. func (client *ResourceGroupsClient) Get(ctx context.Context, planeType string, planeName string, resourceGroupName string, options *ResourceGroupsClientGetOptions) (ResourceGroupsClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, planeType, planeName, resourceGroupName, options) if err != nil { return ResourceGroupsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGroupsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGroupsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGroupsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -209,7 +188,7 @@ func (client *ResourceGroupsClient) getCreateRequest(ctx context.Context, planeT return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -229,49 +208,49 @@ func (client *ResourceGroupsClient) getHandleResponse(resp *http.Response) (Reso return result, nil } -// NewListByRootScopePager - Lists information about all ResourceGroupResource +// NewListPager - List resource groups +// // Generated from API version 2022-09-01-privatepreview -// planeType - The plane type. -// planeName - The name of the plane -// options - ResourceGroupsClientListByRootScopeOptions contains the optional parameters for the ResourceGroupsClient.ListByRootScope -// method. -func (client *ResourceGroupsClient) NewListByRootScopePager(planeType string, planeName string, options *ResourceGroupsClientListByRootScopeOptions) (*runtime.Pager[ResourceGroupsClientListByRootScopeResponse]) { - return runtime.NewPager(runtime.PagingHandler[ResourceGroupsClientListByRootScopeResponse]{ - More: func(page ResourceGroupsClientListByRootScopeResponse) bool { +// - planeType - The plane type. +// - planeName - The name of the plane +// - options - ResourceGroupsClientListOptions contains the optional parameters for the ResourceGroupsClient.NewListPager method. +func (client *ResourceGroupsClient) NewListPager(planeType string, planeName string, options *ResourceGroupsClientListOptions) (*runtime.Pager[ResourceGroupsClientListResponse]) { + return runtime.NewPager(runtime.PagingHandler[ResourceGroupsClientListResponse]{ + More: func(page ResourceGroupsClientListResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *ResourceGroupsClientListByRootScopeResponse) (ResourceGroupsClientListByRootScopeResponse, error) { + Fetcher: func(ctx context.Context, page *ResourceGroupsClientListResponse) (ResourceGroupsClientListResponse, error) { var req *policy.Request var err error if page == nil { - req, err = client.listByRootScopeCreateRequest(ctx, planeType, planeName, options) + req, err = client.listCreateRequest(ctx, planeType, planeName, options) } else { req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) } if err != nil { - return ResourceGroupsClientListByRootScopeResponse{}, err + return ResourceGroupsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { - return ResourceGroupsClientListByRootScopeResponse{}, err + return ResourceGroupsClientListResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGroupsClientListByRootScopeResponse{}, runtime.NewResponseError(resp) + return ResourceGroupsClientListResponse{}, runtime.NewResponseError(resp) } - return client.listByRootScopeHandleResponse(resp) + return client.listHandleResponse(resp) }, }) } -// listByRootScopeCreateRequest creates the ListByRootScope request. -func (client *ResourceGroupsClient) listByRootScopeCreateRequest(ctx context.Context, planeType string, planeName string, options *ResourceGroupsClientListByRootScopeOptions) (*policy.Request, error) { +// listCreateRequest creates the List request. +func (client *ResourceGroupsClient) listCreateRequest(ctx context.Context, planeType string, planeName string, options *ResourceGroupsClientListOptions) (*policy.Request, error) { urlPath := "/planes/{planeType}/{planeName}/resourcegroups" if planeType == "" { return nil, errors.New("parameter planeType cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -282,11 +261,73 @@ func (client *ResourceGroupsClient) listByRootScopeCreateRequest(ctx context.Con return req, nil } -// listByRootScopeHandleResponse handles the ListByRootScope response. -func (client *ResourceGroupsClient) listByRootScopeHandleResponse(resp *http.Response) (ResourceGroupsClientListByRootScopeResponse, error) { - result := ResourceGroupsClientListByRootScopeResponse{} +// listHandleResponse handles the List response. +func (client *ResourceGroupsClient) listHandleResponse(resp *http.Response) (ResourceGroupsClientListResponse, error) { + result := ResourceGroupsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.ResourceGroupResourceListResult); err != nil { - return ResourceGroupsClientListByRootScopeResponse{}, err + return ResourceGroupsClientListResponse{}, err + } + return result, nil +} + +// Update - Update a resource group +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-01-privatepreview +// - planeType - The plane type. +// - planeName - The name of the plane +// - resourceGroupName - The name of resource group +// - properties - The resource properties to be updated. +// - options - ResourceGroupsClientUpdateOptions contains the optional parameters for the ResourceGroupsClient.Update method. +func (client *ResourceGroupsClient) Update(ctx context.Context, planeType string, planeName string, resourceGroupName string, properties ResourceGroupResourceTagsUpdate, options *ResourceGroupsClientUpdateOptions) (ResourceGroupsClientUpdateResponse, error) { + var err error + req, err := client.updateCreateRequest(ctx, planeType, planeName, resourceGroupName, properties, options) + if err != nil { + return ResourceGroupsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ResourceGroupsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGroupsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *ResourceGroupsClient) updateCreateRequest(ctx context.Context, planeType string, planeName string, resourceGroupName string, properties ResourceGroupResourceTagsUpdate, options *ResourceGroupsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/planes/{planeType}/{planeName}/resourcegroups/{resourceGroupName}" + if planeType == "" { + return nil, errors.New("parameter planeType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err +} + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *ResourceGroupsClient) updateHandleResponse(resp *http.Response) (ResourceGroupsClientUpdateResponse, error) { + result := ResourceGroupsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceGroupResource); err != nil { + return ResourceGroupsClientUpdateResponse{}, err } return result, nil } diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_resources_client.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_resources_client.go new file mode 100644 index 0000000000..2b54a983c2 --- /dev/null +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_resources_client.go @@ -0,0 +1,108 @@ +//go:build go1.18 +// +build go1.18 + +// Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package v20220901privatepreview + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ResourcesClient contains the methods for the Resources group. +// Don't use this type directly, use NewResourcesClient() instead. +type ResourcesClient struct { + internal *arm.Client +} + +// NewResourcesClient creates a new instance of ResourcesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewResourcesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourcesClient, error) { + cl, err := arm.NewClient(moduleName+".ResourcesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ResourcesClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List resources in a resource group +// +// Generated from API version 2022-09-01-privatepreview +// - planeType - The plane type. +// - planeName - The name of the plane +// - resourceGroupName - The name of resource group +// - options - ResourcesClientListOptions contains the optional parameters for the ResourcesClient.NewListPager method. +func (client *ResourcesClient) NewListPager(planeType string, planeName string, resourceGroupName string, options *ResourcesClientListOptions) (*runtime.Pager[ResourcesClientListResponse]) { + return runtime.NewPager(runtime.PagingHandler[ResourcesClientListResponse]{ + More: func(page ResourcesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ResourcesClientListResponse) (ResourcesClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, planeType, planeName, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ResourcesClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ResourcesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ResourcesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ResourcesClient) listCreateRequest(ctx context.Context, planeType string, planeName string, resourceGroupName string, options *ResourcesClientListOptions) (*policy.Request, error) { + urlPath := "/planes/{planeType}/{planeName}/resourcegroups/{resourceGroupName}/resources" + if planeType == "" { + return nil, errors.New("parameter planeType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{planeType}", url.PathEscape(planeType)) + urlPath = strings.ReplaceAll(urlPath, "{planeName}", planeName) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-01-privatepreview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ResourcesClient) listHandleResponse(resp *http.Response) (ResourcesClientListResponse, error) { + result := ResourcesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GenericResourceListResult); err != nil { + return ResourcesClientListResponse{}, err + } + return result, nil +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_response_types.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_response_types.go index 59d4496701..f3990338b0 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_response_types.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_response_types.go @@ -2,106 +2,136 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview -// AwsCredentialClientCreateOrUpdateResponse contains the response from method AwsCredentialClient.CreateOrUpdate. -type AwsCredentialClientCreateOrUpdateResponse struct { - AWSCredentialResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 +// AwsCredentialsClientCreateOrUpdateResponse contains the response from method AwsCredentialsClient.CreateOrUpdate. +type AwsCredentialsClientCreateOrUpdateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + AwsCredentialResource } -// AwsCredentialClientDeleteResponse contains the response from method AwsCredentialClient.Delete. -type AwsCredentialClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 +// AwsCredentialsClientDeleteResponse contains the response from method AwsCredentialsClient.Delete. +type AwsCredentialsClientDeleteResponse struct { + // placeholder for future response values } -// AwsCredentialClientGetResponse contains the response from method AwsCredentialClient.Get. -type AwsCredentialClientGetResponse struct { - AWSCredentialResource +// AwsCredentialsClientGetResponse contains the response from method AwsCredentialsClient.Get. +type AwsCredentialsClientGetResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + AwsCredentialResource } -// AwsCredentialClientListByRootScopeResponse contains the response from method AwsCredentialClient.ListByRootScope. -type AwsCredentialClientListByRootScopeResponse struct { - AWSCredentialResourceListResult +// AwsCredentialsClientListResponse contains the response from method AwsCredentialsClient.NewListPager. +type AwsCredentialsClientListResponse struct { + // The response of a AwsCredentialResource list operation. + AwsCredentialResourceListResult } -// AzureCredentialClientCreateOrUpdateResponse contains the response from method AzureCredentialClient.CreateOrUpdate. -type AzureCredentialClientCreateOrUpdateResponse struct { +// AwsCredentialsClientUpdateResponse contains the response from method AwsCredentialsClient.Update. +type AwsCredentialsClientUpdateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + AwsCredentialResource +} + +// AzureCredentialsClientCreateOrUpdateResponse contains the response from method AzureCredentialsClient.CreateOrUpdate. +type AzureCredentialsClientCreateOrUpdateResponse struct { + // Represents Azure Credential Resource AzureCredentialResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// AzureCredentialClientDeleteResponse contains the response from method AzureCredentialClient.Delete. -type AzureCredentialClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 +// AzureCredentialsClientDeleteResponse contains the response from method AzureCredentialsClient.Delete. +type AzureCredentialsClientDeleteResponse struct { + // placeholder for future response values } -// AzureCredentialClientGetResponse contains the response from method AzureCredentialClient.Get. -type AzureCredentialClientGetResponse struct { +// AzureCredentialsClientGetResponse contains the response from method AzureCredentialsClient.Get. +type AzureCredentialsClientGetResponse struct { + // Represents Azure Credential Resource AzureCredentialResource } -// AzureCredentialClientListByRootScopeResponse contains the response from method AzureCredentialClient.ListByRootScope. -type AzureCredentialClientListByRootScopeResponse struct { +// AzureCredentialsClientListResponse contains the response from method AzureCredentialsClient.NewListPager. +type AzureCredentialsClientListResponse struct { + // The response of a AzureCredentialResource list operation. AzureCredentialResourceListResult } -// PlaneTypesClientGetResponse contains the response from method PlaneTypesClient.Get. -type PlaneTypesClientGetResponse struct { - PlaneResource +// AzureCredentialsClientUpdateResponse contains the response from method AzureCredentialsClient.Update. +type AzureCredentialsClientUpdateResponse struct { + // Represents Azure Credential Resource + AzureCredentialResource } -// PlanesClientCreateOrUpdateResponse contains the response from method PlanesClient.CreateOrUpdate. +// PlanesClientCreateOrUpdateResponse contains the response from method PlanesClient.BeginCreateOrUpdate. type PlanesClientCreateOrUpdateResponse struct { + // The plane resource PlaneResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } -// PlanesClientDeleteResponse contains the response from method PlanesClient.Delete. +// PlanesClientDeleteResponse contains the response from method PlanesClient.BeginDelete. type PlanesClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 + // placeholder for future response values } // PlanesClientGetResponse contains the response from method PlanesClient.Get. type PlanesClientGetResponse struct { + // The plane resource PlaneResource } -// PlanesClientListByRootScopeResponse contains the response from method PlanesClient.ListByRootScope. -type PlanesClientListByRootScopeResponse struct { +// PlanesClientListByTypeResponse contains the response from method PlanesClient.NewListByTypePager. +type PlanesClientListByTypeResponse struct { + // The response of a PlaneResource list operation. PlaneResourceListResult } +// PlanesClientListPlanesResponse contains the response from method PlanesClient.NewListPlanesPager. +type PlanesClientListPlanesResponse struct { + // The response of a PlaneResource list operation. + PlaneResourceListResult +} + +// PlanesClientUpdateResponse contains the response from method PlanesClient.BeginUpdate. +type PlanesClientUpdateResponse struct { + // The plane resource + PlaneResource +} + // ResourceGroupsClientCreateOrUpdateResponse contains the response from method ResourceGroupsClient.CreateOrUpdate. type ResourceGroupsClientCreateOrUpdateResponse struct { + // The resource group resource ResourceGroupResource - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 } // ResourceGroupsClientDeleteResponse contains the response from method ResourceGroupsClient.Delete. type ResourceGroupsClientDeleteResponse struct { - // RetryAfter contains the information returned from the Retry-After header response. - RetryAfter *int32 + // placeholder for future response values } // ResourceGroupsClientGetResponse contains the response from method ResourceGroupsClient.Get. type ResourceGroupsClientGetResponse struct { + // The resource group resource ResourceGroupResource } -// ResourceGroupsClientListByRootScopeResponse contains the response from method ResourceGroupsClient.ListByRootScope. -type ResourceGroupsClientListByRootScopeResponse struct { +// ResourceGroupsClientListResponse contains the response from method ResourceGroupsClient.NewListPager. +type ResourceGroupsClientListResponse struct { + // The response of a ResourceGroupResource list operation. ResourceGroupResourceListResult } +// ResourceGroupsClientUpdateResponse contains the response from method ResourceGroupsClient.Update. +type ResourceGroupsClientUpdateResponse struct { + // The resource group resource + ResourceGroupResource +} + +// ResourcesClientListResponse contains the response from method ResourcesClient.NewListPager. +type ResourcesClientListResponse struct { + // The response of a GenericResource list operation. + GenericResourceListResult +} + diff --git a/pkg/ucp/api/v20220901privatepreview/zz_generated_time_rfc3339.go b/pkg/ucp/api/v20220901privatepreview/zz_generated_time_rfc3339.go index b900804ef3..10046752d2 100644 --- a/pkg/ucp/api/v20220901privatepreview/zz_generated_time_rfc3339.go +++ b/pkg/ucp/api/v20220901privatepreview/zz_generated_time_rfc3339.go @@ -2,9 +2,8 @@ // +build go1.18 // Licensed under the Apache License, Version 2.0 . See LICENSE in the repository root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package v20220901privatepreview @@ -66,7 +65,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/pkg/ucp/aws/cloudcontrolclient.go b/pkg/ucp/aws/cloudcontrolclient.go index 7346626844..8c31132f1a 100644 --- a/pkg/ucp/aws/cloudcontrolclient.go +++ b/pkg/ucp/aws/cloudcontrolclient.go @@ -25,7 +25,7 @@ import ( // Didn't see an interface for aws-sdk-go-v2, v1 had: https://pkg.go.dev/github.com/aws/aws-sdk-go/service/cloudcontrolapi/cloudcontrolapiiface // This is most likely due to using json schemas to define types rather than crafting by hand. There are significantly less functions in v2, so a small mock. // -//go:generate mockgen -destination=./mock_awscloudcontrolclient.go -package=aws -self_package github.com/project-radius/radius/pkg/ucp/aws github.com/project-radius/radius/pkg/ucp/aws AWSCloudControlClient +//go:generate mockgen -destination=./mock_awscloudcontrolclient.go -package=aws -self_package github.com/radius-project/radius/pkg/ucp/aws github.com/radius-project/radius/pkg/ucp/aws AWSCloudControlClient type AWSCloudControlClient interface { GetResource(ctx context.Context, params *cloudcontrol.GetResourceInput, optFns ...func(*cloudcontrol.Options)) (*cloudcontrol.GetResourceOutput, error) ListResources(ctx context.Context, params *cloudcontrol.ListResourcesInput, optFns ...func(*cloudcontrol.Options)) (*cloudcontrol.ListResourcesOutput, error) diff --git a/pkg/ucp/aws/cloudformationclient.go b/pkg/ucp/aws/cloudformationclient.go index 4b9fe723ca..4658297a10 100644 --- a/pkg/ucp/aws/cloudformationclient.go +++ b/pkg/ucp/aws/cloudformationclient.go @@ -22,7 +22,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" ) -//go:generate mockgen -destination=./mock_awscloudformationclient.go -package=aws -self_package github.com/project-radius/radius/pkg/ucp/aws github.com/project-radius/radius/pkg/ucp/aws AWSCloudFormationClient +//go:generate mockgen -destination=./mock_awscloudformationclient.go -package=aws -self_package github.com/radius-project/radius/pkg/ucp/aws github.com/radius-project/radius/pkg/ucp/aws AWSCloudFormationClient type AWSCloudFormationClient interface { DescribeType(ctx context.Context, params *cloudformation.DescribeTypeInput, optFns ...func(*cloudformation.Options)) (*cloudformation.DescribeTypeOutput, error) } diff --git a/pkg/ucp/aws/errorhandler.go b/pkg/ucp/aws/errorhandler.go index 3c0ff83251..130af3d3d7 100644 --- a/pkg/ucp/aws/errorhandler.go +++ b/pkg/ucp/aws/errorhandler.go @@ -22,8 +22,8 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" "github.com/aws/smithy-go" smithyhttp "github.com/aws/smithy-go/transport/http" - armrpc_v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" + armrpc_v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" ) // HandleAWSError takes in an error and returns an ARMResponse and an error. It checks the error type and returns an diff --git a/pkg/ucp/aws/mock_awscloudcontrolclient.go b/pkg/ucp/aws/mock_awscloudcontrolclient.go index b3e9a251e7..d58fecccb0 100644 --- a/pkg/ucp/aws/mock_awscloudcontrolclient.go +++ b/pkg/ucp/aws/mock_awscloudcontrolclient.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/ucp/aws (interfaces: AWSCloudControlClient) +// Source: github.com/radius-project/radius/pkg/ucp/aws (interfaces: AWSCloudControlClient) // Package aws is a generated GoMock package. package aws diff --git a/pkg/ucp/aws/mock_awscloudformationclient.go b/pkg/ucp/aws/mock_awscloudformationclient.go index a6b8e62f49..eaeacf97c1 100644 --- a/pkg/ucp/aws/mock_awscloudformationclient.go +++ b/pkg/ucp/aws/mock_awscloudformationclient.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/ucp/aws (interfaces: AWSCloudFormationClient) +// Source: github.com/radius-project/radius/pkg/ucp/aws (interfaces: AWSCloudFormationClient) // Package aws is a generated GoMock package. package aws diff --git a/pkg/ucp/aws/servicecontext/awsrequestcontext.go b/pkg/ucp/aws/servicecontext/awsrequestcontext.go index e345b8e6db..a250562374 100644 --- a/pkg/ucp/aws/servicecontext/awsrequestcontext.go +++ b/pkg/ucp/aws/servicecontext/awsrequestcontext.go @@ -19,8 +19,8 @@ package servicecontext import ( "context" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + resources_aws "github.com/radius-project/radius/pkg/ucp/resources/aws" ) // AWSRequestContext is the context for AWS request. @@ -36,5 +36,5 @@ func AWSRequestContextFromContext(ctx context.Context) *AWSRequestContext { // ResourceTypeInAWSFormat returns the AWS resource type. func (c *AWSRequestContext) ResourceTypeInAWSFormat() string { - return resources.ToAWSResourceType(c.ResourceID) + return resources_aws.ToAWSResourceType(c.ResourceID) } diff --git a/pkg/ucp/aws/servicecontext/awsrequestcontext_test.go b/pkg/ucp/aws/servicecontext/awsrequestcontext_test.go index f9bb588755..04c2e72300 100644 --- a/pkg/ucp/aws/servicecontext/awsrequestcontext_test.go +++ b/pkg/ucp/aws/servicecontext/awsrequestcontext_test.go @@ -24,7 +24,7 @@ import ( "strings" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/aws/ucpcredentialprovider.go b/pkg/ucp/aws/ucpcredentialprovider.go index a803c44629..c77b8055dc 100644 --- a/pkg/ucp/aws/ucpcredentialprovider.go +++ b/pkg/ucp/aws/ucpcredentialprovider.go @@ -24,8 +24,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" - sdk_cred "github.com/project-radius/radius/pkg/ucp/credentials" - "github.com/project-radius/radius/pkg/ucp/ucplog" + sdk_cred "github.com/radius-project/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ aws.CredentialsProvider = (*UCPCredentialProvider)(nil) diff --git a/pkg/ucp/aws/ucpcredentialprovider_test.go b/pkg/ucp/aws/ucpcredentialprovider_test.go index 412841379b..bb5e9fb8d4 100644 --- a/pkg/ucp/aws/ucpcredentialprovider_test.go +++ b/pkg/ucp/aws/ucpcredentialprovider_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" - sdk_cred "github.com/project-radius/radius/pkg/ucp/credentials" + sdk_cred "github.com/radius-project/radius/pkg/ucp/credentials" ) type mockProvider struct { diff --git a/pkg/ucp/backend/service.go b/pkg/ucp/backend/service.go index 12846f10d1..ad3039e447 100644 --- a/pkg/ucp/backend/service.go +++ b/pkg/ucp/backend/service.go @@ -20,8 +20,8 @@ import ( "context" "fmt" - "github.com/project-radius/radius/pkg/armrpc/asyncoperation/worker" - "github.com/project-radius/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + "github.com/radius-project/radius/pkg/armrpc/hostoptions" ) const ( diff --git a/pkg/ucp/config/ucpoptions.go b/pkg/ucp/config/ucpoptions.go index 33a781bae0..57583033ae 100644 --- a/pkg/ucp/config/ucpoptions.go +++ b/pkg/ucp/config/ucpoptions.go @@ -19,7 +19,7 @@ package config import ( "errors" - "github.com/project-radius/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/sdk" "k8s.io/client-go/rest" ) diff --git a/pkg/ucp/credentials/aws.go b/pkg/ucp/credentials/aws.go index 73d8c42506..fe7411eab0 100644 --- a/pkg/ucp/credentials/aws.go +++ b/pkg/ucp/credentials/aws.go @@ -22,11 +22,11 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/to" - ucpapi "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/to" + ucpapi "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/secret/provider" ) var _ CredentialProvider[AWSCredential] = (*AWSCredentialProvider)(nil) @@ -34,13 +34,13 @@ var _ CredentialProvider[AWSCredential] = (*AWSCredentialProvider)(nil) // AWSCredentialProvider is UCP credential provider for Azure. type AWSCredentialProvider struct { secretProvider *provider.SecretProvider - client *ucpapi.AwsCredentialClient + client *ucpapi.AwsCredentialsClient } // NewAWSCredentialProvider creates a new AWSCredentialProvider struct using the given SecretProvider, UCP connection and // TokenCredential, and returns it or an error if one occurs. func NewAWSCredentialProvider(provider *provider.SecretProvider, ucpConn sdk.Connection, credential azcore.TokenCredential) (*AWSCredentialProvider, error) { - cli, err := ucpapi.NewAwsCredentialClient(credential, sdk.NewClientOptions(ucpConn)) + cli, err := ucpapi.NewAwsCredentialsClient(credential, sdk.NewClientOptions(ucpConn)) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func NewAWSCredentialProvider(provider *provider.SecretProvider, ucpConn sdk.Con // Kubernetes secret store). It returns an AWSCredential struct or an error if the fetch fails. func (p *AWSCredentialProvider) Fetch(ctx context.Context, planeName, name string) (*AWSCredential, error) { // 1. Fetch the secret name of AWS IAM access keys from UCP. - cred, err := p.client.Get(ctx, planeName, name, &ucpapi.AwsCredentialClientGetOptions{}) + cred, err := p.client.Get(ctx, planeName, name, &ucpapi.AwsCredentialsClientGetOptions{}) if err != nil { return nil, err } @@ -64,7 +64,7 @@ func (p *AWSCredentialProvider) Fetch(ctx context.Context, planeName, name strin var storage *ucpapi.InternalCredentialStorageProperties switch p := cred.Properties.(type) { - case *ucpapi.AWSAccessKeyCredentialProperties: + case *ucpapi.AwsAccessKeyCredentialProperties: switch c := p.Storage.(type) { case *ucpapi.InternalCredentialStorageProperties: storage = c diff --git a/pkg/ucp/credentials/azure.go b/pkg/ucp/credentials/azure.go index de9f96be50..cba582b5d7 100644 --- a/pkg/ucp/credentials/azure.go +++ b/pkg/ucp/credentials/azure.go @@ -22,11 +22,11 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/to" - ucpapi "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/to" + ucpapi "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/secret/provider" ) var _ CredentialProvider[AzureCredential] = (*AzureCredentialProvider)(nil) @@ -34,13 +34,13 @@ var _ CredentialProvider[AzureCredential] = (*AzureCredentialProvider)(nil) // AzureCredentialProvider is UCP credential provider for Azure. type AzureCredentialProvider struct { secretProvider *provider.SecretProvider - client *ucpapi.AzureCredentialClient + client *ucpapi.AzureCredentialsClient } // NewAzureCredentialProvider creates a new AzureCredentialProvider by creating a new AzureCredentialClient with the given // credential and connection, and returns an error if one occurs. func NewAzureCredentialProvider(provider *provider.SecretProvider, ucpConn sdk.Connection, credential azcore.TokenCredential) (*AzureCredentialProvider, error) { - cli, err := ucpapi.NewAzureCredentialClient(credential, sdk.NewClientOptions(ucpConn)) + cli, err := ucpapi.NewAzureCredentialsClient(credential, sdk.NewClientOptions(ucpConn)) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func NewAzureCredentialProvider(provider *provider.SecretProvider, ucpConn sdk.C // Kubernetes secret store) and returns an AzureCredential struct. If an error occurs, an error is returned. func (p *AzureCredentialProvider) Fetch(ctx context.Context, planeName, name string) (*AzureCredential, error) { // 1. Fetch the secret name of Azure service principal credentials from UCP. - cred, err := p.client.Get(ctx, planeName, name, &ucpapi.AzureCredentialClientGetOptions{}) + cred, err := p.client.Get(ctx, planeName, name, &ucpapi.AzureCredentialsClientGetOptions{}) if err != nil { return nil, err } diff --git a/pkg/ucp/credentials/types.go b/pkg/ucp/credentials/types.go index 2eb9a29a12..2303bead61 100644 --- a/pkg/ucp/credentials/types.go +++ b/pkg/ucp/credentials/types.go @@ -19,7 +19,7 @@ package credentials import ( "context" - ucp_dm "github.com/project-radius/radius/pkg/ucp/datamodel" + ucp_dm "github.com/radius-project/radius/pkg/ucp/datamodel" ) const ( diff --git a/pkg/ucp/data/etcd.go b/pkg/ucp/data/etcd.go index f752d96463..46f041696e 100644 --- a/pkg/ucp/data/etcd.go +++ b/pkg/ucp/data/etcd.go @@ -25,8 +25,8 @@ import ( "strings" "time" - "github.com/project-radius/radius/pkg/ucp/hosting" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/ucplog" etcdclient "go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/server/v3/embed" ) diff --git a/pkg/ucp/datamodel/awsresource.go b/pkg/ucp/datamodel/awsresource.go index 9c04481e28..f62d90e34b 100644 --- a/pkg/ucp/datamodel/awsresource.go +++ b/pkg/ucp/datamodel/awsresource.go @@ -16,7 +16,7 @@ limitations under the License. package datamodel -import v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" +import v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" // AWSResource represents any AWS Resource. // AWSResource is not a tracked resource, so it does not implement ResourceDataModel. diff --git a/pkg/ucp/datamodel/converter/awscredential_converter.go b/pkg/ucp/datamodel/converter/awscredential_converter.go index b2a36d8de4..ea5eec66cd 100644 --- a/pkg/ucp/datamodel/converter/awscredential_converter.go +++ b/pkg/ucp/datamodel/converter/awscredential_converter.go @@ -19,16 +19,16 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) // AWSCredentialDataModelToVersioned converts version agnostic AWS credential datamodel to versioned model. func AWSCredentialDataModelToVersioned(model *datamodel.AWSCredential, version string) (v1.VersionedModelInterface, error) { switch version { case v20220901privatepreview.Version: - versioned := &v20220901privatepreview.AWSCredentialResource{} + versioned := &v20220901privatepreview.AwsCredentialResource{} if err := versioned.ConvertFrom(model); err != nil { return nil, err } @@ -43,7 +43,7 @@ func AWSCredentialDataModelToVersioned(model *datamodel.AWSCredential, version s func AWSCredentialDataModelFromVersioned(content []byte, version string) (*datamodel.AWSCredential, error) { switch version { case v20220901privatepreview.Version: - vm := &v20220901privatepreview.AWSCredentialResource{} + vm := &v20220901privatepreview.AwsCredentialResource{} if err := json.Unmarshal(content, vm); err != nil { return nil, err } diff --git a/pkg/ucp/datamodel/converter/azurecredential_converter.go b/pkg/ucp/datamodel/converter/azurecredential_converter.go index 3e0231b562..30247171c3 100644 --- a/pkg/ucp/datamodel/converter/azurecredential_converter.go +++ b/pkg/ucp/datamodel/converter/azurecredential_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) // AzureCredentialDataModelToVersioned converts version agnostic Azure credential datamodel to versioned model. diff --git a/pkg/ucp/datamodel/converter/genericresource_converter.go b/pkg/ucp/datamodel/converter/genericresource_converter.go new file mode 100644 index 0000000000..7d2cb4bbc1 --- /dev/null +++ b/pkg/ucp/datamodel/converter/genericresource_converter.go @@ -0,0 +1,47 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package converter + +import ( + "errors" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" +) + +// GenericResourceDataModelToVersioned converts version agnostic datamodel to versioned model. +// It returns an error if the conversion fails. +func GenericResourceDataModelToVersioned(model *datamodel.GenericResource, version string) (v1.VersionedModelInterface, error) { + switch version { + case v20220901privatepreview.Version: + versioned := &v20220901privatepreview.GenericResource{} + if err := versioned.ConvertFrom(model); err != nil { + return nil, err + } + return versioned, nil + + default: + return nil, v1.ErrUnsupportedAPIVersion + } +} + +// GenericResourceDataModelFromVersioned converts versioned model to datamodel. +// It returns an error if the conversion fails. +func GenericResourceDataModelFromVersioned(content []byte, version string) (*datamodel.GenericResource, error) { + return nil, errors.New("the GenericResource type does not support conversion from versioned models") +} diff --git a/pkg/ucp/datamodel/converter/plane_converter.go b/pkg/ucp/datamodel/converter/plane_converter.go index d9c856934b..7af1a042cc 100644 --- a/pkg/ucp/datamodel/converter/plane_converter.go +++ b/pkg/ucp/datamodel/converter/plane_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) // PlaneDataModelToVersioned converts version agnostic plane datamodel to versioned model. diff --git a/pkg/ucp/datamodel/converter/resourcegroup_converter.go b/pkg/ucp/datamodel/converter/resourcegroup_converter.go index 7e4ab22422..66a4782543 100644 --- a/pkg/ucp/datamodel/converter/resourcegroup_converter.go +++ b/pkg/ucp/datamodel/converter/resourcegroup_converter.go @@ -19,9 +19,9 @@ package converter import ( "encoding/json" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) // ResourceGroupDataModelToVersioned converts version agnostic environment datamodel to versioned model. diff --git a/pkg/ucp/datamodel/credential.go b/pkg/ucp/datamodel/credential.go index 8149ad444a..921308f1a3 100644 --- a/pkg/ucp/datamodel/credential.go +++ b/pkg/ucp/datamodel/credential.go @@ -16,7 +16,7 @@ limitations under the License. package datamodel -import v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" +import v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" const ( // InternalStorageKind represents ucp credential storage type for internal credential type diff --git a/pkg/ucp/datamodel/genericresource.go b/pkg/ucp/datamodel/genericresource.go new file mode 100644 index 0000000000..f80d60a3b2 --- /dev/null +++ b/pkg/ucp/datamodel/genericresource.go @@ -0,0 +1,55 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package datamodel + +import v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + +// GenericResource represents a stored "tracked resource" within a UCP resource group. +// +// This type is used to store tracked resources within UCP regardless of the actual +// resource type. You can think of it as a "meta-resource". The top level fields like "ID", +// "Name", and "Type" reflect the GenericResource entry itself. The actual resource data +// is stored in the "Properties" field. +// +// GenericResource are returned through the resource list APIs, but don't support PUT or +// DELETE operations directly. The resource ID, Name, and Type of the GenericResource +// are an implementation detail and are never exposed to users. +type GenericResource struct { + v1.BaseResource + + // Properties stores the properties of the resource being tracked. + Properties GenericResourceProperties `json:"properties"` +} + +// ResourceTypeName gives the type of ucp resource. +func (r *GenericResource) ResourceTypeName() string { + return "System.Resources/resources" +} + +// GenericResourceProperties stores the properties of the resource being tracked. +// +// Right now we only track the basic identifiers. This is enough for UCP to remebmer +// which resources exist, but not to act as a cache. We may want to add more fields +// in the future as we support additional scenarios. +type GenericResourceProperties struct { + // ID is the fully qualified resource ID for the resource. + ID string `json:"id"` + // Name is the resource name. + Name string `json:"name"` + // Type is the resource type. + Type string `json:"type"` +} diff --git a/pkg/ucp/datamodel/plane.go b/pkg/ucp/datamodel/plane.go index 668da5462c..39191e2812 100644 --- a/pkg/ucp/datamodel/plane.go +++ b/pkg/ucp/datamodel/plane.go @@ -19,7 +19,7 @@ package datamodel import ( "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) type PlaneKind string diff --git a/pkg/ucp/datamodel/resource.go b/pkg/ucp/datamodel/resource.go deleted file mode 100644 index edcda5fd67..0000000000 --- a/pkg/ucp/datamodel/resource.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package datamodel - -// Resource represents a resource within a UCP resource group -type Resource struct { - ID string `json:"id"` - Name string `json:"name"` - Type string `json:"type"` -} - -// ResourceList represents a list of resources -type ResourceList struct { - Value []Resource `json:"value" yaml:"value"` -} diff --git a/pkg/ucp/datamodel/resourcegroup.go b/pkg/ucp/datamodel/resourcegroup.go index d6bc906ba7..0272b954a6 100644 --- a/pkg/ucp/datamodel/resourcegroup.go +++ b/pkg/ucp/datamodel/resourcegroup.go @@ -16,7 +16,7 @@ limitations under the License. package datamodel -import v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" +import v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" // ResourceGroup represents UCP ResourceGroup. type ResourceGroup struct { diff --git a/pkg/ucp/dataprovider/factory.go b/pkg/ucp/dataprovider/factory.go index 1043873d6a..a5d9ee45d0 100644 --- a/pkg/ucp/dataprovider/factory.go +++ b/pkg/ucp/dataprovider/factory.go @@ -21,12 +21,12 @@ import ( "errors" "fmt" - "github.com/project-radius/radius/pkg/kubeutil" - store "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/store/apiserverstore" - ucpv1alpha1 "github.com/project-radius/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" - "github.com/project-radius/radius/pkg/ucp/store/cosmosdb" - "github.com/project-radius/radius/pkg/ucp/store/etcdstore" + "github.com/radius-project/radius/pkg/kubeutil" + store "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/store/apiserverstore" + ucpv1alpha1 "github.com/radius-project/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" + "github.com/radius-project/radius/pkg/ucp/store/cosmosdb" + "github.com/radius-project/radius/pkg/ucp/store/etcdstore" "k8s.io/apimachinery/pkg/runtime" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/ucp/dataprovider/mock_datastorage_provider.go b/pkg/ucp/dataprovider/mock_datastorage_provider.go index 6cd44631f7..ec128fa196 100644 --- a/pkg/ucp/dataprovider/mock_datastorage_provider.go +++ b/pkg/ucp/dataprovider/mock_datastorage_provider.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/ucp/dataprovider (interfaces: DataStorageProvider) +// Source: github.com/radius-project/radius/pkg/ucp/dataprovider (interfaces: DataStorageProvider) // Package dataprovider is a generated GoMock package. package dataprovider @@ -9,7 +9,7 @@ import ( reflect "reflect" gomock "github.com/golang/mock/gomock" - store "github.com/project-radius/radius/pkg/ucp/store" + store "github.com/radius-project/radius/pkg/ucp/store" ) // MockDataStorageProvider is a mock of DataStorageProvider interface. diff --git a/pkg/ucp/dataprovider/options.go b/pkg/ucp/dataprovider/options.go index eac87c0c0b..7494d18cb4 100644 --- a/pkg/ucp/dataprovider/options.go +++ b/pkg/ucp/dataprovider/options.go @@ -17,7 +17,7 @@ limitations under the License. package dataprovider import ( - "github.com/project-radius/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/hosting" etcdclient "go.etcd.io/etcd/client/v3" ) diff --git a/pkg/ucp/dataprovider/storageprovider.go b/pkg/ucp/dataprovider/storageprovider.go index cce9cff948..ce90641bd5 100644 --- a/pkg/ucp/dataprovider/storageprovider.go +++ b/pkg/ucp/dataprovider/storageprovider.go @@ -21,8 +21,8 @@ import ( "errors" "sync" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/util" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/util" ) var ( diff --git a/pkg/ucp/dataprovider/types.go b/pkg/ucp/dataprovider/types.go index f2b002db46..54e1b2619b 100644 --- a/pkg/ucp/dataprovider/types.go +++ b/pkg/ucp/dataprovider/types.go @@ -19,7 +19,7 @@ package dataprovider import ( "context" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/store" ) // StorageProviderType represents types of storage provider. @@ -36,7 +36,7 @@ const ( TypeETCD StorageProviderType = "etcd" ) -//go:generate mockgen -destination=./mock_datastorage_provider.go -package=dataprovider -self_package github.com/project-radius/radius/pkg/ucp/dataprovider github.com/project-radius/radius/pkg/ucp/dataprovider DataStorageProvider +//go:generate mockgen -destination=./mock_datastorage_provider.go -package=dataprovider -self_package github.com/radius-project/radius/pkg/ucp/dataprovider github.com/radius-project/radius/pkg/ucp/dataprovider DataStorageProvider // DataStorageProvider is an interfae to provide storage client. type DataStorageProvider interface { diff --git a/pkg/ucp/frontend/api/routes.go b/pkg/ucp/frontend/api/routes.go index 1cf395a3eb..7a2ad92ae0 100644 --- a/pkg/ucp/frontend/api/routes.go +++ b/pkg/ucp/frontend/api/routes.go @@ -23,17 +23,17 @@ import ( "github.com/go-chi/chi/v5" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - kubernetes_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/kubernetes" - planes_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/planes" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "github.com/project-radius/radius/pkg/validator" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + kubernetes_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/kubernetes" + planes_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/planes" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/validator" ) const ( diff --git a/pkg/ucp/frontend/api/routes_test.go b/pkg/ucp/frontend/api/routes_test.go index 53ddf399f3..8728540e2e 100644 --- a/pkg/ucp/frontend/api/routes_test.go +++ b/pkg/ucp/frontend/api/routes_test.go @@ -23,10 +23,10 @@ import ( "github.com/go-chi/chi/v5" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" ) func Test_Routes(t *testing.T) { diff --git a/pkg/ucp/frontend/api/server.go b/pkg/ucp/frontend/api/server.go index 00c0592c0e..78f88b04a6 100644 --- a/pkg/ucp/frontend/api/server.go +++ b/pkg/ucp/frontend/api/server.go @@ -24,28 +24,28 @@ import ( "net" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/servicecontext" - "github.com/project-radius/radius/pkg/middleware" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - aws_frontend "github.com/project-radius/radius/pkg/ucp/frontend/aws" - azure_frontend "github.com/project-radius/radius/pkg/ucp/frontend/azure" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - radius_frontend "github.com/project-radius/radius/pkg/ucp/frontend/radius" - "github.com/project-radius/radius/pkg/ucp/frontend/versions" - "github.com/project-radius/radius/pkg/ucp/hosting" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - queueprovider "github.com/project-radius/radius/pkg/ucp/queue/provider" - "github.com/project-radius/radius/pkg/ucp/rest" - secretprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "github.com/project-radius/radius/pkg/validator" - "github.com/project-radius/radius/swagger" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/servicecontext" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + aws_frontend "github.com/radius-project/radius/pkg/ucp/frontend/aws" + azure_frontend "github.com/radius-project/radius/pkg/ucp/frontend/azure" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + radius_frontend "github.com/radius-project/radius/pkg/ucp/frontend/radius" + "github.com/radius-project/radius/pkg/ucp/frontend/versions" + "github.com/radius-project/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + queueprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + "github.com/radius-project/radius/pkg/ucp/rest" + secretprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/validator" + "github.com/radius-project/radius/swagger" "github.com/go-chi/chi/v5" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" @@ -117,7 +117,7 @@ func (s *Service) Initialize(ctx context.Context) (*http.Server, error) { r := chi.NewRouter() s.storageProvider = dataprovider.NewStorageProvider(s.options.StorageProviderOptions) - s.queueProvider = queueprovider.New(s.options.ProviderName, s.options.QueueProviderOptions) + s.queueProvider = queueprovider.New(s.options.QueueProviderOptions) s.secretProvider = secretprovider.NewSecretProvider(s.options.SecretProviderOptions) specLoader, err := validator.LoadSpec(ctx, "ucp", swagger.SpecFilesUCP, []string{s.options.PathBase}, "") @@ -154,7 +154,7 @@ func (s *Service) Initialize(ctx context.Context) (*http.Server, error) { app := http.Handler(r) app = servicecontext.ARMRequestCtx(s.options.PathBase, "global")(app) - app = middleware.WithLogger("ucp")(app) + app = middleware.WithLogger(app) app = otelhttp.NewHandler( middleware.NormalizePath(app), @@ -171,7 +171,7 @@ func (s *Service) Initialize(ctx context.Context) (*http.Server, error) { // Need to be able to respond to requests with planes and resourcegroups segments with any casing e.g.: /Planes, /resourceGroups // AWS SDK is case sensitive. Therefore, cannot use lowercase middleware. Therefore, introducing a new middleware that translates // the path for only these segments and preserves the case for the other parts of the path. - // TODO: https://github.com/project-radius/radius/issues/5921 + // TODO: https://github.com/radius-project/radius/issues/5921 Handler: app, BaseContext: func(ln net.Listener) context.Context { return ctx diff --git a/pkg/ucp/frontend/aws/module.go b/pkg/ucp/frontend/aws/module.go index 8689bc338e..676b4d0966 100644 --- a/pkg/ucp/frontend/aws/module.go +++ b/pkg/ucp/frontend/aws/module.go @@ -18,9 +18,17 @@ package aws import ( "github.com/go-chi/chi/v5" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/validator" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/validator" +) + +const ( + // OperationTypeAWSResource is the operation status type for AWS resources. + OperationStatusResourceType = "System.AWS/operationStatuses" + + // OperationTypeAWSResource is the operation result type for AWS resources. + OperationResultsResourceType = "System.AWS/operationResults" ) // NewModule creates a new AWS module. diff --git a/pkg/ucp/frontend/aws/routes.go b/pkg/ucp/frontend/aws/routes.go index 7d2710b537..2c780c07b1 100644 --- a/pkg/ucp/frontend/aws/routes.go +++ b/pkg/ucp/frontend/aws/routes.go @@ -24,21 +24,21 @@ import ( "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudformation" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - sdk_cred "github.com/project-radius/radius/pkg/ucp/credentials" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - awsproxy_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/awsproxy" - aws_credential_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/credentials/aws" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "github.com/project-radius/radius/pkg/validator" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + sdk_cred "github.com/radius-project/radius/pkg/ucp/credentials" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + awsproxy_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/awsproxy" + aws_credential_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/credentials/aws" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + "github.com/radius-project/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/validator" ) const ( @@ -84,8 +84,8 @@ func (m *Module) Initialize(ctx context.Context) (http.Handler, error) { { // URLs for standard UCP resource async status result. ParentRouter: server.NewSubrouter(baseRouter, operationResultsPath), - Method: v1.OperationGetOperationResult, - OperationType: &v1.OperationType{Type: OperationTypeAWSResource, Method: v1.OperationGetOperationResult}, + Method: v1.OperationGet, + OperationType: &v1.OperationType{Type: OperationResultsResourceType, Method: v1.OperationGet}, ControllerFactory: func(opt controller.Options) (controller.Controller, error) { return awsproxy_ctrl.NewGetAWSOperationResults(opt, m.AWSClients) }, @@ -93,8 +93,8 @@ func (m *Module) Initialize(ctx context.Context) (http.Handler, error) { { // URLs for standard UCP resource async status. ParentRouter: server.NewSubrouter(baseRouter, operationStatusesPath), - Method: v1.OperationGetOperationStatuses, - OperationType: &v1.OperationType{Type: OperationTypeAWSResource, Method: v1.OperationGetOperationStatuses}, + Method: v1.OperationGet, + OperationType: &v1.OperationType{Type: OperationStatusResourceType, Method: v1.OperationGet}, ControllerFactory: func(opts controller.Options) (controller.Controller, error) { return awsproxy_ctrl.NewGetAWSOperationStatuses(opts, m.AWSClients) }, diff --git a/pkg/ucp/frontend/aws/routes_test.go b/pkg/ucp/frontend/aws/routes_test.go index a4e3b23e98..7642d2cc3d 100644 --- a/pkg/ucp/frontend/aws/routes_test.go +++ b/pkg/ucp/frontend/aws/routes_test.go @@ -24,14 +24,14 @@ import ( "github.com/go-chi/chi/v5" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - "github.com/project-radius/radius/pkg/ucp/secret" - secretprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + "github.com/radius-project/radius/pkg/ucp/secret" + secretprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" ) const pathBase = "/some-path-base" @@ -83,11 +83,11 @@ func Test_Routes(t *testing.T) { Method: http.MethodPost, Path: "/planes/aws/aws/accounts/0000000/regions/some-region/providers/AWS.Kinesis/Stream/:delete", }, { - OperationType: v1.OperationType{Type: OperationTypeAWSResource, Method: v1.OperationGetOperationResult}, + OperationType: v1.OperationType{Type: OperationResultsResourceType, Method: v1.OperationGet}, Method: http.MethodGet, Path: "/planes/aws/aws/accounts/0000000/regions/some-region/providers/AWS.Kinesis/locations/global/operationResults/00000000-0000-0000-0000-000000000000", }, { - OperationType: v1.OperationType{Type: OperationTypeAWSResource, Method: v1.OperationGetOperationStatuses}, + OperationType: v1.OperationType{Type: OperationStatusResourceType, Method: v1.OperationGet}, Method: http.MethodGet, Path: "/planes/aws/aws/accounts/0000000/regions/some-region/providers/AWS.Kinesis/locations/global/operationStatuses/00000000-0000-0000-0000-000000000000", }, diff --git a/pkg/ucp/frontend/azure/module.go b/pkg/ucp/frontend/azure/module.go index c7aca3d774..d956d6ce30 100644 --- a/pkg/ucp/frontend/azure/module.go +++ b/pkg/ucp/frontend/azure/module.go @@ -18,8 +18,8 @@ package azure import ( "github.com/go-chi/chi/v5" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/validator" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/validator" ) // NewModule creates a new Azure module. diff --git a/pkg/ucp/frontend/azure/routes.go b/pkg/ucp/frontend/azure/routes.go index b301d6e4e8..50fb08e7d1 100644 --- a/pkg/ucp/frontend/azure/routes.go +++ b/pkg/ucp/frontend/azure/routes.go @@ -20,16 +20,16 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - azure_credential_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/credentials/azure" - planes_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/planes" - "github.com/project-radius/radius/pkg/validator" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + azure_credential_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/credentials/azure" + planes_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/planes" + "github.com/radius-project/radius/pkg/validator" ) const ( @@ -111,7 +111,7 @@ func (m *Module) Initialize(ctx context.Context) (http.Handler, error) { ParentRouter: baseRouter, Path: server.CatchAllPath, OperationType: &v1.OperationType{Type: OperationTypeUCPAzureProxy, Method: v1.OperationProxy}, - ControllerFactory: planes_ctrl.NewProxyPlane, + ControllerFactory: planes_ctrl.NewProxyController, }, } diff --git a/pkg/ucp/frontend/azure/routes_test.go b/pkg/ucp/frontend/azure/routes_test.go index 6a2df68708..6906152b67 100644 --- a/pkg/ucp/frontend/azure/routes_test.go +++ b/pkg/ucp/frontend/azure/routes_test.go @@ -24,14 +24,14 @@ import ( "github.com/go-chi/chi/v5" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - "github.com/project-radius/radius/pkg/ucp/secret" - secretprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + "github.com/radius-project/radius/pkg/ucp/secret" + secretprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" ) const pathBase = "/some-path-base" diff --git a/pkg/ucp/frontend/controller/awsproxy/awsparsing.go b/pkg/ucp/frontend/controller/awsproxy/awsparsing.go index e949237591..c471836c2d 100644 --- a/pkg/ucp/frontend/controller/awsproxy/awsparsing.go +++ b/pkg/ucp/frontend/controller/awsproxy/awsparsing.go @@ -23,11 +23,12 @@ import ( "net/http" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - awsoperations "github.com/project-radius/radius/pkg/aws/operations" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + awsoperations "github.com/radius-project/radius/pkg/aws/operations" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_aws "github.com/radius-project/radius/pkg/ucp/resources/aws" ) // getPrimaryIdentifiersFromSchema returns the primaryIdentifier field from the @@ -128,7 +129,7 @@ func readRegionFromRequest(path string, pathBase string) (string, armrpc_rest.Re response := armrpc_rest.NewBadRequestARMResponse(errResponse) return "", response } - region := resourceID.FindScope(resources.RegionsSegment) + region := resourceID.FindScope(resources_aws.ScopeRegions) if region == "" { errResponse := v1.ErrorResponse{ Error: v1.ErrorDetails{ diff --git a/pkg/ucp/frontend/controller/awsproxy/awsparsing_test.go b/pkg/ucp/frontend/controller/awsproxy/awsparsing_test.go index 3a78af312d..b91418c399 100644 --- a/pkg/ucp/frontend/controller/awsproxy/awsparsing_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/awsparsing_test.go @@ -21,7 +21,7 @@ import ( "encoding/json" "testing" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/awsproxytest.go b/pkg/ucp/frontend/controller/awsproxy/awsproxytest.go index 4a52a5ce24..417cf5d15a 100644 --- a/pkg/ucp/frontend/controller/awsproxy/awsproxytest.go +++ b/pkg/ucp/frontend/controller/awsproxy/awsproxytest.go @@ -22,9 +22,9 @@ import ( "testing" "github.com/golang/mock/gomock" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/store" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" ) const ( diff --git a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource.go b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource.go index a6c9e969ac..aca9f6c88d 100644 --- a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource.go +++ b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource.go @@ -25,14 +25,14 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - awsoperations "github.com/project-radius/radius/pkg/aws/operations" - "github.com/project-radius/radius/pkg/to" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + awsoperations "github.com/radius-project/radius/pkg/aws/operations" + "github.com/radius-project/radius/pkg/to" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) var _ armrpc_controller.Controller = (*CreateOrUpdateAWSResource)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource_test.go b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource_test.go index 825513fa82..e7207f8228 100644 --- a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresource_test.go @@ -29,10 +29,10 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/golang/mock/gomock" "github.com/google/uuid" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost.go b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost.go index 3bd186c806..55eed3453b 100644 --- a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost.go +++ b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost.go @@ -27,15 +27,15 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - awsoperations "github.com/project-radius/radius/pkg/aws/operations" - "github.com/project-radius/radius/pkg/to" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + awsoperations "github.com/radius-project/radius/pkg/aws/operations" + "github.com/radius-project/radius/pkg/to" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*CreateOrUpdateAWSResourceWithPost)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost_test.go b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost_test.go index 0aa807f38a..a7dd6f8042 100644 --- a/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/createorupdateawsresourcewithpost_test.go @@ -29,10 +29,10 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/golang/mock/gomock" "github.com/google/uuid" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/resources" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/deleteawsresource.go b/pkg/ucp/frontend/controller/awsproxy/deleteawsresource.go index 9647a88f83..075ce4b429 100644 --- a/pkg/ucp/frontend/controller/awsproxy/deleteawsresource.go +++ b/pkg/ucp/frontend/controller/awsproxy/deleteawsresource.go @@ -22,13 +22,13 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/to" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/to" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) var _ armrpc_controller.Controller = (*DeleteAWSResource)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/deleteawsresource_test.go b/pkg/ucp/frontend/controller/awsproxy/deleteawsresource_test.go index 25a3248c81..21afc1a937 100644 --- a/pkg/ucp/frontend/controller/awsproxy/deleteawsresource_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/deleteawsresource_test.go @@ -26,9 +26,9 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" "github.com/golang/mock/gomock" "github.com/google/uuid" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost.go b/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost.go index 8ed6bb1047..a9fca38094 100644 --- a/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost.go +++ b/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost.go @@ -24,15 +24,15 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/to" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/to" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*DeleteAWSResourceWithPost)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost_test.go b/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost_test.go index 4b7b553522..15b0cc0fd8 100644 --- a/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/deleteawsresourcewithpost_test.go @@ -29,10 +29,10 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/golang/mock/gomock" "github.com/google/uuid" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rpctest" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rpctest" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults.go b/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults.go index c2ca6cf625..59a31df829 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults.go @@ -22,13 +22,13 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" - armrpcv1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" + armrpcv1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) var _ armrpc_controller.Controller = (*GetAWSOperationResults)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults_test.go b/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults_test.go index 1f0c3a891a..f01c52b216 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsoperationresults_test.go @@ -26,10 +26,10 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses.go b/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses.go index 300c43ae4d..6dc9933584 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses.go @@ -22,14 +22,14 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" - armrpcv1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - manager "github.com/project-radius/radius/pkg/armrpc/asyncoperation/statusmanager" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" + armrpcv1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + manager "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) var _ armrpc_controller.Controller = (*GetAWSOperationStatuses)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses_test.go b/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses_test.go index 3f65fce533..a4761d4560 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsoperationstatuses_test.go @@ -26,11 +26,11 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsresource.go b/pkg/ucp/frontend/controller/awsproxy/getawsresource.go index 37c0936c5d..8c3131e3b6 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsresource.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsresource.go @@ -22,13 +22,13 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/to" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/to" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) var _ armrpc_controller.Controller = (*GetAWSResource)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsresource_test.go b/pkg/ucp/frontend/controller/awsproxy/getawsresource_test.go index 4008301e2b..0ad89bf132 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsresource_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsresource_test.go @@ -29,12 +29,12 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - armrpc_v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/resources" + armrpc_v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost.go b/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost.go index e7664c6116..e60b63492a 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost.go @@ -26,16 +26,16 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudformation" "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/middleware" - "github.com/project-radius/radius/pkg/to" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/to" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*GetAWSResourceWithPost)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost_test.go b/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost_test.go index 006a58db22..8cb8c2d73a 100644 --- a/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/getawsresourcewithpost_test.go @@ -34,12 +34,12 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - armrpc_v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/resources" + armrpc_v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/awsproxy/listawsresources.go b/pkg/ucp/frontend/controller/awsproxy/listawsresources.go index 78854dc0ef..2b9f4acf81 100644 --- a/pkg/ucp/frontend/controller/awsproxy/listawsresources.go +++ b/pkg/ucp/frontend/controller/awsproxy/listawsresources.go @@ -22,13 +22,13 @@ import ( "path" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/to" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/aws/servicecontext" - "github.com/project-radius/radius/pkg/ucp/datamodel" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/to" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/aws/servicecontext" + "github.com/radius-project/radius/pkg/ucp/datamodel" ) var _ armrpc_controller.Controller = (*ListAWSResources)(nil) diff --git a/pkg/ucp/frontend/controller/awsproxy/listawsresources_test.go b/pkg/ucp/frontend/controller/awsproxy/listawsresources_test.go index d56e4121e3..4a0c428879 100644 --- a/pkg/ucp/frontend/controller/awsproxy/listawsresources_test.go +++ b/pkg/ucp/frontend/controller/awsproxy/listawsresources_test.go @@ -29,11 +29,11 @@ import ( "github.com/golang/mock/gomock" "github.com/google/uuid" - armrpc_v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" + armrpc_v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential.go b/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential.go index e61588a0aa..edcab9e37f 100644 --- a/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential.go +++ b/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential.go @@ -19,13 +19,13 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/frontend/controller/credentials" - "github.com/project-radius/radius/pkg/ucp/secret" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/frontend/controller/credentials" + "github.com/radius-project/radius/pkg/ucp/secret" ) var _ armrpc_controller.Controller = (*CreateOrUpdateAWSCredential)(nil) diff --git a/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential_test.go b/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential_test.go index 102f889913..fc4108b25c 100644 --- a/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential_test.go +++ b/pkg/ucp/frontend/controller/credentials/aws/createorupdateawscredential_test.go @@ -22,17 +22,17 @@ import ( "net/http" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" "github.com/stretchr/testify/require" ) @@ -123,7 +123,7 @@ func Test_AWS_Credential(t *testing.T) { t.Run(tt.name, func(t *testing.T) { tt.fn(*mockStorageClient, *mockSecretClient) - credentialVersionedInput := &v20220901privatepreview.AWSCredentialResource{} + credentialVersionedInput := &v20220901privatepreview.AwsCredentialResource{} credentialInput := testutil.ReadFixture(tt.filename) err = json.Unmarshal(credentialInput, credentialVersionedInput) require.NoError(t, err) @@ -146,7 +146,7 @@ func Test_AWS_Credential(t *testing.T) { } func getAwsResponse() armrpc_rest.Response { - return armrpc_rest.NewOKResponseWithHeaders(&v20220901privatepreview.AWSCredentialResource{ + return armrpc_rest.NewOKResponseWithHeaders(&v20220901privatepreview.AwsCredentialResource{ Location: to.Ptr("West US"), ID: to.Ptr("/planes/aws/awscloud/providers/System.AWS/credentials/default"), Name: to.Ptr("default"), @@ -154,11 +154,11 @@ func getAwsResponse() armrpc_rest.Response { Tags: map[string]*string{ "env": to.Ptr("dev"), }, - Properties: &v20220901privatepreview.AWSAccessKeyCredentialProperties{ + Properties: &v20220901privatepreview.AwsAccessKeyCredentialProperties{ AccessKeyID: to.Ptr("00000000-0000-0000-0000-000000000000"), - Kind: to.Ptr("AccessKey"), + Kind: to.Ptr(v20220901privatepreview.AWSCredentialKindAccessKey), Storage: &v20220901privatepreview.InternalCredentialStorageProperties{ - Kind: to.Ptr(string(v20220901privatepreview.CredentialStorageKindInternal)), + Kind: to.Ptr(v20220901privatepreview.CredentialStorageKindInternal), SecretName: to.Ptr("aws-awscloud-default"), }, }, diff --git a/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential.go b/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential.go index 7a975daba1..ed4800f74e 100644 --- a/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential.go +++ b/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential.go @@ -21,16 +21,16 @@ import ( "fmt" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/frontend/controller/credentials" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/frontend/controller/credentials" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*DeleteAWSCredential)(nil) diff --git a/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential_test.go b/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential_test.go index bf0a358c10..7274fd39d7 100644 --- a/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential_test.go +++ b/pkg/ucp/frontend/controller/credentials/aws/deleteawscredential_test.go @@ -22,14 +22,14 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/rest" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/rest" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential.go b/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential.go index dee0844cc6..1149e5134d 100644 --- a/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential.go +++ b/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential.go @@ -19,13 +19,13 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/frontend/controller/credentials" - "github.com/project-radius/radius/pkg/ucp/secret" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/frontend/controller/credentials" + "github.com/radius-project/radius/pkg/ucp/secret" ) var _ armrpc_controller.Controller = (*CreateOrUpdateAzureCredential)(nil) diff --git a/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential_test.go b/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential_test.go index 8602c70e32..4785e23762 100644 --- a/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential_test.go +++ b/pkg/ucp/frontend/controller/credentials/azure/createorupdateazurecredential_test.go @@ -22,17 +22,17 @@ import ( "net/http" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/test/testutil" "github.com/golang/mock/gomock" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" "github.com/stretchr/testify/require" ) @@ -156,9 +156,9 @@ func getAzureCredentialResponse() armrpc_rest.Response { Properties: &v20220901privatepreview.AzureServicePrincipalProperties{ ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - Kind: to.Ptr("ServicePrincipal"), + Kind: to.Ptr(v20220901privatepreview.AzureCredentialKindServicePrincipal), Storage: &v20220901privatepreview.InternalCredentialStorageProperties{ - Kind: to.Ptr(string(v20220901privatepreview.CredentialStorageKindInternal)), + Kind: to.Ptr(v20220901privatepreview.CredentialStorageKindInternal), SecretName: to.Ptr("azure-azurecloud-default"), }, }, diff --git a/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential.go b/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential.go index c79e61ec05..896d936304 100644 --- a/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential.go +++ b/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential.go @@ -21,15 +21,15 @@ import ( "fmt" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/frontend/controller/credentials" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/frontend/controller/credentials" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*DeleteAzureCredential)(nil) diff --git a/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential_test.go b/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential_test.go index c3e6f2529c..ef6ae7ec6b 100644 --- a/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential_test.go +++ b/pkg/ucp/frontend/controller/credentials/azure/deleteazurecredential_test.go @@ -22,13 +22,13 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/credentials/utils.go b/pkg/ucp/frontend/controller/credentials/utils.go index 255c253a23..ab97650422 100644 --- a/pkg/ucp/frontend/controller/credentials/utils.go +++ b/pkg/ucp/frontend/controller/credentials/utils.go @@ -18,8 +18,8 @@ package credentials import ( "strings" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/ucp/resources" ) // GetSecretName takes in a resources.ID and returns a string which is the normalized name of the resource. diff --git a/pkg/ucp/frontend/controller/credentials/utils_test.go b/pkg/ucp/frontend/controller/credentials/utils_test.go index 67e92f3c14..def7234efc 100644 --- a/pkg/ucp/frontend/controller/credentials/utils_test.go +++ b/pkg/ucp/frontend/controller/credentials/utils_test.go @@ -18,7 +18,7 @@ package credentials import ( "testing" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/kubernetes/discoverydoc.go b/pkg/ucp/frontend/controller/kubernetes/discoverydoc.go index cf37efd95f..681e7f4944 100644 --- a/pkg/ucp/frontend/controller/kubernetes/discoverydoc.go +++ b/pkg/ucp/frontend/controller/kubernetes/discoverydoc.go @@ -20,9 +20,9 @@ import ( "encoding/json" http "net/http" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" ) var _ armrpc_controller.Controller = (*DiscoveryDoc)(nil) diff --git a/pkg/ucp/frontend/controller/kubernetes/openapiv2doc.go b/pkg/ucp/frontend/controller/kubernetes/openapiv2doc.go index 2da04e404a..0a80dedfce 100644 --- a/pkg/ucp/frontend/controller/kubernetes/openapiv2doc.go +++ b/pkg/ucp/frontend/controller/kubernetes/openapiv2doc.go @@ -20,9 +20,9 @@ import ( "encoding/json" http "net/http" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" ) var _ armrpc_controller.Controller = (*OpenAPIv2Doc)(nil) diff --git a/pkg/ucp/frontend/controller/kubernetes/openapiv3doc.go b/pkg/ucp/frontend/controller/kubernetes/openapiv3doc.go index e3c330afb6..255c0f4dab 100644 --- a/pkg/ucp/frontend/controller/kubernetes/openapiv3doc.go +++ b/pkg/ucp/frontend/controller/kubernetes/openapiv3doc.go @@ -21,9 +21,9 @@ import ( "encoding/json" http "net/http" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" ) var _ armrpc_controller.Controller = (*OpenAPIv3Doc)(nil) diff --git a/pkg/ucp/frontend/controller/planes/listplanes.go b/pkg/ucp/frontend/controller/planes/listplanes.go index d321e12547..7767493a8f 100644 --- a/pkg/ucp/frontend/controller/planes/listplanes.go +++ b/pkg/ucp/frontend/controller/planes/listplanes.go @@ -20,13 +20,13 @@ import ( "fmt" http "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*ListPlanes)(nil) diff --git a/pkg/ucp/frontend/controller/planes/listplanes_test.go b/pkg/ucp/frontend/controller/planes/listplanes_test.go index e9c00c4a9d..46d3f701e2 100644 --- a/pkg/ucp/frontend/controller/planes/listplanes_test.go +++ b/pkg/ucp/frontend/controller/planes/listplanes_test.go @@ -20,14 +20,14 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/planes/listplanesbytype.go b/pkg/ucp/frontend/controller/planes/listplanesbytype.go index fa09b8e62c..cd22fcc0d7 100644 --- a/pkg/ucp/frontend/controller/planes/listplanesbytype.go +++ b/pkg/ucp/frontend/controller/planes/listplanesbytype.go @@ -22,15 +22,15 @@ import ( http "net/http" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/middleware" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*ListPlanesByType)(nil) diff --git a/pkg/ucp/frontend/controller/planes/listplanesbytype_test.go b/pkg/ucp/frontend/controller/planes/listplanesbytype_test.go index c80a0e1061..269dfe5a92 100644 --- a/pkg/ucp/frontend/controller/planes/listplanesbytype_test.go +++ b/pkg/ucp/frontend/controller/planes/listplanesbytype_test.go @@ -20,14 +20,14 @@ import ( "testing" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/frontend/controller/planes/proxycontroller.go b/pkg/ucp/frontend/controller/planes/proxycontroller.go new file mode 100644 index 0000000000..947db5956c --- /dev/null +++ b/pkg/ucp/frontend/controller/planes/proxycontroller.go @@ -0,0 +1,204 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package planes + +import ( + "context" + "fmt" + http "net/http" + "net/url" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/proxy" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/rest" + "github.com/radius-project/radius/pkg/ucp/ucplog" + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" +) + +const ( + PlanesPath = "/planes" +) + +var _ armrpc_controller.Controller = (*ProxyController)(nil) + +// ProxyController is the controller implementation to proxy requests to appropriate RP or URL. +type ProxyController struct { + armrpc_controller.Operation[*datamodel.Plane, datamodel.Plane] +} + +// NewProxyController creates a new ProxyPlane controller with the given options and returns it, or returns an error if the +// controller cannot be created. +func NewProxyController(opts armrpc_controller.Options) (armrpc_controller.Controller, error) { + return &ProxyController{ + Operation: armrpc_controller.NewOperation(opts, armrpc_controller.ResourceOptions[datamodel.Plane]{}), + }, nil +} + +// Run() takes in a request object and context, looks up the plane and resource provider associated with the +// request, and proxies the request to the appropriate resource provider. +func (p *ProxyController) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (armrpc_rest.Response, error) { + logger := ucplog.FromContextOrDiscard(ctx) + + logger.Info("starting proxy request") + for key, value := range req.Header { + logger.V(ucplog.LevelDebug).Info("incoming request header", "key", key, "value", value) + } + + // Make a copy of the incoming URL and trim the base path + newURL := *req.URL + newURL.Path = middleware.GetRelativePath(p.Options().PathBase, req.URL.Path) + planeType, name, _, err := resources.ExtractPlanesPrefixFromURLPath(newURL.Path) + if err != nil { + return nil, err + } + + // Lookup the plane + planePath := PlanesPath + "/" + planeType + "/" + name + planeID, err := resources.ParseScope(planePath) + if err != nil { + return nil, err + } + + serviceCtx := v1.ARMRequestContextFromContext(ctx) + plane, _, err := p.GetResource(ctx, planeID) + if err != nil { + return nil, err + } + if plane == nil { + restResponse := armrpc_rest.NewNotFoundResponse(serviceCtx.ResourceID) + return restResponse, nil + } + + if plane.Properties.Kind == rest.PlaneKindUCPNative { + // Check if the resource group exists + id, err := resources.Parse(newURL.Path) + if err != nil { + return nil, err + } + rgPath := id.RootScope() + rgID, err := resources.ParseScope(rgPath) + if err != nil { + return nil, err + } + + existingRG, _, err := p.GetResource(ctx, rgID) + if err != nil { + return nil, err + } + if existingRG == nil { + logger.Info(fmt.Sprintf("Resource group %s not found in db", serviceCtx.ResourceID)) + restResponse := armrpc_rest.NewNotFoundResponse(serviceCtx.ResourceID) + return restResponse, nil + } + } + + // Get the resource provider + resourceID, err := resources.Parse(newURL.Path) + if err != nil { + return nil, err + } + + // We expect either a resource or resource collection. + if resourceID.ProviderNamespace() == "" { + err = fmt.Errorf("invalid resourceID specified with no provider") + logger.Error(err, "resourceID %q does not have provider", resourceID.String()) + return armrpc_rest.NewBadRequestResponse(err.Error()), nil + } + + // Lookup the resource providers configured to determine the URL to proxy to + // Not using map lookups to enable case insensitive comparisons + // We need to preserve the case while storing data in DB and therefore iterating for case + // insensitive comparisons + + var proxyURL string + if plane.Properties.Kind == rest.PlaneKindUCPNative { + proxyURL = plane.LookupResourceProvider(resourceID.ProviderNamespace()) + if proxyURL == "" { + err = fmt.Errorf("provider %s not configured", resourceID.ProviderNamespace()) + return nil, err + } + } else { + // For a non UCP-native plane, the configuration should have a URL to which + // all the requests will be forwarded + proxyURL = *plane.Properties.URL + } + + downstream, err := url.Parse(proxyURL) + if err != nil { + return nil, err + } + + options := proxy.ReverseProxyOptions{ + RoundTripper: otelhttp.NewTransport(http.DefaultTransport), + } + + refererURL := url.URL{ + Scheme: "http", + Host: req.Host, + Path: req.URL.Path, + RawQuery: req.URL.RawQuery, + } + + // As per https://github.com/golang/go/issues/28940#issuecomment-441749380, the way to check + // for http vs https is check the TLS field + if req.TLS != nil { + refererURL.Scheme = "https" + } + + uri, err := url.Parse(newURL.Path) + if err != nil { + return nil, err + } + + // Preserving the query strings on the incoming url on the newly constructed url + uri.RawQuery = newURL.Query().Encode() + req.URL = uri + req.Header.Set("X-Forwarded-Proto", refererURL.Scheme) + + logger.Info("setting referer header", "value", refererURL.String()) + req.Header.Set(v1.RefererHeader, refererURL.String()) + + sender := proxy.NewARMProxy(options, downstream, func(builder *proxy.ReverseProxyBuilder) { + if plane.Properties.Kind != rest.PlaneKindUCPNative { + // If we're proxying to Azure then remove the planes prefix. + builder.Directors = append(builder.Directors, trimPlanesPrefix) + } + }) + + logger.Info(fmt.Sprintf("proxying request target: %s", proxyURL)) + sender.ServeHTTP(w, req.WithContext(ctx)) + // The upstream response has already been sent at this point. Therefore, return nil response here + return nil, nil +} + +// trimPlanesPrefix trims the planes prefix from the request URL path. +func trimPlanesPrefix(r *http.Request) { + _, _, remainder, err := resources.ExtractPlanesPrefixFromURLPath(r.URL.Path) + if err != nil { + // Invalid case like path: /planes/foo - do nothing + // If we see an invalid URL here we don't have a good way to report an error at this point + // we expect the error to have been handled before calling into this code. + return + } + + // Success -- truncate the planes prefix + r.URL.Path = remainder +} diff --git a/pkg/ucp/frontend/controller/planes/proxyplane.go b/pkg/ucp/frontend/controller/planes/proxyplane.go deleted file mode 100644 index 14dd6e8bc0..0000000000 --- a/pkg/ucp/frontend/controller/planes/proxyplane.go +++ /dev/null @@ -1,200 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package planes - -import ( - "context" - "fmt" - http "net/http" - "net/url" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/middleware" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/proxy" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/rest" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" -) - -const ( - PlanesPath = "/planes" -) - -var _ armrpc_controller.Controller = (*ProxyPlane)(nil) - -// ProxyPlane is the controller implementation to proxy requests to appropriate RP or URL. -type ProxyPlane struct { - armrpc_controller.Operation[*datamodel.Plane, datamodel.Plane] -} - -// NewProxyPlane creates a new ProxyPlane controller with the given options and returns it, or returns an error if the -// controller cannot be created. -func NewProxyPlane(opts armrpc_controller.Options) (armrpc_controller.Controller, error) { - return &ProxyPlane{ - Operation: armrpc_controller.NewOperation(opts, armrpc_controller.ResourceOptions[datamodel.Plane]{}), - }, nil -} - -// Run() takes in a request object and context, looks up the plane and resource provider associated with the -// request, and proxies the request to the appropriate resource provider. -func (p *ProxyPlane) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (armrpc_rest.Response, error) { - logger := ucplog.FromContextOrDiscard(ctx) - - logger.Info("starting proxy request") - for key, value := range req.Header { - logger.V(ucplog.LevelDebug).Info("incoming request header", "key", key, "value", value) - } - - refererURL := url.URL{ - Host: req.Host, - Path: req.URL.Path, - RawQuery: req.URL.RawQuery, - } - - // Make a copy of the incoming URL and trim the base path - newURL := *req.URL - newURL.Path = middleware.GetRelativePath(p.Options().PathBase, req.URL.Path) - planeType, name, _, err := resources.ExtractPlanesPrefixFromURLPath(newURL.Path) - if err != nil { - return nil, err - } - - // Lookup the plane - planePath := PlanesPath + "/" + planeType + "/" + name - planeID, err := resources.ParseScope(planePath) - if err != nil { - return nil, err - } - - serviceCtx := v1.ARMRequestContextFromContext(ctx) - plane, _, err := p.GetResource(ctx, planeID) - if err != nil { - return nil, err - } - if plane == nil { - restResponse := armrpc_rest.NewNotFoundResponse(serviceCtx.ResourceID) - return restResponse, nil - } - - if plane.Properties.Kind == rest.PlaneKindUCPNative { - // Check if the resource group exists - id, err := resources.Parse(newURL.Path) - if err != nil { - return nil, err - } - rgPath := id.RootScope() - rgID, err := resources.ParseScope(rgPath) - if err != nil { - return nil, err - } - - existingRG, _, err := p.GetResource(ctx, rgID) - if err != nil { - return nil, err - } - if existingRG == nil { - logger.Info(fmt.Sprintf("Resource group %s not found in db", serviceCtx.ResourceID)) - restResponse := armrpc_rest.NewNotFoundResponse(serviceCtx.ResourceID) - return restResponse, nil - } - } - - // Get the resource provider - resourceID, err := resources.Parse(newURL.Path) - if err != nil { - return nil, err - } - - // We expect either a resource or resource collection. - if resourceID.ProviderNamespace() == "" { - err = fmt.Errorf("invalid resourceID specified with no provider") - logger.Error(err, "resourceID %q does not have provider", resourceID.String()) - return armrpc_rest.NewBadRequestResponse(err.Error()), nil - } - - // Lookup the resource providers configured to determine the URL to proxy to - // Not using map lookups to enable case insensitive comparisons - // We need to preserve the case while storing data in DB and therefore iterating for case - // insensitive comparisons - - var proxyURL string - if plane.Properties.Kind == rest.PlaneKindUCPNative { - proxyURL = plane.LookupResourceProvider(resourceID.ProviderNamespace()) - if proxyURL == "" { - err = fmt.Errorf("provider %s not configured", resourceID.ProviderNamespace()) - return nil, err - } - } else { - // For a non UCP-native plane, the configuration should have a URL to which - // all the requests will be forwarded - proxyURL = *plane.Properties.URL - } - - downstream, err := url.Parse(proxyURL) - if err != nil { - return nil, err - } - - options := proxy.ReverseProxyOptions{ - RoundTripper: otelhttp.NewTransport(http.DefaultTransport), - ProxyAddress: p.Options().Address, - TrimPlanesPrefix: (plane.Properties.Kind != rest.PlaneKindUCPNative), - } - - // As per https://github.com/golang/go/issues/28940#issuecomment-441749380, the way to check - // for http vs https is check the TLS field - httpScheme := "http" - if req.TLS != nil { - httpScheme = "https" - } - refererURL.Scheme = httpScheme - - requestInfo := proxy.UCPRequestInfo{ - PlaneURL: proxyURL, - PlaneKind: string(plane.Properties.Kind), - PlaneID: planePath, - HTTPScheme: httpScheme, - // The Host field in the request that the client makes to UCP contains the UCP Host address - // That address will be used to construct the URL for reverse proxying - UCPHost: req.Host + p.Options().PathBase, - } - - uri, err := url.Parse(newURL.Path) - if err != nil { - return nil, err - } - - // Preserving the query strings on the incoming url on the newly constructed url - uri.RawQuery = newURL.Query().Encode() - req.URL = uri - req.Header.Set("X-Forwarded-Proto", httpScheme) - - req.Header.Set(v1.RefererHeader, refererURL.String()) - logger = ucplog.FromContextOrDiscard(ctx) - logger.Info(fmt.Sprintf("Referer Header: %s", req.Header.Get(v1.RefererHeader))) - - ctx = context.WithValue(ctx, proxy.UCPRequestInfoField, requestInfo) - sender := proxy.NewARMProxy(options, downstream, nil) - - logger.Info(fmt.Sprintf("proxying request target: %s", proxyURL)) - sender.ServeHTTP(w, req.WithContext(ctx)) - // The upstream response has already been sent at this point. Therefore, return nil response here - return nil, nil -} diff --git a/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups.go b/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups.go index 7b89e787c3..a7d0430dab 100644 --- a/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups.go +++ b/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups.go @@ -20,14 +20,14 @@ import ( "fmt" http "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var _ armrpc_controller.Controller = (*ListResourceGroups)(nil) diff --git a/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups_test.go b/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups_test.go index 1f17617d2c..f13816461b 100644 --- a/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups_test.go +++ b/pkg/ucp/frontend/controller/resourcegroups/listresourcegroups_test.go @@ -23,14 +23,14 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - armrpc_controller "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - armrpc_rest "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/store" ) func Test_ListResourceGroups(t *testing.T) { diff --git a/pkg/ucp/frontend/controller/resourcegroups/listresources.go b/pkg/ucp/frontend/controller/resourcegroups/listresources.go new file mode 100644 index 0000000000..c0d5d35b4f --- /dev/null +++ b/pkg/ucp/frontend/controller/resourcegroups/listresources.go @@ -0,0 +1,110 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package resourcegroups + +import ( + "context" + "errors" + http "net/http" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" +) + +var _ armrpc_controller.Controller = (*ListResources)(nil) + +// ListResources is the controller implementation to get the list of resources stored in a resource group. +type ListResources struct { + armrpc_controller.Operation[*datamodel.GenericResource, datamodel.GenericResource] +} + +// NewListResources creates a new controller for listing resources stored in a resource group. +func NewListResources(opts armrpc_controller.Options) (armrpc_controller.Controller, error) { + return &ListResources{ + Operation: armrpc_controller.NewOperation(opts, + armrpc_controller.ResourceOptions[datamodel.GenericResource]{ + RequestConverter: converter.GenericResourceDataModelFromVersioned, + ResponseConverter: converter.GenericResourceDataModelToVersioned, + }, + ), + }, nil +} + +// Run implements controller.Controller. +func (r *ListResources) Run(ctx context.Context, w http.ResponseWriter, req *http.Request) (armrpc_rest.Response, error) { + relativePath := middleware.GetRelativePath(r.Options().PathBase, req.URL.Path) + id, err := resources.Parse(relativePath) + if err != nil { + return nil, err + } + + // Cut off the "resources" part of the ID. The ID should be the ID of a resource group. + resourceGroupID := id.Truncate() + + // First check if the resource group exists. + _, err = r.StorageClient().Get(ctx, resourceGroupID.String()) + if errors.Is(err, &store.ErrNotFound{}) { + return armrpc_rest.NewNotFoundResponse(id), nil + } else if err != nil { + return nil, err + } + + query := store.Query{ + RootScope: resourceGroupID.String(), + ResourceType: v20220901privatepreview.ResourceType, + } + + result, err := r.StorageClient().Query(ctx, query) + if err != nil { + return nil, err + } + + response, err := r.createResponse(ctx, req, result) + if err != nil { + return nil, err + } + + return armrpc_rest.NewOKResponse(response), nil +} + +func (r *ListResources) createResponse(ctx context.Context, req *http.Request, result *store.ObjectQueryResult) (*v1.PaginatedList, error) { + items := v1.PaginatedList{} + serviceCtx := v1.ARMRequestContextFromContext(ctx) + + for _, item := range result.Items { + data := datamodel.GenericResource{} + err := item.As(&data) + if err != nil { + return nil, err + } + + versioned, err := converter.GenericResourceDataModelToVersioned(&data, serviceCtx.APIVersion) + if err != nil { + return nil, err + } + + items.Value = append(items.Value, versioned) + } + + return &items, nil +} diff --git a/pkg/ucp/frontend/controller/resourcegroups/listresources_test.go b/pkg/ucp/frontend/controller/resourcegroups/listresources_test.go new file mode 100644 index 0000000000..3a933d372f --- /dev/null +++ b/pkg/ucp/frontend/controller/resourcegroups/listresources_test.go @@ -0,0 +1,144 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package resourcegroups + +import ( + "net/http" + "testing" + + "github.com/golang/mock/gomock" + "github.com/google/uuid" + "github.com/stretchr/testify/require" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + armrpc_controller "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + armrpc_rest "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" +) + +func Test_ListResources(t *testing.T) { + entryResource := v20220901privatepreview.GenericResource{ + ID: to.Ptr("/planes/radius/local/resourceGroups/test-rg/providers/Applications.Core/applications/test-app"), + Type: to.Ptr("Applications.Core/applications"), + Name: to.Ptr("test-app"), + } + entryDatamodel := datamodel.GenericResource{ + BaseResource: v1.BaseResource{ + TrackedResource: v1.TrackedResource{ + ID: "ignored", + Type: "ignored", + Name: "ignored", + }, + }, + Properties: datamodel.GenericResourceProperties{ + ID: *entryResource.ID, + Type: *entryResource.Type, + Name: *entryResource.Name, + }, + } + + // Not currently used, but may be in the future. + resourceGroupDatamodel := datamodel.ResourceGroup{} + + resourceGroupID := "/planes/radius/local/resourceGroups/test-rg" + id := resourceGroupID + "/resources" + + t.Run("success", func(t *testing.T) { + storage, ctrl := setupListResources(t) + + storage.EXPECT(). + Get(gomock.Any(), resourceGroupID). + Return(&store.Object{Data: resourceGroupDatamodel}, nil). + Times(1) + + expectedQuery := store.Query{RootScope: resourceGroupID, ResourceType: v20220901privatepreview.ResourceType} + storage.EXPECT(). + Query(gomock.Any(), expectedQuery). + Return(&store.ObjectQueryResult{Items: []store.Object{{Data: entryDatamodel}}}, nil). + Times(1) + + expected := armrpc_rest.NewOKResponse(&v1.PaginatedList{ + Value: []any{&entryResource}, + }) + + request, err := http.NewRequest(http.MethodGet, ctrl.Options().PathBase+id+"?api-version="+v20220901privatepreview.Version, nil) + require.NoError(t, err) + ctx := rpctest.NewARMRequestContext(request) + response, err := ctrl.Run(ctx, nil, request) + require.NoError(t, err) + require.Equal(t, expected, response) + }) + + t.Run("success - empty", func(t *testing.T) { + storage, ctrl := setupListResources(t) + + storage.EXPECT(). + Get(gomock.Any(), resourceGroupID). + Return(&store.Object{Data: resourceGroupDatamodel}, nil). + Times(1) + + expectedQuery := store.Query{RootScope: resourceGroupID, ResourceType: v20220901privatepreview.ResourceType} + storage.EXPECT(). + Query(gomock.Any(), expectedQuery). + Return(&store.ObjectQueryResult{Items: []store.Object{}}, nil). + Times(1) + + expected := armrpc_rest.NewOKResponse(&v1.PaginatedList{}) + + request, err := http.NewRequest(http.MethodGet, ctrl.Options().PathBase+id+"?api-version="+v20220901privatepreview.Version, nil) + require.NoError(t, err) + ctx := rpctest.NewARMRequestContext(request) + response, err := ctrl.Run(ctx, nil, request) + require.NoError(t, err) + require.Equal(t, expected, response) + }) + + t.Run("resource group not found", func(t *testing.T) { + storage, ctrl := setupListResources(t) + + storage.EXPECT(). + Get(gomock.Any(), resourceGroupID). + Return(nil, &store.ErrNotFound{ID: resourceGroupID}). + Times(1) + + parsed, err := resources.Parse(id) + require.NoError(t, err) + + expected := armrpc_rest.NewNotFoundResponse(parsed) + + request, err := http.NewRequest(http.MethodGet, ctrl.Options().PathBase+id+"?api-version="+v20220901privatepreview.Version, nil) + require.NoError(t, err) + ctx := rpctest.NewARMRequestContext(request) + response, err := ctrl.Run(ctx, nil, request) + require.NoError(t, err) + require.Equal(t, expected, response) + }) +} + +func setupListResources(t *testing.T) (*store.MockStorageClient, *ListResources) { + ctrl := gomock.NewController(t) + storage := store.NewMockStorageClient(ctrl) + + c, err := NewListResources(armrpc_controller.Options{StorageClient: storage, PathBase: "/" + uuid.New().String()}) + require.NoError(t, err) + + return storage, c.(*ListResources) +} diff --git a/pkg/ucp/frontend/modules/errors.go b/pkg/ucp/frontend/modules/errors.go index 6c133d4bbb..4fe434a68b 100644 --- a/pkg/ucp/frontend/modules/errors.go +++ b/pkg/ucp/frontend/modules/errors.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rest" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rest" ) // InvalidPlaneTypeErrorResponse returns a 400 response with error code CodeInvalidPlaneType. diff --git a/pkg/ucp/frontend/modules/types.go b/pkg/ucp/frontend/modules/types.go index 3448d32306..a8d4cd7d05 100644 --- a/pkg/ucp/frontend/modules/types.go +++ b/pkg/ucp/frontend/modules/types.go @@ -20,12 +20,12 @@ import ( "context" "net/http" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - queueprovider "github.com/project-radius/radius/pkg/ucp/queue/provider" - secretprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/validator" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + queueprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + secretprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/validator" ) // Initializer is an interface that can be implemented by modules that want to provide functionality for a plane. diff --git a/pkg/ucp/frontend/radius/module.go b/pkg/ucp/frontend/radius/module.go index ddcf781d0d..1dae8a5641 100644 --- a/pkg/ucp/frontend/radius/module.go +++ b/pkg/ucp/frontend/radius/module.go @@ -18,8 +18,8 @@ package radius import ( "github.com/go-chi/chi/v5" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/validator" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/validator" ) // NewModule creates a new Radius module. diff --git a/pkg/ucp/frontend/radius/routes.go b/pkg/ucp/frontend/radius/routes.go index 8d9dfcf60d..294e12eb9e 100644 --- a/pkg/ucp/frontend/radius/routes.go +++ b/pkg/ucp/frontend/radius/routes.go @@ -20,16 +20,16 @@ import ( "context" "net/http" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/frontend/controller" - "github.com/project-radius/radius/pkg/armrpc/frontend/defaultoperation" - "github.com/project-radius/radius/pkg/armrpc/frontend/server" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/datamodel" - "github.com/project-radius/radius/pkg/ucp/datamodel/converter" - planes_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/planes" - resourcegroups_ctrl "github.com/project-radius/radius/pkg/ucp/frontend/controller/resourcegroups" - "github.com/project-radius/radius/pkg/validator" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/datamodel" + "github.com/radius-project/radius/pkg/ucp/datamodel/converter" + planes_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/planes" + resourcegroups_ctrl "github.com/radius-project/radius/pkg/ucp/frontend/controller/resourcegroups" + "github.com/radius-project/radius/pkg/validator" ) const ( @@ -99,23 +99,32 @@ func (m *Module) Initialize(ctx context.Context) (http.Handler, error) { ) }, }, + { + ParentRouter: resourceGroupResourceRouter, + ResourceType: v20220901privatepreview.ResourceType, + Path: "/resources", + Method: v1.OperationList, + ControllerFactory: func(opt controller.Options) (controller.Controller, error) { + return resourcegroups_ctrl.NewListResources(opt) + }, + }, // Chi router uses radix tree so that it doesn't linear search the matched one. So, to catch all requests, // we need to use CatchAllPath(/*) at the above matched routes path in chi router. // // Note that the API validation is not applied for CatchAllPath(/*). { - // Proxy request should use CatchAllPath(/*) to process all requests under /planes/azure/{planeName}/resourcegroups/{resourceGroupName}. + // Proxy request should use CatchAllPath(/*) to process all requests under /planes/radius/{planeName}/resourcegroups/{resourceGroupName}. ParentRouter: resourceGroupResourceRouter, Path: server.CatchAllPath, OperationType: &v1.OperationType{Type: OperationTypeUCPRadiusProxy, Method: v1.OperationProxy}, - ControllerFactory: planes_ctrl.NewProxyPlane, + ControllerFactory: planes_ctrl.NewProxyController, }, { - // Proxy request should use CatchAllPath(/*) to process all requests under /planes/azure/{planeName}/. + // Proxy request should use CatchAllPath(/*) to process all requests under /planes/radius/{planeName}/. ParentRouter: baseRouter, Path: server.CatchAllPath, OperationType: &v1.OperationType{Type: OperationTypeUCPRadiusProxy, Method: v1.OperationProxy}, - ControllerFactory: planes_ctrl.NewProxyPlane, + ControllerFactory: planes_ctrl.NewProxyController, }, } diff --git a/pkg/ucp/frontend/radius/routes_test.go b/pkg/ucp/frontend/radius/routes_test.go index 9f62a3fad8..5e3fd67667 100644 --- a/pkg/ucp/frontend/radius/routes_test.go +++ b/pkg/ucp/frontend/radius/routes_test.go @@ -23,14 +23,14 @@ import ( "github.com/go-chi/chi/v5" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - "github.com/project-radius/radius/pkg/ucp/secret" - secretprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + "github.com/radius-project/radius/pkg/ucp/secret" + secretprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" ) const pathBase = "/some-path-base" diff --git a/pkg/ucp/hosting/asyncvalue_test.go b/pkg/ucp/hosting/asyncvalue_test.go index a0dd17787c..ec19d4fbe8 100644 --- a/pkg/ucp/hosting/asyncvalue_test.go +++ b/pkg/ucp/hosting/asyncvalue_test.go @@ -23,7 +23,7 @@ import ( "testing" "time" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/hosting/hosting_test.go b/pkg/ucp/hosting/hosting_test.go index c6421b3e88..ceba912aac 100644 --- a/pkg/ucp/hosting/hosting_test.go +++ b/pkg/ucp/hosting/hosting_test.go @@ -22,7 +22,7 @@ import ( "testing" "time" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/hostoptions/hostoptions.go b/pkg/ucp/hostoptions/hostoptions.go index 2a8be883a8..de4605bc3f 100644 --- a/pkg/ucp/hostoptions/hostoptions.go +++ b/pkg/ucp/hostoptions/hostoptions.go @@ -24,7 +24,7 @@ import ( "fmt" "os" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" "gopkg.in/yaml.v3" ) diff --git a/pkg/ucp/hostoptions/providerconfig.go b/pkg/ucp/hostoptions/providerconfig.go index bcfce99972..40907d7082 100644 --- a/pkg/ucp/hostoptions/providerconfig.go +++ b/pkg/ucp/hostoptions/providerconfig.go @@ -17,15 +17,15 @@ limitations under the License. package hostoptions import ( - metricsprovider "github.com/project-radius/radius/pkg/metrics/provider" - profilerprovider "github.com/project-radius/radius/pkg/profiler/provider" - "github.com/project-radius/radius/pkg/trace" - "github.com/project-radius/radius/pkg/ucp/config" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - qprovider "github.com/project-radius/radius/pkg/ucp/queue/provider" - "github.com/project-radius/radius/pkg/ucp/rest" - "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + metricsprovider "github.com/radius-project/radius/pkg/metrics/provider" + profilerprovider "github.com/radius-project/radius/pkg/profiler/provider" + "github.com/radius-project/radius/pkg/trace" + "github.com/radius-project/radius/pkg/ucp/config" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + qprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + "github.com/radius-project/radius/pkg/ucp/rest" + "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) // UCPConfig includes the resource provider configuration. diff --git a/pkg/ucp/integrationtests/aws/awstest.go b/pkg/ucp/integrationtests/aws/awstest.go index 01b85b2cfa..4676b23524 100644 --- a/pkg/ucp/integrationtests/aws/awstest.go +++ b/pkg/ucp/integrationtests/aws/awstest.go @@ -22,12 +22,12 @@ import ( "testing" "github.com/golang/mock/gomock" - ucp_aws "github.com/project-radius/radius/pkg/ucp/aws" - ucp_aws_frontend "github.com/project-radius/radius/pkg/ucp/frontend/aws" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/store" + ucp_aws "github.com/radius-project/radius/pkg/ucp/aws" + ucp_aws_frontend "github.com/radius-project/radius/pkg/ucp/frontend/aws" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/store" ) const ( @@ -43,12 +43,12 @@ func initializeAWSTest(t *testing.T) (*testserver.TestServer, *store.MockStorage cloudControlClient := ucp_aws.NewMockAWSCloudControlClient(ctrl) cloudFormationClient := ucp_aws.NewMockAWSCloudFormationClient(ctrl) - ucp, storeClient, secretClient := testserver.StartWithMocks(t, func(options modules.Options) []modules.Initializer { + ucp := testserver.StartWithMocks(t, func(options modules.Options) []modules.Initializer { module := ucp_aws_frontend.NewModule(options) module.AWSClients.CloudControl = cloudControlClient module.AWSClients.CloudFormation = cloudFormationClient return []modules.Initializer{module} }) - return ucp, storeClient, secretClient, cloudControlClient, cloudFormationClient + return ucp, ucp.Mocks.Storage, ucp.Mocks.Secrets, cloudControlClient, cloudFormationClient } diff --git a/pkg/ucp/integrationtests/aws/createresource_test.go b/pkg/ucp/integrationtests/aws/createresource_test.go index fda10e61b6..408291cda7 100644 --- a/pkg/ucp/integrationtests/aws/createresource_test.go +++ b/pkg/ucp/integrationtests/aws/createresource_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" diff --git a/pkg/ucp/integrationtests/aws/createresourcewithpost_test.go b/pkg/ucp/integrationtests/aws/createresourcewithpost_test.go index 6cc932b60a..6d4c21e209 100644 --- a/pkg/ucp/integrationtests/aws/createresourcewithpost_test.go +++ b/pkg/ucp/integrationtests/aws/createresourcewithpost_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" diff --git a/pkg/ucp/integrationtests/aws/deleteresource_test.go b/pkg/ucp/integrationtests/aws/deleteresource_test.go index fb978fe189..745dba5d2c 100644 --- a/pkg/ucp/integrationtests/aws/deleteresource_test.go +++ b/pkg/ucp/integrationtests/aws/deleteresource_test.go @@ -23,8 +23,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" diff --git a/pkg/ucp/integrationtests/aws/deleteresourcewithpost_test.go b/pkg/ucp/integrationtests/aws/deleteresourcewithpost_test.go index bf5d3e7d82..fa26fa2495 100644 --- a/pkg/ucp/integrationtests/aws/deleteresourcewithpost_test.go +++ b/pkg/ucp/integrationtests/aws/deleteresourcewithpost_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" diff --git a/pkg/ucp/integrationtests/aws/getresource_test.go b/pkg/ucp/integrationtests/aws/getresource_test.go index 833a79b007..e959e5b9e4 100644 --- a/pkg/ucp/integrationtests/aws/getresource_test.go +++ b/pkg/ucp/integrationtests/aws/getresource_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" diff --git a/pkg/ucp/integrationtests/aws/getresourcewithpost_test.go b/pkg/ucp/integrationtests/aws/getresourcewithpost_test.go index 73a2febc07..ece49560d6 100644 --- a/pkg/ucp/integrationtests/aws/getresourcewithpost_test.go +++ b/pkg/ucp/integrationtests/aws/getresourcewithpost_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" diff --git a/pkg/ucp/integrationtests/aws/listresources_test.go b/pkg/ucp/integrationtests/aws/listresources_test.go index cf7b762da8..43455f5f4f 100644 --- a/pkg/ucp/integrationtests/aws/listresources_test.go +++ b/pkg/ucp/integrationtests/aws/listresources_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" diff --git a/pkg/ucp/integrationtests/aws/operationresults_test.go b/pkg/ucp/integrationtests/aws/operationresults_test.go index ed532c65ef..933329b1a2 100644 --- a/pkg/ucp/integrationtests/aws/operationresults_test.go +++ b/pkg/ucp/integrationtests/aws/operationresults_test.go @@ -24,8 +24,8 @@ import ( "strings" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" diff --git a/pkg/ucp/integrationtests/aws/operationstatuses_test.go b/pkg/ucp/integrationtests/aws/operationstatuses_test.go index 96d2d2b519..17ee212563 100644 --- a/pkg/ucp/integrationtests/aws/operationstatuses_test.go +++ b/pkg/ucp/integrationtests/aws/operationstatuses_test.go @@ -25,8 +25,8 @@ import ( "testing" "time" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types" diff --git a/pkg/ucp/integrationtests/aws/updateresource_test.go b/pkg/ucp/integrationtests/aws/updateresource_test.go index f00f95f42c..4d8e7724ea 100644 --- a/pkg/ucp/integrationtests/aws/updateresource_test.go +++ b/pkg/ucp/integrationtests/aws/updateresource_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" diff --git a/pkg/ucp/integrationtests/aws/updateresourcewithpost_test.go b/pkg/ucp/integrationtests/aws/updateresourcewithpost_test.go index 3c32b2ee66..5b690bfdcf 100644 --- a/pkg/ucp/integrationtests/aws/updateresourcewithpost_test.go +++ b/pkg/ucp/integrationtests/aws/updateresourcewithpost_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" diff --git a/pkg/ucp/integrationtests/azure/proxy_test.go b/pkg/ucp/integrationtests/azure/proxy_test.go index 8921a578fc..69a5a327df 100644 --- a/pkg/ucp/integrationtests/azure/proxy_test.go +++ b/pkg/ucp/integrationtests/azure/proxy_test.go @@ -22,12 +22,12 @@ import ( "strings" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testrp" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testrp" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/integrationtests/handler_test.go b/pkg/ucp/integrationtests/handler_test.go index 703dc4015e..4046735a96 100644 --- a/pkg/ucp/integrationtests/handler_test.go +++ b/pkg/ucp/integrationtests/handler_test.go @@ -20,20 +20,20 @@ import ( "net/http" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" "github.com/stretchr/testify/require" ) func Test_Handler_MethodNotAllowed(t *testing.T) { - ucp, _, _ := testserver.StartWithMocks(t, testserver.NoModules) + ucp := testserver.StartWithMocks(t, testserver.NoModules) response := ucp.MakeRequest(http.MethodDelete, "/planes?api-version=2022-09-01-privatepreview", nil) require.Equal(t, "failed to parse route: undefined route path", response.Error.Error.Details[0].Message) } func Test_Handler_NotFound(t *testing.T) { - ucp, _, _ := testserver.StartWithMocks(t, testserver.NoModules) + ucp := testserver.StartWithMocks(t, testserver.NoModules) response := ucp.MakeRequest(http.MethodGet, "/abc", nil) response.EqualsErrorCode(http.StatusNotFound, v1.CodeNotFound) diff --git a/pkg/ucp/integrationtests/planes/aws_test.go b/pkg/ucp/integrationtests/planes/aws_test.go index 82364cb275..c4e1582927 100644 --- a/pkg/ucp/integrationtests/planes/aws_test.go +++ b/pkg/ucp/integrationtests/planes/aws_test.go @@ -19,9 +19,9 @@ package planes import ( "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" ) const ( @@ -73,7 +73,7 @@ func Test_AWSPlane_GET_Found(t *testing.T) { } func Test_AWSPlane_LIST(t *testing.T) { - t.Skip("This functionality is currently broken. See https://github.com/project-radius/radius/issues/4878") + t.Skip("This functionality is currently broken. See https://github.com/radius-project/radius/issues/4878") server := testserver.StartWithETCD(t, api.DefaultModules) defer server.Close() diff --git a/pkg/ucp/integrationtests/planes/planes_test.go b/pkg/ucp/integrationtests/planes/planes_test.go index a9b09298d1..913b6144e4 100644 --- a/pkg/ucp/integrationtests/planes/planes_test.go +++ b/pkg/ucp/integrationtests/planes/planes_test.go @@ -19,8 +19,8 @@ package planes import ( "testing" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" ) const ( diff --git a/pkg/ucp/integrationtests/planes/radius_test.go b/pkg/ucp/integrationtests/planes/radius_test.go index b2f75b9cfc..52f5738f4b 100644 --- a/pkg/ucp/integrationtests/planes/radius_test.go +++ b/pkg/ucp/integrationtests/planes/radius_test.go @@ -19,9 +19,9 @@ package planes import ( "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" ) const ( diff --git a/pkg/ucp/integrationtests/planes/validation_test.go b/pkg/ucp/integrationtests/planes/validation_test.go index 2ee8df7f73..8a864be18c 100644 --- a/pkg/ucp/integrationtests/planes/validation_test.go +++ b/pkg/ucp/integrationtests/planes/validation_test.go @@ -20,11 +20,11 @@ import ( "net/http" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" "github.com/stretchr/testify/require" ) @@ -33,7 +33,7 @@ const ( ) func Test_Planes_GET_BadAPIVersion(t *testing.T) { - ucp, _, _ := testserver.StartWithMocks(t, api.DefaultModules) + ucp := testserver.StartWithMocks(t, api.DefaultModules) response := ucp.MakeRequest(http.MethodGet, "/planes?api-version=unsupported-version", nil) response.EqualsErrorCode(http.StatusBadRequest, v1.CodeInvalidApiVersionParameter) @@ -41,7 +41,7 @@ func Test_Planes_GET_BadAPIVersion(t *testing.T) { } func Test_Planes_PUT_BadAPIVersion(t *testing.T) { - ucp, _, _ := testserver.StartWithMocks(t, api.DefaultModules) + ucp := testserver.StartWithMocks(t, api.DefaultModules) requestBody := v20220901privatepreview.PlaneResource{ Location: to.Ptr(v1.LocationGlobal), diff --git a/pkg/ucp/integrationtests/radius/proxy_test.go b/pkg/ucp/integrationtests/radius/proxy_test.go index e2306ce835..96e45980d4 100644 --- a/pkg/ucp/integrationtests/radius/proxy_test.go +++ b/pkg/ucp/integrationtests/radius/proxy_test.go @@ -17,26 +17,31 @@ limitations under the License. package radius import ( + "context" "encoding/json" "net/http" "strings" "testing" + "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testrp" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + backend_ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/to" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testrp" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) const ( - apiVersionParameter = "api-version=2022-09-01-privatepreview" - testRadiusPlaneID = "/planes/radius/test" - testResourceNamespace = "Applications.Test" - testResourceGroupID = testRadiusPlaneID + "/resourceGroups/test-rg" - testResourceID = testResourceGroupID + "/providers/Applications.Test/testResources/test-resource" + apiVersionParameter = "api-version=2022-09-01-privatepreview" + testRadiusPlaneID = "/planes/radius/test" + testResourceNamespace = "System.Test" + testResourceGroupID = testRadiusPlaneID + "/resourceGroups/test-rg" + testResourceCollectionID = testResourceGroupID + "/providers/System.Test/testResources" + testResourceID = testResourceCollectionID + "/test-resource" ) func Test_RadiusPlane_Proxy_ResourceGroupDoesNotExist(t *testing.T) { @@ -50,27 +55,104 @@ func Test_RadiusPlane_Proxy_ResourceGroupDoesNotExist(t *testing.T) { response := ucp.MakeRequest(http.MethodGet, testResourceID, nil) response.EqualsErrorCode(http.StatusNotFound, "NotFound") - require.Equal(t, "the resource with id '/planes/radius/test/resourceGroups/test-rg/providers/Applications.Test/testResources/test-resource' was not found", response.Error.Error.Message) + require.Equal(t, "the resource with id '/planes/radius/test/resourceGroups/test-rg/providers/System.Test/testResources/test-resource' was not found", response.Error.Error.Message) } -func Test_RadiusPlane_Proxy_Success(t *testing.T) { +func Test_RadiusPlane_ResourceSync(t *testing.T) { ucp := testserver.StartWithETCD(t, api.DefaultModules) rp := testrp.Start(t) + rp.Handler = testrp.SyncResource(t, ucp, testResourceGroupID) - data := map[string]string{ - "message": "here is some test data", + rps := map[string]*string{ + testResourceNamespace: to.Ptr("http://" + rp.Address()), + } + createRadiusPlane(ucp, rps) + + createResourceGroup(ucp, testResourceGroupID) + + message := "here is some test data" + + t.Run("PUT", func(t *testing.T) { + data := testrp.TestResource{ + Properties: testrp.TestResourceProperties{ + Message: to.Ptr(message), + }, + } + body, err := json.Marshal(data) + require.NoError(t, err) + + response := ucp.MakeRequest(http.MethodPut, testResourceID+"?api-version="+testrp.Version, body) + response.EqualsStatusCode(http.StatusOK) + + resource := &testrp.TestResource{} + err = json.Unmarshal(response.Body.Bytes(), resource) + require.NoError(t, err) + require.Equal(t, message, *resource.Properties.Message) + }) + + t.Run("LIST", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceCollectionID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusOK) + + resources := &testrp.TestResourceList{} + err := json.Unmarshal(response.Body.Bytes(), resources) + require.NoError(t, err) + require.Len(t, resources.Value, 1) + require.Equal(t, message, *resources.Value[0].Properties.Message) + }) + + t.Run("GET", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusOK) + + resource := &testrp.TestResource{} + err := json.Unmarshal(response.Body.Bytes(), resource) + require.NoError(t, err) + require.Equal(t, message, *resource.Properties.Message) + }) + + t.Run("DELETE", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodDelete, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusOK) + }) + + t.Run("GET (after delete)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusNotFound) + }) + + t.Run("DELETE (again)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodDelete, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusNoContent) + }) +} + +func Test_RadiusPlane_ResourceAsync(t *testing.T) { + ucp := testserver.StartWithETCD(t, api.DefaultModules) + rp := testrp.Start(t) + + // Block background work item completion until we're ready. + putCh := make(chan struct{}) + deleteCh := make(chan struct{}) + onPut := func(ctx context.Context, request *backend_ctrl.Request) (backend_ctrl.Result, error) { + t.Log("PUT operation is waiting for completion") + <-putCh + return backend_ctrl.Result{}, nil } - body, err := json.Marshal(data) - require.NoError(t, err) - - rp.Handler = func(w http.ResponseWriter, r *http.Request) { - require.Equal(t, strings.ToLower(testResourceID), strings.ToLower(r.URL.Path)) - w.Header().Add("Content-Type", "application/json") - w.Header().Add("SomeHeader", "SomeValue") - w.WriteHeader(http.StatusOK) - _, err = w.Write(body) + onDelete := func(ctx context.Context, request *backend_ctrl.Request) (backend_ctrl.Result, error) { + t.Log("DELETE operation is waiting for completion") + <-deleteCh + + client, err := ucp.Clients.StorageProvider.GetStorageClient(ctx, "System.Test/testResources") + require.NoError(t, err) + err = client.Delete(ctx, testResourceID) + require.NoError(t, err) + + return backend_ctrl.Result{}, nil } + rp.Handler = testrp.AsyncResource(t, ucp, testResourceGroupID, onPut, onDelete) + rps := map[string]*string{ testResourceNamespace: to.Ptr("http://" + rp.Address()), } @@ -78,9 +160,113 @@ func Test_RadiusPlane_Proxy_Success(t *testing.T) { createResourceGroup(ucp, testResourceGroupID) - response := ucp.MakeRequest(http.MethodGet, testResourceID, nil) - response.EqualsResponse(http.StatusOK, body) - require.Equal(t, "SomeValue", response.Raw.Header.Get("SomeHeader")) + message := "here is some test data" + + t.Run("PUT", func(t *testing.T) { + data := testrp.TestResource{ + Properties: testrp.TestResourceProperties{ + Message: to.Ptr(message), + }, + } + body, err := json.Marshal(data) + require.NoError(t, err) + + response := ucp.MakeRequest(http.MethodPut, testResourceID+"?api-version="+testrp.Version, body) + response.EqualsStatusCode(http.StatusCreated) + + resource := &testrp.TestResource{} + err = json.Unmarshal(response.Body.Bytes(), resource) + require.NoError(t, err) + require.Equal(t, message, *resource.Properties.Message) + require.Equal(t, string(v1.ProvisioningStateAccepted), *resource.Properties.ProvisioningState) + + location := response.Raw.Header.Get("Location") + azureAsyncOperation := response.Raw.Header.Get("Azure-AsyncOperation") + require.True(t, strings.HasPrefix(location, ucp.BaseURL), "Location starts with UCP URL") + require.True(t, strings.HasPrefix(azureAsyncOperation, ucp.BaseURL), "Azure-AsyncOperation starts with UCP URL") + }) + + t.Run("LIST (during PUT)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceCollectionID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusOK) + + resources := &testrp.TestResourceList{} + err := json.Unmarshal(response.Body.Bytes(), resources) + require.NoError(t, err) + require.Len(t, resources.Value, 1) + require.Equal(t, message, *resources.Value[0].Properties.Message) + require.Equal(t, string(v1.ProvisioningStateAccepted), *resources.Value[0].Properties.ProvisioningState) + }) + + t.Run("GET (during PUT)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusOK) + + resource := &testrp.TestResource{} + err := json.Unmarshal(response.Body.Bytes(), resource) + require.NoError(t, err) + require.Equal(t, message, *resource.Properties.Message) + require.Equal(t, string(v1.ProvisioningStateAccepted), *resource.Properties.ProvisioningState) + }) + + t.Run("Complete PUT", func(t *testing.T) { + putCh <- struct{}{} + require.EventuallyWithT(t, func(collect *assert.CollectT) { + response := ucp.MakeRequest(http.MethodGet, testResourceID+"?api-version="+testrp.Version, nil) + assert.Equal(collect, http.StatusOK, response.Raw.StatusCode) + + resource := &testrp.TestResource{} + err := json.Unmarshal(response.Body.Bytes(), resource) + assert.NoError(collect, err) + assert.Equal(collect, string(v1.ProvisioningStateSucceeded), *resource.Properties.ProvisioningState) + }, time.Second*5, time.Millisecond*100) + }) + + t.Run("DELETE", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodDelete, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusAccepted) + }) + + t.Run("LIST (during delete)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceCollectionID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusOK) + + resources := &testrp.TestResourceList{} + err := json.Unmarshal(response.Body.Bytes(), resources) + require.NoError(t, err) + require.Len(t, resources.Value, 1) + require.Equal(t, message, *resources.Value[0].Properties.Message) + require.Equal(t, string(v1.ProvisioningStateAccepted), *resources.Value[0].Properties.ProvisioningState) + }) + + t.Run("GET (during delete)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusOK) + + resource := &testrp.TestResource{} + err := json.Unmarshal(response.Body.Bytes(), resource) + require.NoError(t, err) + require.Equal(t, message, *resource.Properties.Message) + require.Equal(t, string(v1.ProvisioningStateAccepted), *resource.Properties.ProvisioningState) + }) + + t.Run("Complete DELETE", func(t *testing.T) { + deleteCh <- struct{}{} + require.EventuallyWithT(t, func(collect *assert.CollectT) { + response := ucp.MakeRequest(http.MethodGet, testResourceID+"?api-version="+testrp.Version, nil) + assert.Equal(collect, http.StatusNotFound, response.Raw.StatusCode) + }, time.Second*5, time.Millisecond*100) + }) + + t.Run("GET (after delete)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodGet, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusNotFound) + }) + + t.Run("DELETE (again)", func(t *testing.T) { + response := ucp.MakeRequest(http.MethodDelete, testResourceID+"?api-version="+testrp.Version, nil) + response.EqualsStatusCode(http.StatusNoContent) + }) } func createRadiusPlane(ucp *testserver.TestServer, resourceProviders map[string]*string) { @@ -98,7 +284,7 @@ func createRadiusPlane(ucp *testserver.TestServer, resourceProviders map[string] func createResourceGroup(ucp *testserver.TestServer, id string) { body := v20220901privatepreview.ResourceGroupResource{ Location: to.Ptr(v1.LocationGlobal), - Properties: &v20220901privatepreview.BasicResourceProperties{}, + Properties: &v20220901privatepreview.ResourceGroupProperties{}, } response := ucp.MakeTypedRequest(http.MethodPut, id+"?"+apiVersionParameter, body) response.EqualsStatusCode(http.StatusOK) diff --git a/pkg/ucp/integrationtests/resourcegroups/resourcegroups_test.go b/pkg/ucp/integrationtests/resourcegroups/resourcegroups_test.go index 8cab5009e6..f8fd723122 100644 --- a/pkg/ucp/integrationtests/resourcegroups/resourcegroups_test.go +++ b/pkg/ucp/integrationtests/resourcegroups/resourcegroups_test.go @@ -19,9 +19,9 @@ package resourcegroups import ( "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/integrationtests/testserver" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" ) const ( diff --git a/pkg/ucp/integrationtests/testrp/async.go b/pkg/ucp/integrationtests/testrp/async.go new file mode 100644 index 0000000000..4723b359e6 --- /dev/null +++ b/pkg/ucp/integrationtests/testrp/async.go @@ -0,0 +1,156 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testrp + +import ( + "context" + "net/http" + "strings" + "testing" + + "github.com/go-chi/chi/v5" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + backend_ctrl "github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/statusmanager" + "github.com/radius-project/radius/pkg/armrpc/asyncoperation/worker" + frontend_ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/armrpc/servicecontext" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" + "github.com/radius-project/radius/test/testcontext" + "github.com/stretchr/testify/require" +) + +type BackendFunc func(ctx context.Context, request *backend_ctrl.Request) (backend_ctrl.Result, error) + +type BackendFuncController struct { + backend_ctrl.BaseController + Func BackendFunc +} + +func (b *BackendFuncController) Run(ctx context.Context, request *backend_ctrl.Request) (backend_ctrl.Result, error) { + return b.Func(ctx, request) +} + +// AsyncResource creates an HTTP handler that can be used to test asynchronous resource lifecycle operations. +func AsyncResource(t *testing.T, ts *testserver.TestServer, rootScope string, put BackendFunc, delete BackendFunc) func(w http.ResponseWriter, r *http.Request) { + rootScope = strings.ToLower(rootScope) + + ctx := testcontext.New(t) + r := chi.NewRouter() + r.Use(servicecontext.ARMRequestCtx("", v1.LocationGlobal), middleware.LowercaseURLPath) + + resourceType := "System.Test/testResources" + + queueClient, err := ts.Clients.QueueProvider.GetClient(ctx) + require.NoError(t, err) + + statusManager := statusmanager.New(ts.Clients.StorageProvider, queueClient, v1.LocationGlobal) + + backendOpts := backend_ctrl.Options{ + DataProvider: ts.Clients.StorageProvider, + } + + registry := worker.NewControllerRegistry(ts.Clients.StorageProvider) + err = registry.Register(ctx, resourceType, v1.OperationPut, func(opts backend_ctrl.Options) (backend_ctrl.Controller, error) { + return &BackendFuncController{BaseController: backend_ctrl.NewBaseAsyncController(opts), Func: put}, nil + }, backendOpts) + require.NoError(t, err) + + err = registry.Register(ctx, resourceType, v1.OperationDelete, func(opts backend_ctrl.Options) (backend_ctrl.Controller, error) { + return &BackendFuncController{BaseController: backend_ctrl.NewBaseAsyncController(opts), Func: delete}, nil + }, backendOpts) + require.NoError(t, err) + + workerContext, cancel := testcontext.NewWithCancel(t) + t.Cleanup(cancel) + + w := worker.New(worker.Options{}, statusManager, queueClient, registry) + go func() { + err = w.Start(workerContext) + require.NoError(t, err) + }() + + frontendOpts := frontend_ctrl.Options{ + DataProvider: ts.Clients.StorageProvider, + StatusManager: statusManager, + } + + err = server.ConfigureDefaultHandlers(ctx, r, rootScope, false, "System.Test", nil, frontendOpts) + require.NoError(t, err) + + rootScopeRouter := server.NewSubrouter(r, rootScope) + testResourceCollectionRouter := server.NewSubrouter(rootScopeRouter, "/providers/system.test/testresources") + testResourceSingleRouter := server.NewSubrouter(rootScopeRouter, "/providers/system.test/testresources/{testResourceName}") + + resourceOptions := frontend_ctrl.ResourceOptions[TestResourceDatamodel]{ + RequestConverter: TestResourceDataModelFromVersioned, + ResponseConverter: TestResourceDataModelToVersioned, + } + + handlerOptions := []server.HandlerOptions{ + { + ParentRouter: testResourceCollectionRouter, + ResourceType: resourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncPut(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultAsyncDelete(opt, resourceOptions) + }, + }, + } + + for _, h := range handlerOptions { + err := server.RegisterHandler(ctx, h, frontendOpts) + require.NoError(t, err) + } + + return r.ServeHTTP +} diff --git a/pkg/ucp/integrationtests/testrp/converter.go b/pkg/ucp/integrationtests/testrp/converter.go new file mode 100644 index 0000000000..656b9394db --- /dev/null +++ b/pkg/ucp/integrationtests/testrp/converter.go @@ -0,0 +1,103 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testrp + +import ( + "encoding/json" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" +) + +// TestResourceDataModelToVersioned converts version agnostic TestResource datamodel to versioned model. +func TestResourceDataModelToVersioned(model *TestResourceDatamodel, version string) (v1.VersionedModelInterface, error) { + switch version { + case Version: + versioned := &TestResource{} + if err := versioned.ConvertFrom(model); err != nil { + return nil, err + } + return versioned, nil + + default: + return nil, v1.ErrUnsupportedAPIVersion + } +} + +// TestResourceDataModelFromVersioned converts versioned TestResource model to datamodel. +func TestResourceDataModelFromVersioned(content []byte, version string) (*TestResourceDatamodel, error) { + switch version { + case Version: + am := &TestResource{} + if err := json.Unmarshal(content, am); err != nil { + return nil, err + } + dm, err := am.ConvertTo() + if err != nil { + return nil, err + } + return dm.(*TestResourceDatamodel), nil + + default: + return nil, v1.ErrUnsupportedAPIVersion + } +} + +func (src *TestResource) ConvertTo() (v1.DataModelInterface, error) { + // Note: SystemData conversion isn't required since this property comes ARM and datastore. + + converted := &TestResourceDatamodel{ + BaseResource: v1.BaseResource{ + TrackedResource: v1.TrackedResource{ + ID: to.String(src.ID), + Name: to.String(src.Name), + Type: to.String(src.Type), + Location: to.String(src.Location), + Tags: to.StringMap(src.Tags), + }, + InternalMetadata: v1.InternalMetadata{ + CreatedAPIVersion: Version, + UpdatedAPIVersion: Version, + }, + }, + Properties: TestResourceDatamodelProperties{ + Message: src.Properties.Message, + }, + } + + return converted, nil +} + +// ConvertFrom converts from version-agnostic datamodel to the versioned TestResource resource. +func (dst *TestResource) ConvertFrom(src v1.DataModelInterface) error { + tr, ok := src.(*TestResourceDatamodel) + if !ok { + return v1.ErrInvalidModelConversion + } + + dst.ID = to.Ptr(tr.ID) + dst.Name = to.Ptr(tr.Name) + dst.Type = to.Ptr(tr.Type) + dst.Location = to.Ptr(tr.Location) + dst.Tags = *to.StringMapPtr(tr.Tags) + dst.Properties = TestResourceProperties{ + Message: tr.Properties.Message, + ProvisioningState: to.Ptr[string](string(tr.InternalMetadata.AsyncProvisioningState)), + } + + return nil +} diff --git a/pkg/ucp/integrationtests/testrp/datamodel.go b/pkg/ucp/integrationtests/testrp/datamodel.go new file mode 100644 index 0000000000..b8bf099ef7 --- /dev/null +++ b/pkg/ucp/integrationtests/testrp/datamodel.go @@ -0,0 +1,28 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testrp + +import v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + +type TestResourceDatamodel struct { + v1.BaseResource + Properties TestResourceDatamodelProperties `json:"properties"` +} + +type TestResourceDatamodelProperties struct { + Message *string `json:"message,omitempty"` +} diff --git a/pkg/ucp/integrationtests/testrp/resource.go b/pkg/ucp/integrationtests/testrp/resource.go new file mode 100644 index 0000000000..f244bb1a61 --- /dev/null +++ b/pkg/ucp/integrationtests/testrp/resource.go @@ -0,0 +1,37 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testrp + +const Version = "2022-03-15-privatepreview" + +type TestResourceList struct { + Value []TestResource `json:"value"` +} + +type TestResource struct { + ID *string `json:"id"` + Type *string `json:"type"` + Name *string `json:"name"` + Location *string `json:"location"` + Tags map[string]*string + Properties TestResourceProperties `json:"properties,omitempty"` +} + +type TestResourceProperties struct { + Message *string `json:"message,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/pkg/ucp/integrationtests/testrp/sync.go b/pkg/ucp/integrationtests/testrp/sync.go new file mode 100644 index 0000000000..53ca8b4438 --- /dev/null +++ b/pkg/ucp/integrationtests/testrp/sync.go @@ -0,0 +1,110 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testrp + +import ( + "net/http" + "strings" + "testing" + + "github.com/go-chi/chi/v5" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + frontend_ctrl "github.com/radius-project/radius/pkg/armrpc/frontend/controller" + "github.com/radius-project/radius/pkg/armrpc/frontend/defaultoperation" + "github.com/radius-project/radius/pkg/armrpc/frontend/server" + "github.com/radius-project/radius/pkg/armrpc/servicecontext" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/ucp/integrationtests/testserver" + "github.com/radius-project/radius/test/testcontext" + "github.com/stretchr/testify/require" +) + +// SyncResource creates an HTTP handler that can be used to test synchronous resource lifecycle operations. +func SyncResource(t *testing.T, ts *testserver.TestServer, rootScope string) func(w http.ResponseWriter, r *http.Request) { + rootScope = strings.ToLower(rootScope) + + ctx := testcontext.New(t) + r := chi.NewRouter() + r.Use(servicecontext.ARMRequestCtx("", v1.LocationGlobal), middleware.LowercaseURLPath) + + ctrlOpts := frontend_ctrl.Options{ + DataProvider: ts.Clients.StorageProvider, + } + + err := server.ConfigureDefaultHandlers(ctx, r, rootScope, false, "System.Test", nil, ctrlOpts) + require.NoError(t, err) + + resourceType := "System.Test/testResources" + rootScopeRouter := server.NewSubrouter(r, rootScope) + testResourceCollectionRouter := server.NewSubrouter(rootScopeRouter, "/providers/system.test/testresources") + testResourceSingleRouter := server.NewSubrouter(rootScopeRouter, "/providers/system.test/testresources/{testResourceName}") + + resourceOptions := frontend_ctrl.ResourceOptions[TestResourceDatamodel]{ + RequestConverter: TestResourceDataModelFromVersioned, + ResponseConverter: TestResourceDataModelToVersioned, + } + + handlerOptions := []server.HandlerOptions{ + { + ParentRouter: testResourceCollectionRouter, + ResourceType: resourceType, + Method: v1.OperationList, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewListResources(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationGet, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewGetResource(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationPut, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultSyncPut(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationPatch, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultSyncPut(opt, resourceOptions) + }, + }, + { + ParentRouter: testResourceSingleRouter, + ResourceType: resourceType, + Method: v1.OperationDelete, + ControllerFactory: func(opt frontend_ctrl.Options) (frontend_ctrl.Controller, error) { + return defaultoperation.NewDefaultSyncDelete(opt, resourceOptions) + }, + }, + } + + for _, h := range handlerOptions { + err := server.RegisterHandler(ctx, h, ctrlOpts) + require.NoError(t, err) + } + + return r.ServeHTTP +} diff --git a/pkg/ucp/integrationtests/testserver/testserver.go b/pkg/ucp/integrationtests/testserver/testserver.go index fb1ba305af..ecc862d00e 100644 --- a/pkg/ucp/integrationtests/testserver/testserver.go +++ b/pkg/ucp/integrationtests/testserver/testserver.go @@ -36,22 +36,24 @@ import ( "github.com/stretchr/testify/require" etcdclient "go.etcd.io/etcd/client/v3" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rpctest" - "github.com/project-radius/radius/pkg/armrpc/servicecontext" - "github.com/project-radius/radius/pkg/middleware" - "github.com/project-radius/radius/pkg/ucp/data" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/frontend/modules" - "github.com/project-radius/radius/pkg/ucp/hosting" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - "github.com/project-radius/radius/pkg/ucp/secret" - secretprovider "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/validator" - "github.com/project-radius/radius/swagger" - "github.com/project-radius/radius/test/testcontext" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rpctest" + "github.com/radius-project/radius/pkg/armrpc/servicecontext" + "github.com/radius-project/radius/pkg/middleware" + "github.com/radius-project/radius/pkg/ucp/data" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/frontend/modules" + "github.com/radius-project/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" + queueprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + "github.com/radius-project/radius/pkg/ucp/secret" + secretprovider "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/validator" + "github.com/radius-project/radius/swagger" + "github.com/radius-project/radius/test/testcontext" ) // NoModules can be used to start a test server without any modules. This is useful for testing the server itself and core functionality @@ -68,6 +70,13 @@ type TestServer struct { // BaseURL is the base URL of the server, including the path base. BaseURL string + // Clients gets access to the clients created by TestServer regardless of whether + // they are mocks. + Clients *TestServerClients + + // Mocks gets access to the mock clients. Will be nil if StartWithETCD is used. + Mocks *TestServerMocks + // Server provides access to the test HTTP server. Server *httptest.Server @@ -79,6 +88,27 @@ type TestServer struct { shutdown sync.Once } +// TestServerClients provides access to the clients created by the TestServer. +type TestServerClients struct { + // QueueProvider is the queue client provider. + QueueProvider *queueprovider.QueueProvider + + // SecretProvider is the secret client provider. + SecretProvider *secretprovider.SecretProvider + + // StorageProvider is the storage client provider. + StorageProvider dataprovider.DataStorageProvider +} + +// TestServerMocks provides access to mock instances created by the TestServer. +type TestServerMocks struct { + // Secrets is the mock secret client. + Secrets *secret.MockClient + + // Storage is the mock storage client. + Storage *store.MockStorageClient +} + // Client provides access to an http.Client that can be used to send requests. Most tests should use the functionality // like MakeRequest instead of testing the client directly. func (ts *TestServer) Client() *http.Client { @@ -104,7 +134,7 @@ func (ts *TestServer) Close() { } // StartWithMocks creates and starts a new TestServer that used an mocks for storage. -func StartWithMocks(t *testing.T, configureModules func(options modules.Options) []modules.Initializer) (*TestServer, *store.MockStorageClient, *secret.MockClient) { +func StartWithMocks(t *testing.T, configureModules func(options modules.Options) []modules.Initializer) *TestServer { ctx, cancel := testcontext.NewWithCancel(t) // Generate a random base path to ensure we're handling it correctly. @@ -118,6 +148,10 @@ func StartWithMocks(t *testing.T, configureModules func(options modules.Options) Return(dataClient, nil). AnyTimes() + queueClient := queue.NewMockClient(ctrl) + queueProvider := queueprovider.New(queueprovider.QueueProviderOptions{Name: "System.Resources"}) + queueProvider.SetClient(queueClient) + secretClient := secret.NewMockClient(ctrl) secretProvider := secretprovider.NewSecretProvider(secretprovider.SecretProviderOptions{}) secretProvider.SetClient(secretClient) @@ -160,13 +194,22 @@ func StartWithMocks(t *testing.T, configureModules func(options modules.Options) ucp := &TestServer{ BaseURL: server.URL + pathBase, - Server: server, - cancel: cancel, - t: t, + Clients: &TestServerClients{ + QueueProvider: queueProvider, + SecretProvider: secretProvider, + StorageProvider: dataProvider, + }, + Mocks: &TestServerMocks{ + Secrets: secretClient, + Storage: dataClient, + }, + Server: server, + cancel: cancel, + t: t, } t.Cleanup(ucp.Close) - return ucp, dataClient, secretClient + return ucp } // StartWithETCD creates and starts a new TestServer that used an embedded ETCD instance for storage. @@ -210,11 +253,17 @@ func StartWithETCD(t *testing.T, configureModules func(options modules.Options) Provider: secretprovider.TypeETCDSecret, ETCD: storageOptions.ETCD, } + queueOptions := queueprovider.QueueProviderOptions{ + Name: "System.Resources", + Provider: queueprovider.TypeInmemory, + InMemory: &queueprovider.InMemoryQueueOptions{}, + } // Generate a random base path to ensure we're handling it correctly. pathBase := "/" + uuid.New().String() dataProvider := dataprovider.NewStorageProvider(storageOptions) secretProvider := secretprovider.NewSecretProvider(secretOptions) + queueProvider := queueprovider.New(queueOptions) router := chi.NewRouter() router.Use(servicecontext.ARMRequestCtx(pathBase, "global")) @@ -235,6 +284,7 @@ func StartWithETCD(t *testing.T, configureModules func(options modules.Options) DataProvider: dataProvider, SecretProvider: secretProvider, SpecLoader: specLoader, + QueueProvider: queueProvider, } if configureModules == nil { @@ -258,8 +308,15 @@ func StartWithETCD(t *testing.T, configureModules func(options modules.Options) require.NoError(t, err, "failed to query etcd") logger.Info("Connected to data store") + // TODO: start worker + ucp := &TestServer{ - BaseURL: server.URL + pathBase, + BaseURL: server.URL + pathBase, + Clients: &TestServerClients{ + QueueProvider: queueProvider, + SecretProvider: secretProvider, + StorageProvider: dataProvider, + }, Server: server, cancel: cancel, etcdService: etcd, diff --git a/pkg/ucp/proxy/arm.go b/pkg/ucp/proxy/arm.go index 596e2d1ea4..b74d7d4bcb 100644 --- a/pkg/ucp/proxy/arm.go +++ b/pkg/ucp/proxy/arm.go @@ -20,33 +20,13 @@ import ( "net/url" ) -type Options struct { -} -type armProxy struct { - ProxyAddress string -} - // NewARMProxy creates a ReverseProxy with custom directors, transport and responders to process requests and responses. func NewARMProxy(options ReverseProxyOptions, downstream *url.URL, configure func(builder *ReverseProxyBuilder)) ReverseProxy { - p := armProxy{ - ProxyAddress: options.ProxyAddress, - } - - directors := []DirectorFunc{} - if options.TrimPlanesPrefix { - // Remove the UCP Planes prefix for non-native planes that do not - // understand UCP IDs - directors = []DirectorFunc{trimPlanesPrefix} - } - builder := ReverseProxyBuilder{ Downstream: downstream, EnableLogging: true, - Directors: directors, - Transport: Transport{ - roundTripper: options.RoundTripper, - }, - Responders: []ResponderFunc{p.processAsyncResponse}, + Transport: options.RoundTripper, + Responders: []ResponderFunc{ProcessAsyncOperationHeaders}, } if configure != nil { diff --git a/pkg/ucp/proxy/arm_test.go b/pkg/ucp/proxy/arm_test.go index f6c05abf28..de25e8ca55 100644 --- a/pkg/ucp/proxy/arm_test.go +++ b/pkg/ucp/proxy/arm_test.go @@ -17,31 +17,19 @@ limitations under the License. package proxy import ( - "context" "net/http/httptest" "net/url" "os" "path/filepath" "testing" - "github.com/project-radius/radius/test/testcontext" - "github.com/project-radius/radius/test/ucp/httpbaseline" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/ucp/httpbaseline" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func createTestContext(ctx context.Context, planeURL string, planeID string, planeKind string, httpScheme string, ucpHost string) context.Context { - ctx = context.WithValue(ctx, UCPRequestInfoField, UCPRequestInfo{ - PlaneURL: planeURL, - PlaneID: planeID, - PlaneKind: planeKind, - HTTPScheme: httpScheme, - UCPHost: ucpHost, - }) - return ctx -} - func Test_ARM_Baselines(t *testing.T) { baselines, err := readBaselines() require.NoError(t, err) @@ -61,12 +49,10 @@ func Test_ARM_Baselines(t *testing.T) { capture := baseline.DownstreamResponse.CreateRoundTripper() options := ReverseProxyOptions{ RoundTripper: capture, - ProxyAddress: "localhost:9443", } pp := NewARMProxy(options, downstream, nil) w := httptest.NewRecorder() - ctx = createTestContext(ctx, "http://example.com", "/planes/example/local", "Azure", "http", "localhost:9443") req := baseline.UpstreamRequest.ToTestRequest(ctx) // Send the request diff --git a/pkg/ucp/proxy/async.go b/pkg/ucp/proxy/async.go new file mode 100644 index 0000000000..886ab651bf --- /dev/null +++ b/pkg/ucp/proxy/async.go @@ -0,0 +1,140 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package proxy + +import ( + "fmt" + "net/http" + "net/url" + "strings" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/ucplog" +) + +const ( + // locationHeader is the name of the Location header. + locationHeader = "Location" + + // azureAsyncOperationHeader is the name of the Azure-AsyncOperation header. + // + // This value has manually been canonizalized to speed up processing. DO NOT modify + // the casing of this value. + azureAsyncOperationHeader = "Azure-Asyncoperation" +) + +// ProcessAsyncOperationHeaders is a ResponderFunc that processes the Azure-AsyncOperation header and +// Location header to match the UCP hostname and scheme based on the Referrer header. +// +// Users of this director should ensure the referrer header is set on the request before proxying. +// The referrer header should contain the original UCP request URL. +// +// The values of the Azure-AsyncOperation and Location headers are rewritten to point to the UCP endpoint. +// If the result header values omit the plane-prefix (eg: /subscriptions/...), then the plane-prefix is +// prepended to the header value. The query string returned by the downstream are preserved. +func ProcessAsyncOperationHeaders(resp *http.Response) error { + ctx := resp.Request.Context() + logger := ucplog.FromContextOrDiscard(ctx) + + // If the response is not a 200, 201 or 202, then we don't need to process the headers + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusAccepted { + logger.V(ucplog.LevelDebug).Info("response status code is not 200, 201 or 202, skipping async operation headers") + return nil + } + + // We process the response based on the Referrer header. If the referrer header is not present, then we don't + // need to process the headers because we don't know how. + referrer := resp.Request.Header.Get(v1.RefererHeader) + if referrer == "" { + logger.V(ucplog.LevelDebug).Info("request has no referrer header, skipping async operation headers") + return nil + } + + referrerURL, err := url.Parse(referrer) + if err != nil { + logger.V(ucplog.LevelDebug).Info("referrer header is not a URL, skipping async operation headers") + return nil + } + + // If the referrer is not a UCP request, then we don't need to process the headers + // + // We also need to extract a "path base". This is the path prefix that was trimmed from the UCP prefix + // when the request was proxied. We need to re-add this path base to the header values. + originalPath := referrerURL.Path + pathBase := "" + planesIndex := strings.Index(strings.ToLower(originalPath), "/"+resources.PlanesSegment+"/") + if planesIndex != -1 && planesIndex != 0 { + logger.V(ucplog.LevelDebug).Info("referrer header has path base", "pathBase", originalPath[:planesIndex]) + pathBase = originalPath[:planesIndex] + originalPath = originalPath[planesIndex:] + } + + planeType, planeName, _, err := resources.ExtractPlanesPrefixFromURLPath(originalPath) + if err != nil { + logger.V(ucplog.LevelDebug).Info("referrer header is not a UCP request, skipping async operation headers") + return nil + } + + planesPrefix := fmt.Sprintf("/%s/%s/%s", resources.PlanesSegment, planeType, planeName) + + // As per https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/async-operations, + // rewrite both the Azure-AsyncOperation and Location headers to point to the UCP endpoint. + for _, header := range []string{azureAsyncOperationHeader, locationHeader} { + if value, ok := resp.Header[header]; ok { + result, err := rewriteHeader(value[0], referrerURL, pathBase, planesPrefix) + if err == nil { + resp.Header.Set(header, result) + logger.V(ucplog.LevelDebug).Info("rewrote header", "header", header, "before", value, "after", result, "referrer", referrerURL) + } else { + logger.Error(err, "failed to rewrite header", "header", header, "value", value, "referrer", referrerURL) + } + } + } + + return nil +} + +func rewriteHeader(header string, referrerURL *url.URL, pathBase string, planesPrefix string) (string, error) { + // COPY the original URL so that we can modify it + builder := *referrerURL + + headerURL, err := url.Parse(header) + if err != nil { + return "", fmt.Errorf("header value is not a valid URL: %w", err) + } + + // Some downstreams are *aware* of the UCP path and will return a URL with the UCP path in it. + // + // However they are generally not aware of the "path base" that's trimmed from the UCP prefix. We need + // to fixup the URL they return no matter what. + if pathBase != "" && strings.HasPrefix(strings.ToLower(headerURL.Path), strings.ToLower(pathBase+planesPrefix)) { + // Value has same basepath + planes prefix as the referrer, so we can just return the value as-is + builder.Path = headerURL.Path + } else if strings.HasPrefix(strings.ToLower(headerURL.Path), strings.ToLower(planesPrefix)) { + // Value has same planes prefix as the referrer, so we can just return the value with path base. + builder.Path = pathBase + headerURL.Path + } else { + // Value does not have path base or planes prefix, so we need to add the planes prefix and path base. + builder.Path = pathBase + planesPrefix + headerURL.Path + } + + builder.RawFragment = "" + builder.RawQuery = headerURL.RawQuery + + return builder.String(), nil +} diff --git a/pkg/ucp/proxy/async_test.go b/pkg/ucp/proxy/async_test.go new file mode 100644 index 0000000000..d06a933c68 --- /dev/null +++ b/pkg/ucp/proxy/async_test.go @@ -0,0 +1,242 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package proxy + +import ( + "fmt" + "net/http" + "net/http/httptest" + "net/url" + "testing" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/test/testcontext" + "github.com/stretchr/testify/require" +) + +func Test_ProcessAsyncOperationHeaders(t *testing.T) { + originalAsyncOperationHeader := "http://localhost:7443/async-operation-url?query=yeah" + originalLocationHeader := "http://localhost:7443/location-url?query=yeah" + createTestRequest := func(t *testing.T) *http.Request { + req := httptest.NewRequest(http.MethodGet, "http://localhost:9443/downstream-url", nil) + req.Header.Set(v1.RefererHeader, "http://localhost:9443/planes/test/local/downstream-url") + + ctx := testcontext.New(t) + req = req.WithContext(ctx) + return req + } + createTestResponse := func(t *testing.T, req *http.Request) *http.Response { + return &http.Response{ + StatusCode: http.StatusAccepted, + Request: req, + Header: http.Header{ + azureAsyncOperationHeader: []string{originalAsyncOperationHeader}, + locationHeader: []string{originalLocationHeader}, + }, + } + } + + t.Run("positive", func(t *testing.T) { + req := createTestRequest(t) + resp := createTestResponse(t, req) + err := ProcessAsyncOperationHeaders(resp) + require.NoError(t, err) + + require.Equal(t, "http://localhost:9443/planes/test/local/async-operation-url?query=yeah", resp.Header.Get(azureAsyncOperationHeader)) + require.Equal(t, "http://localhost:9443/planes/test/local/location-url?query=yeah", resp.Header.Get(locationHeader)) + }) + + t.Run("positive path base", func(t *testing.T) { + req := createTestRequest(t) + req.Header.Set(v1.RefererHeader, "http://localhost:9443/path/base/planes/test/local/downstream-url") + resp := createTestResponse(t, req) + err := ProcessAsyncOperationHeaders(resp) + require.NoError(t, err) + + require.Equal(t, "http://localhost:9443/path/base/planes/test/local/async-operation-url?query=yeah", resp.Header.Get(azureAsyncOperationHeader)) + require.Equal(t, "http://localhost:9443/path/base/planes/test/local/location-url?query=yeah", resp.Header.Get(locationHeader)) + }) + + t.Run("wrong-status-code", func(t *testing.T) { + req := createTestRequest(t) + resp := createTestResponse(t, req) + resp.StatusCode = http.StatusNoContent + err := ProcessAsyncOperationHeaders(resp) + require.NoError(t, err) + + require.Equal(t, originalAsyncOperationHeader, resp.Header.Get(azureAsyncOperationHeader)) + require.Equal(t, originalLocationHeader, resp.Header.Get(locationHeader)) + }) + + t.Run("no referrer", func(t *testing.T) { + req := createTestRequest(t) + req.Header.Del(v1.RefererHeader) + resp := createTestResponse(t, req) + err := ProcessAsyncOperationHeaders(resp) + require.NoError(t, err) + + require.Equal(t, originalAsyncOperationHeader, resp.Header.Get(azureAsyncOperationHeader)) + require.Equal(t, originalLocationHeader, resp.Header.Get(locationHeader)) + }) + + t.Run("invalid referrer", func(t *testing.T) { + req := createTestRequest(t) + req.Header.Set(v1.RefererHeader, "\ninvalid-referrer") + resp := createTestResponse(t, req) + err := ProcessAsyncOperationHeaders(resp) + require.NoError(t, err) + + require.Equal(t, originalAsyncOperationHeader, resp.Header.Get(azureAsyncOperationHeader)) + require.Equal(t, originalLocationHeader, resp.Header.Get(locationHeader)) + }) + + t.Run("non-UCP referrer", func(t *testing.T) { + req := createTestRequest(t) + req.Header.Set(v1.RefererHeader, "http://example.com") + resp := createTestResponse(t, req) + err := ProcessAsyncOperationHeaders(resp) + require.NoError(t, err) + + require.Equal(t, originalAsyncOperationHeader, resp.Header.Get(azureAsyncOperationHeader)) + require.Equal(t, originalLocationHeader, resp.Header.Get(locationHeader)) + }) + + t.Run("invalid response header", func(t *testing.T) { + req := createTestRequest(t) + resp := createTestResponse(t, req) + resp.Header.Set(azureAsyncOperationHeader, "\ninvalid-header") + resp.Header.Set(locationHeader, "\ninvalid-header") + err := ProcessAsyncOperationHeaders(resp) + require.NoError(t, err) + + require.Equal(t, "\ninvalid-header", resp.Header.Get(azureAsyncOperationHeader)) + require.Equal(t, "\ninvalid-header", resp.Header.Get(locationHeader)) + }) +} + +func Test_rewriteHeader(t *testing.T) { + t.Run("positive", func(t *testing.T) { + type positiveTest []struct { + header string + referrer string + pathBase string + expected string + } + positiveTestData := positiveTest{ + // Downsteam header is the original request path without the planes prefix. + { + header: "http://localhost:7443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + referrer: "http://localhost:9443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + expected: "http://localhost:9443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + }, + + // Downsteam header is the original request path with the planes prefix. + { + header: "http://localhost:7443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + referrer: "http://localhost:9443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + expected: "http://localhost:9443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + }, + + // (path base) Downsteam header is the original request path without the planes prefix. + { + header: "http://localhost:7443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + referrer: "http://localhost:9443/path/base/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + pathBase: "/path/base", + expected: "http://localhost:9443/path/base/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + }, + + // (path base) Downsteam header is the original request path with the planes prefix. + { + header: "http://localhost:7443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + referrer: "http://localhost:9443/path/base/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + pathBase: "/path/base", + expected: "http://localhost:9443/path/base/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + }, + + // (path base) Downsteam header is the original request path with the path base planes prefix. + { + header: "http://localhost:7443/path/base/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + referrer: "http://localhost:9443/path/base/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + pathBase: "/path/base", + expected: "http://localhost:9443/path/base/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", + }, + + // Downsteam header has a query string and fragment + { + header: "http://localhost:7443/abcd?efgh=value#ijkl", + referrer: "http://localhost:9443/planes/test/local/abcd", + expected: "http://localhost:9443/planes/test/local/abcd?efgh=value", + }, + + // Downsteam header has a different scheme + { + header: "http://localhost:7443/abcd", + referrer: "https://localhost:9443/planes/test/local/abcd", + expected: "https://localhost:9443/planes/test/local/abcd", + }, + + // Downsteam header has an empty path + { + header: "http://localhost:7443", + referrer: "https://localhost:9443/planes/test/local/abcd", + expected: "https://localhost:9443/planes/test/local", + }, + } + for _, datum := range positiveTestData { + referrerURL, err := url.Parse(datum.referrer) + require.NoError(t, err) + + planeType, planeName, _, err := resources.ExtractPlanesPrefixFromURLPath(referrerURL.Path[len(datum.pathBase):]) + require.NoError(t, err) + + result, err := rewriteHeader(datum.header, referrerURL, datum.pathBase, fmt.Sprintf("/%s/%s/%s", resources.PlanesSegment, planeType, planeName)) + require.NoError(t, err, "%q should have not have failed", datum) + require.Equal(t, datum.expected, result) + } + }) + + t.Run("negative", func(t *testing.T) { + type negativeTest []struct { + header string + referrer string + expectedErr string + } + negativeTestData := negativeTest{ + // It's actually HARD to construct an invalid URL in Go. + // + // Most of the error handling for the header rewrite logic is done before calling rewriteHeader. + { + header: "\n?not-a-url-http://////", + referrer: "https://localhost:9443/planes/test/local/abcd", + expectedErr: "header value is not a valid URL: parse \"\\n?not-a-url-http://////\": net/url: invalid control character in URL", + }, + } + for _, datum := range negativeTestData { + referrerURL, err := url.Parse(datum.referrer) + require.NoError(t, err) + + planeType, planeName, _, err := resources.ExtractPlanesPrefixFromURLPath(referrerURL.Path) + require.NoError(t, err) + + result, err := rewriteHeader(datum.header, referrerURL, "", fmt.Sprintf("/%s/%s/%s", resources.PlanesSegment, planeType, planeName)) + require.Errorf(t, err, "%q should have failed", datum) + require.Equal(t, "", result) + require.Equal(t, datum.expectedErr, err.Error()) + } + }) +} diff --git a/pkg/ucp/proxy/kubernetes.go b/pkg/ucp/proxy/kubernetes.go new file mode 100644 index 0000000000..ad46e20dd8 --- /dev/null +++ b/pkg/ucp/proxy/kubernetes.go @@ -0,0 +1,33 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package proxy + +import ( + "net/http" + "strings" +) + +// filterKubernetesAPIServerHeaders filters out headers that APIServer sets on the request. +func filterKubernetesAPIServerHeaders(r *http.Request) { + for k := range r.Header { + header := strings.ToLower(k) + // https://kubernetes.io/docs/reference/access-authn-authz/authentication/#authenticating-proxy + if header == "x-remote-user" || header == "x-remote-group" || strings.HasPrefix(header, "x-remote-extra-") { + r.Header.Del(k) + } + } +} diff --git a/pkg/ucp/proxy/logging.go b/pkg/ucp/proxy/logging.go new file mode 100644 index 0000000000..df1ee08b61 --- /dev/null +++ b/pkg/ucp/proxy/logging.go @@ -0,0 +1,54 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package proxy + +import ( + "fmt" + "net/http" + + "github.com/radius-project/radius/pkg/ucp/ucplog" +) + +func logUpstreamRequest(r *http.Request) { + logger := ucplog.FromContextOrDiscard(r.Context()) + logger.Info("preparing proxy request") +} + +func logDownstreamRequest(r *http.Request) { + logger := ucplog.FromContextOrDiscard(r.Context()) + logger.Info("sending proxy request to downstream") +} + +func logDownstreamResponse(r *http.Response) error { + logger := ucplog.FromContextOrDiscard(r.Request.Context()) + logger.Info(fmt.Sprintf("received proxy response HTTP status code from downstream %d", r.StatusCode)) + return nil +} + +func logUpstreamResponse(r *http.Response) error { + logger := ucplog.FromContextOrDiscard(r.Request.Context()) + logger.Info(fmt.Sprintf("sending proxy response %d to upstream", r.StatusCode)) + return nil +} + +func logConnectionError(original ErrorHandlerFunc) ErrorHandlerFunc { + return func(w http.ResponseWriter, r *http.Request, err error) { + logger := ucplog.FromContextOrDiscard(r.Context()) + logger.Error(err, "connection failed to downstream") + original(w, r, err) + } +} diff --git a/pkg/ucp/proxy/policy.go b/pkg/ucp/proxy/policy.go deleted file mode 100644 index ebeb0fff26..0000000000 --- a/pkg/ucp/proxy/policy.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package proxy - -import ( - "fmt" - "net/http" - "strings" - - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" -) - -func workaround28169(r *http.Request) { - // See: https://github.com/golang/go/issues/28168 - // - // The built-in support will get the Host header wrong, which is a big problem. Almost every - // significant service validates its Host header. - r.Host = r.URL.Host -} - -func trimPlanesPrefix(r *http.Request) { - _, _, remainder, err := resources.ExtractPlanesPrefixFromURLPath(r.URL.Path) - if err != nil { - // Invalid case like path: /planes/foo - do nothing - // If we see an invalid URL here we don't have a good way to report an error at this point - // we expect the error to have been handled before calling into this code. - return - } - - // Success -- truncate the planes prefix - r.URL.Path = remainder -} - -// filterKubernetesAPIServerHeaders filters out headers that APIServer sets on the request. -func filterKubernetesAPIServerHeaders(r *http.Request) { - for k := range r.Header { - header := strings.ToLower(k) - // https://kubernetes.io/docs/reference/access-authn-authz/authentication/#authenticating-proxy - if header == "x-remote-user" || header == "x-remote-group" || strings.HasPrefix(header, "x-remote-extra-") { - r.Header.Del(k) - } - } -} - -func defaultErrorHandler(w http.ResponseWriter, r *http.Request, err error) { - w.WriteHeader(http.StatusBadGateway) -} - -func noopResponder(r *http.Response) error { - return nil -} - -func logUpstreamRequest(r *http.Request) { - logger := ucplog.FromContextOrDiscard(r.Context()) - logger.Info("preparing proxy request") -} - -func logDownstreamRequest(r *http.Request) { - logger := ucplog.FromContextOrDiscard(r.Context()) - logger.Info("sending proxy request to downstream") -} - -func logDownstreamResponse(r *http.Response) error { - logger := ucplog.FromContextOrDiscard(r.Request.Context()) - logger.Info(fmt.Sprintf("received proxy response HTTP status code from downstream %d", r.StatusCode)) - return nil -} - -func logUpstreamResponse(r *http.Response) error { - logger := ucplog.FromContextOrDiscard(r.Request.Context()) - logger.Info(fmt.Sprintf("sending proxy response %d to upstream ", r.StatusCode)) - return nil -} - -func logConnectionError(w http.ResponseWriter, r *http.Request, err error) { - logger := ucplog.FromContextOrDiscard(r.Context()) - logger.Error(err, "connection failed to downstream") -} diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/downstream-request.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/downstream-request.json new file mode 100644 index 0000000000..7fd227e476 --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/downstream-request.json @@ -0,0 +1,8 @@ +{ + "url": "http://example.com/planes/example/local/some-path?query=yes", + "method": "PUT", + "headers": { + "Referer": ["http://ucp.example.com/path/base/planes/example/local/some-path?query=yes"] + }, + "body": "" +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/downstream-response.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/downstream-response.json new file mode 100644 index 0000000000..af9419e286 --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/downstream-response.json @@ -0,0 +1,8 @@ +{ + "statusCode": 200, + "body": "{}", + "headers": { + "Azure-Asyncoperation": ["http://localhost:9443/planes/example/local/asyncresponseID"], + "Location": ["http://localhost:9443/planes/example/local/asyncresponseID"] + } +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/upstream-request.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/upstream-request.json new file mode 100644 index 0000000000..c90960ba9a --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/upstream-request.json @@ -0,0 +1,7 @@ +{ + "url": "http://ucp.example.com/planes/example/local/some-path?query=yes", + "headers": { + "Referer": ["http://ucp.example.com/path/base/planes/example/local/some-path?query=yes"] + }, + "method": "PUT" +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/upstream-response.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/upstream-response.json new file mode 100644 index 0000000000..36bad624a4 --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip-pathbase/upstream-response.json @@ -0,0 +1,8 @@ +{ + "statusCode": 200, + "headers": { + "Azure-Asyncoperation": ["http://ucp.example.com/path/base/planes/example/local/asyncresponseID"], + "Location": ["http://ucp.example.com/path/base/planes/example/local/asyncresponseID"] + }, + "body": "" +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/downstream-request.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/downstream-request.json new file mode 100644 index 0000000000..f51674e861 --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/downstream-request.json @@ -0,0 +1,8 @@ +{ + "url": "http://example.com/planes/example/local/some-path?query=yes", + "method": "PUT", + "headers": { + "Referer": ["http://ucp.example.com/planes/example/local/some-path?query=yes"] + }, + "body": "" +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/downstream-response.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/downstream-response.json new file mode 100644 index 0000000000..af9419e286 --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/downstream-response.json @@ -0,0 +1,8 @@ +{ + "statusCode": 200, + "body": "{}", + "headers": { + "Azure-Asyncoperation": ["http://localhost:9443/planes/example/local/asyncresponseID"], + "Location": ["http://localhost:9443/planes/example/local/asyncresponseID"] + } +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/upstream-request.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/upstream-request.json new file mode 100644 index 0000000000..eed5f00e23 --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/upstream-request.json @@ -0,0 +1,7 @@ +{ + "url": "http://ucp.example.com/planes/example/local/some-path?query=yes", + "headers": { + "Referer": ["http://ucp.example.com/planes/example/local/some-path?query=yes"] + }, + "method": "PUT" +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/upstream-response.json b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/upstream-response.json new file mode 100644 index 0000000000..bb52ae109e --- /dev/null +++ b/pkg/ucp/proxy/testdata/arm/async-header-roundtrip/upstream-response.json @@ -0,0 +1,8 @@ +{ + "statusCode": 200, + "headers": { + "Azure-Asyncoperation": ["http://ucp.example.com/planes/example/local/asyncresponseID"], + "Location": ["http://ucp.example.com/planes/example/local/asyncresponseID"] + }, + "body": "" +} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/downstream-request.json b/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/downstream-request.json deleted file mode 100644 index 14eb68ab2f..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/downstream-request.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "url": "http://example.com/some-path?query=yes", - "method": "PUT", - "headers": { - }, - "body": "" -} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/downstream-response.json b/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/downstream-response.json deleted file mode 100644 index 8f95327dce..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/downstream-response.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "statusCode": 200, - "body": "{}", - "headers": { - "Azure-Asyncoperation": [ - "http://localhost:9443/planes/example/local/asyncresponseID" - ] - } -} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/upstream-request.json b/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/upstream-request.json deleted file mode 100644 index 85a190cbe3..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/upstream-request.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "url": "http://ucp.example.com/some-path?query=yes", - "headers": { - }, - "method": "PUT" -} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/upstream-response.json b/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/upstream-response.json deleted file mode 100644 index 82898b29ec..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-azureasyncoperationheader-roundtrip/upstream-response.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "statusCode": 200, - "headers": { - "Azure-Asyncoperation": [ - "http://localhost:9443/planes/example/local/asyncresponseID" - ] - }, - "body": "" -} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/downstream-request.json b/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/downstream-request.json deleted file mode 100644 index 14eb68ab2f..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/downstream-request.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "url": "http://example.com/some-path?query=yes", - "method": "PUT", - "headers": { - }, - "body": "" -} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/downstream-response.json b/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/downstream-response.json deleted file mode 100644 index 24018d9641..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/downstream-response.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "statusCode": 200, - "body": "{}", - "headers": { - "Location": [ - "http://localhost:9443/planes/example/local/asyncresponseID" - ] - } -} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/upstream-request.json b/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/upstream-request.json deleted file mode 100644 index 85a190cbe3..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/upstream-request.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "url": "http://ucp.example.com/some-path?query=yes", - "headers": { - }, - "method": "PUT" -} \ No newline at end of file diff --git a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/upstream-response.json b/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/upstream-response.json deleted file mode 100644 index fd0a187fa2..0000000000 --- a/pkg/ucp/proxy/testdata/arm/asyncop-locationheader-roundtrip/upstream-response.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "statusCode": 200, - "headers": { - "Location": [ - "http://localhost:9443/planes/example/local/asyncresponseID" - ] - }, - "body": "" -} \ No newline at end of file diff --git a/pkg/ucp/proxy/types.go b/pkg/ucp/proxy/types.go index 3b792ba0b9..989b84f3e2 100644 --- a/pkg/ucp/proxy/types.go +++ b/pkg/ucp/proxy/types.go @@ -17,201 +17,125 @@ limitations under the License. package proxy import ( - "context" - "fmt" "net/http" "net/http/httputil" "net/url" - "strings" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/rest" - "github.com/project-radius/radius/pkg/ucp/ucplog" -) - -type UCPRequestInfo struct { - PlaneURL string - PlaneKind string - PlaneID string - HTTPScheme string - UCPHost string -} - -type PlaneUrlFieldType string -type PlaneIdFieldType string -type HttpSchemeType string -type UCPHostType string -type UCPRequestInfoFieldType string - -const ( - LocationHeader = "Location" - AzureAsyncOperationHeader = "Azure-Asyncoperation" - UCPRequestInfoField UCPRequestInfoFieldType = "ucprequestinfo" ) +// DirectorFunc is a function that modifies the request before it is sent to the downstream server. type DirectorFunc = func(r *http.Request) + +// ResponderFunc is a function that modifies the response before it is sent to the client. type ResponderFunc = func(r *http.Response) error + +// ErrorHandlerFunc is a function that handles errors that occur during the request. type ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error) +// ReverseProxy defines the interface for a reverse proxy. type ReverseProxy interface { http.Handler } +// ReverseProxyOptions defines the options for creating a reverse proxy. type ReverseProxyOptions struct { - RoundTripper http.RoundTripper - ProxyAddress string - TrimPlanesPrefix bool + // RoundTripper is the round tripper used by the reverse proxy to send requests. + RoundTripper http.RoundTripper } type ReverseProxyBuilder struct { - Downstream *url.URL + // Downstream is the URL of the downstream server. This is the URL of the destination. + // + // The downstream URL will replace the request URL's scheme, host, and port. If the downstream + // URL contains a path, it will be pre-pended to the request URL's path. + Downstream *url.URL + + // EnableLogging enables a set of logging middleware for the proxy. EnableLogging bool - Directors []DirectorFunc - Responders []ResponderFunc - ErrorHandler ErrorHandlerFunc - // Transport is the transport set on the created httputil.ReverseProxy. - Transport Transport -} + // Directors is the set of director functions to be applied to the reverse proxy. + // Directors are applied in order and modify the request before it is sent to the downstream server. + Directors []DirectorFunc -type Transport struct { - roundTripper http.RoundTripper -} + // Responders is the set of responder functions to be applied to the reverse proxy. + // Responses are applied in REVERSE order and modify the response before it is sent to the client. + Responders []ResponderFunc -// The RoundTrip function in the Transport struct uses the roundTripper field to make a request and returns the response -// or an error if one occurs. -func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { - resp, err := t.roundTripper.RoundTrip(req) - if err != nil { - return nil, err - } + // ErrorHandler is the error handler function to be applied to the reverse proxy. + // The error handler is called when an Golang error. This is NOT called for HTTP errors such + // as 404 or 500. + ErrorHandler ErrorHandlerFunc - return resp, nil + // Transport is the transport set on the created httputil.ReverseProxy. + Transport http.RoundTripper } // Build configures a ReverseProxy with the given parameters and returns a http.HandlerFunc. func (builder *ReverseProxyBuilder) Build() ReverseProxy { rp := httputil.NewSingleHostReverseProxy(builder.Downstream) - rp.Transport = &builder.Transport - // We don consider workaround28169 required :-/ the default behavior is just broken. + // NOTE: there's a built-in director. We prepend it here. // - // There's always a default director so this is safe. - rp.Director = appendDirector(rp.Director, workaround28169) - rp.Director = appendDirector(rp.Director, filterKubernetesAPIServerHeaders) - rp.Director = appendDirector(rp.Director, builder.Directors...) + // We don't consider workaround28169 optional :-/ the default behavior is just broken. + // + // We don't want to propagate the Kubernetes authentication headers to the downstream server. + directors := []DirectorFunc{rp.Director, workaround28169, filterKubernetesAPIServerHeaders} + directors = append(directors, builder.Directors...) - // There's never a default responder. - rp.ModifyResponse = appendResponder(noopResponder, builder.Responders...) + responders := builder.Responders - rp.ErrorHandler = builder.ErrorHandler - if rp.ErrorHandler == nil { - rp.ErrorHandler = defaultErrorHandler + errorHandler := defaultErrorHandler + if builder.ErrorHandler != nil { + errorHandler = builder.ErrorHandler } if builder.EnableLogging { // Insert handlers before AND after for logging. - rp.Director = appendDirector(logUpstreamRequest, rp.Director, logDownstreamRequest) - rp.ModifyResponse = appendResponder(logDownstreamResponse, rp.ModifyResponse, logUpstreamResponse) - rp.ErrorHandler = appendErrorHandler(logConnectionError, rp.ErrorHandler) - } - - return http.HandlerFunc(rp.ServeHTTP) -} - -func (p *armProxy) processAsyncResponse(resp *http.Response) error { - ctx := resp.Request.Context() - if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusCreated || resp.StatusCode == http.StatusAccepted { - // As per https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/async-operations, - // first check for Azure-AsyncOperation header and if not found, check for LocationHeader - if header, ok := resp.Header[AzureAsyncOperationHeader]; ok { - if err := convertHeaderToUCPIDs(ctx, AzureAsyncOperationHeader, header, resp); err != nil { - return err - } - } - if header, ok := resp.Header[LocationHeader]; ok { - if err := convertHeaderToUCPIDs(ctx, LocationHeader, header, resp); err != nil { - return err - } - } - } - return nil -} - -func convertHeaderToUCPIDs(ctx context.Context, headerName string, header []string, resp *http.Response) error { - segments := strings.Split(strings.TrimSuffix(strings.TrimPrefix(header[0], "/"), "/"), "/") - // segment 0 -> http - // segment 1 -> "" - // segment 2 -> hostname + port - key := segments[0] + "//" + segments[2] + directors = append([]DirectorFunc{logUpstreamRequest}, directors...) + directors = append(directors, logDownstreamRequest) - if ctx.Value(UCPRequestInfoField) == nil { - return fmt.Errorf("Could not find ucp request data in %s header", headerName) - } - requestInfo := ctx.Value(UCPRequestInfoField).(UCPRequestInfo) - ucpHost, err := hasUCPHost(requestInfo, headerName, header) - if err != nil { - return err - } - if ucpHost { - return nil - } + responders = append([]ResponderFunc{logUpstreamResponse}, responders...) + responders = append(responders, logDownstreamResponse) - // Doing a reverse lookup of the URL of the responding server to find the corresponding plane ID - if requestInfo.PlaneURL == "" { - return fmt.Errorf("Could not find plane URL data in %s header", headerName) + errorHandler = logConnectionError(errorHandler) } - // Match the Plane URL but without the HTTP Scheme since the RP can return a https location/azure-asyncoperation header - // based on the protocol scheme - requestInfoPlaneID := strings.TrimSuffix(strings.Split(requestInfo.PlaneURL, "//")[1], "/") - headerPlaneID := strings.TrimSuffix(strings.Split(key, "//")[1], "/") - if !strings.EqualFold(requestInfoPlaneID, headerPlaneID) { - return fmt.Errorf("PlaneURL: %s received in the request context does not match the url found in %s header: %s", requestInfo.PlaneURL, headerName, header[0]) - } + rp.Transport = builder.Transport + rp.Director = director(directors) + rp.ModifyResponse = responder(responders) + rp.ErrorHandler = errorHandler - if requestInfo.UCPHost == "" { - return fmt.Errorf("UCP Host Address unknown. Cannot convert response header") - } + return rp +} - if requestInfo.PlaneKind == "" { - return fmt.Errorf("Plane Kind unknown. Cannot convert response header") +func director(directors []DirectorFunc) DirectorFunc { + return func(r *http.Request) { + for _, director := range directors { + director(r) + } } +} - var planeID string - if requestInfo.PlaneKind != rest.PlaneKindUCPNative { - if requestInfo.PlaneID == "" { - return fmt.Errorf("Could not find plane ID data in %s header", headerName) +func responder(directors []ResponderFunc) ResponderFunc { + return func(r *http.Response) error { + for i := len(directors) - 1; i >= 0; i-- { + err := directors[i](r) + if err != nil { + return err + } } - // Doing this only for non UCP Native planes. For UCP Native planes, the request URL will have the plane ID in it and therefore no need to - // add the plane ID - planeID = requestInfo.PlaneID - } - if requestInfo.HTTPScheme == "" { - return fmt.Errorf("Could not find http scheme data in %s header", headerName) + return nil } - - // Found a plane matching the URL in the location header - // Convert to UCP ID using the planeID corresponding to the URL of the server from where the response was received - val := requestInfo.HTTPScheme + "://" + requestInfo.UCPHost + planeID + "/" + strings.Join(segments[3:], "/") - - // Replace the header with the computed value. - // Do not use the Del/Set methods on header as it can change the header casing to canonical form - resp.Header[headerName] = []string{val} - - logger := ucplog.FromContextOrDiscard(ctx) - logger.Info(fmt.Sprintf("Converting %s header from %s to %s", headerName, header[0], val)) - return nil } -func hasUCPHost(requestInfo UCPRequestInfo, headerName string, header []string) (bool, error) { - uri, err := url.Parse(header[0]) - if err != nil { - return false, err - } - pathBase := v1.ParsePathBase(uri.Path) - uriHost := uri.Host + pathBase +func workaround28169(r *http.Request) { + // See: https://github.com/golang/go/issues/28168 + // + // The built-in support will get the Host header wrong, which is a big problem. Almost every + // significant service validates its Host header. + r.Host = r.URL.Host +} - return strings.EqualFold(uriHost, requestInfo.UCPHost), nil +func defaultErrorHandler(w http.ResponseWriter, r *http.Request, err error) { + w.WriteHeader(http.StatusBadGateway) } diff --git a/pkg/ucp/proxy/types_test.go b/pkg/ucp/proxy/types_test.go index c14f319b4c..55aefff594 100644 --- a/pkg/ucp/proxy/types_test.go +++ b/pkg/ucp/proxy/types_test.go @@ -17,250 +17,217 @@ limitations under the License. package proxy import ( - "context" - "fmt" + "errors" "net/http" - "net/textproto" + "net/http/httptest" + "net/http/httputil" + "net/url" "testing" - "github.com/project-radius/radius/pkg/ucp/rest" + "github.com/radius-project/radius/test/testcontext" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func Test_ConvertHeaderToUCPIDs(t *testing.T) { - type data []struct { - name string - header []string - planeURL string - planeID string - planeKind string - httpScheme string - ucpHost string - expectedHeader string - } - positiveTestData := data{ - { - name: LocationHeader, - header: []string{"http://localhost:7443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - expectedHeader: "http://localhost:9443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", - planeURL: "http://localhost:7443", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "http", - ucpHost: "localhost:9443", - }, - { - name: AzureAsyncOperationHeader, - header: []string{"http://localhost:7443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - expectedHeader: "http://localhost:9443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", - planeURL: "http://localhost:7443", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "http", - ucpHost: "localhost:9443", - }, - { - name: LocationHeader, - header: []string{"https://localhost:7443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - expectedHeader: "https://localhost:9443/planes/test/local/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test", - planeURL: "https://localhost:7443", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "https", - ucpHost: "localhost:9443", - }, - { - name: AzureAsyncOperationHeader, - header: []string{"https://example.com"}, - expectedHeader: "https://localhost:9443/planes/test/local/", - planeURL: "https://example.com", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "https", - ucpHost: "localhost:9443", - }, - { - name: AzureAsyncOperationHeader, - header: []string{"https://example.com/"}, - expectedHeader: "https://localhost:9443/planes/test/local/", - planeURL: "https://example.com", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "https", - ucpHost: "localhost:9443", - }, - { - name: AzureAsyncOperationHeader, - header: []string{"https://example.com"}, - expectedHeader: "https://localhost:9443/planes/test/local/", - planeURL: "https://example.com/", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "https", - ucpHost: "localhost:9443", - }, - { - name: LocationHeader, - header: []string{"https://localhost:7443/planes/radius/local/resourceGroups/rg/providers/Applications.Core/Containers/test"}, - expectedHeader: "https://localhost:9443/planes/radius/local/resourceGroups/rg/providers/Applications.Core/Containers/test", - planeURL: "https://localhost:7443", - planeKind: rest.PlaneKindUCPNative, - planeID: "/planes/radius/local", - httpScheme: "https", - ucpHost: "localhost:9443", - }, - } - for _, datum := range positiveTestData { - response := http.Response{ - Header: http.Header{}, - } - ctx := createTestContext(context.Background(), datum.planeURL, datum.planeID, datum.planeKind, datum.httpScheme, datum.ucpHost) - err := convertHeaderToUCPIDs(ctx, datum.name, datum.header, &response) - require.NoError(t, err, "%q should have not have failed", datum) - // response.SetHeader converts the header into CanonicalMIME format - require.Equal(t, datum.expectedHeader, response.Header[textproto.CanonicalMIMEHeaderKey(datum.name)][0]) - } - - negativeTestData := data{ - { - name: AzureAsyncOperationHeader, - header: []string{"http://example.com/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - expectedHeader: "", - planeURL: "https://localhost:7443", - }, - { - name: LocationHeader, - header: []string{"http://example.com/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - expectedHeader: "", - planeURL: "http://localhost:7443", - }, - } - for _, datum := range negativeTestData { - response := http.Response{ - Header: http.Header{}, - } - ctx := createTestContext(context.Background(), datum.planeURL, datum.planeID, datum.planeKind, datum.httpScheme, datum.ucpHost) - err := convertHeaderToUCPIDs(ctx, datum.name, datum.header, &response) - require.Error(t, err, "%q should have have failed", datum) - require.Equal(t, fmt.Sprintf("PlaneURL: %s received in the request context does not match the url found in %s header: %s", datum.planeURL, datum.name, datum.header[0]), err.Error()) - } +type transportFunc struct { + Func func(req *http.Request) (*http.Response, error) } -func Test_ConvertHeaderToUCPIDs_NoContextDataSet(t *testing.T) { - response := http.Response{ - Header: http.Header{}, - } - err := convertHeaderToUCPIDs(context.Background(), AzureAsyncOperationHeader, []string{"http://example.com/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, &response) - require.Error(t, err, "Should have have failed") - require.Equal(t, "Could not find ucp request data in Azure-Asyncoperation header", err.Error()) - err = convertHeaderToUCPIDs(context.Background(), LocationHeader, []string{"http://example.com/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, &response) - require.Error(t, err, "Should have have failed") - require.Equal(t, "Could not find ucp request data in Location header", err.Error()) +func (t *transportFunc) RoundTrip(req *http.Request) (*http.Response, error) { + return t.Func(req) } -func Test_ConvertHeaderToUCPIDs_WithUCPHost(t *testing.T) { - type data []struct { - name string - header []string - planeURL string - planeID string - planeKind string - httpScheme string - ucpHost string - } - testData := data{ - { - name: LocationHeader, - header: []string{"http://localhost:9443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - planeURL: "http://localhost:7443", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "http", - ucpHost: "localhost:9443", - }, - } - - for _, datum := range testData { - response := http.Response{ - Header: http.Header{}, +// These tests test the mechanics of the proxy builder, and verify that the configurations +// we build work correctly. +// +// We're not testing the actual request proxying functionality since that's part of the Go std library. +func Test_ReverseProxyBuilder_Build(t *testing.T) { + downstream, err := url.Parse("http://localhost") + require.NoError(t, err) + + t.Run("empty", func(t *testing.T) { + builder := &ReverseProxyBuilder{Downstream: downstream} + proxy := builder.Build() + + require.IsType(t, &httputil.ReverseProxy{}, proxy) + real := proxy.(*httputil.ReverseProxy) + + t.Run("correctly created", func(t *testing.T) { + assert.Nil(t, real.Transport) + + // No good way to assert the contents of these as they are funcs. + assert.NotNil(t, real.Director) + assert.NotNil(t, real.ModifyResponse) + assert.NotNil(t, real.ErrorHandler) + }) + + t.Run("successful request", func(t *testing.T) { + real.Transport = &transportFunc{ + Func: func(req *http.Request) (*http.Response, error) { + return &http.Response{StatusCode: http.StatusOK, Body: http.NoBody, Request: req}, nil + }, + } + + req := httptest.NewRequest(http.MethodGet, "http://localhost", nil) + req = req.WithContext(testcontext.New(t)) + w := httptest.NewRecorder() + real.ServeHTTP(w, req) + + assert.Equal(t, http.StatusOK, w.Code) + }) + + t.Run("connection error", func(t *testing.T) { + real.Transport = &transportFunc{ + Func: func(req *http.Request) (*http.Response, error) { + return nil, errors.New("connection error") + }, + } + + req := httptest.NewRequest(http.MethodGet, "http://localhost", nil) + req = req.WithContext(testcontext.New(t)) + w := httptest.NewRecorder() + real.ServeHTTP(w, req) + + assert.Equal(t, http.StatusBadGateway, w.Code) + }) + }) + + t.Run("with logging", func(t *testing.T) { + builder := &ReverseProxyBuilder{Downstream: downstream, EnableLogging: true} + proxy := builder.Build() + + require.IsType(t, &httputil.ReverseProxy{}, proxy) + real := proxy.(*httputil.ReverseProxy) + + t.Run("correctly created", func(t *testing.T) { + assert.Nil(t, real.Transport) + + // No good way to assert the contents of these as they are funcs. + assert.NotNil(t, real.Director) + assert.NotNil(t, real.ModifyResponse) + assert.NotNil(t, real.ErrorHandler) + }) + + t.Run("successful request", func(t *testing.T) { + real.Transport = &transportFunc{ + Func: func(req *http.Request) (*http.Response, error) { + return &http.Response{StatusCode: http.StatusOK, Body: http.NoBody, Request: req}, nil + }, + } + + req := httptest.NewRequest(http.MethodGet, "http://localhost", nil) + req = req.WithContext(testcontext.New(t)) + w := httptest.NewRecorder() + real.ServeHTTP(w, req) + + assert.Equal(t, http.StatusOK, w.Code) + }) + + t.Run("connection error", func(t *testing.T) { + real.Transport = &transportFunc{ + Func: func(req *http.Request) (*http.Response, error) { + return nil, errors.New("connection error") + }, + } + + req := httptest.NewRequest(http.MethodGet, "http://localhost", nil) + req = req.WithContext(testcontext.New(t)) + w := httptest.NewRecorder() + real.ServeHTTP(w, req) + + assert.Equal(t, http.StatusBadGateway, w.Code) + }) + }) + + t.Run("with custom", func(t *testing.T) { + builder := &ReverseProxyBuilder{Downstream: downstream} + + builder.Directors = append(builder.Directors, func(req *http.Request) { + value := append(req.Header["Director"], "A") + req.Header["Director"] = value + }) + builder.Directors = append(builder.Directors, func(req *http.Request) { + value := append(req.Header["Director"], "B") + req.Header["Director"] = value + }) + builder.Directors = append(builder.Directors, func(req *http.Request) { + value := append(req.Header["Director"], "C") + req.Header["Director"] = value + }) + + builder.Responders = append(builder.Responders, func(resp *http.Response) error { + value := append(resp.Header["Responder"], "A") + resp.Header["Responder"] = value + return nil + }) + builder.Responders = append(builder.Responders, func(resp *http.Response) error { + value := append(resp.Header["Responder"], "B") + resp.Header["Responder"] = value + return nil + }) + builder.Responders = append(builder.Responders, func(resp *http.Response) error { + value := append(resp.Header["Responder"], "C") + resp.Header["Responder"] = value + return nil + }) + + builder.Transport = &transportFunc{} + builder.ErrorHandler = func(w http.ResponseWriter, req *http.Request, err error) { + w.WriteHeader(http.StatusTeapot) } - response.Header.Set(LocationHeader, "http://localhost:9443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test") - ctx := createTestContext(context.Background(), datum.planeURL, datum.planeID, datum.planeKind, datum.httpScheme, datum.ucpHost) - err := convertHeaderToUCPIDs(ctx, datum.name, datum.header, &response) - require.NoError(t, err, "%q should have not have failed", datum) - // response.SetHeader converts the header into CanonicalMIME format - require.Equal(t, datum.header[0], response.Header[textproto.CanonicalMIMEHeaderKey(datum.name)][0]) - } -} -func Test_HasUCPHost(t *testing.T) { - type data []struct { - name string - header []string - planeURL string - planeID string - planeKind string - httpScheme string - ucpHost string - result bool - } - testData := data{ - { - name: AzureAsyncOperationHeader, - header: []string{"http://localhost:9443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - planeURL: "http://localhost:9443", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "http", - ucpHost: "localhost:9443", - result: true, - }, - { - name: LocationHeader, - header: []string{"https://localhost:9443/planes/radius/local/resourceGroups/rg/providers/Applications.Core/Containers/test"}, - planeURL: "https://localhost:9443", - planeKind: rest.PlaneKindUCPNative, - planeID: "/planes/radius/local", - httpScheme: "https", - ucpHost: "localhost:9443", - result: true, - }, - { - name: AzureAsyncOperationHeader, - header: []string{"http://bicep-de.radius-system:6443/subscriptions/sid/resourceGroups/rg/providers/Microsoft.CustomProviders/resourceProviders/radiusv3/Application/testApp/Container/test"}, - planeURL: "http://localhost:9443", - planeKind: rest.PlaneKindAzure, - planeID: "/planes/test/local", - httpScheme: "http", - ucpHost: "localhost:9443", - result: false, - }, - { - name: LocationHeader, - header: []string{"https://bicep-de.radius-system:6443/planes/radius/local/resourceGroups/rg/providers/Applications.Core/Containers/test"}, - planeURL: "https://localhost:9443", - planeKind: rest.PlaneKindUCPNative, - planeID: "/planes/radius/local", - httpScheme: "https", - ucpHost: "localhost:9443", - result: false, - }, - { - name: LocationHeader, - header: []string{"https://localhost:9443/apis/api.ucp.dev/v1alpha3/planes/radius/local/resourceGroups/rg/providers/Applications.Core/Containers/test"}, - planeURL: "https://localhost:9443", - planeKind: rest.PlaneKindUCPNative, - planeID: "/planes/radius/local", - httpScheme: "https", - ucpHost: "localhost:9443/apis/api.ucp.dev/v1alpha3", - result: true, - }, - } - for _, datum := range testData { - - ctx := createTestContext(context.Background(), datum.planeURL, datum.planeID, datum.planeKind, datum.httpScheme, datum.ucpHost) - hasUCPHost, err := hasUCPHost(ctx.Value(UCPRequestInfoField).(UCPRequestInfo), datum.name, datum.header) - require.NoError(t, err, "%q should have not have failed", datum) - require.Equal(t, datum.result, hasUCPHost) - } + proxy := builder.Build() + + require.IsType(t, &httputil.ReverseProxy{}, proxy) + real := proxy.(*httputil.ReverseProxy) + + t.Run("correctly created", func(t *testing.T) { + assert.NotNil(t, real.Transport) + assert.IsType(t, &transportFunc{}, real.Transport) + + // No good way to assert the contents of these as they are funcs. + assert.NotNil(t, real.Director) + assert.NotNil(t, real.ModifyResponse) + assert.NotNil(t, real.ErrorHandler) + }) + + t.Run("successful request", func(t *testing.T) { + real.Transport = &transportFunc{ + Func: func(req *http.Request) (*http.Response, error) { + response := &http.Response{ + StatusCode: http.StatusOK, + Header: http.Header{"Director": req.Header["Director"]}, + Body: http.NoBody, + Request: req, + } + + return response, nil + }, + } + + req := httptest.NewRequest(http.MethodGet, "http://localhost", nil) + req = req.WithContext(testcontext.New(t)) + w := httptest.NewRecorder() + real.ServeHTTP(w, req) + + assert.Equal(t, http.StatusOK, w.Code) + assert.Equal(t, []string{"A", "B", "C"}, w.Header()["Director"]) + assert.Equal(t, []string{"C", "B", "A"}, w.Header()["Responder"]) + }) + + t.Run("connection error", func(t *testing.T) { + real.Transport = &transportFunc{ + Func: func(req *http.Request) (*http.Response, error) { + return nil, errors.New("connection error") + }, + } + + req := httptest.NewRequest(http.MethodGet, "http://localhost", nil) + req = req.WithContext(testcontext.New(t)) + w := httptest.NewRecorder() + real.ServeHTTP(w, req) + + assert.Equal(t, http.StatusTeapot, w.Code) + }) + }) } diff --git a/pkg/ucp/proxy/util.go b/pkg/ucp/proxy/util.go deleted file mode 100644 index 7df889bb25..0000000000 --- a/pkg/ucp/proxy/util.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package proxy - -import "net/http" - -func appendDirector(original DirectorFunc, added ...DirectorFunc) DirectorFunc { - return func(r *http.Request) { - original(r) - for _, director := range added { - director(r) - } - } -} - -func appendResponder(original ResponderFunc, added ...ResponderFunc) ResponderFunc { - return func(r *http.Response) error { - err := original(r) - if err != nil { - return err - } - - for _, director := range added { - err := director(r) - if err != nil { - return err - } - } - - return nil - } -} - -func appendErrorHandler(original ErrorHandlerFunc, added ...ErrorHandlerFunc) ErrorHandlerFunc { - return func(w http.ResponseWriter, r *http.Request, err error) { - original(w, r, err) - for _, director := range added { - director(w, r, err) - } - } -} diff --git a/pkg/ucp/queue/apiserver/client.go b/pkg/ucp/queue/apiserver/client.go index a3386fc348..ed2f2bc49c 100644 --- a/pkg/ucp/queue/apiserver/client.go +++ b/pkg/ucp/queue/apiserver/client.go @@ -60,9 +60,9 @@ import ( "strconv" "time" - "github.com/project-radius/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/queue/client" - v1alpha1 "github.com/project-radius/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" + v1alpha1 "github.com/radius-project/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/ucp/queue/apiserver/client_test.go b/pkg/ucp/queue/apiserver/client_test.go index 61c5905025..6b786ebb51 100644 --- a/pkg/ucp/queue/apiserver/client_test.go +++ b/pkg/ucp/queue/apiserver/client_test.go @@ -22,11 +22,11 @@ import ( "testing" "time" - "github.com/project-radius/radius/pkg/ucp/queue/client" - v1alpha1 "github.com/project-radius/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" - "github.com/project-radius/radius/test/testcontext" - "github.com/project-radius/radius/test/ucp/kubeenv" - sharedtest "github.com/project-radius/radius/test/ucp/queuetest" + "github.com/radius-project/radius/pkg/ucp/queue/client" + v1alpha1 "github.com/radius-project/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/ucp/kubeenv" + sharedtest "github.com/radius-project/radius/test/ucp/queuetest" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/ucp/queue/client/client.go b/pkg/ucp/queue/client/client.go index ee7dbe7bf5..f120008c9b 100644 --- a/pkg/ucp/queue/client/client.go +++ b/pkg/ucp/queue/client/client.go @@ -21,7 +21,7 @@ import ( "errors" "time" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var ( @@ -41,7 +41,7 @@ var ( ErrEmptyMessage = errors.New("message must not be nil or message is empty") ) -//go:generate mockgen -destination=./mock_client.go -package=client -self_package github.com/project-radius/radius/pkg/ucp/queue/client github.com/project-radius/radius/pkg/ucp/queue/client Client +//go:generate mockgen -destination=./mock_client.go -package=client -self_package github.com/radius-project/radius/pkg/ucp/queue/client github.com/radius-project/radius/pkg/ucp/queue/client Client // Client is an interface to implement queue operations. type Client interface { diff --git a/pkg/ucp/queue/client/mock_client.go b/pkg/ucp/queue/client/mock_client.go index 3cd1059ac1..0ca7f44107 100644 --- a/pkg/ucp/queue/client/mock_client.go +++ b/pkg/ucp/queue/client/mock_client.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/ucp/queue/client (interfaces: Client) +// Source: github.com/radius-project/radius/pkg/ucp/queue/client (interfaces: Client) // Package client is a generated GoMock package. package client diff --git a/pkg/ucp/queue/inmemory/client.go b/pkg/ucp/queue/inmemory/client.go index 4f7d23d594..70347ca322 100644 --- a/pkg/ucp/queue/inmemory/client.go +++ b/pkg/ucp/queue/inmemory/client.go @@ -20,7 +20,7 @@ import ( "context" "sync" - "github.com/project-radius/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/queue/client" ) var namedQueue = &sync.Map{} diff --git a/pkg/ucp/queue/inmemory/client_test.go b/pkg/ucp/queue/inmemory/client_test.go index c116201be7..e3b35b9281 100644 --- a/pkg/ucp/queue/inmemory/client_test.go +++ b/pkg/ucp/queue/inmemory/client_test.go @@ -20,10 +20,10 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/queue/client" "github.com/stretchr/testify/require" - sharedtest "github.com/project-radius/radius/test/ucp/queuetest" + sharedtest "github.com/radius-project/radius/test/ucp/queuetest" ) func TestNamedQueue(t *testing.T) { diff --git a/pkg/ucp/queue/inmemory/queue.go b/pkg/ucp/queue/inmemory/queue.go index 009d0baa7d..5a428db340 100644 --- a/pkg/ucp/queue/inmemory/queue.go +++ b/pkg/ucp/queue/inmemory/queue.go @@ -22,7 +22,7 @@ import ( "time" "github.com/google/uuid" - "github.com/project-radius/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/queue/client" ) var ( diff --git a/pkg/ucp/queue/inmemory/queue_test.go b/pkg/ucp/queue/inmemory/queue_test.go index 864390c139..1a13e8d769 100644 --- a/pkg/ucp/queue/inmemory/queue_test.go +++ b/pkg/ucp/queue/inmemory/queue_test.go @@ -22,7 +22,7 @@ import ( "time" - "github.com/project-radius/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/pkg/ucp/queue/client" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/queue/provider/factory.go b/pkg/ucp/queue/provider/factory.go index 0da9a09ded..d3e9b3923d 100644 --- a/pkg/ucp/queue/provider/factory.go +++ b/pkg/ucp/queue/provider/factory.go @@ -21,27 +21,27 @@ import ( "errors" "fmt" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/ucp/queue/apiserver" - queue "github.com/project-radius/radius/pkg/ucp/queue/client" - qinmem "github.com/project-radius/radius/pkg/ucp/queue/inmemory" - ucpv1alpha1 "github.com/project-radius/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/ucp/queue/apiserver" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" + qinmem "github.com/radius-project/radius/pkg/ucp/queue/inmemory" + ucpv1alpha1 "github.com/radius-project/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" "k8s.io/apimachinery/pkg/runtime" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" ) -type factoryFunc func(context.Context, string, QueueProviderOptions) (queue.Client, error) +type factoryFunc func(context.Context, QueueProviderOptions) (queue.Client, error) var clientFactory = map[QueueProviderType]factoryFunc{ TypeInmemory: initInMemory, TypeAPIServer: initAPIServer, } -func initInMemory(ctx context.Context, name string, opt QueueProviderOptions) (queue.Client, error) { - return qinmem.NewNamedQueue(name), nil +func initInMemory(ctx context.Context, opt QueueProviderOptions) (queue.Client, error) { + return qinmem.NewNamedQueue(opt.Name), nil } -func initAPIServer(ctx context.Context, name string, opt QueueProviderOptions) (queue.Client, error) { +func initAPIServer(ctx context.Context, opt QueueProviderOptions) (queue.Client, error) { if opt.APIServer.Namespace == "" { return nil, errors.New("failed to initialize APIServer client: namespace is required") } @@ -76,7 +76,7 @@ func initAPIServer(ctx context.Context, name string, opt QueueProviderOptions) ( } return apiserver.New(rc, apiserver.Options{ - Name: name, + Name: opt.Name, Namespace: opt.APIServer.Namespace, }) } diff --git a/pkg/ucp/queue/provider/options.go b/pkg/ucp/queue/provider/options.go index 8c06d01985..116313d03a 100644 --- a/pkg/ucp/queue/provider/options.go +++ b/pkg/ucp/queue/provider/options.go @@ -21,6 +21,9 @@ type QueueProviderOptions struct { // Provider configures the storage provider. Provider QueueProviderType `yaml:"provider"` + // Name represents the unique name of queue. + Name string `yaml:"name"` + // InMemory represents inmemory queue client options. (Optional) InMemory *InMemoryQueueOptions `yaml:"inMemoryQueue,omitempty"` diff --git a/pkg/ucp/queue/provider/provider.go b/pkg/ucp/queue/provider/provider.go index 7e01f8c46b..b22418800c 100644 --- a/pkg/ucp/queue/provider/provider.go +++ b/pkg/ucp/queue/provider/provider.go @@ -21,8 +21,7 @@ import ( "errors" "sync" - queue "github.com/project-radius/radius/pkg/ucp/queue/client" - "github.com/project-radius/radius/pkg/ucp/util" + queue "github.com/radius-project/radius/pkg/ucp/queue/client" ) var ( @@ -31,7 +30,6 @@ var ( // QueueProvider is the provider to create and manage queue client. type QueueProvider struct { - name string options QueueProviderOptions queueClient queue.Client @@ -39,9 +37,8 @@ type QueueProvider struct { } // New creates new QueueProvider instance. -func New(name string, opts QueueProviderOptions) *QueueProvider { +func New(opts QueueProviderOptions) *QueueProvider { return &QueueProvider{ - name: util.NormalizeStringToLower(name), queueClient: nil, options: opts, } @@ -56,9 +53,14 @@ func (p *QueueProvider) GetClient(ctx context.Context) (queue.Client, error) { err := ErrUnsupportedStorageProvider p.once.Do(func() { if fn, ok := clientFactory[p.options.Provider]; ok { - p.queueClient, err = fn(ctx, p.name, p.options) + p.queueClient, err = fn(ctx, p.options) } }) return p.queueClient, err } + +// SetClient sets the queue client for the QueueProvider. This should be used by tests that need to mock the queue client. +func (p *QueueProvider) SetClient(client queue.Client) { + p.queueClient = client +} diff --git a/pkg/ucp/queue/provider/provider_test.go b/pkg/ucp/queue/provider/provider_test.go index 839108557d..1a1bb49320 100644 --- a/pkg/ucp/queue/provider/provider_test.go +++ b/pkg/ucp/queue/provider/provider_test.go @@ -24,7 +24,8 @@ import ( ) func TestGetClient_ValidQueue(t *testing.T) { - p := New("Applications.Core", QueueProviderOptions{ + p := New(QueueProviderOptions{ + Name: "Applications.Core", Provider: TypeInmemory, InMemory: &InMemoryQueueOptions{}, }) @@ -38,7 +39,8 @@ func TestGetClient_ValidQueue(t *testing.T) { } func TestGetClient_InvalidQueue(t *testing.T) { - p := New("Applications.Core", QueueProviderOptions{ + p := New(QueueProviderOptions{ + Name: "Applications.Core", Provider: QueueProviderType("undefined"), }) diff --git a/pkg/ucp/resources/aws.go b/pkg/ucp/resources/aws.go deleted file mode 100644 index 3695972f91..0000000000 --- a/pkg/ucp/resources/aws.go +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resources - -import "strings" - -// ToAWSResourceType takes an ID and returns a string representing the AWS resource type. -func ToAWSResourceType(id ID) string { - parts := []string{} - // AWS ARNs use :: as separator. - for _, segment := range id.TypeSegments() { - parts = append(parts, strings.ReplaceAll(strings.ReplaceAll(segment.Type, ".", "::"), "/", "::")) - } - resourceType := strings.Join(parts, "::") - return resourceType -} diff --git a/pkg/ucp/resources/aws/aws.go b/pkg/ucp/resources/aws/aws.go new file mode 100644 index 0000000000..1fef076151 --- /dev/null +++ b/pkg/ucp/resources/aws/aws.go @@ -0,0 +1,45 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package aws + +import ( + "strings" + + "github.com/radius-project/radius/pkg/ucp/resources" +) + +const ( + // PlaneTypeAWS defines the type name of the AWS plane. + PlaneTypeAWS = "aws" + + // ScopeAccounts defines the account scope for AWS resources. + ScopeAccounts = "accounts" + + // ScopeRegions defines the region scope for AWS resources. + ScopeRegions = "regions" +) + +// ToAWSResourceType takes an ID and returns a string representing the AWS resource type. +func ToAWSResourceType(id resources.ID) string { + parts := []string{} + // AWS ARNs use :: as separator. + for _, segment := range id.TypeSegments() { + parts = append(parts, strings.ReplaceAll(strings.ReplaceAll(segment.Type, ".", "::"), "/", "::")) + } + resourceType := strings.Join(parts, "::") + return resourceType +} diff --git a/pkg/ucp/resources/aws_test.go b/pkg/ucp/resources/aws/aws_test.go similarity index 89% rename from pkg/ucp/resources/aws_test.go rename to pkg/ucp/resources/aws/aws_test.go index 519d081472..fae5ba586f 100644 --- a/pkg/ucp/resources/aws_test.go +++ b/pkg/ucp/resources/aws/aws_test.go @@ -14,11 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package resources +package aws import ( "testing" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) @@ -26,7 +27,7 @@ func Test_ToAWSResourceType(t *testing.T) { expected := "AWS::S3::Bucket" resourceId := "/planes/aws/aws/accounts/123341234/regions/us-west-2/providers/AWS.S3/Bucket" - id, err := Parse(resourceId) + id, err := resources.Parse(resourceId) require.NoError(t, err) actual := ToAWSResourceType(id) diff --git a/pkg/ucp/resources/aws/doc.go b/pkg/ucp/resources/aws/doc.go new file mode 100644 index 0000000000..fa7b5f4ad6 --- /dev/null +++ b/pkg/ucp/resources/aws/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// package aws defines utility functions and constants for working with AWS types and UCP resource IDs. +package aws diff --git a/pkg/ucp/resources/azure/azure.go b/pkg/ucp/resources/azure/azure.go new file mode 100644 index 0000000000..1c19114e80 --- /dev/null +++ b/pkg/ucp/resources/azure/azure.go @@ -0,0 +1,34 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package azure + +import "github.com/radius-project/radius/pkg/ucp/resources" + +const ( + // PlaneTypeAzure defines the type name of the Azure plane. + PlaneTypeAzure = "azure" + + // ScopeSubscriptions is the scope for an Azure subscription ID. + ScopeSubscriptions = "subscriptions" + // ScopeResourceGroups is the scope for an Azure Resource Group. + ScopeResourceGroups = "resourcegroups" +) + +// IsAzureResource returns true if the given resource ID is an Azure resource. +func IsAzureResource(id resources.ID) bool { + return (id.FindScope(ScopeSubscriptions) != "" || id.FindScope(PlaneTypeAzure) != "") && id.IsResource() +} diff --git a/pkg/ucp/resources/azure/doc.go b/pkg/ucp/resources/azure/doc.go new file mode 100644 index 0000000000..9dbc99d15f --- /dev/null +++ b/pkg/ucp/resources/azure/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// package azure defines utility functions and constants for working with Azure types and UCP resource IDs. +package azure diff --git a/pkg/ucp/resources/azure/resource_types.go b/pkg/ucp/resources/azure/resource_types.go new file mode 100644 index 0000000000..a770af17fe --- /dev/null +++ b/pkg/ucp/resources/azure/resource_types.go @@ -0,0 +1,26 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package azure + +const ( + // ResourceTypeManagedIdentityUserAssignedManagedIdentity is the resource type of a user-assigned managed identity. + ResourceTypeManagedIdentityUserAssignedManagedIdentity = "Microsoft.ManagedIdentity/userAssignedIdentities" + // ResourceTypeManagedIdentityUserAssignedManagedIdentityFederatedIdentityCredential is the resource type of a federated identity credential for a user-assigned managed identity. + ResourceTypeManagedIdentityUserAssignedManagedIdentityFederatedIdentityCredential = "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials" + // ResourceTypeAuthorizationRoleAssignment is the resource type of a role assignment. + ResourceTypeAuthorizationRoleAssignment = "Microsoft.Authorization/roleAssignments" +) diff --git a/pkg/ucp/resources/id.go b/pkg/ucp/resources/id.go index 09b04c96e3..00abdf92f1 100644 --- a/pkg/ucp/resources/id.go +++ b/pkg/ucp/resources/id.go @@ -17,47 +17,33 @@ limitations under the License. package resources import ( + "encoding/json" "fmt" "net/http" "strings" - - "golang.org/x/exp/slices" ) const ( - SegmentSeparator = "/" - PlanesSegment = "planes" - ProvidersSegment = "providers" - ResourceGroupsSegment = "resourcegroups" - SubscriptionsSegment = "subscriptions" - LocationsSegment = "locations" - AccountsSegment = "accounts" - RegionsSegment = "regions" - - CoreRPNamespace = "Applications.Core" - LinkRPNamespace = "Applications.Link" - DatastoresRPNamespace = "Applications.Datastores" - DaprRPNamespace = "Applications.Dapr" - MessagingRPNamespace = "Applications.Messaging" + // SegmentSeparator is the separator between segments in a resource ID. + SegmentSeparator = "/" + + // ProvidersSegment is the segment that separates the scope from the resource type. + ProvidersSegment = "providers" + + // PlanesSegment is the segment the planes delimiter that distinguishes between UCP and ARM resource IDs. + PlanesSegment = "planes" PlaneTypePrefix = "System.Planes" ResourceGroupType = "System.Resources/resourceGroups" ) -var supportedNamespaces = []string{ - CoreRPNamespace, - LinkRPNamespace, - DatastoresRPNamespace, - DaprRPNamespace, - MessagingRPNamespace, -} - // ID represents an ARM or UCP resource id. ID is immutable once created. Use Parse() or ParseXyz() // to create IDs and use String() to convert back to strings. type ID struct { - id string - scopeSegments []ScopeSegment - typeSegments []TypeSegment + id string + scopeSegments []ScopeSegment + typeSegments []TypeSegment + extensionSegments []TypeSegment } // ScopeSegment represents one of the root-scope pairs of a resource ID. @@ -89,10 +75,18 @@ type TypeSegment struct { Name string } +// KnownType represents a known resource type. Since resource types can have child types, this +// includes multiple segments. type KnownType struct { + // Types is the set of TypeSegments that make up the type. Types []TypeSegment } +// IDEquals compares two IDs for equality. +func IDEquals(x ID, y ID) bool { + return strings.EqualFold(x.String(), y.String()) +} + // IsEmpty checks if the ID is empty. func (ri ID) IsEmpty() bool { return ri.id == "" @@ -106,6 +100,7 @@ func (ri ID) IsEmpty() bool { func (ri ID) IsScope() bool { return !ri.IsEmpty() && // Not empty len(ri.typeSegments) == 0 && // Not a type + len(ri.extensionSegments) == 0 && (len(ri.scopeSegments) == 0 || len(ri.scopeSegments[len(ri.scopeSegments)-1].Name) > 0) // No scope segments or last one is named } @@ -114,9 +109,19 @@ func (ri ID) IsScope() bool { // Example: // // /planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app +// /planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type/my-extension func (ri ID) IsResource() bool { - return !ri.IsEmpty() && // Not empty - len(ri.typeSegments) > 0 && len(ri.typeSegments[len(ri.typeSegments)-1].Name) > 0 // Has type segments and last one is named + if ri.IsEmpty() { + return false + } + + if len(ri.extensionSegments) > 0 { + // Has at least one extension segment, and the last one is named. + return len(ri.extensionSegments) > 0 && len(ri.extensionSegments[len(ri.extensionSegments)-1].Name) > 0 + } + + // Has type segments and last one is named + return len(ri.typeSegments) > 0 && len(ri.typeSegments[len(ri.typeSegments)-1].Name) > 0 } // IsScopeCollection returns true if the ID represents a collection or custom action on a scope. @@ -127,6 +132,7 @@ func (ri ID) IsResource() bool { func (ri ID) IsScopeCollection() bool { return !ri.IsEmpty() && // Not empty len(ri.typeSegments) == 0 && // No type segments + len(ri.extensionSegments) == 0 && // No extension segments len(ri.scopeSegments) > 0 && len(ri.scopeSegments[len(ri.scopeSegments)-1].Name) == 0 // Has scope segments and last one is un-named } @@ -135,9 +141,39 @@ func (ri ID) IsScopeCollection() bool { // Example: // // /planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications +// /planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type func (ri ID) IsResourceCollection() bool { - return !ri.IsEmpty() && // Not empty - len(ri.typeSegments) > 0 && len(ri.typeSegments[len(ri.typeSegments)-1].Name) == 0 // Has type segments and last one is un-named + if ri.IsEmpty() { + return false + } + + if len(ri.extensionSegments) > 0 { + // Has at least one extension segment, and the last one is un-named. + return len(ri.extensionSegments) > 0 && len(ri.extensionSegments[len(ri.extensionSegments)-1].Name) == 0 + } + + // Has type segments and last one is un-named + return len(ri.typeSegments) > 0 && len(ri.typeSegments[len(ri.typeSegments)-1].Name) == 0 +} + +// IsExtensionResource returns true if the ID represents an extension resource. +// +// Example: +// +// /planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type/my-extension +func (ri ID) IsExtensionResource() bool { + // Has at least one extension segment, and the last one is named. + return len(ri.extensionSegments) > 0 && len(ri.extensionSegments[len(ri.extensionSegments)-1].Name) > 0 +} + +// IsExtensionCollection returns true if the ID represents a collection or custom action on an extension resource. +// +// Example: +// +// /planes/radius/local/resourceGroups/rg1/providers/Applications.Core/applications/my-app/providers/Some.Other/type +func (ri ID) IsExtensionCollection() bool { + // Has at least one extension segment, and the last one is named. + return len(ri.extensionSegments) > 0 && len(ri.extensionSegments[len(ri.extensionSegments)-1].Name) == 0 } // IsUCPQualfied checks if the ID has a prefix of SegmentSeparator and PlanesSegment. @@ -155,6 +191,11 @@ func (ri ID) TypeSegments() []TypeSegment { return ri.typeSegments } +// ExtensionSegments gets the slice of extension segments. +func (ri ID) ExtensionSegments() []TypeSegment { + return ri.extensionSegments +} + // This function returns the "id" field of the given ID instance. func (ri ID) String() string { return ri.id @@ -170,7 +211,9 @@ func (ri ID) FindScope(scopeType string) string { return "" } -// RootScope returns the root-scope (the part before 'providers'), taking into account whether the ID is qualified for UCP or not. +// RootScope returns the root-scope (the part before the first 'providers'), taking into account whether the ID is qualified for UCP or not. +// +// For an exension resource the root scope is the same as its parent resource's root scope. // // Examples: // @@ -202,7 +245,7 @@ func (ri ID) RootScope() string { func (ri ID) PlaneScope() string { segments := []string{} for _, t := range ri.scopeSegments { - if !strings.EqualFold(t.Type, ResourceGroupsSegment) { + if !strings.EqualFold(t.Type, "resourcegroups") { segments = append(segments, t.Type) if t.Name != "" { segments = append(segments, t.Name) @@ -219,31 +262,31 @@ func (ri ID) PlaneScope() string { return SegmentSeparator + joined } -// ProviderNamespace returns the providers part of the ID +// ProviderNamespace returns the namespace of the resource provider. Will be empty if the resource ID +// is empty or refers to a scope. +// // Examples: // // Applications.Core func (ri ID) ProviderNamespace() string { - if len(ri.typeSegments) == 0 { - return "" + if len(ri.extensionSegments) > 0 { + segments := strings.Split(ri.extensionSegments[0].Type, SegmentSeparator) + return segments[0] + } + + if len(ri.typeSegments) > 0 { + segments := strings.Split(ri.typeSegments[0].Type, SegmentSeparator) + return segments[0] } - segments := strings.Split(ri.typeSegments[0].Type, SegmentSeparator) - return segments[0] -} -// IsRadiusRPResource checks if the given ID is a supported Radius resource. -func (ri ID) IsRadiusRPResource() bool { - return slices.Contains(supportedNamespaces, ri.ProviderNamespace()) + return "" } // PlaneNamespace returns the plane part of the UCP ID, or an empty string if the ID is not UCP qualified. // -// Note: This function does NOT handle invalid IDs. If an invalid ID calls this function then there is -// a chance that it is going to trigger a panic. -// // Examples: // -// radius +// radius/local func (ri ID) PlaneNamespace() string { if !ri.IsUCPQualfied() { return "" @@ -261,21 +304,57 @@ func (ri ID) PlaneNamespace() string { // // Examples: // -// /Applications.Core/applications/my-app +// Applications.Core/applications/my-app func (ri ID) RoutingScope() string { segments := []string{} - for _, t := range ri.typeSegments { - segments = append(segments, t.Type) - if t.Name != "" { - segments = append(segments, t.Name) + + if len(ri.extensionSegments) > 0 { + for _, t := range ri.extensionSegments { + segments = append(segments, t.Type) + if t.Name != "" { + segments = append(segments, t.Name) + } + } + } else { + for _, t := range ri.typeSegments { + segments = append(segments, t.Type) + if t.Name != "" { + segments = append(segments, t.Name) + } } } return strings.Join(segments, SegmentSeparator) } +// ParentResource returns the parent resource of the resource ID, or an empty string if the ID is a scope or non-extension resource. +// +// Example: +// +// /planes/radius/local/resourceGroups/cool-group/providers/Applications.Core/application/my-app/providers/Applications.Core/someExtensionType/my-extension +// => /planes/radius/local/resourceGroups/cool-group/providers/Applications.Core/application/my-app +func (ri ID) ParentResource() string { + if len(ri.extensionSegments) == 0 { + return "" + } + + if ri.IsUCPQualfied() { + return MakeUCPID(ri.scopeSegments, ri.typeSegments, nil) + } else { + return MakeRelativeID(ri.scopeSegments, ri.typeSegments, nil) + } +} + // Type returns the fully-qualified resource type of a ResourceID, or an empty string if the type cannot be determined. func (ri ID) Type() string { + if len(ri.extensionSegments) > 0 { + types := make([]string, len(ri.extensionSegments)) + for i, t := range ri.extensionSegments { + types[i] = t.Type + } + return strings.Join(types, SegmentSeparator) + } + if len(ri.typeSegments) > 0 { types := make([]string, len(ri.typeSegments)) for i, t := range ri.typeSegments { @@ -297,24 +376,50 @@ func (ri ID) Type() string { // QualifiedName gets the fully-qualified resource name (eg. `radiusv3/myapp/mycontainer`) by joining the type segments with the SegmentSeparator. func (ri ID) QualifiedName() string { - names := make([]string, len(ri.typeSegments)) - for i, t := range ri.typeSegments { - names[i] = t.Name + names := []string{} + if len(ri.extensionSegments) > 0 { + for _, t := range ri.extensionSegments { + if t.Name != "" { + names = append(names, t.Name) + } + } + + } else if len(ri.typeSegments) > 0 { + for _, t := range ri.typeSegments { + if t.Name != "" { + names = append(names, t.Name) + } + } + } else if len(ri.scopeSegments) > 0 { + for _, t := range ri.scopeSegments { + if t.Name != "" { + names = append(names, t.Name) + } + } + } + + if len(names) == 0 { + return "" } + return strings.Join(names, SegmentSeparator) } // Name gets the resource or scope name. func (ri ID) Name() string { - if len(ri.typeSegments) == 0 && len(ri.scopeSegments) == 0 { - return "" + if len(ri.extensionSegments) > 0 { + return ri.extensionSegments[len(ri.extensionSegments)-1].Name } - if len(ri.typeSegments) == 0 { + if len(ri.typeSegments) > 0 { + return ri.typeSegments[len(ri.typeSegments)-1].Name + } + + if len(ri.scopeSegments) > 0 { return ri.scopeSegments[len(ri.scopeSegments)-1].Name } - return ri.typeSegments[len(ri.typeSegments)-1].Name + return "" } // ValidateResourceType validates that the resource ID type segment matches the expected type. @@ -350,17 +455,23 @@ func invalidType(id string) error { // Append appends a resource type segment to the ID and returns the resulting ID. If the ID is UCP qualified, it will // return a UCP qualified ID, otherwise it will return a relative ID. func (ri ID) Append(resourceType TypeSegment) ID { - types := append(ri.typeSegments, resourceType) + typeSegments := ri.typeSegments + extensionSegments := ri.extensionSegments + if len(ri.extensionSegments) > 0 { + extensionSegments = append(extensionSegments, resourceType) + } else { + typeSegments = append(typeSegments, resourceType) + } if ri.IsUCPQualfied() { - result, err := Parse(MakeUCPID(ri.scopeSegments, types...)) + result, err := Parse(MakeUCPID(ri.scopeSegments, typeSegments, extensionSegments)) if err != nil { panic(err) // Should not be possible. } return result } else { - result, err := Parse(MakeRelativeID(ri.scopeSegments, types...)) + result, err := Parse(MakeRelativeID(ri.scopeSegments, typeSegments, extensionSegments)) if err != nil { panic(err) // Should not be possible. } @@ -371,43 +482,34 @@ func (ri ID) Append(resourceType TypeSegment) ID { // Truncate removes the last type/name pair for a resource id or scope id. Calling truncate on a top level resource or scope has no effect. func (ri ID) Truncate() ID { - if len(ri.typeSegments) == 0 && len(ri.scopeSegments) == 0 { - return ri // Top level scope already - } - - if len(ri.typeSegments) > 0 && len(ri.typeSegments) < 2 { - return ri // Top level resource already - } - - if len(ri.typeSegments) == 0 { - // Truncate the root scope - if ri.IsUCPQualfied() { - result, err := Parse(MakeUCPID(ri.scopeSegments[0:len(ri.scopeSegments)-1], []TypeSegment{}...)) - if err != nil { - panic(err) // Should not be possible. - } - - return result - } else { - result, err := Parse(MakeRelativeID(ri.scopeSegments[0:len(ri.scopeSegments)-1], []TypeSegment{}...)) - if err != nil { - panic(err) // Should not be possible. - } - - return result - } + scopeSegments := ri.scopeSegments + typeSegments := ri.typeSegments + extensionSegments := ri.extensionSegments + + if len(ri.extensionSegments) > 1 { + extensionSegments = extensionSegments[0 : len(extensionSegments)-1] + } else if len(ri.extensionSegments) == 1 { + // Do nothing + return ri + } else if len(ri.typeSegments) > 1 { + typeSegments = typeSegments[0 : len(typeSegments)-1] + } else if len(ri.typeSegments) == 1 { + // Do nothing + return ri + } else if len(ri.scopeSegments) >= 1 { + // Allow the last scope to be truncated. An empty ID is still a "scope". + scopeSegments = scopeSegments[0 : len(scopeSegments)-1] } - // Truncate the resource type if ri.IsUCPQualfied() { - result, err := Parse(MakeUCPID(ri.scopeSegments, ri.typeSegments[0:len(ri.typeSegments)-1]...)) + result, err := Parse(MakeUCPID(scopeSegments, typeSegments, extensionSegments)) if err != nil { panic(err) // Should not be possible. } return result } else { - result, err := Parse(MakeRelativeID(ri.scopeSegments, ri.typeSegments[0:len(ri.typeSegments)-1]...)) + result, err := Parse(MakeRelativeID(scopeSegments, typeSegments, extensionSegments)) if err != nil { panic(err) // Should not be possible. } @@ -416,6 +518,46 @@ func (ri ID) Truncate() ID { } } +// MarshalText implements text marshalling support for Resource IDs. +func (id ID) MarshalText() ([]byte, error) { + return []byte(id.String()), nil +} + +// UnmarshalText implements text unmarshalling support for Resource IDs. +func (id *ID) UnmarshalText(data []byte) error { + parsed, err := Parse(string(data)) + if err != nil { + return fmt.Errorf("failed to unmarshal text, value was not a valid resource ID: %w", err) + } + + // Assign fields into self. + *id = parsed + return nil +} + +// MarshalJSON implements JSON marshalling support for Resource IDs. +func (id ID) MarshalJSON() ([]byte, error) { + return json.Marshal(id.String()) +} + +// UnmarshalJSON implements JSON unmarshalling support for Resource IDs. +func (id *ID) UnmarshalJSON(data []byte) error { + str := "" + err := json.Unmarshal(data, &str) + if err != nil { + return fmt.Errorf("failed to unmarshal JSON, value was not a string: %w", err) + } + + parsed, err := Parse(str) + if err != nil { + return fmt.Errorf("failed to unmarshal JSON, value was not a valid resource ID: %w", err) + } + + // Assign fields into self. + *id = parsed + return nil +} + // ParseByMethod is a helper function to extract the custom actions from the id. // If there is a custom action in the request, then the method will be POST. To be able // to get the proper type, we need to remove the custom action from the id. @@ -472,37 +614,14 @@ func ParseResource(id string) (ID, error) { // Most code should use a more specific function like ParseResource to parse the specific kind of ID // they want to handle. func Parse(id string) (ID, error) { - isUCPQualified := false - if strings.HasPrefix(id, SegmentSeparator+PlanesSegment) { - isUCPQualified = true - id = strings.TrimPrefix(id, SegmentSeparator+PlanesSegment) - - // Handles /planes and /planes/ - if id == "" || id == "/" { - normalized := MakeUCPID([]ScopeSegment{}, []TypeSegment{}...) - return ID{ - id: normalized, - scopeSegments: []ScopeSegment{}, - typeSegments: []TypeSegment{}, - }, nil - } - } - - if id == "/" { - normalized := MakeRelativeID([]ScopeSegment{}, []TypeSegment{}...) - return ID{ - id: normalized, - scopeSegments: []ScopeSegment{}, - typeSegments: []TypeSegment{}, - }, nil - } - - // If UCP forwards a request to the RP, the incoming URL - // will not have the UCP Prefix but will have a planes segment - isUCPForwarded := false - if strings.HasPrefix(id, SegmentSeparator+PlanesSegment) { - isUCPForwarded = true - id = strings.TrimPrefix(id, SegmentSeparator+PlanesSegment) + original := id + // We require the leading / for all IDs, and tolerate a trailing /. + // + // We block // for explicitly for security reasons so we can avoid a reflected redirect attack. + // A URL path that contains `//example.com` could end up in the Location header and result in an open + // redirect. + if !strings.HasPrefix(id, SegmentSeparator) || strings.HasPrefix(id, SegmentSeparator+SegmentSeparator) { + return ID{}, invalid(original) } // trim the leading and ending / so we don't end up with an empty segment - we disallow @@ -510,30 +629,54 @@ func Parse(id string) (ID, error) { id = strings.TrimPrefix(id, SegmentSeparator) id = strings.TrimSuffix(id, SegmentSeparator) - // The minimum segment count is 2 since we can parse "root scope only" ids. - segments := strings.Split(id, SegmentSeparator) + isUCPQualified := false + if strings.EqualFold(id, PlanesSegment) { + isUCPQualified = true + + // We don't need to process the planes segment while parsing. + id = strings.TrimPrefix(id, PlanesSegment) + } else if strings.HasPrefix(id, PlanesSegment+SegmentSeparator) { + isUCPQualified = true - if len(segments) < 2 { - return ID{}, invalid(id) + // We don't need to process the planes segment while parsing. + id = strings.TrimPrefix(id, PlanesSegment+SegmentSeparator) + } + + // Handle trivial case + if id == "" { + normalized := "" + if isUCPQualified { + normalized = MakeUCPID(nil, nil, nil) + } else { + normalized = MakeRelativeID(nil, nil, nil) + } + return ID{ + id: normalized, + }, nil } // Check up front for empty segments + segments := strings.Split(id, SegmentSeparator) for _, s := range segments { if s == "" { - return ID{}, invalid(id) + return ID{}, invalid(original) } } // Parse scopes - iterate until we get to "providers" // - // Each id has a 'scope' portion and an optional 'resource'. The 'providers' segment is the - // delimiter between these. + // Each id has a 'scope' portion and an optional 'resource' followed by an optional 'extension'. + // The '/providers/' segment is the delimiter between these. scopes := []ScopeSegment{} i := 0 for i < len(segments) { - // We're done parsing scopes + // We're done parsing scopes when we reach the providers segment. if strings.ToLower(segments[i]) == ProvidersSegment { + if len(segments) == i+1 { + // Last segment is "providers" + return ID{}, invalid(original) + } i++ // advance past "providers" break } @@ -552,13 +695,9 @@ func Parse(id string) (ID, error) { // odd number of non-providers segments inside the root scope followed by 'providers', this is invalid. // // eg: /planes/radius/local/resourceGroups/test-rg/|resources|/providers/.... - return ID{}, invalid(id) + return ID{}, invalid(original) } - if isUCPForwarded && i == 0 { - // Add the planes segment to the scope - segments[i] = PlanesSegment + SegmentSeparator + segments[i] - } scopes = append(scopes, ScopeSegment{Type: segments[i], Name: segments[i+1]}) i += 2 } @@ -568,22 +707,21 @@ func Parse(id string) (ID, error) { if len(segments)-i == 0 { normalized := "" if isUCPQualified { - normalized = MakeUCPID(scopes, []TypeSegment{}...) + normalized = MakeUCPID(scopes, nil, nil) } else { - normalized = MakeRelativeID(scopes, []TypeSegment{}...) + normalized = MakeRelativeID(scopes, nil, nil) } return ID{ id: normalized, scopeSegments: scopes, - typeSegments: []TypeSegment{}, }, nil } // Now that're past providers, we're looking for the namespace/type - that is // at least 2 segments. if len(segments)-i < 2 { - return ID{}, invalid(id) + return ID{}, invalid(original) } resourceType := TypeSegment{Type: fmt.Sprintf("%s/%s", segments[i], segments[i+1])} @@ -597,6 +735,16 @@ func Parse(id string) (ID, error) { types := []TypeSegment{resourceType} for i < len(segments) { + // We're done parsing types when we reach the providers segment. + if strings.ToLower(segments[i]) == ProvidersSegment { + if len(segments) == i+1 { + // Last segment is "providers" + return ID{}, invalid(original) + } + i++ // advance past "providers" + break + } + rt := TypeSegment{Type: segments[i]} i++ @@ -614,17 +762,69 @@ func Parse(id string) (ID, error) { types = append(types, rt) } + if len(segments)-i == 0 { + normalized := "" + if isUCPQualified { + normalized = MakeUCPID(scopes, types, nil) + } else { + normalized = MakeRelativeID(scopes, types, nil) + } + + return ID{ + id: normalized, + scopeSegments: scopes, + typeSegments: types, + }, nil + } + + // If we get here then this is an extension resource. We need to parse another type. + + // Now that're past providers, we're looking for the namespace/type - that is + // at least 2 segments. + if len(segments)-i < 2 { + return ID{}, invalid(original) + } + + extensionType := TypeSegment{Type: fmt.Sprintf("%s/%s", segments[i], segments[i+1])} + i += 2 + + // We intentionally tolerate a "collection" id that omits the last name segment + if len(segments)-i > 0 { + extensionType.Name = segments[i] + i++ + } + extensionTypes := []TypeSegment{extensionType} + + for i < len(segments) { + et := TypeSegment{Type: segments[i]} + i++ + + // check for a resource name + if len(segments)-i == 0 { + // This is a collection. + extensionTypes = append(extensionTypes, et) + break + } + + // we have a name - keep parsing + et.Name = segments[i] + i++ + + extensionTypes = append(extensionTypes, et) + } + normalized := "" if isUCPQualified { - normalized = MakeUCPID(scopes, types...) + normalized = MakeUCPID(scopes, types, extensionTypes) } else { - normalized = MakeRelativeID(scopes, types...) + normalized = MakeRelativeID(scopes, types, extensionTypes) } return ID{ - id: normalized, - scopeSegments: scopes, - typeSegments: types, + id: normalized, + scopeSegments: scopes, + typeSegments: types, + extensionSegments: extensionTypes, }, nil } @@ -632,11 +832,29 @@ func invalid(id string) error { return fmt.Errorf("'%s' is not a valid resource id", id) } +// MustParse parses a resource ID. MustParse will panic if the ID is not valid. This should only +// be used in tests and other circumstances where the ID is known to be valid. +func MustParse(id string) ID { + parsed, err := Parse(id) + if err != nil { + panic(err) + } + return parsed +} + // MakeUCPID creates a fully-qualified UCP resource ID, from the given scopes and resource types. -func MakeUCPID(scopes []ScopeSegment, resourceTypes ...TypeSegment) string { - segments := []string{ - PlanesSegment, +func MakeUCPID(scopes []ScopeSegment, resourceTypes []TypeSegment, extensionTypes []TypeSegment) string { + relative := MakeRelativeID(scopes, resourceTypes, extensionTypes) + if relative == "/" { + return SegmentSeparator + PlanesSegment } + + return SegmentSeparator + PlanesSegment + relative +} + +// MakeRelativeID makes a plane-relative resource ID (ARM style) from a slice of ScopeSegment and a variadic of TypeSegment.. +func MakeRelativeID(scopes []ScopeSegment, resourceTypes []TypeSegment, extensionTypes []TypeSegment) string { + segments := []string{} for _, scope := range scopes { segments = append(segments, scope.Type) if scope.Name != "" { @@ -655,23 +873,13 @@ func MakeUCPID(scopes []ScopeSegment, resourceTypes ...TypeSegment) string { } } - return SegmentSeparator + strings.Join(segments, SegmentSeparator) -} - -// MakeRelativeID makes a plane-relative resource ID (ARM style) from a slice of ScopeSegment and a variadic of TypeSegment.. -func MakeRelativeID(scopes []ScopeSegment, resourceTypes ...TypeSegment) string { - segments := []string{} - for _, scope := range scopes { - segments = append(segments, scope.Type, scope.Name) - } - - if len(resourceTypes) != 0 { + if len(extensionTypes) != 0 { segments = append(segments, ProvidersSegment) - for _, rt := range resourceTypes { - segments = append(segments, rt.Type) - if rt.Name != "" { - segments = append(segments, rt.Name) + for _, et := range extensionTypes { + segments = append(segments, et.Type) + if et.Name != "" { + segments = append(segments, et.Name) } } } diff --git a/pkg/ucp/resources/id_test.go b/pkg/ucp/resources/id_test.go index e599070d53..b11869c21a 100644 --- a/pkg/ucp/resources/id_test.go +++ b/pkg/ucp/resources/id_test.go @@ -21,22 +21,30 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/azure/azresources" - "github.com/project-radius/radius/pkg/linkrp" + "github.com/radius-project/radius/pkg/azure/azresources" + "github.com/radius-project/radius/pkg/portableresources" "github.com/stretchr/testify/require" ) func Test_ParseInvalidIDs(t *testing.T) { values := []string{ "", + "invalid", + "//", + "//example.com", + "subscriptions/{%s}/resourceGroups/{%s}/providers/Microsoft.CustomProviders/", "/subscriptions/{%s}/resourceGroups/{%s}/providers/Microsoft.CustomProviders/", "//subscriptions/{%s}/resourceGroups/{%s}/providers/Microsoft.CustomProviders/resourceProviders", "/subscriptions/{%s}/resourceGroups/{%s}/providers/Microsoft.CustomProviders/resourceProviders//", "/subscriptions/{%s}/resourceGroups/{%s}/providers/Microsoft.CustomProviders//", "/subscriptions/{%s}/resourceGroups//providers/Microsoft.CustomProviders/resourceProviders", "/subscriptions/{%s}/resourceGroups/providers/Microsoft.CustomProviders/resourceProviders", - "/planes/radius", - "/planes/radius/local/resourceGroups//providers/Microsoft.CustomProviders/resourceProviders", + "/subscriptions/{%s}/resourceGroups/providers", + "planes/radius/local/resourceGroups/test-rg/providers/Applications.Test/testType", + + // Missing extension type + "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Test/testType/testResource/providers", + "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Test/testType/testResource/providers/Some.Extension", } for i, v := range values { @@ -50,21 +58,30 @@ func Test_ParseInvalidIDs(t *testing.T) { type idkind string const ( - kindnone idkind = "none" - kindscope idkind = "scope" - kindscopecollection idkind = "scopecollection" - kindresource idkind = "resource" - kindresourcecollection idkind = "resourcecollection" + kindnone idkind = "none" + kindscope idkind = "scope" + kindscopecollection idkind = "scopecollection" + kindresource idkind = "resource" + kindresourcecollection idkind = "resourcecollection" + kindextension idkind = "extension" + kindextensioncollection idkind = "extensioncollection" ) func Test_ParseValidIDs(t *testing.T) { values := []struct { - id string - expected string - scopes []ScopeSegment - types []TypeSegment - kind idkind - provider string + id string + expected string + rootScope string + routingScope string + parentResource string + scopes []ScopeSegment + types []TypeSegment + extensions []TypeSegment + kind idkind + provider string + typeName string + name string + qualifiedName string }{ { id: "/subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders", @@ -76,30 +93,24 @@ func Test_ParseValidIDs(t *testing.T) { types: []TypeSegment{ {Type: "Microsoft.CustomProviders/resourceProviders"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresourcecollection, }, { id: "/planes", expected: "/planes", - scopes: []ScopeSegment{}, - types: []TypeSegment{}, provider: "", kind: kindscope, }, { id: "/planes/", expected: "/planes", - scopes: []ScopeSegment{}, - types: []TypeSegment{}, provider: "", kind: kindscope, }, { id: "/", expected: "/", - scopes: []ScopeSegment{}, - types: []TypeSegment{}, provider: "", kind: kindscope, }, @@ -113,20 +124,7 @@ func Test_ParseValidIDs(t *testing.T) { types: []TypeSegment{ {Type: "Microsoft.CustomProviders/resourceProviders"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", - kind: kindresourcecollection, - }, - { - id: "subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders", - expected: "/subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders", - scopes: []ScopeSegment{ - {Type: "subscriptions", Name: "s1"}, - {Type: "resourceGroups", Name: "r1"}, - }, - types: []TypeSegment{ - {Type: "Microsoft.CustomProviders/resourceProviders"}, - }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresourcecollection, }, { @@ -139,7 +137,7 @@ func Test_ParseValidIDs(t *testing.T) { types: []TypeSegment{ {Type: "Microsoft.CustomProviders/resourceProviders"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresourcecollection, }, { @@ -165,7 +163,7 @@ func Test_ParseValidIDs(t *testing.T) { types: []TypeSegment{ {Type: "Microsoft.CustomProviders/resourceProviders", Name: "radius"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresource, }, { @@ -178,7 +176,7 @@ func Test_ParseValidIDs(t *testing.T) { types: []TypeSegment{ {Type: "Microsoft.CustomProviders/resourceProviders", Name: "radius"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresource, }, { @@ -191,7 +189,7 @@ func Test_ParseValidIDs(t *testing.T) { types: []TypeSegment{ {Type: "Microsoft.CustomProviders/resourceProviders", Name: "radius"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresource, }, { @@ -205,7 +203,7 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "Microsoft.CustomProviders/resourceProviders", Name: "radius"}, {Type: "Applications"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresourcecollection, }, { @@ -219,8 +217,11 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "Microsoft.CustomProviders/resourceProviders", Name: "radius"}, {Type: "Applications", Name: "test-app"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", - kind: kindresource, + provider: "Microsoft.CustomProviders", + kind: kindresource, + typeName: "Microsoft.CustomProviders/resourceProviders/Applications", + name: "test-app", + qualifiedName: "radius/test-app", }, { id: "/Subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders/radius/Applications/test-app/Containers", @@ -234,7 +235,7 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "Applications", Name: "test-app"}, {Type: "Containers"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresourcecollection, }, { @@ -249,7 +250,7 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "Applications", Name: "test-app"}, {Type: "Containers", Name: "test"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresource, }, { @@ -265,7 +266,7 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "Applications", Name: "test-app"}, {Type: "Containers", Name: "test"}, }, - provider: "Microsoft.CustomProviders/resourceProviders", + provider: "Microsoft.CustomProviders", kind: kindresource, }, { @@ -281,13 +282,29 @@ func Test_ParseValidIDs(t *testing.T) { provider: "Applications.Core", kind: kindresource, }, + { + id: "/planes", + expected: "/planes", + provider: "", + kind: kindscope, + }, + { + id: "/planes/test", + expected: "/planes/test", + scopes: []ScopeSegment{ + { + Type: "test", + }, + }, + provider: "", + kind: kindscopecollection, + }, { id: "/planes/radius/local/", expected: "/planes/radius/local", scopes: []ScopeSegment{ {Type: "radius", Name: "local"}, }, - types: []TypeSegment{}, provider: "", kind: kindscope, }, @@ -298,9 +315,11 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "radius", Name: "local"}, {Type: "resourceGroups", Name: "r1"}, }, - types: []TypeSegment{}, - provider: "", - kind: kindscope, + provider: "", + kind: kindscope, + typeName: "System.Resources/resourceGroups", + name: "r1", + qualifiedName: "local/r1", }, { id: "/planes/radius/local/resourceGroups/r1/resources", @@ -310,7 +329,6 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "resourceGroups", Name: "r1"}, {Type: "resources", Name: ""}, }, - types: []TypeSegment{}, provider: "", kind: kindscopecollection, }, @@ -327,7 +345,104 @@ func Test_ParseValidIDs(t *testing.T) { provider: "Applications.Core", kind: kindresource, }, - + { + id: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType", + expected: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType", + rootScope: "/planes/radius/local/resourceGroups/r1", + routingScope: "Some.Extension/extensionType", + parentResource: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env", + scopes: []ScopeSegment{ + {Type: "radius", Name: "local"}, + {Type: "resourceGroups", Name: "r1"}, + }, + types: []TypeSegment{{ + Type: "Applications.Core/environments", Name: "env"}, + }, + extensions: []TypeSegment{{ + Type: "Some.Extension/extensionType", Name: "", + }}, + provider: "Some.Extension", + kind: kindextensioncollection, + typeName: "Some.Extension/extensionType", + name: "", + qualifiedName: "", + }, + { + id: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType/extensionResource", + expected: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType/extensionResource", + rootScope: "/planes/radius/local/resourceGroups/r1", + routingScope: "Some.Extension/extensionType/extensionResource", + parentResource: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env", + scopes: []ScopeSegment{ + {Type: "radius", Name: "local"}, + {Type: "resourceGroups", Name: "r1"}, + }, + types: []TypeSegment{{ + Type: "Applications.Core/environments", Name: "env"}, + }, + extensions: []TypeSegment{{ + Type: "Some.Extension/extensionType", Name: "extensionResource", + }}, + provider: "Some.Extension", + kind: kindextension, + typeName: "Some.Extension/extensionType", + name: "extensionResource", + qualifiedName: "extensionResource", + }, + { + id: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType/extensionResource/anotherType", + expected: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType/extensionResource/anotherType", + rootScope: "/planes/radius/local/resourceGroups/r1", + routingScope: "Some.Extension/extensionType/extensionResource/anotherType", + parentResource: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env", + scopes: []ScopeSegment{ + {Type: "radius", Name: "local"}, + {Type: "resourceGroups", Name: "r1"}, + }, + types: []TypeSegment{{ + Type: "Applications.Core/environments", Name: "env"}, + }, + extensions: []TypeSegment{ + { + Type: "Some.Extension/extensionType", Name: "extensionResource", + }, + { + Type: "anotherType", Name: "", + }, + }, + provider: "Some.Extension", + kind: kindextensioncollection, + typeName: "Some.Extension/extensionType/anotherType", + name: "", + qualifiedName: "extensionResource", + }, + { + id: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType/extensionResource/anotherType/anotherName", + expected: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env/providers/Some.Extension/extensionType/extensionResource/anotherType/anotherName", + rootScope: "/planes/radius/local/resourceGroups/r1", + routingScope: "Some.Extension/extensionType/extensionResource/anotherType/anotherName", + parentResource: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env", + scopes: []ScopeSegment{ + {Type: "radius", Name: "local"}, + {Type: "resourceGroups", Name: "r1"}, + }, + types: []TypeSegment{{ + Type: "Applications.Core/environments", Name: "env"}, + }, + extensions: []TypeSegment{ + { + Type: "Some.Extension/extensionType", Name: "extensionResource", + }, + { + Type: "anotherType", Name: "anotherName", + }, + }, + provider: "Some.Extension", + kind: kindextension, + typeName: "Some.Extension/extensionType/anotherType", + name: "anotherName", + qualifiedName: "extensionResource/anotherName", + }, // NOTE: this is NOT actually invalid, just confusing. { id: "/planes/radius/local/resourceGroups/r1/Applications.Core/environments/env", @@ -338,7 +453,6 @@ func Test_ParseValidIDs(t *testing.T) { {Type: "Applications.Core", Name: "environments"}, {Type: "env", Name: ""}, }, - types: []TypeSegment{}, provider: "", kind: kindscopecollection, }, @@ -346,22 +460,40 @@ func Test_ParseValidIDs(t *testing.T) { for i, v := range values { t.Run(fmt.Sprintf("%d: %v", i, v.id), func(t *testing.T) { + t.Logf("parsing %q", v.id) id, err := Parse(v.id) require.NoError(t, err) require.Equalf(t, v.expected, id.id, "id comparison failed for %s", v.id) require.Equalf(t, v.scopes, id.scopeSegments, "scope comparison failed for %s", v.id) + require.Equalf(t, v.types, id.typeSegments, "type comparison failed for %s", v.id) + require.Equalf(t, v.extensions, id.extensionSegments, "extension comparison failed for %s", v.id) + require.Equal(t, v.provider, id.ProviderNamespace(), "Provider") + if v.rootScope != "" { + require.Equal(t, v.rootScope, id.RootScope(), "RootScope") + } + if v.routingScope != "" { + require.Equal(t, v.routingScope, id.RoutingScope(), "RoutingScope") + } + require.Equal(t, v.parentResource, id.ParentResource(), "ParentResource") + + if v.typeName != "" { + require.Equal(t, v.typeName, id.Type(), "Type") + } + if v.name != "" { + require.Equal(t, v.name, id.Name(), "Name") + } + if v.qualifiedName != "" { + require.Equal(t, v.qualifiedName, id.QualifiedName(), "QualifiedName") + } require.NotEqual(t, kindnone, v.kind, "test must specify id kind") - require.Equal(t, v.kind == kindresource, id.IsResource(), "IsResource") require.Equal(t, v.kind == kindscope, id.IsScope(), "IsScope") - require.Equal(t, v.kind == kindresourcecollection, id.IsResourceCollection(), "IsResourceCollection") require.Equal(t, v.kind == kindscopecollection, id.IsScopeCollection(), "IsScopeCollection") - - require.Lenf(t, id.typeSegments, len(v.types), "types comparison failed for %s", v.id) - for i := range id.typeSegments { - require.Equalf(t, v.types[i], id.typeSegments[i], "types comparison failed for %s", v.id) - } + require.Equal(t, (v.kind == kindresource || v.kind == kindextension), id.IsResource(), "IsResource") + require.Equal(t, (v.kind == kindresourcecollection || v.kind == kindextensioncollection), id.IsResourceCollection(), "IsResourceCollection") + require.Equal(t, v.kind == kindextension, id.IsExtensionResource(), "IsExtensionResource") + require.Equal(t, v.kind == kindextensioncollection, id.IsExtensionCollection(), "IsExtensionCollection") }) } } @@ -471,7 +603,7 @@ func Test_MakeRelativeID(t *testing.T) { {Type: "resourceGroups", Name: "r1"}, } t.Run(fmt.Sprintf("%d: %v", i, v.expected), func(t *testing.T) { - actual := MakeRelativeID(scopes, v.types...) + actual := MakeRelativeID(scopes, v.types, nil) require.Equal(t, v.expected, actual) }) } @@ -487,17 +619,17 @@ func Test_FindScope(t *testing.T) { cases := []testcase{ { ID: "/subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders/radius/Applications/test-app", - Segment: SubscriptionsSegment, + Segment: "subscriptions", Expected: "s1", }, { ID: "/subscriPtions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders/radius/Applications/test-app", - Segment: SubscriptionsSegment, + Segment: "Subscriptions", Expected: "s1", }, { ID: "/subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders/radius/Applications/test-app", - Segment: ResourceGroupsSegment, + Segment: "resourcegroups", Expected: "r1", }, { @@ -507,7 +639,7 @@ func Test_FindScope(t *testing.T) { }, { ID: "/planes/radius/local/resourceGroups/r1/providers/Applications.Core/environments/env", - Segment: ResourceGroupsSegment, + Segment: "resourcegroups", Expected: "r1", }, } @@ -553,6 +685,14 @@ func Test_Append_NamedResource_UCP(t *testing.T) { require.Equal(t, "/planes/azure/azurecloud/subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders/radius/Applications/test-app/test-resource/test-name", appended.id) } +func Test_Append_Extension(t *testing.T) { + id, err := Parse("/planes/azure/azurecloud/subscriptions/s1/resourceGroups/r1/providers/Microsoft.Storage/storageAccounts/test-account/providers/Some.Extension/extensionType/extensionResource") + require.NoError(t, err) + + appended := id.Append(TypeSegment{Name: "test-name", Type: "test-resource"}) + require.Equal(t, "/planes/azure/azurecloud/subscriptions/s1/resourceGroups/r1/providers/Microsoft.Storage/storageAccounts/test-account/providers/Some.Extension/extensionType/extensionResource/test-resource/test-name", appended.id) +} + func Test_Truncate_Success(t *testing.T) { id, err := Parse("/subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders/radius/Applications/test-app") require.NoError(t, err) @@ -569,6 +709,14 @@ func Test_Truncate_Success_Scope(t *testing.T) { require.Equal(t, "/subscriptions/s1", truncated.id) } +func Test_Truncate_Success_Extension(t *testing.T) { + id, err := Parse("/subscriptions/s1/resourceGroups/r1/providers/Microsoft.Storage/storageAccounts/test-account/providers/Some.Extension/extensionType/extensionResource/anotherType/anotherName") + require.NoError(t, err) + + truncated := id.Truncate() + require.Equal(t, "/subscriptions/s1/resourceGroups/r1/providers/Microsoft.Storage/storageAccounts/test-account/providers/Some.Extension/extensionType/extensionResource", truncated.id) +} + func Test_Truncate_Success_Scope_UCP(t *testing.T) { id, err := Parse("/planes/azure/azurecloud/subscriptions/s1/resourceGroups/r1/") require.NoError(t, err) @@ -577,6 +725,14 @@ func Test_Truncate_Success_Scope_UCP(t *testing.T) { require.Equal(t, "/planes/azure/azurecloud/subscriptions/s1", truncated.id) } +func Test_Truncate_Success_Scope_Empty(t *testing.T) { + id, err := Parse("/planes/azure/azurecloud") + require.NoError(t, err) + + truncated := id.Truncate() + require.Equal(t, "/planes", truncated.id) +} + func Test_Truncate_Success_UCP(t *testing.T) { id, err := Parse("/planes/azure/azurecloud/subscriptions/s1/resourceGroups/r1/providers/Microsoft.CustomProviders/resourceProviders/radius/Applications/test-app") require.NoError(t, err) @@ -609,12 +765,20 @@ func Test_Truncate_ReturnsSelfForTopLevelScope_UCP(t *testing.T) { require.Equal(t, "/planes", truncated.id) } +func Test_Truncate_ReturnsSelfForTopLevelExtension(t *testing.T) { + id, err := Parse("/subscriptions/s1/resourceGroups/r1/providers/Microsoft.Storage/storageAccounts/test-account/providers/Some.Extension/extensionType/extensionResource") + require.NoError(t, err) + + truncated := id.Truncate() + require.Equal(t, "/subscriptions/s1/resourceGroups/r1/providers/Microsoft.Storage/storageAccounts/test-account/providers/Some.Extension/extensionType/extensionResource", truncated.id) +} + func Test_Truncate_WithCustomAction(t *testing.T) { - id, err := Parse("/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0/listSecrets") + id, err := Parse("/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0/listSecrets") require.NoError(t, err) truncated := id.Truncate() - require.Equal(t, "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", truncated.id) + require.Equal(t, "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", truncated.id) } func Test_IdParsing_WithNoTypeSegments(t *testing.T) { @@ -680,12 +844,6 @@ func TestPlaneNamespace(t *testing.T) { false, "", }, - { - "ucp-invalid-resource", - "/planes/radius", - true, - "", - }, { "ucp-valid-resource", "/planes/radius/local/resourceGroups/radius-test-rg/providers/Applications.Core/containers/test-container-0", @@ -845,98 +1003,98 @@ func Test_ParseByMethod(t *testing.T) { }{ { desc: "ucp-post-with-custom-action", - id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0/listSecrets", + id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0/listSecrets", method: http.MethodPost, err: false, - eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "ucp-get", - id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodGet, err: false, - eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "ucp-list", - id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases", + id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases", method: http.MethodGet, err: false, - eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "ucp-put", - id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodPut, err: false, - eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "ucp-patch", - id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodPatch, err: false, - eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "ucp-delete", - id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodDelete, err: false, - eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "arm-post-with-custom-action", - id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0/listSecrets", + id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0/listSecrets", method: http.MethodPost, err: false, - eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "arm-get", - id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodGet, err: false, - eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "arm-list", - id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases", + id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases", method: http.MethodGet, err: false, - eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "arm-put", - id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodPut, err: false, - eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "arm-patch", - id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodPatch, err: false, - eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, { desc: "arm-delete", - id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", + id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", method: http.MethodDelete, err: false, - eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - eRType: linkrp.MongoDatabasesResourceType, + eID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + eRType: portableresources.MongoDatabasesResourceType, }, } @@ -954,60 +1112,6 @@ func Test_ParseByMethod(t *testing.T) { } } -func Test_RadiusRPResource(t *testing.T) { - values := []struct { - testID ID - expected bool - }{ - { - testID: ID{ - id: "/subscriptions/s1/resourceGroups/r1/providers/Applications.Core/containers/test-container", - scopeSegments: []ScopeSegment{ - {Type: "subscriptions", Name: "s1"}, - {Type: "resourceGroups", Name: "r1"}, - }, - typeSegments: []TypeSegment{ - {Type: "Applications.Core/containers", Name: "test-container"}, - }, - }, - expected: true, - }, - { - testID: ID{ - id: "/subscriptions/s1/resourceGroups/r1/providers/Applications.Link/mongoDatabases/test-mongo", - scopeSegments: []ScopeSegment{ - {Type: "subscriptions", Name: "s1"}, - {Type: "resourceGroups", Name: "r1"}, - }, - typeSegments: []TypeSegment{ - {Type: linkrp.MongoDatabasesResourceType, Name: "test-mongo"}, - }, - }, - expected: true, - }, - { - testID: ID{ - id: "/subscriptions/s1/resourceGroups/r1/providers/Applications.foo/containers/test-container", - scopeSegments: []ScopeSegment{ - {Type: "subscriptions", Name: "s1"}, - {Type: "resourceGroups", Name: "r1"}, - }, - typeSegments: []TypeSegment{ - {Type: "Applications.foo/containers", Name: "test-container"}, - }, - }, - expected: false, - }, - } - - for i, v := range values { - t.Run(fmt.Sprintf("%d: %v", i, v.testID.id), func(t *testing.T) { - radiusResource := v.testID.IsRadiusRPResource() - require.Equal(t, v.expected, radiusResource) - }) - } -} - func Test_Type(t *testing.T) { values := []struct { desc string @@ -1035,9 +1139,9 @@ func Test_Type(t *testing.T) { expected: ResourceGroupType, }, { - desc: "LinkRP resource", - id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - expected: "Applications.Link/mongoDatabases", + desc: "Datasource RP resource", + id: "/planes/radius/local/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + expected: "Applications.Datastores/mongoDatabases", }, { desc: "AWS resource", @@ -1046,8 +1150,8 @@ func Test_Type(t *testing.T) { }, { desc: "Azure resource", - id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Link/mongoDatabases/mongo-database-0", - expected: "Applications.Link/mongoDatabases", + id: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Applications.Datastores/mongoDatabases/mongo-database-0", + expected: "Applications.Datastores/mongoDatabases", }, } for _, tt := range values { @@ -1069,8 +1173,8 @@ func Test_ParseProviderScope(t *testing.T) { desc: "Azure provider resource group", scope: "/subscriptions/test-sub/resourcegroups/test-rg", expectedScopeSegments: []ScopeSegment{ - {Type: SubscriptionsSegment, Name: "test-sub"}, - {Type: ResourceGroupsSegment, Name: "test-rg"}, + {Type: "subscriptions", Name: "test-sub"}, + {Type: "resourcegroups", Name: "test-rg"}, }, }, { @@ -1078,8 +1182,8 @@ func Test_ParseProviderScope(t *testing.T) { scope: "/planes/aws/aws/accounts/000/regions/us-east-1", expectedScopeSegments: []ScopeSegment{ {Type: "aws", Name: "aws"}, - {Type: AccountsSegment, Name: "000"}, - {Type: RegionsSegment, Name: "us-east-1"}, + {Type: "accounts", Name: "000"}, + {Type: "regions", Name: "us-east-1"}, }, }, } diff --git a/pkg/ucp/resources/kubernetes/doc.go b/pkg/ucp/resources/kubernetes/doc.go new file mode 100644 index 0000000000..732aab6736 --- /dev/null +++ b/pkg/ucp/resources/kubernetes/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// package kubernetes defines utility functions and constants for working with Kubernetes types and UCP resource IDs. +package kubernetes diff --git a/pkg/ucp/resources/kubernetes/kubernetes.go b/pkg/ucp/resources/kubernetes/kubernetes.go new file mode 100644 index 0000000000..bf58726e3f --- /dev/null +++ b/pkg/ucp/resources/kubernetes/kubernetes.go @@ -0,0 +1,86 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kubernetes + +import ( + "strings" + + "github.com/radius-project/radius/pkg/ucp/resources" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + // PlaneTypeKubernetes defines the type name of the Kubernetes plane. + PlaneTypeKubernetes = "kubernetes" + + // PlaneNameTODO is the name of the Kubernetes plane to use when the plane name is not known. + // This is similar to context.TODO() in the Go standard library. When we support multiple kubernetes + // clusters in a single Radius instance, we will need to remove this and replace all occurrences. + PlaneNameTODO = "local" + + // ScopeTypeNamespaces defines the type name of the Kubernetes namespace scope. + ScopeNamespaces = "namespaces" +) + +// ToParts returns the component parts of the given UCP resource ID. +func ToParts(id resources.ID) (group, kind, namespace, name string) { + namespace = id.FindScope(ScopeNamespaces) + name = id.Name() + group = id.ProviderNamespace() + if group == "core" { + group = "" + } + _, kind, _ = strings.Cut(id.Type(), "/") + return group, kind, namespace, name +} + +// IDFromMeta returns the UCP resource ID for the given Kubernetes object specified by its GroupVersionKind +// and ObjectMeta. +func IDFromMeta(planeName string, gvk schema.GroupVersionKind, objectMeta metav1.ObjectMeta) resources.ID { + return IDFromParts(planeName, gvk.Group, gvk.Kind, objectMeta.Namespace, objectMeta.Name) +} + +// IDFromParts returns the UCP resource ID for the given Kubernetes object specified by its component parts. +func IDFromParts(planeName string, group string, kind string, namespace string, name string) resources.ID { + if group == "" { + group = "core" + } + + scopes := []resources.ScopeSegment{ + { + Type: PlaneTypeKubernetes, + Name: planeName, + }, + } + + if namespace != "" { + scopes = append(scopes, resources.ScopeSegment{ + Type: ScopeNamespaces, + Name: namespace, + }) + } + + types := []resources.TypeSegment{ + { + Type: group + "/" + kind, + Name: name, + }, + } + + return resources.MustParse(resources.MakeUCPID(scopes, types, nil)) +} diff --git a/pkg/ucp/resources/kubernetes/resource_types.go b/pkg/ucp/resources/kubernetes/resource_types.go new file mode 100644 index 0000000000..6c6e7c6b9d --- /dev/null +++ b/pkg/ucp/resources/kubernetes/resource_types.go @@ -0,0 +1,68 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kubernetes + +import "k8s.io/apimachinery/pkg/runtime/schema" + +const ( + // KindDeployment is the kind of a Kubernetes Deployment. + KindDeployment = "Deployment" + // ResourceTypeDeployment is the resource type of a Kubernetes Deployment. + ResourceTypeDeployment = "apps/Deployment" + // KindSecret is the kind of a Kubernetes Secret. + KindSecret = "Secret" + // ResourceTypeSecret is the resource type of a Kubernetes Secret. + ResourceTypeSecret = "core/Secret" + // KindService is the kind of a Kubernetes Service. + KindService = "Service" + // ResourceTypeService is the resource type of a Kubernetes Service. + ResourceTypeService = "core/Service" + // KindServiceAccount is the kind of a Kubernetes ServiceAccount. + KindServiceAccount = "ServiceAccount" + // ResourceTypeServiceAccount is the resource type of a Kubernetes ServiceAccount. + ResourceTypeServiceAccount = "core/ServiceAccount" + // KindRole is the kind of a Kubernetes Role. + KindRole = "Role" + // ResourceTypeRole is the resource type of a Kubernetes Role. + ResourceTypeRole = "rbac.authorization.k8s.io/Role" + // KindRoleBinding is the kind of a Kubernetes RoleBinding. + KindRoleBinding = "RoleBinding" + // ResourceTypeRoleBinding is the resource type of a Kubernetes RoleBinding. + ResourceTypeRoleBinding = "rbac.authorization.k8s.io/RoleBinding" + // KindSecretProviderClass is the kind of a Kubernetes SecretProviderClass. + KindSecretProviderClass = "SecretProviderClass" + // ResourceTypeSecretProviderClass is the resource type of a Kubernetes SecretProviderClass. + ResourceTypeSecretProviderClass = "secrets-store.csi.x-k8s.io/SecretProviderClass" + + // KindContourHTTPProxy is the kind of a Contour HTTPProxy. + KindContourHTTPProxy = "HTTPProxy" + // ResourceTypeContourHTTPProxy is the resource type of a Contour HTTPProxy. + ResourceTypeContourHTTPProxy = "projectcontour.io/HTTPProxy" + + // ResourceTypeDaprComponent is the resource type of a Dapr component. + ResourceTypeDaprComponent = "dapr.io/Component" +) + +// ResourceTypeFromGVK returns the resource type of a Kubernetes resource given its group, version, and kind. +func ResourceTypeFromGVK(gvk schema.GroupVersionKind) string { + group := gvk.Group + if group == "" { + group = "core" + } + + return group + "/" + gvk.Kind +} diff --git a/pkg/ucp/resources/radius/doc.go b/pkg/ucp/resources/radius/doc.go new file mode 100644 index 0000000000..363be57a77 --- /dev/null +++ b/pkg/ucp/resources/radius/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// package radius defines utility functions and constants for working with Radius types and UCP resource IDs. +package radius diff --git a/pkg/ucp/resources/radius/radius.go b/pkg/ucp/resources/radius/radius.go new file mode 100644 index 0000000000..1cfaf5a50f --- /dev/null +++ b/pkg/ucp/resources/radius/radius.go @@ -0,0 +1,44 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package radius + +import "github.com/radius-project/radius/pkg/ucp/resources" + +const ( + // PlaneTypeRadius defines the type name of the Radius plane. + PlaneTypeRadius = "radius" + + // ScopeResourceGroups is the scope for a Radius Resource Group. + ScopeResourceGroups = "resourcegroups" + + // NamespaceApplicationsCore defines the namespace for the Radius Applications.Core resource provider. + NamespaceApplicationsCore = "Applications.Core" + + // NamespaceApplicationsDatastores defines the namespace for the Radius Applications.Datastores resource provider. + NamespaceApplicationsDatastores = "Applications.Datastores" + + // NamespaceApplicationsDapr defines the namespace for the Radius Applications.Dapr resource provider. + NamespaceApplicationsDapr = "Applications.Dapr" + + // NamespaceApplicationsMessaging defines the namespace for the Radius Applications.Messaging resource provider. + NamespaceApplicationsMessaging = "Applications.Messaging" +) + +// IsRadiusResource checks if the given ID represents a resource type, and is defined in the Radius plane. +func IsRadiusResource(id resources.ID) bool { + return id.FindScope("radius") != "" && id.IsResource() +} diff --git a/pkg/ucp/resources/radius/radius_test.go b/pkg/ucp/resources/radius/radius_test.go new file mode 100644 index 0000000000..001ae8920a --- /dev/null +++ b/pkg/ucp/resources/radius/radius_test.go @@ -0,0 +1,56 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package radius + +import ( + "fmt" + "testing" + + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/stretchr/testify/require" +) + +func Test_IsRadiusResource(t *testing.T) { + values := []struct { + testID resources.ID + expected bool + }{ + { + testID: resources.MustParse("/planes/radius/local/resourceGroups/r1/providers/Applications.Core/containers/test-container"), + expected: true, + }, + { + testID: resources.MustParse("/planes/radius/local/resourceGroups/r1/providers/Applications.Datastores/mongoDatabases/test-mongo"), + expected: true, + }, + { + testID: resources.MustParse("/planes/radius/local/resourceGroups/r1/providers/Applications.foo/containers/test-container"), + expected: true, + }, + { + testID: resources.MustParse("/planes/kubernetes/local/resourceGroups/r1/providers/Applications.core/containers/test-container"), + expected: false, + }, + } + + for i, v := range values { + t.Run(fmt.Sprintf("%d: %v", i, v.testID.String()), func(t *testing.T) { + radiusResource := IsRadiusResource(v.testID) + require.Equal(t, v.expected, radiusResource) + }) + } +} diff --git a/pkg/ucp/resources/url.go b/pkg/ucp/resources/url.go index a99d68eab8..90488e4512 100644 --- a/pkg/ucp/resources/url.go +++ b/pkg/ucp/resources/url.go @@ -25,7 +25,7 @@ import ( // ExtractPlanesPrefixFromURLPath splits a URL path into segments and checks if the first two segments are valid, returning // // the first two segments and the remainder of the URL path if valid, or an error if not. -func ExtractPlanesPrefixFromURLPath(path string) (string, string, string, error) { +func ExtractPlanesPrefixFromURLPath(path string) (planeType string, planeName string, remainder string, err error) { // Remove the /planes/foo/bar/ prefix from the URL with the minimum amount of // garbage allocated during parsing. splitCount := 5 @@ -54,7 +54,7 @@ func ExtractPlanesPrefixFromURLPath(path string) (string, string, string, error) return "", "", "", errors.New("URL paths should not contain empty segments") } - remainder := "/" + remainder = "/" if len(segments) > minimumSegmentCount { remainder = SegmentSeparator + segments[3] } diff --git a/pkg/ucp/secret/client.go b/pkg/ucp/secret/client.go index 725ded2b18..c3f9dfad98 100644 --- a/pkg/ucp/secret/client.go +++ b/pkg/ucp/secret/client.go @@ -21,7 +21,7 @@ import ( "encoding/json" ) -//go:generate mockgen -destination=./mock_client.go -package=secret -self_package github.com/project-radius/radius/pkg/ucp/secret github.com/project-radius/radius/pkg/ucp/secret Client +//go:generate mockgen -destination=./mock_client.go -package=secret -self_package github.com/radius-project/radius/pkg/ucp/secret github.com/radius-project/radius/pkg/ucp/secret Client // Client is an interface to implement secret operations. type Client interface { diff --git a/pkg/ucp/secret/etcd/client.go b/pkg/ucp/secret/etcd/client.go index 0416960924..05a26276d6 100644 --- a/pkg/ucp/secret/etcd/client.go +++ b/pkg/ucp/secret/etcd/client.go @@ -19,8 +19,8 @@ package etcd import ( "context" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/util" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/util" etcdclient "go.etcd.io/etcd/client/v3" ) diff --git a/pkg/ucp/secret/etcd/client_test.go b/pkg/ucp/secret/etcd/client_test.go index cd9bdf0f67..f7f033a11d 100644 --- a/pkg/ucp/secret/etcd/client_test.go +++ b/pkg/ucp/secret/etcd/client_test.go @@ -22,10 +22,10 @@ import ( "strconv" "testing" - "github.com/project-radius/radius/pkg/ucp/data" - "github.com/project-radius/radius/pkg/ucp/hosting" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/ucp/data" + "github.com/radius-project/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" etcdclient "go.etcd.io/etcd/client/v3" ) diff --git a/pkg/ucp/secret/kubernetes/client.go b/pkg/ucp/secret/kubernetes/client.go index cc52ebf9b7..6a1c7dfc89 100644 --- a/pkg/ucp/secret/kubernetes/client.go +++ b/pkg/ucp/secret/kubernetes/client.go @@ -19,8 +19,8 @@ package kubernetes import ( "context" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/pkg/ucp/secret" corev1 "k8s.io/api/core/v1" k8s_error "k8s.io/apimachinery/pkg/api/errors" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/ucp/secret/kubernetes/client_test.go b/pkg/ucp/secret/kubernetes/client_test.go index 75ffa2b2b9..f65d502ab3 100644 --- a/pkg/ucp/secret/kubernetes/client_test.go +++ b/pkg/ucp/secret/kubernetes/client_test.go @@ -21,8 +21,8 @@ import ( "encoding/json" "testing" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/test/k8sutil" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/test/k8sutil" "github.com/stretchr/testify/require" "k8s.io/kubectl/pkg/scheme" diff --git a/pkg/ucp/secret/mock_client.go b/pkg/ucp/secret/mock_client.go index e155a7e69d..ccbfdbda66 100644 --- a/pkg/ucp/secret/mock_client.go +++ b/pkg/ucp/secret/mock_client.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/ucp/secret (interfaces: Client) +// Source: github.com/radius-project/radius/pkg/ucp/secret (interfaces: Client) // Package secret is a generated GoMock package. package secret diff --git a/pkg/ucp/secret/provider/factory.go b/pkg/ucp/secret/provider/factory.go index 07d26cc744..396b1995c6 100644 --- a/pkg/ucp/secret/provider/factory.go +++ b/pkg/ucp/secret/provider/factory.go @@ -20,12 +20,12 @@ import ( "context" "errors" - "github.com/project-radius/radius/pkg/kubeutil" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/secret" - "github.com/project-radius/radius/pkg/ucp/secret/etcd" - kubernetes_client "github.com/project-radius/radius/pkg/ucp/secret/kubernetes" - "github.com/project-radius/radius/pkg/ucp/store/etcdstore" + "github.com/radius-project/radius/pkg/kubeutil" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/secret/etcd" + kubernetes_client "github.com/radius-project/radius/pkg/ucp/secret/kubernetes" + "github.com/radius-project/radius/pkg/ucp/store/etcdstore" "k8s.io/kubectl/pkg/scheme" controller_runtime "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -56,7 +56,7 @@ func initETCDSecretClient(ctx context.Context, opts SecretProviderOptions) (secr func initKubernetesSecretClient(ctx context.Context, opt SecretProviderOptions) (secret.Client, error) { s := scheme.Scheme cfg, err := kubeutil.NewClientConfig(&kubeutil.ConfigOptions{ - // TODO: Allow to use custom context via configuration. - https://github.com/project-radius/radius/issues/5433 + // TODO: Allow to use custom context via configuration. - https://github.com/radius-project/radius/issues/5433 ContextName: "", QPS: kubeutil.DefaultServerQPS, Burst: kubeutil.DefaultServerBurst, diff --git a/pkg/ucp/secret/provider/options.go b/pkg/ucp/secret/provider/options.go index b29ce116a6..7e54354446 100644 --- a/pkg/ucp/secret/provider/options.go +++ b/pkg/ucp/secret/provider/options.go @@ -16,7 +16,7 @@ limitations under the License. package provider -import "github.com/project-radius/radius/pkg/ucp/dataprovider" +import "github.com/radius-project/radius/pkg/ucp/dataprovider" // SecretProviderOptions contains provider information of the secret. type SecretProviderOptions struct { diff --git a/pkg/ucp/secret/provider/provider.go b/pkg/ucp/secret/provider/provider.go index ea16ace19e..8365851aef 100644 --- a/pkg/ucp/secret/provider/provider.go +++ b/pkg/ucp/secret/provider/provider.go @@ -21,7 +21,7 @@ import ( "errors" "sync" - "github.com/project-radius/radius/pkg/ucp/secret" + "github.com/radius-project/radius/pkg/ucp/secret" ) var ( diff --git a/pkg/ucp/server/server.go b/pkg/ucp/server/server.go index d6cbc7c75b..85d9f6eab1 100644 --- a/pkg/ucp/server/server.go +++ b/pkg/ucp/server/server.go @@ -18,31 +18,30 @@ package server import ( "errors" - "flag" "fmt" "os" "strings" "time" - hostOpts "github.com/project-radius/radius/pkg/armrpc/hostoptions" - "github.com/project-radius/radius/pkg/kubeutil" - metricsprovider "github.com/project-radius/radius/pkg/metrics/provider" - metricsservice "github.com/project-radius/radius/pkg/metrics/service" - profilerprovider "github.com/project-radius/radius/pkg/profiler/provider" - profilerservice "github.com/project-radius/radius/pkg/profiler/service" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/trace" - "github.com/project-radius/radius/pkg/ucp/backend" - "github.com/project-radius/radius/pkg/ucp/config" - "github.com/project-radius/radius/pkg/ucp/data" - "github.com/project-radius/radius/pkg/ucp/dataprovider" - "github.com/project-radius/radius/pkg/ucp/frontend/api" - "github.com/project-radius/radius/pkg/ucp/hosting" - "github.com/project-radius/radius/pkg/ucp/hostoptions" - qprovider "github.com/project-radius/radius/pkg/ucp/queue/provider" - "github.com/project-radius/radius/pkg/ucp/rest" - "github.com/project-radius/radius/pkg/ucp/secret/provider" - "github.com/project-radius/radius/pkg/ucp/ucplog" + hostOpts "github.com/radius-project/radius/pkg/armrpc/hostoptions" + "github.com/radius-project/radius/pkg/kubeutil" + metricsprovider "github.com/radius-project/radius/pkg/metrics/provider" + metricsservice "github.com/radius-project/radius/pkg/metrics/service" + profilerprovider "github.com/radius-project/radius/pkg/profiler/provider" + profilerservice "github.com/radius-project/radius/pkg/profiler/service" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/trace" + "github.com/radius-project/radius/pkg/ucp/backend" + "github.com/radius-project/radius/pkg/ucp/config" + "github.com/radius-project/radius/pkg/ucp/data" + "github.com/radius-project/radius/pkg/ucp/dataprovider" + "github.com/radius-project/radius/pkg/ucp/frontend/api" + "github.com/radius-project/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/hostoptions" + qprovider "github.com/radius-project/radius/pkg/ucp/queue/provider" + "github.com/radius-project/radius/pkg/ucp/rest" + "github.com/radius-project/radius/pkg/ucp/secret/provider" + "github.com/radius-project/radius/pkg/ucp/ucplog" kube_rest "k8s.io/client-go/rest" ) @@ -114,7 +113,7 @@ func NewServerOptionsFromEnvironment() (Options, error) { var cfg *kube_rest.Config if opts.Config.UCP.Kind == config.UCPConnectionKindKubernetes { cfg, err = kubeutil.NewClientConfig(&kubeutil.ConfigOptions{ - // TODO: Allow to use custom context via configuration. - https://github.com/project-radius/radius/issues/5433 + // TODO: Allow to use custom context via configuration. - https://github.com/radius-project/radius/issues/5433 ContextName: "", QPS: kubeutil.DefaultServerQPS, Burst: kubeutil.DefaultServerBurst, @@ -151,9 +150,6 @@ func NewServerOptionsFromEnvironment() (Options, error) { // NewServer creates a new hosting.Host instance with services for API, EmbeddedETCD, Metrics, Profiler and Backend (if // enabled) based on the given Options. func NewServer(options *Options) (*hosting.Host, error) { - var enableAsyncWorker bool - flag.BoolVar(&enableAsyncWorker, "enable-asyncworker", true, "Flag to run async request process worker (for private preview and dev/test purpose).") - hostingServices := []hosting.Service{ api.NewService(api.ServiceOptions{ ProviderName: UCPProviderName, @@ -191,19 +187,17 @@ func NewServer(options *Options) (*hosting.Host, error) { hostingServices = append(hostingServices, profilerservice.NewService(profilerOptions)) } - if enableAsyncWorker { - backendServiceOptions := hostOpts.HostOptions{ - Config: &hostOpts.ProviderConfig{ - StorageProvider: options.StorageProviderOptions, - SecretProvider: options.SecretProviderOptions, - QueueProvider: options.QueueProviderOptions, - MetricsProvider: options.MetricsProviderOptions, - TracerProvider: options.TracerProviderOptions, - ProfilerProvider: options.ProfilerProviderOptions, - }, - } - hostingServices = append(hostingServices, backend.NewService(backendServiceOptions)) + backendServiceOptions := hostOpts.HostOptions{ + Config: &hostOpts.ProviderConfig{ + StorageProvider: options.StorageProviderOptions, + SecretProvider: options.SecretProviderOptions, + QueueProvider: options.QueueProviderOptions, + MetricsProvider: options.MetricsProviderOptions, + TracerProvider: options.TracerProviderOptions, + ProfilerProvider: options.ProfilerProviderOptions, + }, } + hostingServices = append(hostingServices, backend.NewService(backendServiceOptions)) return &hosting.Host{ Services: hostingServices, diff --git a/pkg/ucp/store/apiserverstore/apiserverclient.go b/pkg/ucp/store/apiserverstore/apiserverclient.go index 2eb75c07ae..739f9766bb 100644 --- a/pkg/ucp/store/apiserverstore/apiserverclient.go +++ b/pkg/ucp/store/apiserverstore/apiserverclient.go @@ -48,12 +48,12 @@ import ( "strings" "unicode" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - ucpv1alpha1 "github.com/project-radius/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" - "github.com/project-radius/radius/pkg/ucp/store/storeutil" - "github.com/project-radius/radius/pkg/ucp/ucplog" - "github.com/project-radius/radius/pkg/ucp/util/etag" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + ucpv1alpha1 "github.com/radius-project/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" + "github.com/radius-project/radius/pkg/ucp/store/storeutil" + "github.com/radius-project/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/util/etag" apierrors "k8s.io/apimachinery/pkg/api/errors" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" diff --git a/pkg/ucp/store/apiserverstore/apiserverclient_test.go b/pkg/ucp/store/apiserverstore/apiserverclient_test.go index e626711737..22cfbcb80f 100644 --- a/pkg/ucp/store/apiserverstore/apiserverclient_test.go +++ b/pkg/ucp/store/apiserverstore/apiserverclient_test.go @@ -28,13 +28,13 @@ import ( "k8s.io/apimachinery/pkg/runtime" runtimeclient "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - ucpv1alpha1 "github.com/project-radius/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" - "github.com/project-radius/radius/pkg/ucp/util/etag" - "github.com/project-radius/radius/test/testcontext" - "github.com/project-radius/radius/test/ucp/kubeenv" - shared "github.com/project-radius/radius/test/ucp/storetest" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + ucpv1alpha1 "github.com/radius-project/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" + "github.com/radius-project/radius/pkg/ucp/util/etag" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/ucp/kubeenv" + shared "github.com/radius-project/radius/test/ucp/storetest" ) func Test_ResourceName_Normalize(t *testing.T) { diff --git a/pkg/ucp/store/client.go b/pkg/ucp/store/client.go index c09df0856b..8f735c1b46 100644 --- a/pkg/ucp/store/client.go +++ b/pkg/ucp/store/client.go @@ -20,7 +20,7 @@ import ( "context" ) -//go:generate mockgen -destination=./mock_storageClient.go -package=store -self_package github.com/project-radius/radius/pkg/ucp/store github.com/project-radius/radius/pkg/ucp/store StorageClient +//go:generate mockgen -destination=./mock_storageClient.go -package=store -self_package github.com/radius-project/radius/pkg/ucp/store github.com/radius-project/radius/pkg/ucp/store StorageClient type StorageClient interface { Query(ctx context.Context, query Query, options ...QueryOptions) (*ObjectQueryResult, error) diff --git a/pkg/ucp/store/cosmosdb/cosmosdbstorageclient.go b/pkg/ucp/store/cosmosdb/cosmosdbstorageclient.go index 0ebf58fe57..dc4b4f504b 100644 --- a/pkg/ucp/store/cosmosdb/cosmosdbstorageclient.go +++ b/pkg/ucp/store/cosmosdb/cosmosdbstorageclient.go @@ -21,8 +21,9 @@ import ( "fmt" "strings" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/vippsas/go-cosmosdb/cosmosapi" ) @@ -32,7 +33,7 @@ const ( // go-cosmosdb does not return the error response code. Comparing error message is the only way to check the errors. // Once we move to official Go SDK, we can have the better error handling. - // TODO: Switch to the official cosmosdb SDK - https://github.com/project-radius/radius/issues/2225 + // TODO: Switch to the official cosmosdb SDK - https://github.com/radius-project/radius/issues/2225 // 1. Repalce github.com/vippsas/go-cosmosdb/cosmosapi with the official sdk when it supports query api. // 2. Improve error handling using response code instead of string match. errResourceNotFoundMsg = "Resource that no longer exists" @@ -449,7 +450,7 @@ func (c *CosmosDBStorageClient) Save(ctx context.Context, obj *store.Object, opt // /planes/radius/local/... - Partition Key: radius/local // subscriptions/{guid}/... - Partition Key: {guid} func GetPartitionKey(id resources.ID) (string, error) { - partitionKey := NormalizeSubscriptionID(id.FindScope(resources.SubscriptionsSegment)) + partitionKey := NormalizeSubscriptionID(id.FindScope(resources_azure.ScopeSubscriptions)) if id.IsUCPQualfied() { partitionKey = NormalizeLetterOrDigitToUpper(id.PlaneNamespace()) diff --git a/pkg/ucp/store/cosmosdb/cosmosdbstorageclient_test.go b/pkg/ucp/store/cosmosdb/cosmosdbstorageclient_test.go index ce64d2c15f..a696d9d753 100644 --- a/pkg/ucp/store/cosmosdb/cosmosdbstorageclient_test.go +++ b/pkg/ucp/store/cosmosdb/cosmosdbstorageclient_test.go @@ -25,11 +25,11 @@ import ( "testing" "github.com/google/uuid" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/corerp/datamodel" - rpv1 "github.com/project-radius/radius/pkg/rp/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/corerp/datamodel" + rpv1 "github.com/radius-project/radius/pkg/rp/v1" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" "github.com/vippsas/go-cosmosdb/cosmosapi" ) @@ -743,12 +743,12 @@ func TestGetPartitionKey(t *testing.T) { }{ { "env-partition-key", - "subscriptions/00000000-0000-0000-1000-000000000001/resourcegroups/testGroup/providers/applications.core/environments/env0", + "/subscriptions/00000000-0000-0000-1000-000000000001/resourcegroups/testGroup/providers/applications.core/environments/env0", "00000000000000001000000000000001", }, { "env-no-subscription-partition-key", - "resourcegroups/testGroup/providers/applications.core/environments/env0", + "/resourcegroups/testGroup/providers/applications.core/environments/env0", "", }, { diff --git a/pkg/ucp/store/cosmosdb/options.go b/pkg/ucp/store/cosmosdb/options.go index 62f3e1eba9..a0dc279aca 100644 --- a/pkg/ucp/store/cosmosdb/options.go +++ b/pkg/ucp/store/cosmosdb/options.go @@ -16,7 +16,7 @@ limitations under the License. package cosmosdb -import "github.com/project-radius/radius/pkg/ucp/store" +import "github.com/radius-project/radius/pkg/ucp/store" const ( defaultQueryItemCount = 20 diff --git a/pkg/ucp/store/cosmosdb/util.go b/pkg/ucp/store/cosmosdb/util.go index afb5936303..4af73d0ea3 100644 --- a/pkg/ucp/store/cosmosdb/util.go +++ b/pkg/ucp/store/cosmosdb/util.go @@ -22,8 +22,9 @@ import ( "strings" "unicode" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_azure "github.com/radius-project/radius/pkg/ucp/resources/azure" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/spaolacci/murmur3" ) @@ -131,9 +132,9 @@ func NormalizeStorageKey(storageKey string, maxLength int) (string, error) { // GenerateCosmosDBKey takes in an ID object and returns a string and an error if the resource group or resource type and // name fail to normalize. func GenerateCosmosDBKey(id resources.ID) (string, error) { - storageKeys := []string{NormalizeSubscriptionID(id.FindScope(resources.SubscriptionsSegment))} + storageKeys := []string{NormalizeSubscriptionID(id.FindScope(resources_azure.ScopeSubscriptions))} - resourceGroup := id.FindScope(resources.ResourceGroupsSegment) + resourceGroup := id.FindScope(resources_azure.ScopeResourceGroups) if resourceGroup != "" { uniqueResourceGroup, err := NormalizeStorageKey(resourceGroup, ResourceGroupNameMaxStorageKeyLen) diff --git a/pkg/ucp/store/cosmosdb/util_test.go b/pkg/ucp/store/cosmosdb/util_test.go index de25182b47..2a70fa46eb 100644 --- a/pkg/ucp/store/cosmosdb/util_test.go +++ b/pkg/ucp/store/cosmosdb/util_test.go @@ -19,8 +19,8 @@ package cosmosdb import ( "testing" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) @@ -132,49 +132,49 @@ func TestGenerateCosmosDBKey(t *testing.T) { }{ { "env-success-1", - "subscriptions/00000000-0000-0000-1000-000000000001/resourcegroups/testGroup/providers/applications.core/environments/env0", + "/subscriptions/00000000-0000-0000-1000-000000000001/resourcegroups/testGroup/providers/applications.core/environments/env0", "00000000000000001000000000000001-TESTGROUP-APPLICATIONS:2ECORE:2FENVIRONMENTS:2FENV0", nil, }, { "env-success-2", - "subscriptions/eaf9116d-84e7-4720-a841-67ca2b67f888/resourcegroups/testGroup/providers/Applications.Core/environments/appenv", + "/subscriptions/eaf9116d-84e7-4720-a841-67ca2b67f888/resourcegroups/testGroup/providers/Applications.Core/environments/appenv", "EAF9116D84E74720A84167CA2B67F888-TESTGROUP-APPLICATIONS:2ECORE:2FENVIRONMENTS:2FAPPENV", nil, }, { "env-no-rg-success", - "subscriptions/00000000-0000-0000-1000-000000000001/providers/Applications.Core/environments/env0", + "/subscriptions/00000000-0000-0000-1000-000000000001/providers/Applications.Core/environments/env0", "00000000000000001000000000000001-APPLICATIONS:2ECORE:2FENVIRONMENTS:2FENV0", nil, }, { "os-success", - "subscriptions/00000000-0000-0000-1000-000000000001/providers/Applications.Core/locations/westus/operationStatuses/os1", + "/subscriptions/00000000-0000-0000-1000-000000000001/providers/Applications.Core/locations/westus/operationStatuses/os1", "00000000000000001000000000000001-APPLICATIONS:2ECORE:2FLOCATIONS:2FWESTUS:2FOPERATIONSTATUSES:2FOS1", nil, }, { "app-success", - "subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/radius-westus/providers/Applications.Core/applications/todoapp", + "/subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/radius-westus/providers/Applications.Core/applications/todoapp", "7826D962510F407A92A25AEB37AA7B6E-RADIUS:2DWESTUS-APPLICATIONS:2ECORE:2FAPPLICATIONS:2FTODOAPP", nil, }, { "app-long-name-success", - "subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/radius-westus/providers/Applications.Core/applications/longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1", + "/subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/radius-westus/providers/Applications.Core/applications/longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1", "7826D962510F407A92A25AEB37AA7B6E-RADIUS:2DWESTUS-APPLICATIONS:2ECORE:2FAPPLICATIONS:2FLONGAPPLICATIONNAME1LONGAPPLICATIONNAME1LONGAPPLICATIONNAME1LONGAPPLICATIONNAME1LONGAPPLICATIONNAME1LON|651E511DBBDDC783", nil, }, { "app-long-resource-name-success", - "subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/radius-westus/providers/Applications.Core/longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0/longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1", + "/subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/radius-westus/providers/Applications.Core/longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0/longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1", "7826D962510F407A92A25AEB37AA7B6E-RADIUS:2DWESTUS-APPLICATIONS:2ECORE:2FLONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME|279366913EF52FC7", nil, }, { "app-long-rg-app-names-success", - "subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0/providers/Applications.Core/longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0/longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1", + "/subscriptions/7826d962-510f-407a-92a2-5aeb37aa7b6e/resourcegroups/longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0longresourcegroup0/providers/Applications.Core/longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0longresourcename0/longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1longapplicationname1", "7826D962510F407A92A25AEB37AA7B6E-LONGRESOURCEGROUP0LONGRESOURCEGROUP0LONGRESOURC|EF662FD5E8286859-APPLICATIONS:2ECORE:2FLONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME0LONGRESOURCENAME|279366913EF52FC7", nil, }, diff --git a/pkg/ucp/store/etcdstore/etcdclient.go b/pkg/ucp/store/etcdstore/etcdclient.go index 4fbcf365c3..93a81e771b 100644 --- a/pkg/ucp/store/etcdstore/etcdclient.go +++ b/pkg/ucp/store/etcdstore/etcdclient.go @@ -51,10 +51,10 @@ import ( "errors" "strings" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/store/storeutil" - "github.com/project-radius/radius/pkg/ucp/util/etag" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/store/storeutil" + "github.com/radius-project/radius/pkg/ucp/util/etag" etcdclient "go.etcd.io/etcd/client/v3" ) diff --git a/pkg/ucp/store/etcdstore/etcdclient_test.go b/pkg/ucp/store/etcdstore/etcdclient_test.go index 734044d9d6..7fa57dd31f 100644 --- a/pkg/ucp/store/etcdstore/etcdclient_test.go +++ b/pkg/ucp/store/etcdstore/etcdclient_test.go @@ -20,13 +20,13 @@ import ( "context" "testing" - "github.com/project-radius/radius/pkg/ucp/data" - "github.com/project-radius/radius/pkg/ucp/hosting" + "github.com/radius-project/radius/pkg/ucp/data" + "github.com/radius-project/radius/pkg/ucp/hosting" "github.com/stretchr/testify/require" etcdclient "go.etcd.io/etcd/client/v3" - "github.com/project-radius/radius/test/testcontext" - shared "github.com/project-radius/radius/test/ucp/storetest" + "github.com/radius-project/radius/test/testcontext" + shared "github.com/radius-project/radius/test/ucp/storetest" ) func Test_ETCDClient(t *testing.T) { diff --git a/pkg/ucp/store/map.go b/pkg/ucp/store/map.go index 110688ff50..ab236e8f3f 100644 --- a/pkg/ucp/store/map.go +++ b/pkg/ucp/store/map.go @@ -30,7 +30,8 @@ func DecodeMap(in any, out any) error { Result: out, Squash: true, DecodeHook: mapstructure.ComposeDecodeHookFunc( - toTimeHookFunc()), + toTimeHookFunc(), + mapstructure.TextUnmarshallerHookFunc()), } decoder, err := mapstructure.NewDecoder(cfg) if err != nil { diff --git a/pkg/ucp/store/map_test.go b/pkg/ucp/store/map_test.go index d3898f5d7e..fd99198bcd 100644 --- a/pkg/ucp/store/map_test.go +++ b/pkg/ucp/store/map_test.go @@ -22,6 +22,7 @@ import ( "time" "github.com/mitchellh/mapstructure" + "github.com/radius-project/radius/pkg/ucp/resources" "github.com/stretchr/testify/require" ) @@ -105,3 +106,31 @@ func TestDecodeMap_WithTimeDecodeHook(t *testing.T) { require.Equal(t, now, out.CreatedAt.UTC()) } } + +func TestDecodeMap_WithResourceIDs(t *testing.T) { + type datatype struct { + ID resources.ID + } + + t.Run("valid", func(t *testing.T) { + data := map[string]any{ + "ID": "/planes/radius/local/resourceGroups/test-group/providers/Applications.Core/applications/test-app", + } + + out := datatype{} + err := DecodeMap(data, &out) + require.NoError(t, err) + + require.Equal(t, data["ID"], out.ID.String()) + }) + + t.Run("invalid", func(t *testing.T) { + data := map[string]any{ + "ID": "asdf", + } + + out := datatype{} + err := DecodeMap(data, &out) + require.Error(t, err) + }) +} diff --git a/pkg/ucp/store/mock_storageClient.go b/pkg/ucp/store/mock_storageClient.go index dc6ee2e430..1d86105389 100644 --- a/pkg/ucp/store/mock_storageClient.go +++ b/pkg/ucp/store/mock_storageClient.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/project-radius/radius/pkg/ucp/store (interfaces: StorageClient) +// Source: github.com/radius-project/radius/pkg/ucp/store (interfaces: StorageClient) // Package store is a generated GoMock package. package store diff --git a/pkg/ucp/store/storeutil/id.go b/pkg/ucp/store/storeutil/id.go index 57f9bd88bb..03cd8700e5 100644 --- a/pkg/ucp/store/storeutil/id.go +++ b/pkg/ucp/store/storeutil/id.go @@ -19,8 +19,8 @@ package storeutil import ( "strings" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" ) const ( diff --git a/pkg/ucp/store/storeutil/id_test.go b/pkg/ucp/store/storeutil/id_test.go index 8a55b3c476..b118279147 100644 --- a/pkg/ucp/store/storeutil/id_test.go +++ b/pkg/ucp/store/storeutil/id_test.go @@ -19,8 +19,8 @@ package storeutil import ( "testing" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" "github.com/stretchr/testify/require" ) diff --git a/pkg/ucp/ucplog/log.go b/pkg/ucp/ucplog/log.go index 15b0067a10..22f42c35a2 100644 --- a/pkg/ucp/ucplog/log.go +++ b/pkg/ucp/ucplog/log.go @@ -25,7 +25,7 @@ import ( "github.com/go-logr/logr" "github.com/go-logr/zapr" - "github.com/project-radius/radius/pkg/version" + "github.com/radius-project/radius/pkg/version" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" "go.uber.org/zap/zapcore" diff --git a/pkg/ucp/util/normalize_test.go b/pkg/ucp/util/normalize_test.go index 2848a69945..1de19355d7 100644 --- a/pkg/ucp/util/normalize_test.go +++ b/pkg/ucp/util/normalize_test.go @@ -29,7 +29,7 @@ func TestNormalizeString(t *testing.T) { }{ {"applications.core/environments", "applicationscore-environments"}, {"applications.core/provider", "applicationscore-provider"}, - {"applications.link/provider", "applicationslink-provider"}, + {"applications.dapr/provider", "applicationsdapr-provider"}, } for _, tc := range testrt { diff --git a/pkg/validator/apivalidator.go b/pkg/validator/apivalidator.go index 33e3af84ba..84f628eb67 100644 --- a/pkg/validator/apivalidator.go +++ b/pkg/validator/apivalidator.go @@ -23,10 +23,10 @@ import ( "strings" "github.com/go-chi/chi/v5" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/armrpc/rest" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/ucplog" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/armrpc/rest" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) const ( diff --git a/pkg/validator/apivalidator_test.go b/pkg/validator/apivalidator_test.go index a419be3cb0..44d9e05d3f 100644 --- a/pkg/validator/apivalidator_test.go +++ b/pkg/validator/apivalidator_test.go @@ -25,9 +25,9 @@ import ( "strings" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/swagger" - "github.com/project-radius/radius/test/testutil" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/swagger" + "github.com/radius-project/radius/test/testutil" "github.com/go-chi/chi/v5" "github.com/stretchr/testify/require" diff --git a/pkg/validator/loader.go b/pkg/validator/loader.go index d90bf6a5c3..349dfd9f24 100644 --- a/pkg/validator/loader.go +++ b/pkg/validator/loader.go @@ -28,7 +28,7 @@ import ( "github.com/go-openapi/loads" "github.com/go-openapi/spec" - "github.com/project-radius/radius/pkg/ucp/ucplog" + "github.com/radius-project/radius/pkg/ucp/ucplog" ) var ( @@ -57,7 +57,7 @@ func (l *Loader) SupportedVersions(resourceType string) []string { return versions } - // using the openapi key here as all the link resource app models are defines as part of openapi.json. + // using the openapi key here as all the portable resource app models are defines as part of openapi.json. if versions, ok := l.supportedVersions[getOpenapiKey(resourceType)]; ok { return versions } @@ -72,7 +72,7 @@ func (l *Loader) GetValidator(resourceType, version string) (Validator, bool) { return &v, true } - // using the openapi key here as all the link resource app models are defines as part of openapi.json. + // using the openapi key here as all the portable resource app models are defines as part of openapi.json. v, ok = l.validators[getValidatorKey(getOpenapiKey(resourceType), version)] if ok { return &v, true @@ -174,7 +174,7 @@ func getValidatorKey(resourceType, version string) string { return strings.ToLower(resourceType + "-" + version) } -// getOpenapiKey returns Applications.Link/openapi or Applications.Core/openapi based on the resource type. +// getOpenapiKey returns /openapi based on the resource type. func getOpenapiKey(resourceType string) string { s := strings.Split(resourceType, "/") return s[0] + "/openapi" diff --git a/pkg/validator/loader_test.go b/pkg/validator/loader_test.go index 917ec7f75d..0c609332e4 100644 --- a/pkg/validator/loader_test.go +++ b/pkg/validator/loader_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/project-radius/radius/swagger" + "github.com/radius-project/radius/swagger" "github.com/stretchr/testify/require" ) diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index 3c74f5acb1..953208637c 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -33,8 +33,8 @@ import ( "github.com/go-openapi/spec" "github.com/go-openapi/strfmt" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/resources" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/ucp/resources" ) const ( @@ -198,7 +198,7 @@ func (v *validator) ValidateRequest(req *http.Request) []ValidationError { }} } - // WORKAROUND: https://github.com/project-radius/radius/issues/2683 + // WORKAROUND: https://github.com/radius-project/radius/issues/2683 // UCP or DE sends the invalid request which has -1 ContentLength header so validator treats it as empty content. if req.ContentLength < 0 && len(content) > 0 { req.ContentLength = (int64)(len(content)) diff --git a/pkg/validator/validator_test.go b/pkg/validator/validator_test.go index c450731dde..0eb8293b8b 100644 --- a/pkg/validator/validator_test.go +++ b/pkg/validator/validator_test.go @@ -26,7 +26,7 @@ import ( "github.com/go-openapi/runtime/middleware" "github.com/stretchr/testify/require" - "github.com/project-radius/radius/swagger" + "github.com/radius-project/radius/swagger" ) func Test_FindParam(t *testing.T) { @@ -60,7 +60,8 @@ func Test_ToRouteParams(t *testing.T) { } t.Run("non-match", func(t *testing.T) { - req, err := http.NewRequest("", "http://radius/test", nil) + // double slash is an invalid resource ID '//test' + req, err := http.NewRequest("", "http://radius//test", nil) require.NoError(t, err) ps := v.toRouteParams(req) require.Empty(t, ps) diff --git a/pkg/version/version.go b/pkg/version/version.go index 329d5469d9..9e4c596d2c 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -20,7 +20,7 @@ import ( "encoding/json" "fmt" - "github.com/project-radius/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/output" ) // Values for these are injected by the build. diff --git a/swagger/doc.go b/swagger/doc.go index 62a1b9ede9..276098a4ea 100644 --- a/swagger/doc.go +++ b/swagger/doc.go @@ -23,12 +23,12 @@ the REST APIs of Radius resource providers. We use OpenAPI Spec v2 as a source of truth to: 1. Validate the incoming request (/pkg/validator) - 2. Generate Go resource models via autorest (/pkg/corerp/api, /pkg/linkrp/api) and + 2. Generate Go resource models via autorest (/pkg/corerp/api, /pkg/datastores/api, /pkg/dapr/api, /pkg/messaging/api) and 3. Generate Bicep types. OpenAPI specification files must be stored in the structured directory: - specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview + specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview ------------ ---------------------- ------- ------------------------- Product Name RP Namespace preview API version or diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/applications.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/applications.json deleted file mode 100644 index 602fbfc561..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/applications.json +++ /dev/null @@ -1,412 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST API for Applications.Core Application Resource", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/applications": { - "get": { - "description": "List all applications in the given scope.", - "operationId": "Applications_ListByScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusApplicationsListByScope": { - "$ref": "./examples/ApplicationsListByScope.json" - } - }, - "tags": [ - "Applications" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - - ], - "responses": { - "200": { - "description": "Application details.", - "schema": { - "$ref": "#/definitions/ApplicationResourceList" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/applications/{applicationName}": { - "get": { - "description": "Gets the properties of an Application.", - "operationId": "Applications_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusApplicationsGet": { - "$ref": "./examples/ApplicationsGet.json" - } - }, - "tags": [ - "Applications" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "#/parameters/ApplicationNameParameter" - } - ], - "responses": { - "200": { - "description": "Application details.", - "schema": { - "$ref": "#/definitions/ApplicationResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Create or update an Application.", - "operationId": "Applications_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusApplicationsPut": { - "$ref": "./examples/ApplicationsPut.json" - } - }, - "tags": [ - "Applications" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/ApplicationNameParameter" - }, - { - "name": "ApplicationResource", - "description": "application details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/ApplicationResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/ApplicationResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/ApplicationResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "patch": { - "description": "Update the properties of an existing Application.", - "operationId": "Applications_Update", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusApplicationsPatch": { - "$ref": "./examples/ApplicationsPatch.json" - } - }, - "tags": [ - "Applications" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/ApplicationNameParameter" - }, - { - "name": "ApplicationResource", - "description": "application details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/ApplicationResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/ApplicationResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/ApplicationResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Delete an Application.", - "operationId": "Applications_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusApplicationsDelete": { - "$ref": "./examples/ApplicationsDelete.json" - } - }, - "tags": [ - "Applications" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/ApplicationNameParameter" - } - ], - "responses": { - "200": { - "description": "The application was successfully deleted." - }, - "202": { - "description": "The application will be deleted asynchronously." - }, - "204": { - "description": "The application does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "ApplicationResourceList": { - "description": "The list of applications.", - "type": "object", - "properties": { - "value": { - "description": "The list of applications.", - "type": "array", - "items": { - "$ref": "#/definitions/ApplicationResource" - } - }, - "nextLink": { - "description": "The link used to get the next page of applications list.", - "type": "string" - } - } - }, - "ApplicationResource": { - "description": "Radius Application.", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/ApplicationProperties" - } - } - }, - "ApplicationExtension": { - "allOf": [ - { - "$ref": "global.json#/definitions/Extension" - } - ] - }, - "ApplicationKubernetesNamespaceExtension": { - "description": "Specifies application-scoped namespace.", - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/ApplicationExtension" - } - ], - "properties": { - "namespace": { - "type": "string", - "description": "The Kubernetes namespace to use for this application." - } - }, - "required": [ - "namespace" - ], - "x-ms-discriminator-value": "kubernetesNamespace" - }, - "ApplicationKubernetesMetadataExtension": { - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/ApplicationExtension" - } - ], - "description": "Specifies the metadata that should be applied to Kubernetes resources created by all Containers in this Application.", - "properties": { - "annotations": { - "description": "Annotations to be applied to the Kubernetes resources output by the resource", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "labels": { - "description": "Labels to be applied to the Kubernetes resources output by the resource", - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "additionalProperties": false, - "x-ms-discriminator-value": "kubernetesMetadata" - }, - "ApplicationProperties": { - "description": "Application properties", - "type": "object", - "required": [ - "environment" - ], - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Provisioning state of the application at the time the operation was called." - }, - "environment": { - "description": "The resource id of the environment linked to application.", - "type": "string" - }, - "extensions": { - "type": "array", - "items": { - "$ref": "#/definitions/ApplicationExtension" - }, - "description": "Extensions spec of the resource" - }, - "status": { - "$ref": "global.json#/definitions/ResourceStatus", - "description": "Status of the resource", - "readOnly": true - } - } - } - }, - "parameters": { - "ApplicationNameParameter": { - "name": "applicationName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the application.", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/containers.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/containers.json deleted file mode 100644 index 277821d494..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/containers.json +++ /dev/null @@ -1,787 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST API for Applications.Core Container Resource", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/containers": { - "get": { - "description": "List all containers in the given scope.", - "operationId": "Containers_ListByScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ContainersListByScope": { - "$ref": "./examples/ContainersListByScope.json" - } - }, - "tags": [ - "Containers" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - ], - "responses": { - "200": { - "description": "List of Container resources", - "schema": { - "$ref": "#/definitions/ContainerResourceList" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/containers/{containerName}": { - "get": { - "description": "Gets the properties of an Container.", - "operationId": "Containers_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ContainersGet": { - "$ref": "./examples/ContainersGet.json" - } - }, - "tags": [ - "Containers" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/ContainerNameParameter" - } - ], - "responses": { - "200": { - "description": "Container details.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Create or update a Container.", - "operationId": "Containers_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ContainersPut": { - "$ref": "./examples/ContainersPut.json" - } - }, - "tags": [ - "Containers" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/ContainerNameParameter" - }, - { - "name": "ContainerResource", - "description": "containers details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/ContainerResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "patch": { - "description": "Update the properties of an existing Container.", - "operationId": "Containers_Update", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ContainersPatch": { - "$ref": "./examples/ContainersPatch.json" - } - }, - "tags": [ - "Containers" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/ContainerNameParameter" - }, - { - "name": "ContainersResource", - "description": "Container details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/ContainerResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/ContainerResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Delete a Container.", - "operationId": "Containers_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ContainersDelete": { - "$ref": "./examples/ContainersDelete.json" - } - }, - "tags": [ - "Containers" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/ContainerNameParameter" - } - ], - "responses": { - "200": { - "description": "The container was successfully deleted." - }, - "202": { - "description": "The container will be deleted asynchronously." - }, - "204": { - "description": "The container does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "ContainerResourceList": { - "description": "The list of containers.", - "type": "object", - "properties": { - "value": { - "description": "The list of containers.", - "type": "array", - "items": { - "$ref": "#/definitions/ContainerResource" - } - }, - "nextLink": { - "description": "The link used to get the next page of containers list.", - "type": "string" - } - } - }, - "ContainerResource": { - "description": "Container", - "type": "object", - "x-ms-azure-resource": true, - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/ContainerProperties" - } - } - }, - "IamProperties": { - "description": "The properties of IAM", - "type": "object", - "properties": { - "kind": { - "description": "The kind of IAM provider to configure", - "type": "string", - "enum": [ - "azure" - ], - "x-ms-enum": { - "name": "Kind", - "modelAsString": true - } - }, - "roles": { - "description": "RBAC permissions to be assigned on the source resource", - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "kind" - ] - }, - "ConnectionProperties": { - "properties": { - "source": { - "description": "The source of the connection", - "type": "string" - }, - "disableDefaultEnvVars": { - "default": false, - "type": "boolean" - }, - "iam": { - "$ref": "#/definitions/IamProperties" - } - }, - "required": [ - "source" - ] - }, - "ContainerPort": { - "description": "Specifies a listening port for the container", - "type": "object", - "additionalProperties": false, - "required": [ - "containerPort" - ], - "properties": { - "containerPort": { - "description": "The listening port number", - "type": "integer" - }, - "protocol": { - "description": "Protocol in use by the port", - "type": "string", - "enum": [ - "TCP", - "UDP" - ], - "x-ms-enum": { - "name": "Protocol", - "modelAsString": true - } - }, - "provides": { - "description": "Specifies a route provided by this port", - "type": "string" - }, - "scheme": { - "description": "Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value.", - "type": "string" - }, - "port": { - "description": "Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired.", - "type": "integer" - } - } - }, - "HealthProbeProperties": { - "description": "Properties for readiness/liveness probe", - "type": "object", - "discriminator": "kind", - "properties": { - "kind": { - "description": "The HealthProbeProperties kind", - "type": "string" - }, - "initialDelaySeconds": { - "description": "Initial delay in seconds before probing for readiness/liveness", - "type": "number" - }, - "failureThreshold": { - "description": "Threshold number of times the probe fails after which a failure would be reported", - "type": "number" - }, - "periodSeconds": { - "description": "Interval for the readiness/liveness probe in seconds", - "type": "number" - }, - "timeoutSeconds": { - "description": "Number of seconds after which the readiness/liveness probe times out. Defaults to 5 seconds", - "type": "number" - } - }, - "required": [ - "kind" - ] - }, - "HttpGetHealthProbeProperties": { - "description": "Specifies the properties for readiness/liveness probe using HTTP Get", - "allOf": [ - { - "$ref": "#/definitions/HealthProbeProperties" - } - ], - "type": "object", - "additionalProperties": false, - "properties": { - "containerPort": { - "description": "The listening port number", - "type": "integer" - }, - "path": { - "description": "The route to make the HTTP request on", - "type": "string" - }, - "headers": { - "description": "Custom HTTP headers to add to the get request", - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "required": [ - "kind", - "containerPort", - "path" - ], - "x-ms-discriminator-value": "httpGet" - }, - "TcpHealthProbeProperties": { - "description": "Specifies the properties for readiness/liveness probe using TCP", - "allOf": [ - { - "$ref": "#/definitions/HealthProbeProperties" - } - ], - "type": "object", - "additionalProperties": false, - "properties": { - "containerPort": { - "description": "The listening port number", - "type": "integer" - } - }, - "required": [ - "kind", - "containerPort" - ], - "x-ms-discriminator-value": "tcp" - }, - "ExecHealthProbeProperties": { - "description": "Specifies the properties for readiness/liveness probe using an executable", - "allOf": [ - { - "$ref": "#/definitions/HealthProbeProperties" - } - ], - "type": "object", - "additionalProperties": false, - "properties": { - "command": { - "description": "Command to execute to probe readiness/liveness", - "type": "string" - } - }, - "required": [ - "kind", - "command" - ], - "x-ms-discriminator-value": "exec" - }, - "Volume": { - "description": "Specifies a volume for a container", - "discriminator": "kind", - "properties": { - "kind": { - "description": "The Volume kind", - "type": "string" - }, - "mountPath": { - "description": "The path where the volume is mounted", - "type": "string" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - "EphemeralVolume": { - "description": "Specifies an ephemeral volume for a container", - "allOf": [ - { - "$ref": "#/definitions/Volume" - } - ], - "type": "object", - "additionalProperties": false, - "required": [ - "mountPath", - "kind", - "managedStore" - ], - "properties": { - "managedStore": { - "description": "Backing store for the ephemeral volume", - "type": "string", - "enum": [ - "memory", - "disk" - ], - "x-ms-enum": { - "name": "ManagedStore", - "modelAsString": true - } - } - }, - "x-ms-discriminator-value": "ephemeral" - }, - "PersistentVolume": { - "description": "Specifies a persistent volume for a container", - "allOf": [ - { - "$ref": "#/definitions/Volume" - } - ], - "type": "object", - "additionalProperties": false, - "required": [ - "mountPath", - "kind", - "source" - ], - "properties": { - "permission": { - "description": "Container read/write access to the volume", - "type": "string", - "enum": [ - "read", - "write" - ], - "x-ms-enum": { - "name": "VolumePermission", - "modelAsString": true - } - }, - "source": { - "description": "The source of the volume", - "type": "string" - } - }, - "x-ms-discriminator-value": "persistent" - }, - "Container": { - "description": "Definition of a container.", - "type": "object", - "required": [ - "image" - ], - "properties": { - "image": { - "description": "The registry and image to download and run in your container", - "type": "string" - }, - "env": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "ports": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/ContainerPort" - } - }, - "readinessProbe": { - "$ref": "#/definitions/HealthProbeProperties" - }, - "livenessProbe": { - "$ref": "#/definitions/HealthProbeProperties" - }, - "volumes": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Volume" - } - }, - "command": { - "description": "Entrypoint array. Overrides the container image's ENTRYPOINT", - "type": "array", - "items": { - "type": "string" - } - }, - "args": { - "description": "Arguments to the entrypoint. Overrides the container image's CMD", - "type": "array", - "items": { - "type": "string" - } - }, - "workingDir": { - "description": "Working directory for the container", - "type": "string" - } - } - }, - "ContainerExtension": { - "allOf": [ - { - "$ref": "global.json#/definitions/Extension" - } - ] - }, - "ManualScalingExtension": { - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/ContainerExtension" - } - ], - "description": "ManualScaling Extension", - "properties": { - "replicas": { - "description": "Replica count.", - "type": "integer" - } - }, - "additionalProperties": false, - "x-ms-discriminator-value": "manualScaling" - }, - "DaprSidecarExtension": { - "allOf": [ - { - "$ref": "#/definitions/ContainerExtension" - } - ], - "type": "object", - "description": "Specifies the resource should have a Dapr sidecar injected", - "required": [ - "appId" - ], - "properties": { - "appPort": { - "description": "The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. ", - "type": "integer" - }, - "appId": { - "description": "The Dapr appId. Specifies the identifier used by Dapr for service invocation.", - "type": "string" - }, - "config": { - "description": "Specifies the Dapr configuration to use for the resource.", - "type": "string" - }, - "protocol": { - "description": "Specifies the Dapr app-protocol to use for the resource.", - "type": "string", - "enum": [ - "http", - "grpc" - ], - "x-ms-enum": { - "name": "Protocol", - "modelAsString": true - } - } - }, - "additionalProperties": false, - "x-ms-discriminator-value": "daprSidecar" - }, - "ContainerKubernetesMetadataExtension": { - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/ContainerExtension" - } - ], - "description": "Specifies the metadata that should be applied to Kubernetes resources created for the Container resource", - "properties": { - "annotations": { - "description": "Annotations to be applied to the Kubernetes resources output by the resource", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "labels": { - "description": "Labels to be applied to the Kubernetes resources output by the resource", - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "additionalProperties": false, - "x-ms-discriminator-value": "kubernetesMetadata" - }, - "ContainerProperties": { - "allOf": [ - { - "$ref": "global.json#/definitions/BasicResourceProperties" - } - ], - "description": "Container properties", - "type": "object", - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Gets the status of the container at the time the operation was called." - }, - "connections": { - "additionalProperties": { - "$ref": "#/definitions/ConnectionProperties", - "description": "Specifies a connection to another resource." - }, - "type": "object" - }, - "container": { - "$ref": "#/definitions/Container", - "description": "Definition of a container." - }, - "identity": { - "description": "Configuration for supported external identity providers", - "$ref": "global.json#/definitions/IdentitySettings" - }, - "extensions": { - "type": "array", - "items": { - "$ref": "#/definitions/ContainerExtension" - }, - "description": "Extensions spec of the resource" - } - }, - "required": [ - "application", - "container" - ] - } - }, - "parameters": { - "ContainerNameParameter": { - "name": "containerName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the conatiner.", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/environments.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/environments.json deleted file mode 100644 index 155f37af7c..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/environments.json +++ /dev/null @@ -1,593 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST API for Applications.Core Environment Resource", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/environments": { - "get": { - "description": "List all environments in a scope.", - "operationId": "Environments_ListByScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusEnvironmentsListByScope": { - "$ref": "./examples/EnvironmentsListByScope.json" - } - }, - "tags": [ - "Environments" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - ], - "responses": { - "200": { - "description": "Environment details.", - "schema": { - "$ref": "#/definitions/EnvironmentResourceList" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/environments/{environmentName}": { - "get": { - "description": "Gets the properties of an Environment.", - "operationId": "Environments_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusEnvironmentsGet": { - "$ref": "./examples/EnvironmentsGetEnv0.json" - } - }, - "tags": [ - "Environments" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/EnvironmentNameParameter" - } - ], - "responses": { - "200": { - "description": "Environment details.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Create or update an Environment.", - "operationId": "Environments_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusEnvironmentsPut": { - "$ref": "./examples/EnvironmentsPutEnv0.json" - } - }, - "tags": [ - "Environments" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/EnvironmentNameParameter" - }, - { - "name": "EnvironmentResource", - "description": "environment details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "patch": { - "description": "Update the properties of an existing Environment.", - "operationId": "Environments_Update", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusEnvironmentsPatch": { - "$ref": "./examples/EnvironmentsPatchEnv0.json" - } - }, - "tags": [ - "Environments" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/EnvironmentNameParameter" - }, - { - "name": "EnvironmentResource", - "description": "environment details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Delete an Environment.", - "operationId": "Environments_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusEnvironmentsDelete": { - "$ref": "./examples/EnvironmentsDeleteEnv0.json" - } - }, - "tags": [ - "Environments" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/EnvironmentNameParameter" - } - ], - "responses": { - "200": { - "description": "The environment was successfully deleted." - }, - "202": { - "description": "The environment will be deleted asynchronously." - }, - "204": { - "description": "The environment does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Core/environments/{environmentName}/getmetadata": { - "post": { - "description": "Gets recipe metadata including parameters and any constraints on the parameters.", - "operationId": "Environments_GetRecipeMetadata", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusEnvironmentsGetRecipeMetadata": { - "$ref": "./examples/EnvironmentsGetRecipeMetadata.json" - } - }, - "tags": [ - "Environments" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/EnvironmentNameParameter" - }, - { - "name": "RecipeParameter", - "in": "body", - "required": true, - "description": "Recipe parameters.", - "schema": { - "$ref": "#/definitions/Recipe" - } - } - ], - "responses": { - "200": { - "description": "Recipe metadata including parameters and any constraints on the parameters.", - "schema": { - "$ref": "#/definitions/RecipeMetadataProperties" - } - }, - "default": { - "description": "Error response describing the reason for operation failure", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "EnvironmentResourceList": { - "description": "The list of environments.", - "type": "object", - "properties": { - "value": { - "description": "The list of environments.", - "type": "array", - "items": { - "$ref": "#/definitions/EnvironmentResource" - } - }, - "nextLink": { - "description": "The link used to get the next page of environments list.", - "type": "string" - } - } - }, - "EnvironmentResource": { - "description": "Application environment.", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/EnvironmentProperties" - } - } - }, - "EnvironmentExtension": { - "allOf": [ - { - "$ref": "global.json#/definitions/Extension" - } - ] - }, - "EnvironmentKubernetesMetadataExtension": { - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/EnvironmentExtension" - } - ], - "description": "Specifies the metadata that should be applied to Kubernetes resources created by all Containers in this Environment.", - "properties": { - "annotations": { - "description": "Annotations to be applied to the Kubernetes resources output by the resource", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "labels": { - "description": "Labels to be applied to the Kubernetes resources output by the resource", - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "additionalProperties": false, - "x-ms-discriminator-value": "kubernetesMetadata" - }, - "EnvironmentProperties": { - "description": "Application environment properties", - "type": "object", - "required": [ - "compute" - ], - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Provisioning state of the environment at the time the operation was called." - }, - "compute": { - "$ref": "global.json#/definitions/EnvironmentCompute" - }, - "providers": { - "$ref": "#/definitions/Providers", - "description": "Cloud providers configuration for the environment." - }, - "recipes": { - "description": "Specifies Recipes linked to the Environment.", - "additionalProperties": { - "additionalProperties": { - "$ref": "#/definitions/EnvironmentRecipeProperties" - } - }, - "type": "object", - "example": [ - { - "Applications.Link/mongoDatabases": { - "default":{ - "templateKind": "bicep", - "templatePath":"br:sampleregistry.azureacr.io/radius/recipes/mongodb", - "parameters":{ - "port":6060 - } - } - } - } - ] - }, - "extensions": { - "type": "array", - "items": { - "$ref": "#/definitions/EnvironmentExtension" - }, - "description": "Extensions spec of the resource" - } - } - }, - "Providers": { - "description": "Cloud providers configuration", - "properties": { - "azure": { - "type": "object", - "description": "Azure cloud provider configuration", - "properties": { - "scope": { - "type": "string", - "description": "Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup'" - } - } - }, - "aws": { - "type": "object", - "description": "AWS cloud provider configuration", - "properties": { - "scope": { - "type": "string", - "description": "Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2'" - } - } - } - } - }, - "TerraformRecipeProperties":{ - "additionalProperties": false, - "description": "Properties of a Recipe linked to an Environment.", - "allOf": [ - { - "$ref": "#/definitions/EnvironmentRecipeProperties" - } - ], - "properties": { - "templateVersion": { - "description": "Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources.", - "type": "string" - } - }, - "type": "object", - "x-ms-discriminator-value": "terraform" - }, - "BicepRecipeProperties":{ - "additionalProperties": false, - "description": "Properties of a Recipe linked to an Environment.", - "allOf": [ - { - "$ref": "#/definitions/EnvironmentRecipeProperties" - } - ], - "properties": {}, - "type": "object", - "x-ms-discriminator-value": "bicep" - }, - "EnvironmentRecipeProperties": { - "description": "Properties of a Recipe linked to an Environment.", - "discriminator": "templateKind", - "properties": { - "templateKind": { - "description": "Format of the template provided by the recipe. Allowed values: bicep, terraform.", - "type": "string" - }, - "templatePath": { - "description": "Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported.", - "type": "string" - }, - "parameters": { - "description": "Key/value parameters to pass to the recipe template at deployment", - "type": "object", - "example": [ - { - "port": 6060 - } - ] - } - }, - "required": [ - "templateKind", - "templatePath" - ] - }, - "Recipe":{ - "description": "Recipe properties.", - "properties": { - "linkType": { - "description": "Type of the link this recipe can be consumed by. For example: 'Applications.Link/mongoDatabases'", - "type": "string" - }, - "name":{ - "description": "Name of the recipe registered to the environment.", - "type": "string" - } - } - }, - "RecipeMetadataProperties": { - "description": "Properties of a Recipe linked to an Environment.", - "properties": { - "templateKind": { - "description": "Format of the template provided by the recipe. Allowed values: bicep, terraform.", - "type": "string" - }, - "templatePath": { - "description": "Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported.", - "type": "string" - }, - "templateVersion": { - "description": "Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources.", - "type": "string" - }, - "parameters": { - "description": "Key/value parameters to pass to the recipe template at deployment", - "type": "object", - "example": [ - { - "port": 6060 - } - ] - } - } - } - }, - "parameters": { - "EnvironmentNameParameter": { - "name": "environmentName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the environment", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - }, - "RecipeNameParameter": { - "name": "recipeName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the recipe", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsDelete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsDelete.json deleted file mode 100644 index e11f322006..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "applicationName": "app0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsGet.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsGet.json deleted file mode 100644 index cb3f938dfd..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsGet.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "applicationName": "app0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "name": "app0", - "type": "Applications.Core/applications", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - }, - { - "kind": "kubernetesNamespace", - "namespace": "app-ns" - } - ] - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsList.json deleted file mode 100644 index 46f95ae0b2..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsList.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000", - "resourceGroupName": "testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "name": "app0", - "type": "Applications.Core/applications", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - }, - { - "kind": "kubernetesNamespace", - "namespace": "app-ns" - } - ] - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/app1", - "name": "app1", - "type": "Applications.Core/applications", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/applications?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsListByScope.json deleted file mode 100644 index 5b528294ab..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsListByScope.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "name": "app0", - "type": "Applications.Core/applications", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/app1", - "name": "app1", - "type": "Applications.Core/applications", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/applications?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsPatch.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsPatch.json deleted file mode 100644 index d50d58cb20..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsPatch.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "applicationName": "app0", - "api-version": "2022-03-15-privatepreview", - "ApplicationResource": { - "location": "West US", - "properties": { - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - }, - { - "kind": "kubernetesNamespace", - "namespace": "app-ns" - } - ] - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "name": "app0", - "type": "Applications.Core/applications", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - }, - { - "kind": "kubernetesNamespace", - "namespace": "app-ns" - } - ] - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsPut.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsPut.json deleted file mode 100644 index d50d58cb20..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ApplicationsPut.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "applicationName": "app0", - "api-version": "2022-03-15-privatepreview", - "ApplicationResource": { - "location": "West US", - "properties": { - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - }, - { - "kind": "kubernetesNamespace", - "namespace": "app-ns" - } - ] - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "name": "app0", - "type": "Applications.Core/applications", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - }, - { - "kind": "kubernetesNamespace", - "namespace": "app-ns" - } - ] - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_CreateOrUpdate.json new file mode 100644 index 0000000000..14c050a927 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_CreateOrUpdate.json @@ -0,0 +1,62 @@ +{ + "operationId": "Applications_CreateOrUpdate", + "title": "Create or update an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "applicationName": "app0", + "api-version": "2022-03-15-privatepreview", + "ApplicationResource": { + "location": "West US", + "properties": { + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Delete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Delete.json new file mode 100644 index 0000000000..fb1d0bce84 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Applications_Delete", + "title": "Delete an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "applicationName": "app0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Get.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Get.json new file mode 100644 index 0000000000..ff352ff388 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Get.json @@ -0,0 +1,39 @@ +{ + "operationId": "Applications_Get", + "title": "Get an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "applicationName": "app0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_List.json new file mode 100644 index 0000000000..a043784e0d --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_List.json @@ -0,0 +1,52 @@ +{ + "operationId": "Applications_ListByScope", + "title": "Get applications by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/app1", + "name": "app1", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_ListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_ListByScope.json new file mode 100644 index 0000000000..0367e5fb54 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_ListByScope.json @@ -0,0 +1,35 @@ +{ + "operationId": "Applications_ListByScope", + "title": "Get applications by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/app1", + "name": "app1", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/applications?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Update.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Update.json new file mode 100644 index 0000000000..b4dc7bc7d5 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Applications_Update.json @@ -0,0 +1,62 @@ +{ + "operationId": "Applications_Update", + "title": "Update (Patch) an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "applicationName": "app0", + "api-version": "2022-03-15-privatepreview", + "ApplicationResource": { + "location": "West US", + "properties": { + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersDelete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersDelete.json deleted file mode 100644 index 0c05b42c66..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "containerName": "app0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersGet.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersGet.json deleted file mode 100644 index c87ecec53a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersGet.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "containerName": "container0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersList.json deleted file mode 100644 index 4d3350e6f7..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersList.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/containers/container1", - "name": "container1", - "type": "Applications.Core/containers", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app1", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" - }, - "extensions": [ - { - "kind": "manualScaling", - "replicas": 2 - }, - { - "kind": "daprSidecar", - "appId": "app-id", - "appPort": 80, - "config": "config", - "protocol": "http" - }, - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/containers?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersListByScope.json deleted file mode 100644 index 4176c79b19..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersListByScope.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" - }, - "extensions": [ - { - "kind": "manualScaling", - "replicas": 2 - }, - { - "kind": "daprSidecar", - "appId": "app-id", - "appPort": 80, - "config": "config", - "protocol": "http", - "provides": "provides", - "port": 443, - "scheme": "https" - }, - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/containers/container1", - "name": "container1", - "type": "Applications.Core/containers", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app1", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/containers?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersPatch.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersPatch.json deleted file mode 100644 index 8378d06485..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersPatch.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "containerName": "container0", - "api-version": "2022-03-15-privatepreview", - "ContainerResource": { - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" - }, - "extensions": [ - { - "kind": "manualScaling", - "replicas": 2 - }, - { - "kind": "daprSidecar", - "appId": "app-id", - "appPort": 80, - "config": "config", - "protocol": "http" - }, - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersPut.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersPut.json deleted file mode 100644 index 27d06cd251..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ContainersPut.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "containerName": "app0", - "api-version": "2022-03-15-privatepreview", - "ContainerResource": { - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/containers/container0", - "name": "container0", - "type": "Applications.Core/containers", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "connections": { - "inventory": { - "kind": "dapr.io/InvokeHttp", - "source": "inventory_route_id" - } - }, - "container": { - "image": "radius.azurecr.io/webapptutorial-todoapp", - "command": [ - "/bin/sh" - ], - "args": [ - "-c", - "while true; do echo hello; sleep 10;done" - ], - "workingDir": "/app" - }, - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_CreateOrUpdate.json new file mode 100644 index 0000000000..e565785399 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_CreateOrUpdate.json @@ -0,0 +1,66 @@ +{ + "operationId": "Containers_CreateOrUpdate", + "title": "Create or update an container resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "containerName": "app0", + "api-version": "2022-03-15-privatepreview", + "ContainerResource": { + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_CreateOrUpdate_BaseManifest.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_CreateOrUpdate_BaseManifest.json new file mode 100644 index 0000000000..c9198a6a57 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_CreateOrUpdate_BaseManifest.json @@ -0,0 +1,76 @@ +{ + "operationId": "Containers_CreateOrUpdate", + "title": "Create or update an container resource with base manifest", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "containerName": "app0", + "api-version": "2022-03-15-privatepreview", + "ContainerResource": { + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "runtimes": { + "kubernetes": { + "base": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: webserver\n namespace: app-scoped\n labels:\n app: webserver\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: webserver\n template:\n metadata:\n labels:\n app: webserver\n spec:\n containers:\n - name: nginx\n image: nginx:1.14.2\n ports:\n - containerPort: 80\n" + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "runtimes": { + "kubernetes": { + "base": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: webserver\n namespace: app-scoped\n labels:\n app: webserver\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: webserver\n template:\n metadata:\n labels:\n app: webserver\n spec:\n containers:\n - name: nginx\n image: nginx:1.14.2\n ports:\n - containerPort: 80\n" + } + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_Delete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_Delete.json new file mode 100644 index 0000000000..9a9bf28c14 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Containers_Delete", + "title": "Delete an container resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "containerName": "app0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_Get.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_Get.json new file mode 100644 index 0000000000..371b16c101 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_Get.json @@ -0,0 +1,44 @@ +{ + "operationId": "Containers_Get", + "title": "Get an container resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "containerName": "container0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_List.json new file mode 100644 index 0000000000..a19eab3370 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_List.json @@ -0,0 +1,103 @@ +{ + "operationId": "Containers_ListByScope", + "title": "List containers at resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container1", + "name": "container1", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app1", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 + }, + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" + }, + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_ListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_ListByScope.json new file mode 100644 index 0000000000..48084fdec0 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Containers_ListByScope.json @@ -0,0 +1,106 @@ +{ + "operationId": "Containers_ListByScope", + "title": "List containers at root scope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 + }, + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http", + "provides": "provides", + "port": 443, + "scheme": "https" + }, + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container1", + "name": "container1", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app1", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/containers?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsDeleteEnv0.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsDeleteEnv0.json deleted file mode 100644 index f3088c0e5d..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsDeleteEnv0.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "environmentName": "env0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsGetEnv0.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsGetEnv0.json deleted file mode 100644 index f75ec6cf44..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsGetEnv0.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "environmentName": "env0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "name": "env0", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc" - } - }, - "providers" : { - "azure" : { - "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" - } - }, - "recipes": { - "Applications.Link/mongoDatabases":{ - "cosmos-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" - } - } - }, - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsGetRecipeMetadata.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsGetRecipeMetadata.json deleted file mode 100644 index 1d66725b36..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsGetRecipeMetadata.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "environmentName": "env0", - "recipeName": "mongotest" - }, - "responses": { - "200": { - "body": { - "linkType": "Applications.Link/mongoDatabases", - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", - "parameters": { - "throughput": { - "type" : "int", - "defaultValue" : 400 - }, - "location": { - "type" : "string", - "defaultValue" : "[resourceGroup().location]" - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsList.json deleted file mode 100644 index cd17fc3ef4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsList.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "name": "env0", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc" - } - }, - "providers" : { - "azure" : { - "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" - } - }, - "recipes": { - "Applications.Link/mongoDatabases":{ - "cosmos-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" - }, - "default":{ - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/mongo" - } - }, - "Applications.Link/redisCaches":{ - "redis-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/rediscache" - }, - "default":{ - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/redis" - } - } - }, - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "name": "env0", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc" - } - }, - "providers" : { - "aws" : { - "scope":"/planes/aws/aws/accounts/140313373712/regions/us-west-2" - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "name": "env1", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster1", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc" - } - }, - "providers" : { - "azure" : { - "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" - } - }, - "recipes": { - "Applications.Link/mongoDatabases":{ - "cosmos-recipe": { - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" - } - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Radius/environments?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsListByScope.json deleted file mode 100644 index 8ab94f2129..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsListByScope.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "name": "env0", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc" - } - }, - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "name": "env1", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster1", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc", - "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/radius-mi-app" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/environments?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsPatchEnv0.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsPatchEnv0.json deleted file mode 100644 index ec6b8c27b4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsPatchEnv0.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "environmentName": "env0", - "api-version": "2022-03-15-privatepreview", - "EnvironmentResource": { - "location": "West US", - "properties": { - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc" - } - }, - "recipes": { - "Applications.Link/mongoDatabases":{ - "cosmos-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" - } - } - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "name": "env0", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default" - }, - "providers" : { - "azure" : { - "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" - } - }, - "recipes": { - "Applications.Link/mongoDatabases":{ - "cosmos-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" - } - } - }, - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsPutEnv0.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsPutEnv0.json deleted file mode 100644 index 1302d136df..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/EnvironmentsPutEnv0.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "environmentName": "env0", - "api-version": "2022-03-15-privatepreview", - "EnvironmentResource": { - "location": "West US", - "properties": { - "compute": { - "kind": "Kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default", - "identity": { - "kind": "azure.com.workload", - "oidcIssuer": "https://oidcissuer/oidc" - } - }, - "recipes": { - "Applications.Link/mongoDatabases":{ - "cosmos-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" - } - } - }, - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "name": "env0", - "type": "Applications.Core/environments", - "properties": { - "provisioningState": "Succeeded", - "compute": { - "kind": "kubernetes", - "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", - "namespace": "default" - }, - "providers" : { - "azure" : { - "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" - } - }, - "recipes": { - "Applications.Link/mongoDatabases":{ - "cosmos-recipe": { - "templateKind": "bicep", - "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" - } - } - }, - "extensions": [ - { - "kind": "kubernetesMetadata", - "annotations": { - "prometheus.io/scrape": "true", - "prometheus.io/port": "80" - }, - "labels": { - "foo/bar/team": "credit", - "foo/bar/contact": "radiususer" - } - } - ] - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_CreateOrUpdate.json new file mode 100644 index 0000000000..1f2ba81c85 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_CreateOrUpdate.json @@ -0,0 +1,87 @@ +{ + "operationId": "Environments_CreateOrUpdate", + "title": "Create or Update an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "environmentName": "env0", + "api-version": "2022-03-15-privatepreview", + "EnvironmentResource": { + "location": "West US", + "properties": { + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default" + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_DeleteEnv0.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_DeleteEnv0.json new file mode 100644 index 0000000000..3f57144f67 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_DeleteEnv0.json @@ -0,0 +1,14 @@ +{ + "operationId": "Environments_Delete", + "title": "Delete an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "environmentName": "env0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_GetEnv0.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_GetEnv0.json new file mode 100644 index 0000000000..43070c4772 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_GetEnv0.json @@ -0,0 +1,56 @@ +{ + "operationId": "Environments_Get", + "title": "Get an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "environmentName": "env0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_GetRecipeMetadata.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_GetRecipeMetadata.json new file mode 100644 index 0000000000..d17ab65f66 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_GetRecipeMetadata.json @@ -0,0 +1,29 @@ +{ + "operationId": "Environments_GetMetadata", + "title": "Get recipe metadata from environment", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "environmentName": "env0", + "recipeName": "mongotest" + }, + "responses": { + "200": { + "body": { + "resourceType": "Applications.Datastores/mongoDatabases", + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", + "parameters": { + "throughput": { + "type" : "int", + "defaultValue" : 400 + }, + "location": { + "type" : "string", + "defaultValue" : "[resourceGroup().location]" + } + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_List.json new file mode 100644 index 0000000000..639bf67f6b --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_List.json @@ -0,0 +1,125 @@ +{ + "operationId": "Environments_ListByScope", + "title": "Get environments by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + }, + "default":{ + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/mongo" + } + }, + "Applications.Datastores/redisCaches":{ + "redis-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/rediscache" + }, + "default":{ + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/redis" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "aws" : { + "scope":"/planes/aws/aws/accounts/140313373712/regions/us-west-2" + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "name": "env1", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster1", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_ListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_ListByScope.json new file mode 100644 index 0000000000..cc9fe2cf6d --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_ListByScope.json @@ -0,0 +1,65 @@ +{ + "operationId": "Environments_ListByScope", + "title": "Get environments by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "name": "env1", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster1", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/radius-mi-app" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/environments?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_PatchEnv0.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_PatchEnv0.json new file mode 100644 index 0000000000..a12a1ad8e2 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Environments_PatchEnv0.json @@ -0,0 +1,74 @@ +{ + "operationId": "Environments_Update", + "title": "Update an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "environmentName": "env0", + "api-version": "2022-03-15-privatepreview", + "EnvironmentResource": { + "location": "West US", + "properties": { + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default" + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersDelete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersDelete.json deleted file mode 100644 index 67c09ee3ea..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "extenderName": "extender0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersGet.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersGet.json deleted file mode 100644 index b322a59318..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersGet.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview", - "extenderName": "extender0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersList.json deleted file mode 100644 index a26917e573..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersList.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersListByRootScope.json deleted file mode 100644 index ae7c86cf65..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersListByRootScope.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/extenders?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersListSecrets.json deleted file mode 100644 index 56abae506a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersListSecrets.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroupName": "testGroup", - "api-version": "2022-03-15-privatepreview", - "extenderName": "extender0" - }, - "responses": { - "200": { - "body": { - "accountSid": "sid", - "authToken:": "token" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersPut.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersPut.json deleted file mode 100644 index 58d94658b1..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersPut.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "extenderName": "extender0", - "api-version": "2022-03-15-privatepreview", - "ExtenderParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", - "name": "extender1", - "type": "Applications.Core/extenders", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - } - } -} - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersPutWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersPutWithRecipe.json deleted file mode 100644 index 135e006028..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/ExtendersPutWithRecipe.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "extenderName": "extender0", - "api-version": "2022-03-15-privatepreview", - "ExtenderParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "s3" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", - "name": "extender0", - "type": "Applications.Core/extenders", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "s3" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", - "name": "extender1", - "type": "Applications.Core/extenders", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "s3" - } - } - } - } - } -} - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_CreateOrUpdate.json new file mode 100644 index 0000000000..36a863f2f1 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_CreateOrUpdate.json @@ -0,0 +1,62 @@ +{ + "operationId": "Extenders_CreateOrUpdate", + "title": "Create or Update an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview", + "ExtenderParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", + "name": "extender1", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + } + } +} + \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_CreateOrUpdateWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_CreateOrUpdateWithRecipe.json new file mode 100644 index 0000000000..f7b994db37 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_CreateOrUpdateWithRecipe.json @@ -0,0 +1,54 @@ +{ + "operationId": "Extenders_CreateOrUpdate", + "title": "Create or Update an extender resource with recipe", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview", + "ExtenderParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "s3" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "s3" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", + "name": "extender1", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "s3" + } + } + } + } + } +} + \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Delete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Delete.json new file mode 100644 index 0000000000..f8241d9c17 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Extenders_Delete", + "title": "Delete an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Get.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Get.json new file mode 100644 index 0000000000..a6883eaa24 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Get.json @@ -0,0 +1,31 @@ +{ + "operationId": "Extenders_Get", + "title": "Get an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "api-version": "2022-03-15-privatepreview", + "extenderName": "extender0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_List.json new file mode 100644 index 0000000000..544a601a76 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_List.json @@ -0,0 +1,34 @@ +{ + "operationId": "Extenders_ListByScope", + "title": "List extender resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_ListByRootScope.json new file mode 100644 index 0000000000..29aaa22970 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_ListByRootScope.json @@ -0,0 +1,34 @@ +{ + "operationId": "Extenders_ListByScope", + "title": "List extender resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/extenders?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_ListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_ListSecrets.json new file mode 100644 index 0000000000..3ba02d58b5 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_ListSecrets.json @@ -0,0 +1,19 @@ +{ + "operationId": "Extenders_ListSecrets", + "title": "List the secrets from extender resources", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroupName": "testGroup", + "api-version": "2022-03-15-privatepreview", + "extenderName": "extender0" + }, + "responses": { + "200": { + "body": { + "accountSid": "sid", + "authToken:": "token" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Update.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Update.json new file mode 100644 index 0000000000..ebdcfcd21a --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Extenders_Update.json @@ -0,0 +1,61 @@ +{ + "operationId": "Extenders_Update", + "title": "Update an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview", + "ExtenderParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", + "name": "extender1", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysDelete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysDelete.json deleted file mode 100644 index 3b9646feec..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "gatewayName": "gateway0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysGet.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysGet.json deleted file mode 100644 index b66a02685f..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysGet.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "gatewayName": "gateway0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" - } - ], - "tls":{ - "sslPassthrough": false, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysList.json deleted file mode 100644 index 2e3a615a8a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysList.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" - } - ], - "tls":{ - "sslPassthrough": false, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/gateways?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysListByScope.json deleted file mode 100644 index ee04c8dcc4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysListByScope.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte", - "path":"/" - } - ], - "tls":{ - "sslPassthrough": false, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway1", - "name": "gateway1", - "type": "Applications.Core/gateways", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-back-rte", - "path":"/backend2" - } - ], - "tls":{ - "sslPassthrough": false, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/gateways?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysPatch.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysPatch.json deleted file mode 100644 index 6660ffe845..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysPatch.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "gatewayName": "gateway0", - "api-version": "2022-03-15-privatepreview", - "GatewayResource": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" - } - ], - "tls":{ - "sslPassthrough": true, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" - } - ], - "tls":{ - "sslPassthrough": false, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysPut.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysPut.json deleted file mode 100644 index b1d360ae90..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/GatewaysPut.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "gatewayName": "gateway0", - "api-version": "2022-03-15-privatepreview", - "GatewayResource": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" - } - ], - "tls":{ - "sslPassthrough": false, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", - "name": "gateway0", - "type": "Applications.Core/gateways", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "routes":[ - { - "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" - } - ], - "tls":{ - "sslPassthrough": false, - "hostname": "myapp.radapp.dev", - "minimumProtocolVersion": "1.2", - "certificateFrom": "myapp-tls-cert" - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_CreateOrUpdate.json new file mode 100644 index 0000000000..cecb497c19 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_CreateOrUpdate.json @@ -0,0 +1,50 @@ +{ + "operationId": "Gateways_CreateOrUpdate", + "title": "Create or update a gateway resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "gatewayName": "gateway0", + "api-version": "2022-03-15-privatepreview", + "GatewayResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_Delete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_Delete.json new file mode 100644 index 0000000000..10c4503eb1 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Gateways_Delete", + "title": "Delete an gateway resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "gatewayName": "gateway0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_Get.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_Get.json new file mode 100644 index 0000000000..e71430e547 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_Get.json @@ -0,0 +1,33 @@ +{ + "operationId": "Gateways_Get", + "title": "Get an gateway resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "gatewayName": "gateway0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_List.json new file mode 100644 index 0000000000..35f79c6018 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_List.json @@ -0,0 +1,37 @@ +{ + "operationId": "Gateways_ListByScope", + "title": "List gateway resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_ListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_ListByScope.json new file mode 100644 index 0000000000..7e69b93d1f --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Gateways_ListByScope.json @@ -0,0 +1,59 @@ +{ + "operationId": "Gateways_ListByScope", + "title": "List gateway resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte", + "path":"/" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway1", + "name": "gateway1", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-back-rte", + "path":"/backend2" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/gateways?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesDelete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesDelete.json deleted file mode 100644 index be8d9efee4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "httpRouteName": "route0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesGet.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesGet.json deleted file mode 100644 index 3a63fc6cda..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesGet.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "httpRouteName": "route0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", - "name": "route0", - "type": "Applications.Core/httpRoutes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesList.json deleted file mode 100644 index 2239bd3bb7..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesList.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", - "name": "route0", - "type": "Applications.Core/httpRoutes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route1", - "name": "route1", - "type": "Applications.Core/httpRoutes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/httproutes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesListByScope.json deleted file mode 100644 index 8430d0f784..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesListByScope.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-00000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", - "name": "route0", - "type": "Applications.Core/httpRoutes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route1", - "name": "route1", - "type": "Applications.Core/httpRoutes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/httproutes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesPatch.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesPatch.json deleted file mode 100644 index c5d2030a89..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesPatch.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "httpRouteName": "route0", - "api-version": "2022-03-15-privatepreview", - "HttpRouteResource": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/routes0", - "name": "routes0", - "type": "Applications.Core/httpRoutes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesPut.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesPut.json deleted file mode 100644 index c5d2030a89..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutesPut.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "httpRouteName": "route0", - "api-version": "2022-03-15-privatepreview", - "HttpRouteResource": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/routes0", - "name": "routes0", - "type": "Applications.Core/httpRoutes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_CreateOrUpdate.json new file mode 100644 index 0000000000..41f0d24102 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_CreateOrUpdate.json @@ -0,0 +1,28 @@ +{ + "operationId": "HttpRoutes_CreateOrUpdate", + "title": "Create or Update httpRoutes resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "httpRouteName": "route0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/routes0", + "name": "routes0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Delete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Delete.json new file mode 100644 index 0000000000..0a2aa56541 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "HttpRoutes_Delete", + "title": "Delete a httpRoutes resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "httpRouteName": "route0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Get.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Get.json new file mode 100644 index 0000000000..e9e2411461 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Get.json @@ -0,0 +1,22 @@ +{ + "operationId": "HttpRoutes_Get", + "title": "Get a httpRoutes resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "httpRouteName": "route0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_List.json new file mode 100644 index 0000000000..134bef7b10 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_List.json @@ -0,0 +1,35 @@ +{ + "operationId": "HttpRoutes_ListByScope", + "title": "List httpRoutes resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route1", + "name": "route1", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httproutes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_ListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_ListByScope.json new file mode 100644 index 0000000000..cd929b0da1 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_ListByScope.json @@ -0,0 +1,35 @@ +{ + "operationId": "HttpRoutes_ListByScope", + "title": "List httpRoutes resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route1", + "name": "route1", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/httproutes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Update.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Update.json new file mode 100644 index 0000000000..46cd2cf074 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/HttpRoutes_Update.json @@ -0,0 +1,28 @@ +{ + "operationId": "HttpRoutes_Update", + "title": "Update a httpRoutes resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "httpRouteName": "route0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/routes0", + "name": "routes0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/OperationsList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/OperationsList.json deleted file mode 100644 index 10424001db..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/OperationsList.json +++ /dev/null @@ -1,193 +0,0 @@ -{ - "parameters": { - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "name": "Applications.Core/operations/read", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "Operations", - "operation": "Get operations", - "description": "Get the list of Operations" - } - }, - { - "name": "Applications.Core/environments/read", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "environments", - "operation": "Get/List environment", - "description": "Get or list of environments." - } - }, - { - "name": "Applications.Core/environments/write", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "environments", - "operation": "Create/Update environment", - "description": "Create or update an environment." - } - }, - { - "name": "Applications.Core/environments/delete", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "environments", - "operation": "Delete environment", - "description": "Deletes an environment." - } - }, - { - "name": "Applications.Core/environments/join/action", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "environments", - "operation": "Join environment", - "description": "Join to application environment." - } - }, - { - "name": "Applications.Core/register/action", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "Applications.Core", - "operation": "Register the Applications.Core", - "description": "Register the subscription for Applications.Core" - } - }, - { - "name": "Applications.Core/unregister/action", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "Applications.Core", - "operation": "Unregister the Applications.Core", - "description": "Unregister the subscription for Applications.Core" - } - }, - { - "name": "Applications.Core/applications/read", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "applications", - "operation": "Get/List application", - "description": "Get or list of applications." - } - }, - { - "name": "Applications.Core/applications/write", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "applications", - "operation": "Create/Update application", - "description": "Create or update an application." - } - }, - { - "name": "Applications.Core/applications/delete", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "applications", - "operation": "Delete application", - "description": "Deletes an application." - } - }, - { - "name": "Applications.Core/applications/join/action", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "applications", - "operation": "Join application", - "description": "Join to application." - } - }, - { - "name": "Applications.Core/httpRoutes/read", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "httpRoutes", - "operation": "Get/List HTTP Route", - "description": "Get or list of HTTP Routes." - } - }, - { - "name": "Applications.Core/httpRoutes/write", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "httpRoutes", - "operation": "Create/Update HTTP Route", - "description": "Create or update an HTTP Route." - } - }, - { - "name": "Applications.Core/httpRoutes/delete", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "httpRoutes", - "operation": "Delete HTTP Route", - "description": "Deletes an HTTP Route." - } - }, - { - "name": "Applications.Core/gateways/read", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "gateways", - "operation": "Get/List Gateways", - "description": "Get or list of Gateways." - } - }, - { - "name": "Applications.Core/gateways/write", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "gateways", - "operation": "Create/Update Gateway", - "description": "Create or update a Gateway." - } - }, - { - "name": "Applications.Core/gateways/delete", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "gateways", - "operation": "Delete Gateway", - "description": "Deletes a Gateway." - } - }, - { - "name": "Applications.Core/gateways/join/action", - "isDataAction": false, - "display": { - "provider": "Applications.Core", - "resource": "gateways", - "operation": "Join Gateway", - "description": "Join to Gateway." - } - } - ] - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Operations_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Operations_List.json new file mode 100644 index 0000000000..d5a1aaa939 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Operations_List.json @@ -0,0 +1,195 @@ +{ + "operationId": "Operations_List", + "title": "Get the operations for the Applications.Core resource provider", + "parameters": { + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "Applications.Core/operations/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "Operations", + "operation": "Get operations", + "description": "Get the list of Operations" + } + }, + { + "name": "Applications.Core/environments/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Get/List environment", + "description": "Get or list of environments." + } + }, + { + "name": "Applications.Core/environments/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Create/Update environment", + "description": "Create or update an environment." + } + }, + { + "name": "Applications.Core/environments/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Delete environment", + "description": "Deletes an environment." + } + }, + { + "name": "Applications.Core/environments/join/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Join environment", + "description": "Join to application environment." + } + }, + { + "name": "Applications.Core/register/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "Applications.Core", + "operation": "Register the Applications.Core", + "description": "Register the subscription for Applications.Core" + } + }, + { + "name": "Applications.Core/unregister/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "Applications.Core", + "operation": "Unregister the Applications.Core", + "description": "Unregister the subscription for Applications.Core" + } + }, + { + "name": "Applications.Core/applications/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Get/List application", + "description": "Get or list of applications." + } + }, + { + "name": "Applications.Core/applications/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Create/Update application", + "description": "Create or update an application." + } + }, + { + "name": "Applications.Core/applications/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Delete application", + "description": "Deletes an application." + } + }, + { + "name": "Applications.Core/applications/join/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Join application", + "description": "Join to application." + } + }, + { + "name": "Applications.Core/httpRoutes/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "httpRoutes", + "operation": "Get/List HTTP Route", + "description": "Get or list of HTTP Routes." + } + }, + { + "name": "Applications.Core/httpRoutes/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "httpRoutes", + "operation": "Create/Update HTTP Route", + "description": "Create or update an HTTP Route." + } + }, + { + "name": "Applications.Core/httpRoutes/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "httpRoutes", + "operation": "Delete HTTP Route", + "description": "Deletes an HTTP Route." + } + }, + { + "name": "Applications.Core/gateways/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Get/List Gateways", + "description": "Get or list of Gateways." + } + }, + { + "name": "Applications.Core/gateways/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Create/Update Gateway", + "description": "Create or update a Gateway." + } + }, + { + "name": "Applications.Core/gateways/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Delete Gateway", + "description": "Deletes a Gateway." + } + }, + { + "name": "Applications.Core/gateways/join/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Join Gateway", + "description": "Join to Gateway." + } + } + ] + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresDelete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresDelete.json deleted file mode 100644 index 532ff2273b..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "volumeName": "keyvault0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresGet.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresGet.json deleted file mode 100644 index 439447b5d6..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresGet.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "secretStoreName": "secret0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/secretStores/secret0", - "name": "secret0", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - }, - "tls.key": { - } - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresGet_AzureKeyVault.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresGet_AzureKeyVault.json deleted file mode 100644 index e13bfa3e92..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresGet_AzureKeyVault.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "secretStoreName": "secretazkv" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", - "name": "secretazkv", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/public_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/private_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresList.json deleted file mode 100644 index 38427308dc..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresList.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/secretStores/secret0", - "name": "secret0", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - }, - "tls.key": { - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", - "name": "secretazkv", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/public_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/private_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/secretStores?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresListSecrets.json deleted file mode 100644 index 00c01112fe..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresListSecrets.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "secretStoreName": "secret0" - }, - "responses": { - "200": { - "type": "certificate", - "data": { - "tls.crt": { - "value": "secrets ..." - }, - "tls.key": { - "value": "secrets ..." - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPatch.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPatch.json deleted file mode 100644 index 35eb4fb756..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPatch.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "secretStoreName": "secretazkv", - "api-version": "2022-03-15-privatepreview", - "SecretStoreResource": { - "location": "global", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/public_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/private_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", - "name": "secretazkv", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/public_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/private_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPutValue.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPutValue.json deleted file mode 100644 index 524252ed86..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPutValue.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "secretStoreName": "secretazkv", - "api-version": "2022-03-15-privatepreview", - "SecretStoreResource": { - "location": "global", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "encoding": "base64", - "value": "certificate" - }, - "tls.key": { - "encoding": "base64", - "value": "certificate" - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", - "name": "secretazkv", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "encoding": "base64" - }, - "tls.key": { - "encoding": "base64" - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPutValueFrom.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPutValueFrom.json deleted file mode 100644 index 35eb4fb756..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStoresPutValueFrom.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "secretStoreName": "secretazkv", - "api-version": "2022-03-15-privatepreview", - "SecretStoreResource": { - "location": "global", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/public_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/private_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", - "name": "secretazkv", - "type": "Applications.Core/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "type": "certificate", - "data": { - "tls.crt": { - "valueFrom": { - "name": "secret/public_cert", - "version": "1" - } - }, - "tls.key": { - "valueFrom": { - "name": "secret/private_key", - "version": "1" - } - } - }, - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdate.json new file mode 100644 index 0000000000..8350409c65 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdate.json @@ -0,0 +1,51 @@ +{ + "operationId": "SecretStores_CreateOrUpdate", + "title": "Create or Update a secret store resource with azure keyvault", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "secretazkv", + "api-version": "2022-03-15-privatepreview", + "SecretStoreResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "encoding": "base64", + "value": "certificate" + }, + "tls.key": { + "encoding": "base64", + "value": "certificate" + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "encoding": "base64" + }, + "tls.key": { + "encoding": "base64" + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdateValueFrom.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdateValueFrom.json new file mode 100644 index 0000000000..470379feb9 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdateValueFrom.json @@ -0,0 +1,61 @@ +{ + "operationId": "SecretStores_CreateOrUpdate", + "title": "Create or Update a secret store resource with valueFrom", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "secretazkv", + "api-version": "2022-03-15-privatepreview", + "SecretStoreResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Delete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Delete.json new file mode 100644 index 0000000000..2511b39056 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "SecretStores_Update", + "title": "Update a secret store resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Get.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Get.json new file mode 100644 index 0000000000..4ed53c64f2 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Get.json @@ -0,0 +1,30 @@ +{ + "operationId": "SecretStores_Get", + "title": "Get a secret store", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "secret0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + }, + "tls.key": { + } + } + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Get_AzureKeyVault.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Get_AzureKeyVault.json new file mode 100644 index 0000000000..635c47fbfb --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Get_AzureKeyVault.json @@ -0,0 +1,39 @@ +{ + "operationId": "SecretStores_Get", + "title": "Get a secret store for Azure Keyvault", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "secretazkv" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_List.json new file mode 100644 index 0000000000..3e66a39aba --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_List.json @@ -0,0 +1,60 @@ +{ + "operationId": "SecretStores_ListByScope", + "title": "List secret stores", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + }, + "tls.key": { + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_ListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_ListSecrets.json new file mode 100644 index 0000000000..b5e9ed9e71 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_ListSecrets.json @@ -0,0 +1,22 @@ +{ + "operationId": "SecretStores_ListSecrets", + "title": "List secret stores", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "secret0" + }, + "responses": { + "200": { + "type": "certificate", + "data": { + "tls.crt": { + "value": "secrets ..." + }, + "tls.key": { + "value": "secrets ..." + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Update.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Update.json new file mode 100644 index 0000000000..c04faeab9e --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/SecretStores_Update.json @@ -0,0 +1,61 @@ +{ + "operationId": "SecretStores_Update", + "title": "Update a secret store", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "secretazkv", + "api-version": "2022-03-15-privatepreview", + "SecretStoreResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesDelete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesDelete.json deleted file mode 100644 index 532ff2273b..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "volumeName": "keyvault0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesGet.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesGet.json deleted file mode 100644 index a386c24315..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesGet.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "volumeName": "keyvault0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", - "name": "keyvault0", - "type": "Applications.Core/volumes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "version": "1" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "certType": "certificate" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesList.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesList.json deleted file mode 100644 index 692d7063b8..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesList.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [{ - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", - "name": "keyvault0", - "type": "Applications.Core/volumes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "version": "1" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "certType": "certificate" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault1", - "name": "keyvault1", - "type": "Applications.Core/volumes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "version": "1" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "certType": "certificate" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/volumes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesListByScope.json deleted file mode 100644 index 64725dad52..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesListByScope.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-00000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", - "name": "keyvault0", - "type": "Applications.Core/volumes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "version": "1" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "certType": "certificate" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault1", - "name": "keyvault1", - "type": "Applications.Core/volumes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "version": "1" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "certType": "certificate" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Core/volumes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesPatch.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesPatch.json deleted file mode 100644 index 04112d8b07..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesPatch.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "volumeName": "keyvault0", - "api-version": "2022-03-15-privatepreview", - "HttpRouteResource": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/volumes/routes0", - "name": "keyvault0", - "type": "Applications.Core/volumes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "version": "1" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "certType": "certificate" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesPut.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesPut.json deleted file mode 100644 index 04112d8b07..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/VolumesPut.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "volumeName": "keyvault0", - "api-version": "2022-03-15-privatepreview", - "HttpRouteResource": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/volumes/routes0", - "name": "keyvault0", - "type": "Applications.Core/volumes", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/app0", - "kind": "azure.com.keyvault", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", - "secrets": { - "mysecret-1": { - "name": "mysecret-1", - "version": "1" - }, - "mysecret-2": { - "name": "mysecret-2", - "encoding": "base64" - } - }, - "keys": { - "mykey-1": { - "name": "key1", - "version": "1" - }, - "mykey-2": { - "name": "key2" - } - }, - "certificates": { - "mycert-1": { - "name": "cert1", - "certType": "certificate" - }, - "mycert-2": { - "name": "cert2", - "certType": "privatekey", - "format": "pfx", - "encoding": "hex" - } - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_CreateOrUpdate.json new file mode 100644 index 0000000000..db34af3074 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_CreateOrUpdate.json @@ -0,0 +1,61 @@ +{ + "operationId": "Volumes_CreateOrUpdate", + "title": "Create or update a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/routes0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Delete.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Delete.json new file mode 100644 index 0000000000..ec812ffa7e --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Volumes_Delete", + "title": "Delete a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Get.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Get.json new file mode 100644 index 0000000000..5d3c065c62 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Get.json @@ -0,0 +1,55 @@ +{ + "operationId": "Volumes_Get", + "title": "Get a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "volumeName": "keyvault0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_List.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_List.json new file mode 100644 index 0000000000..f52dc9ae53 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_List.json @@ -0,0 +1,100 @@ +{ + "operationId": "Volumes_ListByScope", + "title": "List volumes by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [{ + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault1", + "name": "keyvault1", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_ListByScope.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_ListByScope.json new file mode 100644 index 0000000000..4d14bacbc3 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_ListByScope.json @@ -0,0 +1,101 @@ +{ + "operationId": "Volumes_ListByScope", + "title": "List volumes by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault1", + "name": "keyvault1", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/volumes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Update.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Update.json new file mode 100644 index 0000000000..413bb773d3 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/examples/Volumes_Update.json @@ -0,0 +1,61 @@ +{ + "operationId": "Volumes_Update", + "title": "Update a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/routes0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/extenders.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/extenders.json deleted file mode 100644 index 4334a692c0..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/extenders.json +++ /dev/null @@ -1,406 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST APIs for Applications.Core/extenders.", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/extenders": { - "get": { - "description": "Lists information about all Extender portable resources in the given root scope.", - "operationId": "Extenders_ListByRootScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersListByRootScope": { - "$ref": "./examples/ExtendersListByRootScope.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - ], - "responses": { - "200": { - "description": "List of Extender portable resources.", - "schema": { - "$ref": "#/definitions/ExtenderList" - } - }, - "default": { - "description": "Error response describing the reason for operation failure.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/extenders/{extenderName}": { - "get": { - "description": "Retrieves information about a Extender portable resource.", - "operationId": "Extenders_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersGet": { - "$ref": "./examples/ExtendersGet.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - } - ], - "responses": { - "200": { - "description": "Extender portable resource.", - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "default": { - "description": "Error response describing the reason for operation failure.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Creates or updates a Extender portable resource.", - "operationId": "Extenders_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersPut": { - "$ref": "./examples/ExtendersPut.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - }, - { - "name": "ExtenderParameters", - "description": "Extender create parameters.", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - } - ], - "responses": { - "200": { - "description": "The request was successful; response contains the Extender portable resource.", - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "201": { - "description": "The request was successful, resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "default": { - "description": "Error response describing the reason for operation failure.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Deletes an existing Extender portable resource.", - "operationId": "Extenders_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersDelete": { - "$ref": "./examples/ExtendersDelete.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - } - ], - "responses": { - "200": { - "description": "The Extender portable resource was successfully deleted." - }, - "202": { - "description": "The Extender portable resource will be deleted asynchronously." - }, - "204": { - "description": "The Extender portable resource does not exist." - }, - "default": { - "description": "Error response describing the reason for operation failure.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Core/extenders/{extenderName}/listSecrets": { - "post": { - "description": "Lists secrets values for the specified Extender portable resource.", - "operationId": "Extenders_listSecrets", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersGet": { - "$ref": "./examples/ExtendersListSecrets.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - } - ], - "responses": { - "200": { - "description": "Extender secrets.", - "schema": { - "$ref": "#/definitions/ExtenderListSecretsResult" - } - }, - "default": { - "description": "Error response describing the reason for operation failure.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "ResourceRecipe": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The name of the recipe within the environment to use." - }, - "parameters": { - "$ref": "global.json#/definitions/Parameters", - "description": "Key/value parameters to pass into the recipe at deployment." - } - }, - "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource.", - "required": [ - "name" - ] - }, - "ResourceProvisioning": { - "type": "string", - "description": "Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.", - "enum": [ - "recipe", - "manual" - ], - "x-ms-enum": { - "name": "ResourceProvisioning", - "modelAsString": true - } - }, - "ExtenderList": { - "description": "Object that includes an array of Extender and a possible portable resource for next set.", - "type": "object", - "properties": { - "value": { - "description": "List of Extender portable resources.", - "type": "array", - "items": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "nextLink": { - "description": "The link used to fetch the next page of Extender list.", - "type": "string" - } - } - }, - "ExtenderResource": { - "description": "Extender portable resource.", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/ExtenderProperties" - } - } - }, - "ExtenderListSecretsResult": { - "description": "The secret values for the given Extender portable resource.", - "$ref": "#/definitions/ExtenderSecrets" - }, - "ExtenderSecrets": { - "description": "The secret values for the given Extender portable resource.", - "additionalProperties": true, - "properties": {} - }, - "ExtenderProperties": { - "description": "Extender portable resource properties.", - "type": "object", - "allOf": [ - { - "$ref": "#/definitions/PortableResourceBasicProperties" - } - ], - "additionalProperties": true, - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Provisioning state of the Extender portable resource at the time the operation was called." - }, - "secrets": { - "additionalProperties": true, - "$ref": "#/definitions/ExtenderSecrets" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - }, - "recipe": { - "$ref": "#/definitions/ResourceRecipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Extender portable resource." - } - }, - "required": [ - "environment" - ] - }, - "PortableResourceBasicProperties": { - "type": "object", - "properties": { - "status": { - "$ref": "global.json#/definitions/ResourceStatus", - "description": "Status of a Portable resource.", - "readOnly": true - }, - "environment": { - "type": "string", - "description": "The resource id of the environment linked to the resource" - }, - "application": { - "$ref": "global.json#/definitions/Application" - } - }, - "description": "Basic properties of a Portable resource.", - "required": [ - "environment" - ] - } - }, - "parameters": { - "ExtenderNameParameter": { - "description": "The name of the Extender portable resource.", - "name": "extenderName", - "in": "path", - "required": true, - "type": "string", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/gateways.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/gateways.json deleted file mode 100644 index b5b95442fa..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/gateways.json +++ /dev/null @@ -1,431 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST API for Applications.Core Gateway Resource", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/gateways": { - "get": { - "description": "List all Gateways in the given scope.", - "operationId": "Gateways_ListByScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusGatewaysListByScope": { - "$ref": "./examples/GatewaysListByScope.json" - } - }, - "tags": [ - "Gateways" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - ], - "responses": { - "200": { - "description": "Gateway details.", - "schema": { - "$ref": "#/definitions/GatewayResourceList" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/gateways/{gatewayName}": { - "get": { - "description": "Gets the properties of a Gateway.", - "operationId": "Gateways_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusGatewaysGet": { - "$ref": "./examples/GatewaysGet.json" - } - }, - "tags": [ - "Gateways" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/GatewayNameParameter" - } - ], - "responses": { - "200": { - "description": "Gateway details.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Create or update a Gateway.", - "operationId": "Gateways_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusGatewaysPut": { - "$ref": "./examples/GatewaysPut.json" - } - }, - "tags": [ - "Gateways" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/GatewayNameParameter" - }, - { - "name": "GatewayResource", - "description": "Gateway details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/GatewayResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "204": { - "description": "The Gateway does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "patch": { - "description": "Update the properties of an existing Gateway.", - "operationId": "Gateways_Update", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusGatewaysPatch": { - "$ref": "./examples/GatewaysPatch.json" - } - }, - "tags": [ - "Gateways" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/GatewayNameParameter" - }, - { - "name": "GatewayResource", - "description": "Gateway details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/GatewayResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/GatewayResource" - } - }, - "204": { - "description": "The Gateway does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Delete a Gateway.", - "operationId": "Gateways_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusGatewaysDelete": { - "$ref": "./examples/GatewaysDelete.json" - } - }, - "tags": [ - "Gateways" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/GatewayNameParameter" - } - ], - "responses": { - "200": { - "description": "The Gateway was successfully deleted." - }, - "202": { - "description": "The Gateway will be deleted asynchronously." - }, - "204": { - "description": "The Gateway does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "GatewayResourceList": { - "description": "The list of Gateways.", - "type": "object", - "properties": { - "value": { - "description": "The list of Gateways.", - "type": "array", - "items": { - "$ref": "#/definitions/GatewayResource" - } - }, - "nextLink": { - "description": "The link used to get the next page of Gateways list.", - "type": "string" - } - } - }, - "GatewayResource": { - "description": "Gateway Resource that specifies how traffic is exposed to the application.", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/GatewayProperties" - } - } - }, - "GatewayProperties": { - "description": "Gateway properties", - "type": "object", - "allOf": [ - { - "$ref": "global.json#/definitions/BasicResourceProperties" - } - ], - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Provisioning state of the Gateway at the time the operation was called." - }, - "internal": { - "description": "Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).", - "type": "boolean" - }, - "hostname": { - "type": "object", - "description": "Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io.", - "properties": { - "prefix": { - "description": "Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined.", - "type": "string" - }, - "fullyQualifiedHostname": { - "description": "Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined.", - "type": "string" - } - }, - "additionalProperties": false - }, - "tls": { - "type": "object", - "description": "TLS configuration for the Gateway.", - "properties": { - "sslPassthrough": { - "description": "If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption.", - "type": "boolean" - }, - "minimumProtocolVersion": { - "description": "TLS minimum protocol version (defaults to 1.2).", - "type": "string", - "enum": [ - "1.2", - "1.3" - ], - "default": "1.2", - "x-ms-enum": { - "name": "TlsMinVersion", - "modelAsString": false - } - }, - "certificateFrom": { - "description": "Declares which Kubernetes TLS secret will be used.", - "type": "string" - } - } - }, - "routes": { - "type": "array", - "minItems": 1, - "description": "Routes attached to this Gateway", - "items": { - "$ref": "#/definitions/GatewayRoute" - } - }, - "url": { - "type": "string", - "readOnly": true, - "description": "URL of the gateway resource. Readonly." - } - }, - "required": [ - "application", - "routes" - ] - }, - "GatewayRoute": { - "type": "object", - "additionalProperties": false, - "properties": { - "path": { - "description": "The path to match the incoming request path on. Ex - /myservice.", - "type": "string" - }, - "destination": { - "description": "The HttpRoute to route to. Ex - myserviceroute.id.", - "type": "string" - }, - "replacePrefix": { - "description": "Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute'", - "type": "string" - } - } - } - }, - "parameters": { - "GatewayNameParameter": { - "name": "gatewayName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the Gateway.", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/global.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/global.json deleted file mode 100644 index 83a0e0933d..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/global.json +++ /dev/null @@ -1,242 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "definitions": { - "ProvisioningState": { - "readOnly": true, - "type": "string", - "description": "Provisioning state of the resource at the time the operation was called.", - "enum": [ - "Succeeded", - "Failed", - "Canceled", - "Accepted", - "Updating", - "Deleting", - "Provisioning" - ], - "x-ms-enum": { - "name": "ProvisioningState", - "modelAsString": true - } - }, - "Application": { - "description": "Specifies the resource id of the application", - "type": "string" - }, - "Parameters": { - "type": "object", - "properties": {}, - "description": "Key/value parameters to pass into the recipe at deployment" - }, - "BasicResourceProperties": { - "description": "Basic properties of a Radius resource.", - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of the resource", - "readOnly": true - }, - "environment": { - "description": "The resource id of the environment linked to the resource", - "type": "string" - }, - "application": { - "$ref": "#/definitions/Application" - } - }, - "required": [ - "application" - ] - }, - "ResourceStatus": { - "description": "Status of a resource.", - "type": "object", - "properties": { - "compute": { - "$ref": "#/definitions/EnvironmentCompute" - }, - "outputResources": { - "type": "array", - "items": { - "$ref": "#/definitions/OutputResource" - } - } - } - }, - "EnvironmentCompute": { - "description": "Compute resource used by application environment resource.", - "type": "object", - "discriminator": "kind", - "properties": { - "kind": { - "type": "string", - "description": "Type of compute resource." - }, - "resourceId": { - "type": "string", - "description": "The resource id of the compute resource for application environment." - }, - "identity": { - "description": "Configuration for supported external identity providers", - "$ref": "global.json#/definitions/IdentitySettings" - } - }, - "required": [ - "kind" - ] - }, - "KubernetesCompute": { - "description": "Specifies the properties for Kubernetes compute environment", - "allOf": [ - { - "$ref": "#/definitions/EnvironmentCompute" - } - ], - "type": "object", - "properties": { - "namespace": { - "type": "string", - "description": "The namespace to use for the environment." - } - }, - "required": [ - "namespace" - ], - "x-ms-discriminator-value": "kubernetes" - }, - "OutputResource": { - "description": "Properties of an output resource.", - "type": "object", - "properties": {} - }, - "IdentitySettings": { - "properties": { - "kind": { - "description": "Configuration for supported external identity providers", - "type": "string", - "enum": [ - "undefined", - "azure.com.workload" - ], - "default": "azure.com.workload", - "x-ms-enum": { - "name": "IdentitySettingKind", - "modelAsString": false - } - }, - "oidcIssuer": { - "description": "The URI for your compute platform's OIDC issuer", - "type": "string" - }, - "resource": { - "description": "The resource ID of the provisioned identity", - "type": "string" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - "Extension": { - "description": "Extension of a resource.", - "discriminator": "kind", - "properties": { - "kind": { - "description": "Specifies the extensions of a resource.", - "type": "string" - } - }, - "required": [ - "kind" - ], - "type": "object" - } - }, - "parameters": { - "RootScopeParameter": { - "name": "rootScope", - "in": "path", - "required": true, - "type": "string", - "description": "The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroups/{resourcegroupID}", - "minLength": 1, - "x-ms-skip-url-encoding": true - } - }, - "paths": { - "/providers/Applications.Core/operations": { - "get": { - "tags": [ - "Operations" - ], - "description": "Lists the available API operations.", - "operationId": "Operations_List", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusOperationsList": { - "$ref": "./examples/OperationsList.json" - } - }, - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "Operation details.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/OperationListResult" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/httpRoutes.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/httpRoutes.json deleted file mode 100644 index 48e75e10f1..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/httpRoutes.json +++ /dev/null @@ -1,369 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST API for Applications.Core HTTPRoute Resource", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/httpRoutes": { - "get": { - "description": "List all HTTP Routes in the given scope.", - "operationId": "HttpRoutes_ListByScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusHttpRoutesListByScope": { - "$ref": "./examples/HttpRoutesListByScope.json" - } - }, - "tags": [ - "HttpRoutes" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - ], - "responses": { - "200": { - "description": "HTTP Route details.", - "schema": { - "$ref": "#/definitions/HttpRouteResourceList" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/httpRoutes/{httpRouteName}": { - "get": { - "description": "Gets the properties of an HTTP Route.", - "operationId": "HttpRoutes_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusHttpRoutesGet": { - "$ref": "./examples/HttpRoutesGet.json" - } - }, - "tags": [ - "HttpRoutes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/HttpRouteNameParameter" - } - ], - "responses": { - "200": { - "description": "HTTP Route details.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Create or update an HTTP Route.", - "operationId": "HttpRoutes_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusHttpRoutesPut": { - "$ref": "./examples/HttpRoutesPut.json" - } - }, - "tags": [ - "HttpRoutes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/HttpRouteNameParameter" - }, - { - "name": "HttpRouteResource", - "description": "HTTP Route details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "204": { - "description": "The HTTP Route does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "patch": { - "description": "Update the properties of an existing HTTP Route.", - "operationId": "HttpRoutes_Update", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusHttpRoutesPatch": { - "$ref": "./examples/HttpRoutesPatch.json" - } - }, - "tags": [ - "HttpRoutes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/HttpRouteNameParameter" - }, - { - "name": "HttpRouteResource", - "description": "HTTP Route details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "204": { - "description": "The HTTP Route does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Delete an HTTP Route.", - "operationId": "HttpRoutes_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusHttpRoutesDelete": { - "$ref": "./examples/HttpRoutesDelete.json" - } - }, - "tags": [ - "HttpRoutes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/HttpRouteNameParameter" - } - ], - "responses": { - "200": { - "description": "The HTTP Route was successfully deleted." - }, - "202": { - "description": "The HTTP Route will be deleted asynchronously." - }, - "204": { - "description": "The HTTP Route does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "HttpRouteResourceList": { - "description": "The list of HTTP Routes.", - "type": "object", - "properties": { - "value": { - "description": "The list of HTTP Route.", - "type": "array", - "items": { - "$ref": "#/definitions/HttpRouteResource" - } - }, - "nextLink": { - "description": "The link used to get the next page of HTTP Routes list.", - "type": "string" - } - } - }, - "HttpRouteResource": { - "description": "Radius HTTP Route Resource.", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/HttpRouteProperties" - } - } - }, - "HttpRouteProperties": { - "description": "HTTP Route properties", - "type": "object", - "allOf": [ - { - "$ref": "global.json#/definitions/BasicResourceProperties" - } - ], - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Provisioning state of the HTTP Route at the time the operation was called." - }, - "hostname": { - "description": "The internal hostname accepting traffic for the HTTP Route. Readonly.", - "type": "string" - }, - "port": { - "description": "The port number for the HTTP Route. Defaults to 80. Readonly.", - "type": "integer" - }, - "scheme": { - "description": "The scheme used for traffic. Readonly.", - "type": "string" - }, - "url": { - "description": "A stable URL that that can be used to route traffic to a resource. Readonly.", - "type": "string" - } - }, - "required": [ - "application" - ] - } - }, - "parameters": { - "HttpRouteNameParameter": { - "name": "httpRouteName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the HTTP Route.", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/openapi.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/openapi.json new file mode 100644 index 0000000000..2cb9c48775 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/openapi.json @@ -0,0 +1,5168 @@ +{ + "swagger": "2.0", + "info": { + "title": "Applications.Core Management APIs", + "version": "2022-03-15-privatepreview", + "description": "REST APIs for Applications.Core", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] + }, + "schemes": [ + "https" + ], + "host": "management.azure.com", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow.", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "tags": [ + { + "name": "Operations" + }, + { + "name": "Environments" + }, + { + "name": "Applications" + }, + { + "name": "Containers" + }, + { + "name": "Gateways" + }, + { + "name": "HttpRoutes" + }, + { + "name": "SecretStores" + }, + { + "name": "Volumes" + }, + { + "name": "Extenders" + } + ], + "paths": { + "/{rootScope}/providers/Applications.Core/applications": { + "get": { + "operationId": "Applications_ListByScope", + "tags": [ + "Applications" + ], + "description": "List ApplicationResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ApplicationResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get applications by resource group": { + "$ref": "./examples/Applications_List.json" + }, + "Get applications by rootScope": { + "$ref": "./examples/Applications_ListByScope.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/applications/{applicationName}": { + "get": { + "operationId": "Applications_Get", + "tags": [ + "Applications" + ], + "description": "Get a ApplicationResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "applicationName", + "in": "path", + "description": "The application name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ApplicationResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get an application resource": { + "$ref": "./examples/Applications_Get.json" + } + } + }, + "put": { + "operationId": "Applications_CreateOrUpdate", + "tags": [ + "Applications" + ], + "description": "Create a ApplicationResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "applicationName", + "in": "path", + "description": "The application name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/ApplicationResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'ApplicationResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/ApplicationResource" + } + }, + "201": { + "description": "Resource 'ApplicationResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/ApplicationResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update an application resource": { + "$ref": "./examples/Applications_CreateOrUpdate.json" + } + } + }, + "patch": { + "operationId": "Applications_Update", + "tags": [ + "Applications" + ], + "description": "Update a ApplicationResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "applicationName", + "in": "path", + "description": "The application name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/ApplicationResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ApplicationResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Update (Patch) an application resource": { + "$ref": "./examples/Applications_Update.json" + } + } + }, + "delete": { + "operationId": "Applications_Delete", + "tags": [ + "Applications" + ], + "description": "Delete a ApplicationResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "applicationName", + "in": "path", + "description": "The application name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete an application resource": { + "$ref": "./examples/Applications_Delete.json" + } + } + } + }, + "/{rootScope}/providers/Applications.Core/containers": { + "get": { + "operationId": "Containers_ListByScope", + "tags": [ + "Containers" + ], + "description": "List ContainerResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ContainerResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List containers at resource group": { + "$ref": "./examples/Containers_List.json" + }, + "List containers at root scope": { + "$ref": "./examples/Containers_ListByScope.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/containers/{containerName}": { + "get": { + "operationId": "Containers_Get", + "tags": [ + "Containers" + ], + "description": "Get a ContainerResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "containerName", + "in": "path", + "description": "Container name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ContainerResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get an container resource": { + "$ref": "./examples/Containers_Get.json" + } + } + }, + "put": { + "operationId": "Containers_CreateOrUpdate", + "tags": [ + "Containers" + ], + "description": "Create a ContainerResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "containerName", + "in": "path", + "description": "Container name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/ContainerResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'ContainerResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/ContainerResource" + } + }, + "201": { + "description": "Resource 'ContainerResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/ContainerResource" + }, + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update an container resource": { + "$ref": "./examples/Containers_CreateOrUpdate.json" + }, + "Create or update an container resource with base manifest": { + "$ref": "./examples/Containers_CreateOrUpdate_BaseManifest.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Containers_Update", + "tags": [ + "Containers" + ], + "description": "Update a ContainerResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "containerName", + "in": "path", + "description": "Container name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/ContainerResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ContainerResource" + } + }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "Containers_Delete", + "tags": [ + "Containers" + ], + "description": "Delete a ContainerResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "containerName", + "in": "path", + "description": "Container name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete an container resource": { + "$ref": "./examples/Containers_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + }, + "/{rootScope}/providers/Applications.Core/environments": { + "get": { + "operationId": "Environments_ListByScope", + "tags": [ + "Environments" + ], + "description": "List EnvironmentResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/EnvironmentResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get environments by resource group": { + "$ref": "./examples/Environments_List.json" + }, + "Get environments by rootScope": { + "$ref": "./examples/Environments_ListByScope.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/environments/{environmentName}": { + "get": { + "operationId": "Environments_Get", + "tags": [ + "Environments" + ], + "description": "Get a EnvironmentResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "environmentName", + "in": "path", + "description": "environment name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/EnvironmentResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get an environment resource": { + "$ref": "./examples/Environments_GetEnv0.json" + } + } + }, + "put": { + "operationId": "Environments_CreateOrUpdate", + "tags": [ + "Environments" + ], + "description": "Create a EnvironmentResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "environmentName", + "in": "path", + "description": "environment name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/EnvironmentResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'EnvironmentResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/EnvironmentResource" + } + }, + "201": { + "description": "Resource 'EnvironmentResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/EnvironmentResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or Update an environment resource": { + "$ref": "./examples/Environments_CreateOrUpdate.json" + } + } + }, + "patch": { + "operationId": "Environments_Update", + "tags": [ + "Environments" + ], + "description": "Update a EnvironmentResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "environmentName", + "in": "path", + "description": "environment name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/EnvironmentResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/EnvironmentResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Update an environment resource": { + "$ref": "./examples/Environments_PatchEnv0.json" + } + } + }, + "delete": { + "operationId": "Environments_Delete", + "tags": [ + "Environments" + ], + "description": "Delete a EnvironmentResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "environmentName", + "in": "path", + "description": "environment name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete an environment resource": { + "$ref": "./examples/Environments_DeleteEnv0.json" + } + } + } + }, + "/{rootScope}/providers/Applications.Core/environments/{environmentName}/getMetadata": { + "post": { + "operationId": "Environments_GetMetadata", + "tags": [ + "Environments" + ], + "description": "Gets recipe metadata including parameters and any constraints on the parameters.", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "environmentName", + "in": "path", + "description": "environment name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "$ref": "#/definitions/RecipeGetMetadata" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/RecipeGetMetadataResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get recipe metadata from environment": { + "$ref": "./examples/Environments_GetRecipeMetadata.json" + } + } + } + }, + "/{rootScope}/providers/Applications.Core/extenders": { + "get": { + "operationId": "Extenders_ListByScope", + "tags": [ + "Extenders" + ], + "description": "List ExtenderResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ExtenderResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List extender resources by resource group": { + "$ref": "./examples/Extenders_List.json" + }, + "List extender resources by rootScope": { + "$ref": "./examples/Extenders_ListByRootScope.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/extenders/{extenderName}": { + "get": { + "operationId": "Extenders_Get", + "tags": [ + "Extenders" + ], + "description": "Get a ExtenderResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "extenderName", + "in": "path", + "description": "The name of the ExtenderResource portable resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ExtenderResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get an extender resource": { + "$ref": "./examples/Extenders_Get.json" + } + } + }, + "put": { + "operationId": "Extenders_CreateOrUpdate", + "tags": [ + "Extenders" + ], + "description": "Create a ExtenderResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "extenderName", + "in": "path", + "description": "The name of the ExtenderResource portable resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/ExtenderResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'ExtenderResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/ExtenderResource" + } + }, + "201": { + "description": "Resource 'ExtenderResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/ExtenderResource" + }, + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or Update an extender resource": { + "$ref": "./examples/Extenders_CreateOrUpdate.json" + }, + "Create or Update an extender resource with recipe": { + "$ref": "./examples/Extenders_CreateOrUpdateWithRecipe.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Extenders_Update", + "tags": [ + "Extenders" + ], + "description": "Update a ExtenderResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "extenderName", + "in": "path", + "description": "The name of the ExtenderResource portable resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/ExtenderResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ExtenderResource" + } + }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Update an extender resource": { + "$ref": "./examples/Extenders_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "Extenders_Delete", + "tags": [ + "Extenders" + ], + "description": "Delete a ExtenderResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "extenderName", + "in": "path", + "description": "The name of the ExtenderResource portable resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete an extender resource": { + "$ref": "./examples/Extenders_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + }, + "/{rootScope}/providers/Applications.Core/extenders/{extenderName}/listSecrets": { + "post": { + "operationId": "Extenders_ListSecrets", + "tags": [ + "Extenders" + ], + "description": "Lists secrets values for the specified Extender resource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "extenderName", + "in": "path", + "description": "The name of the ExtenderResource portable resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "type": "object", + "properties": {} + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ExtenderListSecretResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List the secrets from extender resources": { + "$ref": "./examples/Extenders_ListSecrets.json" + } + } + } + }, + "/{rootScope}/providers/Applications.Core/gateways": { + "get": { + "operationId": "Gateways_ListByScope", + "tags": [ + "Gateways" + ], + "description": "List GatewayResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/GatewayResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List gateway resources": { + "$ref": "./examples/Gateways_List.json" + }, + "List gateway resources by rootScope": { + "$ref": "./examples/Gateways_ListByScope.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/gateways/{gatewayName}": { + "get": { + "operationId": "Gateways_Get", + "tags": [ + "Gateways" + ], + "description": "Get a GatewayResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "gatewayName", + "in": "path", + "description": "Gateway name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/GatewayResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get an gateway resource": { + "$ref": "./examples/Gateways_Get.json" + } + } + }, + "put": { + "operationId": "Gateways_Create", + "tags": [ + "Gateways" + ], + "description": "Create a GatewayResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "gatewayName", + "in": "path", + "description": "Gateway name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/GatewayResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'GatewayResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/GatewayResource" + } + }, + "201": { + "description": "Resource 'GatewayResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/GatewayResource" + }, + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Gateways_CreateOrUpdate", + "tags": [ + "Gateways" + ], + "description": "Update a GatewayResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "gatewayName", + "in": "path", + "description": "Gateway name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/GatewayResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/GatewayResource" + } + }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a gateway resource": { + "$ref": "./examples/Gateways_CreateOrUpdate.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "Gateways_Delete", + "tags": [ + "Gateways" + ], + "description": "Delete a GatewayResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "gatewayName", + "in": "path", + "description": "Gateway name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete an gateway resource": { + "$ref": "./examples/Gateways_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + }, + "/{rootScope}/providers/Applications.Core/httpRoutes": { + "get": { + "operationId": "HttpRoutes_ListByScope", + "tags": [ + "HttpRoutes" + ], + "description": "List HttpRouteResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/HttpRouteResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List httpRoutes resources by resource group": { + "$ref": "./examples/HttpRoutes_List.json" + }, + "List httpRoutes resources by rootScope": { + "$ref": "./examples/HttpRoutes_ListByScope.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/httpRoutes/{httpRouteName}": { + "get": { + "operationId": "HttpRoutes_Get", + "tags": [ + "HttpRoutes" + ], + "description": "Get a HttpRouteResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "httpRouteName", + "in": "path", + "description": "HTTPRoute name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/HttpRouteResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get a httpRoutes resource": { + "$ref": "./examples/HttpRoutes_Get.json" + } + } + }, + "put": { + "operationId": "HttpRoutes_CreateOrUpdate", + "tags": [ + "HttpRoutes" + ], + "description": "Create a HttpRouteResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "httpRouteName", + "in": "path", + "description": "HTTPRoute name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/HttpRouteResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'HttpRouteResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/HttpRouteResource" + } + }, + "201": { + "description": "Resource 'HttpRouteResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/HttpRouteResource" + }, + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or Update httpRoutes resources": { + "$ref": "./examples/HttpRoutes_CreateOrUpdate.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "HttpRoutes_Update", + "tags": [ + "HttpRoutes" + ], + "description": "Update a HttpRouteResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "httpRouteName", + "in": "path", + "description": "HTTPRoute name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/HttpRouteResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/HttpRouteResource" + } + }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Update a httpRoutes resource": { + "$ref": "./examples/HttpRoutes_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "HttpRoutes_Delete", + "tags": [ + "HttpRoutes" + ], + "description": "Delete a HttpRouteResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "httpRouteName", + "in": "path", + "description": "HTTPRoute name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete a httpRoutes resource": { + "$ref": "./examples/HttpRoutes_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + }, + "/{rootScope}/providers/Applications.Core/secretStores": { + "get": { + "operationId": "SecretStores_ListByScope", + "tags": [ + "SecretStores" + ], + "description": "List SecretStoreResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/SecretStoreResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List secret stores": { + "$ref": "./examples/SecretStores_List.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}": { + "get": { + "operationId": "SecretStores_Get", + "tags": [ + "SecretStores" + ], + "description": "Get a SecretStoreResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "secretStoreName", + "in": "path", + "description": "SecretStore name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/SecretStoreResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get a secret store": { + "$ref": "./examples/SecretStores_Get.json" + }, + "Get a secret store for Azure Keyvault": { + "$ref": "./examples/SecretStores_Get_AzureKeyVault.json" + } + } + }, + "put": { + "operationId": "SecretStores_CreateOrUpdate", + "tags": [ + "SecretStores" + ], + "description": "Create a SecretStoreResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "secretStoreName", + "in": "path", + "description": "SecretStore name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/SecretStoreResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'SecretStoreResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/SecretStoreResource" + } + }, + "201": { + "description": "Resource 'SecretStoreResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/SecretStoreResource" + }, + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or Update a secret store resource with azure keyvault": { + "$ref": "./examples/SecretStores_CreateOrUpdate.json" + }, + "Create or Update a secret store resource with valueFrom": { + "$ref": "./examples/SecretStores_CreateOrUpdateValueFrom.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "SecretStores_Update", + "tags": [ + "SecretStores" + ], + "description": "Update a SecretStoreResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "secretStoreName", + "in": "path", + "description": "SecretStore name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/SecretStoreResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/SecretStoreResource" + } + }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Update a secret store resource": { + "$ref": "./examples/SecretStores_Delete.json" + }, + "Update a secret store": { + "$ref": "./examples/SecretStores_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "SecretStores_Delete", + "tags": [ + "SecretStores" + ], + "description": "Delete a SecretStoreResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "secretStoreName", + "in": "path", + "description": "SecretStore name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + }, + "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}/listSecrets": { + "post": { + "operationId": "SecretStores_ListSecrets", + "tags": [ + "SecretStores" + ], + "description": "List the secrets of a secret stores.", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "secretStoreName", + "in": "path", + "description": "SecretStore name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "type": "object", + "properties": {} + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/SecretStoreListSecretsResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List secret stores": { + "$ref": "./examples/SecretStores_ListSecrets.json" + } + } + } + }, + "/{rootScope}/providers/Applications.Core/volumes": { + "get": { + "operationId": "Volumes_ListByScope", + "tags": [ + "Volumes" + ], + "description": "List VolumeResource resources by Scope", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/VolumeResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List volumes by resource group": { + "$ref": "./examples/Volumes_List.json" + }, + "List volumes by rootScope": { + "$ref": "./examples/Volumes_ListByScope.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/{rootScope}/providers/Applications.Core/volumes/{volumeName}": { + "get": { + "operationId": "Volumes_Get", + "tags": [ + "Volumes" + ], + "description": "Get a VolumeResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "volumeName", + "in": "path", + "description": "Volume name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/VolumeResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get a volume": { + "$ref": "./examples/Volumes_Get.json" + } + } + }, + "put": { + "operationId": "Volumes_CreateOrUpdate", + "tags": [ + "Volumes" + ], + "description": "Create a VolumeResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "volumeName", + "in": "path", + "description": "Volume name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/VolumeResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'VolumeResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/VolumeResource" + } + }, + "201": { + "description": "Resource 'VolumeResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/VolumeResource" + }, + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a volume": { + "$ref": "./examples/Volumes_CreateOrUpdate.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Volumes_Update", + "tags": [ + "Volumes" + ], + "description": "Update a VolumeResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "volumeName", + "in": "path", + "description": "Volume name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/VolumeResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/VolumeResource" + } + }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Update a volume": { + "$ref": "./examples/Volumes_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "Volumes_Delete", + "tags": [ + "Volumes" + ], + "description": "Delete a VolumeResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "volumeName", + "in": "path", + "description": "Volume name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete a volume": { + "$ref": "./examples/Volumes_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + }, + "/providers/Applications.Core/operations": { + "get": { + "operationId": "Operations_List", + "tags": [ + "Operations" + ], + "description": "List the operations for the provider", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/OperationListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Get the operations for the Applications.Core resource provider": { + "$ref": "./examples/Operations_List.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + } + }, + "definitions": { + "ApplicationProperties": { + "type": "object", + "description": "Application properties", + "properties": { + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "extensions": { + "type": "array", + "description": "The application extension.", + "items": { + "$ref": "#/definitions/Extension" + }, + "x-ms-identifiers": [] + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + } + }, + "required": [ + "environment" + ] + }, + "ApplicationResource": { + "type": "object", + "description": "Radius Application resource", + "properties": { + "properties": { + "$ref": "#/definitions/ApplicationProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "ApplicationResourceListResult": { + "type": "object", + "description": "The response of a ApplicationResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The ApplicationResource items on this page", + "items": { + "$ref": "#/definitions/ApplicationResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "ApplicationResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the ApplicationResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/ApplicationResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "ApplicationResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the ApplicationResource.", + "properties": { + "compute": { + "$ref": "#/definitions/EnvironmentComputeUpdate", + "description": "The compute resource used by application environment." + }, + "providers": { + "$ref": "#/definitions/ProvidersUpdate", + "description": "Cloud providers configuration for the environment." + }, + "recipes": { + "type": "object", + "description": "Specifies Recipes linked to the Environment.", + "additionalProperties": { + "additionalProperties": { + "$ref": "#/definitions/RecipePropertiesUpdate" + }, + "type": "object" + } + }, + "extensions": { + "type": "array", + "description": "The environment extension.", + "items": { + "$ref": "#/definitions/Extension" + }, + "x-ms-identifiers": [] + } + } + }, + "AzureKeyVaultVolumeProperties": { + "type": "object", + "description": "Represents Azure Key Vault Volume properties", + "properties": { + "certificates": { + "type": "object", + "description": "The KeyVault certificates that this volume exposes", + "additionalProperties": { + "$ref": "#/definitions/CertificateObjectProperties" + } + }, + "keys": { + "type": "object", + "description": "The KeyVault keys that this volume exposes", + "additionalProperties": { + "$ref": "#/definitions/KeyObjectProperties" + } + }, + "resource": { + "type": "string", + "description": "The ID of the keyvault to use for this volume resource" + }, + "secrets": { + "type": "object", + "description": "The KeyVault secrets that this volume exposes", + "additionalProperties": { + "$ref": "#/definitions/SecretObjectProperties" + } + } + }, + "required": [ + "resource" + ], + "allOf": [ + { + "$ref": "#/definitions/VolumeProperties" + } + ], + "x-ms-discriminator-value": "azure.com.keyvault" + }, + "BicepRecipeProperties": { + "type": "object", + "description": "Represents Bicep recipe properties.", + "properties": {}, + "allOf": [ + { + "$ref": "#/definitions/RecipeProperties" + } + ], + "x-ms-discriminator-value": "bicep" + }, + "BicepRecipePropertiesUpdate": { + "type": "object", + "description": "Represents Bicep recipe properties.", + "properties": {}, + "allOf": [ + { + "$ref": "#/definitions/RecipePropertiesUpdate" + } + ], + "x-ms-discriminator-value": "bicep" + }, + "CertificateFormats": { + "type": "string", + "description": "Represents certificate formats", + "enum": [ + "pem", + "pfx" + ], + "x-ms-enum": { + "name": "CertificateFormats", + "modelAsString": true, + "values": [ + { + "name": "pem", + "value": "pem", + "description": "PEM Certificate format" + }, + { + "name": "pfx", + "value": "pfx", + "description": "PFX Certificate format" + } + ] + } + }, + "CertificateObjectProperties": { + "type": "object", + "description": "Represents certificate object properties", + "properties": { + "alias": { + "type": "string", + "description": "File name when written to disk" + }, + "encoding": { + "$ref": "#/definitions/VolumeSecretEncodings", + "description": "Encoding format. Default utf-8", + "default": "utf-8" + }, + "format": { + "$ref": "#/definitions/CertificateFormats", + "description": "Certificate format. Default pem", + "default": "pem" + }, + "name": { + "type": "string", + "description": "The name of the certificate" + }, + "certType": { + "$ref": "#/definitions/CertificateTypes", + "description": "Certificate object type to be downloaded - the certificate itself, private key or public key of the certificate" + }, + "version": { + "type": "string", + "description": "Certificate version" + } + }, + "required": [ + "name" + ] + }, + "CertificateTypes": { + "type": "string", + "description": "Represents certificate types", + "enum": [ + "certificate", + "privatekey", + "publickey" + ], + "x-ms-enum": { + "name": "CertificateTypes", + "modelAsString": true, + "values": [ + { + "name": "certificate", + "value": "certificate", + "description": "Certificate type" + }, + { + "name": "privatekey", + "value": "privatekey", + "description": "Private Key type" + }, + { + "name": "publickey", + "value": "publickey", + "description": "Public Key type" + } + ] + } + }, + "ConnectionProperties": { + "type": "object", + "description": "Connection Properties", + "properties": { + "source": { + "type": "string", + "description": "The source of the connection" + }, + "disableDefaultEnvVars": { + "type": "boolean", + "description": "default environment variable override", + "default": false + }, + "iam": { + "$ref": "#/definitions/IamProperties", + "description": "iam properties" + } + }, + "required": [ + "source" + ] + }, + "ConnectionPropertiesUpdate": { + "type": "object", + "description": "Connection Properties", + "properties": { + "source": { + "type": "string", + "description": "The source of the connection" + }, + "disableDefaultEnvVars": { + "type": "boolean", + "description": "default environment variable override", + "default": false + }, + "iam": { + "$ref": "#/definitions/IamPropertiesUpdate", + "description": "iam properties" + } + } + }, + "Container": { + "type": "object", + "description": "Definition of a container", + "properties": { + "image": { + "type": "string", + "description": "The registry and image to download and run in your container" + }, + "imagePullPolicy": { + "$ref": "#/definitions/ImagePullPolicy", + "description": "The pull policy for the container image" + }, + "env": { + "type": "object", + "description": "environment", + "additionalProperties": { + "type": "string" + } + }, + "ports": { + "type": "object", + "description": "container ports", + "additionalProperties": { + "$ref": "#/definitions/ContainerPortProperties" + } + }, + "readinessProbe": { + "$ref": "#/definitions/HealthProbeProperties", + "description": "readiness probe properties" + }, + "livenessProbe": { + "$ref": "#/definitions/HealthProbeProperties", + "description": "liveness probe properties" + }, + "volumes": { + "type": "object", + "description": "container volumes", + "additionalProperties": { + "$ref": "#/definitions/Volume" + } + }, + "command": { + "type": "array", + "description": "Entrypoint array. Overrides the container image's ENTRYPOINT", + "items": { + "type": "string" + } + }, + "args": { + "type": "array", + "description": "Arguments to the entrypoint. Overrides the container image's CMD", + "items": { + "type": "string" + } + }, + "workingDir": { + "type": "string", + "description": "Working directory for the container" + } + }, + "required": [ + "image" + ] + }, + "ContainerPortProperties": { + "type": "object", + "description": "Specifies a listening port for the container", + "properties": { + "containerPort": { + "type": "integer", + "format": "int32", + "description": "The listening port number" + }, + "protocol": { + "$ref": "#/definitions/PortProtocol", + "description": "Protocol in use by the port" + }, + "provides": { + "type": "string", + "description": "Specifies a route provided by this port" + }, + "scheme": { + "type": "string", + "description": "Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired" + } + }, + "required": [ + "containerPort" + ] + }, + "ContainerPortPropertiesUpdate": { + "type": "object", + "description": "Specifies a listening port for the container", + "properties": { + "containerPort": { + "type": "integer", + "format": "int32", + "description": "The listening port number" + }, + "protocol": { + "$ref": "#/definitions/PortProtocol", + "description": "Protocol in use by the port" + }, + "provides": { + "type": "string", + "description": "Specifies a route provided by this port" + }, + "scheme": { + "type": "string", + "description": "Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired" + } + } + }, + "ContainerProperties": { + "type": "object", + "description": "Container properties", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "container": { + "$ref": "#/definitions/Container", + "description": "Definition of a container." + }, + "connections": { + "type": "object", + "description": "Specifies a connection to another resource.", + "additionalProperties": { + "$ref": "#/definitions/ConnectionProperties" + } + }, + "identity": { + "$ref": "#/definitions/IdentitySettings", + "description": "Configuration for supported external identity providers" + }, + "extensions": { + "type": "array", + "description": "Extensions spec of the resource", + "items": { + "$ref": "#/definitions/Extension" + }, + "x-ms-identifiers": [] + }, + "runtimes": { + "$ref": "#/definitions/RuntimesProperties", + "description": "Specifies Runtime-specific functionality" + } + }, + "required": [ + "application", + "container" + ] + }, + "ContainerResource": { + "type": "object", + "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "properties": { + "properties": { + "$ref": "#/definitions/ContainerProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "ContainerResourceListResult": { + "type": "object", + "description": "The response of a ContainerResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The ContainerResource items on this page", + "items": { + "$ref": "#/definitions/ContainerResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "ContainerResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the ContainerResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/ContainerResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "ContainerResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the ContainerResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "container": { + "$ref": "#/definitions/ContainerUpdate", + "description": "Definition of a container." + }, + "connections": { + "type": "object", + "description": "Specifies a connection to another resource.", + "additionalProperties": { + "$ref": "#/definitions/ConnectionPropertiesUpdate" + } + }, + "identity": { + "$ref": "#/definitions/IdentitySettingsUpdate", + "description": "Configuration for supported external identity providers" + }, + "extensions": { + "type": "array", + "description": "Extensions spec of the resource", + "items": { + "$ref": "#/definitions/Extension" + }, + "x-ms-identifiers": [] + }, + "runtimes": { + "$ref": "#/definitions/RuntimesProperties", + "description": "Specifies Runtime-specific functionality" + } + } + }, + "ContainerUpdate": { + "type": "object", + "description": "Definition of a container", + "properties": { + "image": { + "type": "string", + "description": "The registry and image to download and run in your container" + }, + "imagePullPolicy": { + "$ref": "#/definitions/ImagePullPolicy", + "description": "The pull policy for the container image" + }, + "env": { + "type": "object", + "description": "environment", + "additionalProperties": { + "type": "string" + } + }, + "ports": { + "type": "object", + "description": "container ports", + "additionalProperties": { + "$ref": "#/definitions/ContainerPortPropertiesUpdate" + } + }, + "readinessProbe": { + "$ref": "#/definitions/HealthProbeProperties", + "description": "readiness probe properties" + }, + "livenessProbe": { + "$ref": "#/definitions/HealthProbeProperties", + "description": "liveness probe properties" + }, + "volumes": { + "type": "object", + "description": "container volumes", + "additionalProperties": { + "$ref": "#/definitions/Volume" + } + }, + "command": { + "type": "array", + "description": "Entrypoint array. Overrides the container image's ENTRYPOINT", + "items": { + "type": "string" + } + }, + "args": { + "type": "array", + "description": "Arguments to the entrypoint. Overrides the container image's CMD", + "items": { + "type": "string" + } + }, + "workingDir": { + "type": "string", + "description": "Working directory for the container" + } + } + }, + "DaprSidecarExtension": { + "type": "object", + "description": "Specifies the resource should have a Dapr sidecar injected", + "properties": { + "appPort": { + "type": "integer", + "format": "int32", + "description": "The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. " + }, + "appId": { + "type": "string", + "description": "The Dapr appId. Specifies the identifier used by Dapr for service invocation." + }, + "config": { + "type": "string", + "description": "Specifies the Dapr configuration to use for the resource." + }, + "protocol": { + "$ref": "#/definitions/DaprSidecarExtensionProtocol", + "description": "Specifies the Dapr app-protocol to use for the resource." + } + }, + "required": [ + "appId" + ], + "allOf": [ + { + "$ref": "#/definitions/Extension" + } + ], + "x-ms-discriminator-value": "daprSidecar" + }, + "DaprSidecarExtensionProtocol": { + "type": "string", + "description": "The Dapr sidecar extension protocol", + "enum": [ + "http", + "grpc" + ], + "x-ms-enum": { + "name": "DaprSidecarExtensionProtocol", + "modelAsString": true, + "values": [ + { + "name": "http", + "value": "http", + "description": "HTTP protocol" + }, + { + "name": "grpc", + "value": "grpc", + "description": "gRPC protocol" + } + ] + } + }, + "EnvironmentCompute": { + "type": "object", + "description": "Represents backing compute resource", + "properties": { + "kind": { + "type": "string", + "description": "Discriminator property for EnvironmentCompute." + }, + "resourceId": { + "type": "string", + "description": "The resource id of the compute resource for application environment." + }, + "identity": { + "$ref": "#/definitions/IdentitySettings", + "description": "Configuration for supported external identity providers" + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "EnvironmentComputeUpdate": { + "type": "object", + "description": "Represents backing compute resource", + "properties": { + "kind": { + "type": "string", + "description": "Discriminator property for EnvironmentCompute." + }, + "resourceId": { + "type": "string", + "description": "The resource id of the compute resource for application environment." + }, + "identity": { + "$ref": "#/definitions/IdentitySettingsUpdate", + "description": "Configuration for supported external identity providers" + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "EnvironmentProperties": { + "type": "object", + "description": "Environment properties", + "properties": { + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "compute": { + "$ref": "#/definitions/EnvironmentCompute", + "description": "The compute resource used by application environment." + }, + "providers": { + "$ref": "#/definitions/Providers", + "description": "Cloud providers configuration for the environment." + }, + "recipes": { + "type": "object", + "description": "Specifies Recipes linked to the Environment.", + "additionalProperties": { + "additionalProperties": { + "$ref": "#/definitions/RecipeProperties" + }, + "type": "object" + } + }, + "extensions": { + "type": "array", + "description": "The environment extension.", + "items": { + "$ref": "#/definitions/Extension" + }, + "x-ms-identifiers": [] + } + }, + "required": [ + "compute" + ] + }, + "EnvironmentResource": { + "type": "object", + "description": "The environment resource", + "properties": { + "properties": { + "$ref": "#/definitions/EnvironmentProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "EnvironmentResourceListResult": { + "type": "object", + "description": "The response of a EnvironmentResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The EnvironmentResource items on this page", + "items": { + "$ref": "#/definitions/EnvironmentResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "EnvironmentResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the EnvironmentResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/EnvironmentResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "EnvironmentResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the EnvironmentResource.", + "properties": { + "compute": { + "$ref": "#/definitions/EnvironmentComputeUpdate", + "description": "The compute resource used by application environment." + }, + "providers": { + "$ref": "#/definitions/ProvidersUpdate", + "description": "Cloud providers configuration for the environment." + }, + "recipes": { + "type": "object", + "description": "Specifies Recipes linked to the Environment.", + "additionalProperties": { + "additionalProperties": { + "$ref": "#/definitions/RecipePropertiesUpdate" + }, + "type": "object" + } + }, + "extensions": { + "type": "array", + "description": "The environment extension.", + "items": { + "$ref": "#/definitions/Extension" + }, + "x-ms-identifiers": [] + } + } + }, + "EphemeralVolume": { + "type": "object", + "description": "Specifies an ephemeral volume for a container", + "properties": { + "managedStore": { + "$ref": "#/definitions/ManagedStore", + "description": "Backing store for the ephemeral volume" + } + }, + "required": [ + "managedStore" + ], + "allOf": [ + { + "$ref": "#/definitions/Volume" + } + ], + "x-ms-discriminator-value": "ephemeral" + }, + "ExecHealthProbeProperties": { + "type": "object", + "description": "Specifies the properties for readiness/liveness probe using an executable", + "properties": { + "command": { + "type": "string", + "description": "Command to execute to probe readiness/liveness" + } + }, + "required": [ + "command" + ], + "allOf": [ + { + "$ref": "#/definitions/HealthProbeProperties" + } + ], + "x-ms-discriminator-value": "exec" + }, + "ExtenderListSecretResponse": { + "type": "object", + "description": "Response for list secrets API call", + "properties": {} + }, + "ExtenderProperties": { + "type": "object", + "description": "ExtenderResource portable resource properties", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "secrets": { + "type": "object", + "description": "The secrets for referenced resource", + "properties": {} + }, + "recipe": { + "$ref": "#/definitions/Recipe", + "description": "The recipe used to automatically deploy underlying infrastructure for the extender portable resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + }, + "required": [ + "environment" + ], + "additionalProperties": true, + "allOf": [ + { + "type": "object", + "additionalProperties": true + } + ] + }, + "ExtenderResource": { + "type": "object", + "description": "ExtenderResource portable resource", + "properties": { + "properties": { + "$ref": "#/definitions/ExtenderProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "ExtenderResourceListResult": { + "type": "object", + "description": "The response of a ExtenderResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The ExtenderResource items on this page", + "items": { + "$ref": "#/definitions/ExtenderResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "ExtenderResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the ExtenderResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/ExtenderResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "ExtenderResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the ExtenderResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "secrets": { + "type": "object", + "description": "The secrets for referenced resource", + "properties": {} + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the extender portable resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, + "Extension": { + "type": "object", + "description": "Extension of a environment/application resource.", + "properties": { + "kind": { + "type": "string", + "description": "Discriminator property for Extension." + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "GatewayHostname": { + "type": "object", + "description": "Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io.", + "properties": { + "prefix": { + "type": "string", + "description": "Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined." + }, + "fullyQualifiedHostname": { + "type": "string", + "description": "Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined." + } + } + }, + "GatewayProperties": { + "type": "object", + "description": "Gateway properties", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "internal": { + "type": "boolean", + "description": "Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).", + "default": false + }, + "hostname": { + "$ref": "#/definitions/GatewayHostname", + "description": "Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io." + }, + "routes": { + "type": "array", + "description": "Routes attached to this Gateway", + "items": { + "$ref": "#/definitions/GatewayRoute" + }, + "x-ms-identifiers": [] + }, + "tls": { + "$ref": "#/definitions/GatewayTls", + "description": "TLS configuration for the Gateway." + }, + "url": { + "type": "string", + "description": "URL of the gateway resource. Readonly", + "readOnly": true + } + }, + "required": [ + "application", + "routes" + ] + }, + "GatewayResource": { + "type": "object", + "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "properties": { + "properties": { + "$ref": "#/definitions/GatewayProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "GatewayResourceListResult": { + "type": "object", + "description": "The response of a GatewayResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The GatewayResource items on this page", + "items": { + "$ref": "#/definitions/GatewayResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "GatewayResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the GatewayResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/GatewayResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "GatewayResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the GatewayResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "internal": { + "type": "boolean", + "description": "Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).", + "default": false + }, + "hostname": { + "$ref": "#/definitions/GatewayHostname", + "description": "Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io." + }, + "routes": { + "type": "array", + "description": "Routes attached to this Gateway", + "items": { + "$ref": "#/definitions/GatewayRoute" + }, + "x-ms-identifiers": [] + }, + "tls": { + "$ref": "#/definitions/GatewayTls", + "description": "TLS configuration for the Gateway." + } + } + }, + "GatewayRoute": { + "type": "object", + "description": "Route attached to Gateway", + "properties": { + "path": { + "type": "string", + "description": "The path to match the incoming request path on. Ex - /myservice." + }, + "destination": { + "type": "string", + "description": "The HttpRoute to route to. Ex - myserviceroute.id." + }, + "replacePrefix": { + "type": "string", + "description": "Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute'" + } + } + }, + "GatewayTls": { + "type": "object", + "description": "TLS configuration definition for Gateway resource.", + "properties": { + "sslPassthrough": { + "type": "boolean", + "description": "If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption.", + "default": false + }, + "minimumProtocolVersion": { + "$ref": "#/definitions/TlsMinVersion", + "description": "TLS minimum protocol version (defaults to 1.2).", + "default": "1.2" + }, + "certificateFrom": { + "type": "string", + "description": "The resource id for the secret containing the TLS certificate and key for the gateway." + } + } + }, + "HealthProbeProperties": { + "type": "object", + "description": "Properties for readiness/liveness probe", + "properties": { + "kind": { + "type": "string", + "description": "Discriminator property for HealthProbeProperties." + }, + "initialDelaySeconds": { + "type": "number", + "format": "float", + "description": "Initial delay in seconds before probing for readiness/liveness" + }, + "failureThreshold": { + "type": "number", + "format": "float", + "description": "Threshold number of times the probe fails after which a failure would be reported" + }, + "periodSeconds": { + "type": "number", + "format": "float", + "description": "Interval for the readiness/liveness probe in seconds" + }, + "timeoutSeconds": { + "type": "number", + "format": "float", + "description": "Number of seconds after which the readiness/liveness probe times out. Defaults to 5 seconds", + "default": 5 + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "HttpGetHealthProbeProperties": { + "type": "object", + "description": "Specifies the properties for readiness/liveness probe using HTTP Get", + "properties": { + "containerPort": { + "type": "integer", + "format": "int32", + "description": "The listening port number" + }, + "path": { + "type": "string", + "description": "The route to make the HTTP request on" + }, + "headers": { + "type": "object", + "description": "Custom HTTP headers to add to the get request", + "additionalProperties": { + "type": "string" + } + } + }, + "required": [ + "containerPort", + "path" + ], + "allOf": [ + { + "$ref": "#/definitions/HealthProbeProperties" + } + ], + "x-ms-discriminator-value": "httpGet" + }, + "HttpRouteProperties": { + "type": "object", + "description": "HTTPRoute properties", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "hostname": { + "type": "string", + "description": "The internal hostname accepting traffic for the HTTP Route. Readonly." + }, + "port": { + "type": "integer", + "format": "int32", + "description": "The port number for the HTTP Route. Defaults to 80. Readonly." + }, + "scheme": { + "type": "string", + "description": "The scheme used for traffic. Readonly.", + "readOnly": true + }, + "url": { + "type": "string", + "description": "A stable URL that that can be used to route traffic to a resource. Readonly.", + "readOnly": true + } + }, + "required": [ + "application" + ] + }, + "HttpRouteResource": { + "type": "object", + "description": "Radius HTTPRoute Resource.", + "properties": { + "properties": { + "$ref": "#/definitions/HttpRouteProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "HttpRouteResourceListResult": { + "type": "object", + "description": "The response of a HttpRouteResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The HttpRouteResource items on this page", + "items": { + "$ref": "#/definitions/HttpRouteResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "HttpRouteResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the HttpRouteResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/HttpRouteResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "HttpRouteResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the HttpRouteResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "hostname": { + "type": "string", + "description": "The internal hostname accepting traffic for the HTTP Route. Readonly." + }, + "port": { + "type": "integer", + "format": "int32", + "description": "The port number for the HTTP Route. Defaults to 80. Readonly." + } + } + }, + "IAMKind": { + "type": "string", + "description": "The kind of IAM provider to configure", + "enum": [ + "azure" + ], + "x-ms-enum": { + "name": "IAMKind", + "modelAsString": true, + "values": [ + { + "name": "azure", + "value": "azure", + "description": "Azure Active Directory" + } + ] + } + }, + "IamProperties": { + "type": "object", + "description": "IAM properties", + "properties": { + "kind": { + "$ref": "#/definitions/IAMKind", + "description": "The kind of IAM provider to configure" + }, + "roles": { + "type": "array", + "description": "RBAC permissions to be assigned on the source resource", + "items": { + "type": "string" + } + } + }, + "required": [ + "kind" + ] + }, + "IamPropertiesUpdate": { + "type": "object", + "description": "IAM properties", + "properties": { + "kind": { + "$ref": "#/definitions/IAMKind", + "description": "The kind of IAM provider to configure" + }, + "roles": { + "type": "array", + "description": "RBAC permissions to be assigned on the source resource", + "items": { + "type": "string" + } + } + } + }, + "IdentitySettingKind": { + "type": "string", + "description": "IdentitySettingKind is the kind of supported external identity setting", + "enum": [ + "undefined", + "azure.com.workload" + ], + "x-ms-enum": { + "name": "IdentitySettingKind", + "modelAsString": true, + "values": [ + { + "name": "undefined", + "value": "undefined", + "description": "undefined identity" + }, + { + "name": "azure.com.workload", + "value": "azure.com.workload", + "description": "azure ad workload identity" + } + ] + } + }, + "IdentitySettings": { + "type": "object", + "description": "IdentitySettings is the external identity setting.", + "properties": { + "kind": { + "$ref": "#/definitions/IdentitySettingKind", + "description": "kind of identity setting" + }, + "oidcIssuer": { + "type": "string", + "description": "The URI for your compute platform's OIDC issuer" + }, + "resource": { + "type": "string", + "description": "The resource ID of the provisioned identity" + } + }, + "required": [ + "kind" + ] + }, + "IdentitySettingsUpdate": { + "type": "object", + "description": "IdentitySettings is the external identity setting.", + "properties": { + "kind": { + "$ref": "#/definitions/IdentitySettingKind", + "description": "kind of identity setting" + }, + "oidcIssuer": { + "type": "string", + "description": "The URI for your compute platform's OIDC issuer" + }, + "resource": { + "type": "string", + "description": "The resource ID of the provisioned identity" + } + } + }, + "ImagePullPolicy": { + "type": "string", + "description": "The image pull policy for the container", + "enum": [ + "Always", + "IfNotPresent", + "Never" + ], + "x-ms-enum": { + "name": "ImagePullPolicy", + "modelAsString": true, + "values": [ + { + "name": "Always", + "value": "Always", + "description": "Always" + }, + { + "name": "IfNotPresent", + "value": "IfNotPresent", + "description": "IfNotPresent" + }, + { + "name": "Never", + "value": "Never", + "description": "Never" + } + ] + } + }, + "KeyObjectProperties": { + "type": "object", + "description": "Represents key object properties", + "properties": { + "alias": { + "type": "string", + "description": "File name when written to disk" + }, + "name": { + "type": "string", + "description": "The name of the key" + }, + "version": { + "type": "string", + "description": "Key version" + } + }, + "required": [ + "name" + ] + }, + "KubernetesCompute": { + "type": "object", + "description": "The Kubernetes compute configuration", + "properties": { + "namespace": { + "type": "string", + "description": "The namespace to use for the environment." + } + }, + "required": [ + "namespace" + ], + "allOf": [ + { + "$ref": "#/definitions/EnvironmentCompute" + } + ], + "x-ms-discriminator-value": "kubernetes" + }, + "KubernetesComputeUpdate": { + "type": "object", + "description": "The Kubernetes compute configuration", + "properties": { + "namespace": { + "type": "string", + "description": "The namespace to use for the environment." + } + }, + "allOf": [ + { + "$ref": "#/definitions/EnvironmentComputeUpdate" + } + ], + "x-ms-discriminator-value": "kubernetes" + }, + "KubernetesMetadataExtension": { + "type": "object", + "description": "Kubernetes metadata extension of a environment/application resource.", + "properties": { + "annotations": { + "type": "object", + "description": "Annotations to be applied to the Kubernetes resources output by the resource", + "additionalProperties": { + "type": "string" + } + }, + "labels": { + "type": "object", + "description": "Labels to be applied to the Kubernetes resources output by the resource", + "additionalProperties": { + "type": "string" + } + } + }, + "allOf": [ + { + "$ref": "#/definitions/Extension" + } + ], + "x-ms-discriminator-value": "kubernetesMetadata" + }, + "KubernetesNamespaceExtension": { + "type": "object", + "description": "Kubernetes namespace extension of a environment/application resource.", + "properties": { + "namespace": { + "type": "string", + "description": "The namespace of the application environment." + } + }, + "required": [ + "namespace" + ], + "allOf": [ + { + "$ref": "#/definitions/Extension" + } + ], + "x-ms-discriminator-value": "kubernetesNamespace" + }, + "KubernetesPodSpec": { + "type": "object", + "description": "A strategic merge patch that will be applied to the PodSpec object when this container is being deployed.", + "additionalProperties": true + }, + "KubernetesRuntimeProperties": { + "type": "object", + "description": "The runtime configuration properties for Kubernetes", + "properties": { + "base": { + "type": "string", + "description": "The serialized YAML manifest which represents the base Kubernetes resources to deploy, such as Deployment, Service, ServiceAccount, Secrets, and ConfigMaps." + }, + "pod": { + "$ref": "#/definitions/KubernetesPodSpec", + "description": "A strategic merge patch that will be applied to the PodSpec object when this container is being deployed." + } + } + }, + "ManagedStore": { + "type": "string", + "description": "The managed store for the ephemeral volume", + "enum": [ + "memory", + "disk" + ], + "x-ms-enum": { + "name": "ManagedStore", + "modelAsString": true, + "values": [ + { + "name": "memory", + "value": "memory", + "description": "Memory store" + }, + { + "name": "disk", + "value": "disk", + "description": "Disk store" + } + ] + } + }, + "ManualScalingExtension": { + "type": "object", + "description": "ManualScaling Extension", + "properties": { + "replicas": { + "type": "integer", + "format": "int32", + "description": "Replica count." + } + }, + "required": [ + "replicas" + ], + "allOf": [ + { + "$ref": "#/definitions/Extension" + } + ], + "x-ms-discriminator-value": "manualScaling" + }, + "OutputResource": { + "type": "object", + "description": "Properties of an output resource.", + "properties": { + "localId": { + "type": "string", + "description": "The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships." + }, + "id": { + "type": "string", + "description": "The UCP resource ID of the underlying resource." + }, + "radiusManaged": { + "type": "boolean", + "description": "Determines whether Radius manages the lifecycle of the underlying resource." + } + } + }, + "PersistentVolume": { + "type": "object", + "description": "Specifies a persistent volume for a container", + "properties": { + "permission": { + "$ref": "#/definitions/VolumePermission", + "description": "Container read/write access to the volume" + }, + "source": { + "type": "string", + "description": "The source of the volume" + } + }, + "required": [ + "source" + ], + "allOf": [ + { + "$ref": "#/definitions/Volume" + } + ], + "x-ms-discriminator-value": "persistent" + }, + "PortProtocol": { + "type": "string", + "description": "The protocol in use by the port", + "enum": [ + "TCP", + "UDP" + ], + "x-ms-enum": { + "name": "PortProtocol", + "modelAsString": true, + "values": [ + { + "name": "TCP", + "value": "TCP", + "description": "TCP protocol" + }, + { + "name": "UDP", + "value": "UDP", + "description": "UDP protocol" + } + ] + } + }, + "Providers": { + "type": "object", + "description": "The Cloud providers configuration", + "properties": { + "azure": { + "$ref": "#/definitions/ProvidersAzure", + "description": "The Azure cloud provider configuration" + }, + "aws": { + "$ref": "#/definitions/ProvidersAws", + "description": "The AWS cloud provider configuration" + } + } + }, + "ProvidersAws": { + "type": "object", + "description": "The AWS cloud provider definition", + "properties": { + "scope": { + "type": "string", + "description": "Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2'" + } + }, + "required": [ + "scope" + ] + }, + "ProvidersAwsUpdate": { + "type": "object", + "description": "The AWS cloud provider definition", + "properties": { + "scope": { + "type": "string", + "description": "Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2'" + } + } + }, + "ProvidersAzure": { + "type": "object", + "description": "The Azure cloud provider definition", + "properties": { + "scope": { + "type": "string", + "description": "Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup'" + } + }, + "required": [ + "scope" + ] + }, + "ProvidersAzureUpdate": { + "type": "object", + "description": "The Azure cloud provider definition", + "properties": { + "scope": { + "type": "string", + "description": "Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup'" + } + } + }, + "ProvidersUpdate": { + "type": "object", + "description": "The Cloud providers configuration", + "properties": { + "azure": { + "$ref": "#/definitions/ProvidersAzureUpdate", + "description": "The Azure cloud provider configuration" + }, + "aws": { + "$ref": "#/definitions/ProvidersAwsUpdate", + "description": "The AWS cloud provider configuration" + } + } + }, + "ProvisioningState": { + "type": "string", + "description": "Provisioning state of the portable resource at the time the operation was called", + "enum": [ + "Succeeded", + "Failed", + "Canceled", + "Provisioning", + "Updating", + "Deleting", + "Accepted" + ], + "x-ms-enum": { + "name": "ProvisioningState", + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + }, + { + "name": "Provisioning", + "value": "Provisioning", + "description": "The resource is being provisioned" + }, + { + "name": "Updating", + "value": "Updating", + "description": "The resource is updating" + }, + { + "name": "Deleting", + "value": "Deleting", + "description": "The resource is being deleted" + }, + { + "name": "Accepted", + "value": "Accepted", + "description": "The resource create request has been accepted" + } + ] + }, + "readOnly": true + }, + "Recipe": { + "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", + "properties": { + "name": { + "type": "string", + "description": "The name of the recipe within the environment to use" + }, + "parameters": { + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} + } + }, + "required": [ + "name" + ] + }, + "RecipeGetMetadata": { + "type": "object", + "description": "Represents the request body of the getmetadata action.", + "properties": { + "resourceType": { + "type": "string", + "description": "Type of the resource this recipe can be consumed by. For example: 'Applications.Datastores/mongoDatabases'" + }, + "name": { + "type": "string", + "description": "The name of the recipe registered to the environment" + } + }, + "required": [ + "resourceType", + "name" + ] + }, + "RecipeGetMetadataResponse": { + "type": "object", + "description": "The properties of a Recipe linked to an Environment.", + "properties": { + "templateKind": { + "type": "string", + "description": "The format of the template provided by the recipe. Allowed values: bicep, terraform." + }, + "templatePath": { + "type": "string", + "description": "The path to the template provided by the recipe. Currently only link to Azure Container Registry is supported." + }, + "templateVersion": { + "type": "string", + "description": "The version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources." + }, + "parameters": { + "type": "object", + "description": "The key/value parameters to pass to the recipe template at deployment.", + "properties": {} + } + }, + "required": [ + "templateKind", + "templatePath", + "parameters" + ] + }, + "RecipeProperties": { + "type": "object", + "description": "Format of the template provided by the recipe. Allowed values: bicep, terraform.", + "properties": { + "templateKind": { + "type": "string", + "description": "Discriminator property for RecipeProperties." + }, + "templatePath": { + "type": "string", + "description": "Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported." + }, + "parameters": { + "type": "object", + "description": "Key/value parameters to pass to the recipe template at deployment", + "properties": {} + } + }, + "discriminator": "templateKind", + "required": [ + "templateKind", + "templatePath" + ] + }, + "RecipePropertiesUpdate": { + "type": "object", + "description": "Format of the template provided by the recipe. Allowed values: bicep, terraform.", + "properties": { + "templateKind": { + "type": "string", + "description": "Discriminator property for RecipeProperties." + }, + "templatePath": { + "type": "string", + "description": "Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported." + }, + "parameters": { + "type": "object", + "description": "Key/value parameters to pass to the recipe template at deployment", + "properties": {} + } + }, + "discriminator": "templateKind", + "required": [ + "templateKind" + ] + }, + "RecipeUpdate": { + "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", + "properties": { + "name": { + "type": "string", + "description": "The name of the recipe within the environment to use" + }, + "parameters": { + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} + } + } + }, + "ResourceProvisioning": { + "type": "string", + "description": "Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.", + "enum": [ + "recipe", + "manual" + ], + "x-ms-enum": { + "name": "ResourceProvisioning", + "modelAsString": true, + "values": [ + { + "name": "recipe", + "value": "recipe", + "description": "The resource lifecycle will be managed by Radius" + }, + { + "name": "manual", + "value": "manual", + "description": "The resource lifecycle will be managed by the user" + } + ] + } + }, + "ResourceStatus": { + "type": "object", + "description": "Status of a resource.", + "properties": { + "compute": { + "$ref": "#/definitions/EnvironmentCompute", + "description": "The compute resource associated with the resource." + }, + "outputResources": { + "type": "array", + "description": "Properties of an output resource", + "items": { + "$ref": "#/definitions/OutputResource" + }, + "x-ms-identifiers": [] + } + } + }, + "RuntimesProperties": { + "type": "object", + "description": "The properties for runtime configuration", + "properties": { + "kubernetes": { + "$ref": "#/definitions/KubernetesRuntimeProperties", + "description": "The runtime configuration properties for Kubernetes" + } + } + }, + "SecretObjectProperties": { + "type": "object", + "description": "Represents secret object properties", + "properties": { + "alias": { + "type": "string", + "description": "File name when written to disk" + }, + "encoding": { + "$ref": "#/definitions/VolumeSecretEncodings", + "description": "Encoding format. Default utf-8", + "default": "utf-8" + }, + "name": { + "type": "string", + "description": "The name of the secret" + }, + "version": { + "type": "string", + "description": "secret version" + } + }, + "required": [ + "name" + ] + }, + "SecretStoreDataType": { + "type": "string", + "description": "The type of SecretStore data", + "enum": [ + "generic", + "certificate" + ], + "x-ms-enum": { + "name": "SecretStoreDataType", + "modelAsString": true, + "values": [ + { + "name": "generic", + "value": "generic", + "description": "Generic secret data type" + }, + { + "name": "certificate", + "value": "certificate", + "description": "Certificate secret data type" + } + ] + } + }, + "SecretStoreListSecretsResult": { + "type": "object", + "description": "The list of secrets", + "properties": { + "type": { + "$ref": "#/definitions/SecretStoreDataType", + "description": "The type of secret store data" + }, + "data": { + "type": "object", + "description": "An object to represent key-value type secrets", + "additionalProperties": { + "$ref": "#/definitions/SecretValueProperties" + } + } + }, + "required": [ + "type", + "data" + ] + }, + "SecretStoreProperties": { + "type": "object", + "description": "The properties of SecretStore", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "type": { + "$ref": "#/definitions/SecretStoreDataType", + "description": "The type of secret store data", + "default": "generic" + }, + "data": { + "type": "object", + "description": "An object to represent key-value type secrets", + "additionalProperties": { + "$ref": "#/definitions/SecretValueProperties" + } + }, + "resource": { + "type": "string", + "description": "The resource id of external secret store." + } + }, + "required": [ + "application", + "data" + ] + }, + "SecretStoreResource": { + "type": "object", + "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", + "properties": { + "properties": { + "$ref": "#/definitions/SecretStoreProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "SecretStoreResourceListResult": { + "type": "object", + "description": "The response of a SecretStoreResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The SecretStoreResource items on this page", + "items": { + "$ref": "#/definitions/SecretStoreResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "SecretStoreResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the SecretStoreResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/SecretStoreResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "SecretStoreResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the SecretStoreResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "type": { + "$ref": "#/definitions/SecretStoreDataType", + "description": "The type of secret store data", + "default": "generic" + }, + "data": { + "type": "object", + "description": "An object to represent key-value type secrets", + "additionalProperties": { + "$ref": "#/definitions/SecretValueProperties" + } + }, + "resource": { + "type": "string", + "description": "The resource id of external secret store." + } + } + }, + "SecretValueEncoding": { + "type": "string", + "description": "The type of SecretValue Encoding", + "enum": [ + "raw", + "base64" + ], + "x-ms-enum": { + "name": "SecretValueEncoding", + "modelAsString": true, + "values": [ + { + "name": "raw", + "value": "raw", + "description": "The raw secret value" + }, + { + "name": "base64", + "value": "base64", + "description": "The base64-encoded secret value" + } + ] + } + }, + "SecretValueProperties": { + "type": "object", + "description": "The properties of SecretValue", + "properties": { + "encoding": { + "$ref": "#/definitions/SecretValueEncoding", + "description": "The encoding of value", + "default": "raw" + }, + "value": { + "type": "string", + "format": "password", + "description": "The value of secret.", + "x-ms-secret": true + }, + "valueFrom": { + "$ref": "#/definitions/ValueFromProperties", + "description": "The referenced secret in properties.resource" + } + } + }, + "TcpHealthProbeProperties": { + "type": "object", + "description": "Specifies the properties for readiness/liveness probe using TCP", + "properties": { + "containerPort": { + "type": "integer", + "format": "int32", + "description": "The listening port number" + } + }, + "required": [ + "containerPort" + ], + "allOf": [ + { + "$ref": "#/definitions/HealthProbeProperties" + } + ], + "x-ms-discriminator-value": "tcp" + }, + "TerraformRecipeProperties": { + "type": "object", + "description": "Represents Terraform recipe properties.", + "properties": { + "templateVersion": { + "type": "string", + "description": "Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources." + } + }, + "allOf": [ + { + "$ref": "#/definitions/RecipeProperties" + } + ], + "x-ms-discriminator-value": "terraform" + }, + "TerraformRecipePropertiesUpdate": { + "type": "object", + "description": "Represents Terraform recipe properties.", + "properties": { + "templateVersion": { + "type": "string", + "description": "Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources." + } + }, + "allOf": [ + { + "$ref": "#/definitions/RecipePropertiesUpdate" + } + ], + "x-ms-discriminator-value": "terraform" + }, + "TlsMinVersion": { + "type": "string", + "description": "Tls Minimum versions for Gateway resource.", + "enum": [ + "1.2", + "1.3" + ], + "x-ms-enum": { + "name": "TlsMinVersion", + "modelAsString": true, + "values": [ + { + "name": "tls12", + "value": "1.2", + "description": "TLS Version 1.2" + }, + { + "name": "tls13", + "value": "1.3", + "description": "TLS Version 1.3" + } + ] + } + }, + "ValueFromProperties": { + "type": "object", + "description": "The Secret value source properties", + "properties": { + "name": { + "type": "string", + "description": "The name of the referenced secret." + }, + "version": { + "type": "string", + "description": "The version of the referenced secret." + } + }, + "required": [ + "name" + ] + }, + "Versions": { + "type": "string", + "description": "Supported API versions for the Applications.Core resource provider.", + "enum": [ + "2022-03-15-privatepreview" + ], + "x-ms-enum": { + "name": "Versions", + "modelAsString": true, + "values": [ + { + "name": "v2022_03_15_privatepreview", + "value": "2022-03-15-privatepreview", + "description": "2022-03-15-privatepreview" + } + ] + } + }, + "Volume": { + "type": "object", + "description": "Specifies a volume for a container", + "properties": { + "kind": { + "type": "string", + "description": "Discriminator property for Volume." + }, + "mountPath": { + "type": "string", + "description": "The path where the volume is mounted" + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "VolumePermission": { + "type": "string", + "description": "The persistent volume permission", + "enum": [ + "read", + "write" + ], + "x-ms-enum": { + "name": "VolumePermission", + "modelAsString": true, + "values": [ + { + "name": "read", + "value": "read", + "description": "Read only" + }, + { + "name": "write", + "value": "write", + "description": "Read and write" + } + ] + } + }, + "VolumeProperties": { + "type": "object", + "description": "Volume properties", + "properties": { + "kind": { + "type": "string", + "description": "Discriminator property for VolumeProperties." + }, + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + } + }, + "discriminator": "kind", + "required": [ + "kind", + "application" + ] + }, + "VolumeResource": { + "type": "object", + "description": "Radius Volume resource.", + "properties": { + "properties": { + "$ref": "#/definitions/VolumeProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "VolumeResourceListResult": { + "type": "object", + "description": "The response of a VolumeResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The VolumeResource items on this page", + "items": { + "$ref": "#/definitions/VolumeResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "VolumeResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the VolumeResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/VolumeResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "VolumeResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the VolumeResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + } + } + }, + "VolumeSecretEncodings": { + "type": "string", + "description": "Represents secret encodings", + "enum": [ + "utf-8", + "hex", + "base64" + ], + "x-ms-enum": { + "name": "VolumeSecretEncodings", + "modelAsString": true, + "values": [ + { + "name": "utf8", + "value": "utf-8", + "description": "UTF-8 encoding" + }, + { + "name": "hex", + "value": "hex", + "description": "Hex encoding" + }, + { + "name": "base64", + "value": "base64", + "description": "Base64 encoding" + } + ] + } + } + }, + "parameters": { + "RootScopeParameter": { + "name": "rootScope", + "in": "path", + "description": "The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} and Azure resource scope is /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", + "required": true, + "type": "string", + "minLength": 1, + "x-ms-parameter-location": "client", + "x-ms-skip-url-encoding": true + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/secretstores.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/secretstores.json deleted file mode 100644 index 35125aca3b..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/secretstores.json +++ /dev/null @@ -1,483 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST API for Applications.Core Persistent SecretStore Resource", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/secretStores": { - "get": { - "description": "List all secret stores in the given scope.", - "operationId": "SecretStores_List", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusSecretStoresList": { - "$ref": "./examples/SecretStoresList.json" - } - }, - "tags": [ - "SecretStores" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - ], - "responses": { - "200": { - "description": "SecretStores list.", - "schema": { - "$ref": "#/definitions/SecretStoreResourceList" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}": { - "get": { - "description": "Gets the properties of a secret store.", - "operationId": "SecretStores_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusSecretStoresGet": { - "$ref": "./examples/SecretStoresGet.json" - }, - "RadiusSecretStoresAzureKeyVaultGet": { - "$ref": "./examples/SecretStoresGet_AzureKeyVault.json" - } - }, - "tags": [ - "SecretStores" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SecretStoreNameParameter" - } - ], - "responses": { - "200": { - "description": "SecretStore details.", - "schema": { - "$ref": "#/definitions/SecretStoreResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Create or update a secret store.", - "operationId": "SecretStores_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusSecretStoresPutValueFrom": { - "$ref": "./examples/SecretStoresPutValueFrom.json" - }, - "RadiusSecretStoresPutValue": { - "$ref": "./examples/SecretStoresPutValue.json" - } - }, - "tags": [ - "SecretStores" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SecretStoreNameParameter" - }, - { - "name": "SecretStoreResource", - "description": "SecretStore details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/SecretStoreResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/SecretStoreResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/SecretStoreResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "patch": { - "description": "Update the properties of an existing secret store.", - "operationId": "SecretStores_Update", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusSecretStoresPatch": { - "$ref": "./examples/SecretStoresPatch.json" - } - }, - "tags": [ - "SecretStores" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SecretStoreNameParameter" - }, - { - "name": "SecretStoreResource", - "description": "SecretStore details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/SecretStoreResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/SecretStoreResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/SecretStoreResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Delete a secret store.", - "operationId": "SecretStores_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusSecretStoresDelete": { - "$ref": "./examples/SecretStoresDelete.json" - } - }, - "tags": [ - "SecretStores" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SecretStoreNameParameter" - } - ], - "responses": { - "200": { - "description": "The SecretStore was successfully deleted." - }, - "202": { - "description": "The SecretStore will be deleted asynchronously." - }, - "204": { - "description": "The SecretStore does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Core/secretStores/{secretStoreName}/listSecrets": { - "post": { - "description": "List the secrets of a secret stores.", - "operationId": "SecretStores_ListSecrets", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusSecretStoresPostListSecret": { - "$ref": "./examples/SecretStoresListSecrets.json" - } - }, - "tags": [ - "SecretStores" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SecretStoreNameParameter" - } - ], - "responses": { - "200": { - "description": "The list of secret values in this secret store", - "schema": { - "$ref": "#/definitions/SecretStoreListSecretsResult" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "SecretStoreResourceList": { - "description": "The list of SecretStores.", - "type": "object", - "properties": { - "value": { - "description": "The list of SecretStore.", - "type": "array", - "items": { - "$ref": "#/definitions/SecretStoreResource" - } - }, - "nextLink": { - "description": "The link used to get the next page of SecretStores list.", - "type": "string" - } - } - }, - "SecretStoreResource": { - "description": "Radius SecretStore Resource.", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "$ref": "#/definitions/SecretStoreProperties" - } - } - }, - "SecretStoreDataType": { - "description": "The type of secret store data", - "type": "string", - "enum": [ - "generic", - "certificate" - ], - "default": "generic", - "x-ms-enum": { - "name": "SecretStoreDataType", - "modelAsString": false - } - }, - "SecretStoreProperties": { - "allOf": [ - { - "$ref": "global.json#/definitions/BasicResourceProperties" - } - ], - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Provisioning state of the SecretStore at the time the operation was called." - }, - "type": { - "description": "The type of secret store data", - "$ref": "#/definitions/SecretStoreDataType" - }, - "data": { - "description": "An object to represent key-value type secrets", - "additionalProperties": { - "$ref": "#/definitions/SecretValueProperties" - }, - "type": "object" - }, - "resource": { - "description": "The resource id of external secret store.", - "type": "string" - } - }, - "required": [ - "data" - ], - "type": "object" - }, - "SecretStoreListSecretsResult": { - "description": "The list of secrets", - "properties": { - "type": { - "description": "The type of secret store data", - "$ref": "#/definitions/SecretStoreDataType" - }, - "data": { - "description": "An object to represent key-value type secrets", - "additionalProperties": { - "$ref": "#/definitions/SecretValueProperties" - }, - "type": "object" - } - }, - "type": "object" - }, - "SecretValueProperties": { - "properties": { - "encoding": { - "description": "The encoding of value", - "type": "string", - "enum": [ - "raw", - "base64" - ], - "default": "raw", - "x-ms-enum": { - "name": "SecretValueEncoding", - "modelAsString": false - } - }, - "value": { - "description": "The value of secret.", - "type": "string", - "x-ms-secret": true - }, - "valueFrom": { - "description": "The referenced secret in properties.resource", - "$ref": "#/definitions/ValueFromProperties" - } - }, - "type": "object" - }, - "ValueFromProperties": { - "properties": { - "name": { - "description": "The name of the referenced secret.", - "type": "string" - }, - "version": { - "description": "The version of the referenced secret.", - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - } - }, - "parameters": { - "SecretStoreNameParameter": { - "name": "secretStoreName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the secret store.", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/volumes.json b/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/volumes.json deleted file mode 100644 index c09559c169..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/volumes.json +++ /dev/null @@ -1,514 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Core Management APIs", - "description": "REST API for Applications.Core Persistent Volume Resource", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Core/volumes": { - "get": { - "description": "List all volumes in the given scope.", - "operationId": "Volumes_ListByScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusVolumesListByScope": { - "$ref": "./examples/VolumesListByScope.json" - } - }, - "tags": [ - "Volumes" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "global.json#/parameters/RootScopeParameter" - } - ], - "responses": { - "200": { - "description": "Volumes details.", - "schema": { - "$ref": "#/definitions/VolumeResourceList" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Core/volumes/{volumeName}": { - "get": { - "description": "Gets the properties of an Volume.", - "operationId": "Volumes_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusVolumesGet": { - "$ref": "./examples/VolumesGet.json" - } - }, - "tags": [ - "Volumes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/VolumeNameParameter" - } - ], - "responses": { - "200": { - "description": "Volume details.", - "schema": { - "$ref": "#/definitions/VolumeResource" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Create or update an Volume.", - "operationId": "Volumes_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusVolumesPut": { - "$ref": "./examples/VolumesPut.json" - } - }, - "tags": [ - "Volumes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/VolumeNameParameter" - }, - { - "name": "VolumeResource", - "description": "Volume details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/VolumeResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/VolumeResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/VolumeResource" - } - }, - "204": { - "description": "The Volume does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "patch": { - "description": "Update the properties of an existing Volume.", - "operationId": "Volumes_Update", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusVolumesPatch": { - "$ref": "./examples/VolumesPatch.json" - } - }, - "tags": [ - "Volumes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/VolumeNameParameter" - }, - { - "name": "VolumeResource", - "description": "Volume details", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/VolumeResource" - } - } - ], - "responses": { - "200": { - "description": "The resource was updated successfully.", - "schema": { - "$ref": "#/definitions/VolumeResource" - } - }, - "201": { - "description": "The resource will be updated asynchronously.", - "schema": { - "$ref": "#/definitions/VolumeResource" - } - }, - "204": { - "description": "The Volume does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Delete an Volume.", - "operationId": "Volumes_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "RadiusVolumesDelete": { - "$ref": "./examples/VolumesDelete.json" - } - }, - "tags": [ - "Volumes" - ], - "parameters": [ - { - "$ref": "global.json#/parameters/RootScopeParameter" - }, - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/VolumeNameParameter" - } - ], - "responses": { - "200": { - "description": "The Volume was successfully deleted." - }, - "202": { - "description": "The Volume will be deleted asynchronously." - }, - "204": { - "description": "The Volume does not exist." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "VolumeResourceList": { - "description": "The list of Volumes.", - "type": "object", - "properties": { - "value": { - "description": "The list of Volume.", - "type": "array", - "items": { - "$ref": "#/definitions/VolumeResource" - } - }, - "nextLink": { - "description": "The link used to get the next page of Volumes list.", - "type": "string" - } - } - }, - "VolumeResource": { - "description": "Radius Volume Resource.", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v2/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/VolumeProperties" - } - } - }, - "VolumeProperties": { - "allOf": [ - { - "$ref": "global.json#/definitions/BasicResourceProperties" - } - ], - "discriminator": "kind", - "properties": { - "kind": { - "description": "The volume kind", - "type": "string" - }, - "provisioningState": { - "readOnly": true, - "$ref": "global.json#/definitions/ProvisioningState", - "description": "Provisioning state of the Volume at the time the operation was called." - } - }, - "required": [ - "application", - "kind" - ], - "type": "object" - }, - "CertificateObjectProperties": { - "properties": { - "alias": { - "description": "File name when written to disk.", - "type": "string" - }, - "encoding": { - "description": "Encoding format. Default utf-8", - "type": "string", - "enum": [ - "utf-8", - "hex", - "base64" - ], - "default": "utf-8", - "x-ms-enum": { - "name": "encoding", - "modelAsString": false - } - }, - "format": { - "description": "Certificate format. Default pem", - "type": "string", - "enum": [ - "pem", - "pfx" - ], - "default": "pem", - "x-ms-enum": { - "name": "format", - "modelAsString": false - } - }, - "name": { - "description": "The name of the certificate", - "type": "string" - }, - "certType": { - "description": "Certificate object type to be downloaded - the certificate itself, private key or public key of the certificate", - "type": "string", - "enum": [ - "certificate", - "publickey", - "privatekey" - ], - "x-ms-enum": { - "name": "certType", - "modelAsString": false - } - }, - "version": { - "description": "Certificate version", - "type": "string" - } - }, - "required": [ - "name", - "value" - ], - "type": "object" - }, - "KeyObjectProperties": { - "properties": { - "alias": { - "description": "File name when written to disk.", - "type": "string" - }, - "name": { - "description": "The name of the key", - "type": "string" - }, - "version": { - "description": "Key version", - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "SecretObjectProperties": { - "properties": { - "alias": { - "description": "File name when written to disk.", - "type": "string" - }, - "encoding": { - "description": "Encoding format. Default utf-8", - "type": "string", - "enum": [ - "utf-8", - "hex", - "base64" - ], - "default": "utf-8", - "x-ms-enum": { - "name": "encoding", - "modelAsString": false - } - }, - "name": { - "description": "The name of the secret", - "type": "string" - }, - "version": { - "description": "Secret version", - "type": "string" - } - }, - "required": [ - "name" - ], - "type": "object" - }, - "AzureKeyVaultVolumeProperties": { - "additionalProperties": false, - "allOf": [ - { - "$ref": "#/definitions/VolumeProperties" - } - ], - "properties": { - "certificates": { - "additionalProperties": { - "$ref": "#/definitions/CertificateObjectProperties" - }, - "description": "The KeyVault certificates that this volume exposes", - "type": "object" - }, - "keys": { - "additionalProperties": { - "$ref": "#/definitions/KeyObjectProperties" - }, - "description": "The KeyVault keys that this volume exposes", - "type": "object" - }, - "resource": { - "description": "The ID of the keyvault to use for this volume resource", - "type": "string" - }, - "secrets": { - "additionalProperties": { - "$ref": "#/definitions/SecretObjectProperties" - }, - "description": "The KeyVault secrets that this volume exposes", - "type": "object" - } - }, - "required": [ - "kind", - "resource" - ], - "type": "object", - "x-ms-discriminator-value": "azure.com.keyvault" - } - }, - "parameters": { - "VolumeNameParameter": { - "name": "volumeName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the Volume.", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersDelete.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersDelete.json deleted file mode 100644 index 24c9b77867..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprPubSubBrokerName": "daprpubsub0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersGet.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersGet.json deleted file mode 100644 index c0c5ff6e51..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersGet.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "daprPubSubBrokerName": "daprpubsub0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", - "name": "daprpubsub0", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersList.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersList.json deleted file mode 100644 index 5fb3b1ac37..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersList.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub0", - "name": "daprPubSub0", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub1", - "name": "daprPubSub1", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "pubsub.kafka", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub2", - "name": "daprPubSub2", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersListByRootScope.json deleted file mode 100644 index 1b8d123b2e..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersListByRootScope.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub0", - "name": "daprPubSub0", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Dapr/pubSubBrokers/daprPubSub1", - "name": "daprPubSub1", - "type": "Applications.Dapr/pubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "pubsub.kafka", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Dapr/pubSubBrokers?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersPut.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersPut.json deleted file mode 100644 index 9905ed6511..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersPut.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprPubSubBrokerName": "daprpubsub0", - "api-version": "2022-03-15-privatepreview", - "DaprPubSubBrokerParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", - "name": "daprpubsub0", - "type": "Applications.Dapr/pubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", - "name": "daprpubsub0", - "type": "Applications.Dapr/pubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersPutWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersPutWithRecipe.json deleted file mode 100644 index a42ce2035a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokersPutWithRecipe.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprPubSubBrokerName": "daprpubsub0", - "api-version": "2022-03-15-privatepreview", - "DaprPubSubBrokerParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", - "name": "daprpubsub0", - "type": "Applications.Dapr/pubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "recipe", - "type": "pubsub.azure.servicebus", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", - "name": "daprpubsub0", - "type": "Applications.Dapr/pubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "recipe", - "type": "pubsub.azure.servicebus", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_CreateOrUpdate.json new file mode 100644 index 0000000000..bcc72c4ab8 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_CreateOrUpdate.json @@ -0,0 +1,77 @@ +{ + "operationId": "PubSubBrokers_CreateOrUpdate", + "title": "Create or update a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview", + "PubSubBrokerParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_CreateOrUpdateWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_CreateOrUpdateWithRecipe.json new file mode 100644 index 0000000000..83391aca67 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_CreateOrUpdateWithRecipe.json @@ -0,0 +1,66 @@ +{ + "operationId": "PubSubBrokers_CreateOrUpdate", + "title": "Create or update a PubSubBroker resource with recipe", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview", + "PubSubBrokerParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "recipe", + "type": "pubsub.azure.servicebus", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "recipe", + "type": "pubsub.azure.servicebus", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Delete.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Delete.json new file mode 100644 index 0000000000..be9fe77463 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "PubSubBrokers_Delete", + "title": "Delete a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Get.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Get.json new file mode 100644 index 0000000000..eaaad281b0 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Get.json @@ -0,0 +1,35 @@ +{ + "operationId": "PubSubBrokers_Get", + "title": "Get a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "pubSubBrokerName": "daprpubsub0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_List.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_List.json new file mode 100644 index 0000000000..28213b5b37 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_List.json @@ -0,0 +1,73 @@ +{ + "operationId": "PubSubBrokers_ListByScope", + "title": "List a PubSubBroker resource by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub0", + "name": "daprPubSub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub1", + "name": "daprPubSub1", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "pubsub.kafka", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub2", + "name": "daprPubSub2", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_ListByRootScope.json new file mode 100644 index 0000000000..a10cf160c7 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_ListByRootScope.json @@ -0,0 +1,56 @@ +{ + "operationId": "PubSubBrokers_ListByScope", + "title": "List a PubSubBroker resource by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub0", + "name": "daprPubSub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Dapr/pubSubBrokers/daprPubSub1", + "name": "daprPubSub1", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "pubsub.kafka", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Dapr/pubSubBrokers?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Update.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Update.json new file mode 100644 index 0000000000..f22de30773 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/PubSubBrokers_Update.json @@ -0,0 +1,77 @@ +{ + "operationId": "PubSubBrokers_Update", + "title": "Update a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview", + "PubSubBrokerParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresDelete.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresDelete.json deleted file mode 100644 index ec511b165e..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprSecretStoreName": "daprsecretstore0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresGet.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresGet.json deleted file mode 100644 index 693095b80a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresGet.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "daprSecretStoreName": "daprsecretstore0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprsecretstore0", - "name": "daprsecretstore0", - "type": "Applications.Dapr/secretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresList.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresList.json deleted file mode 100644 index 4c0375079c..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresList.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Dapr/secretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Dapr/secretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters": { - "foo": "bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresListByRootScope.json deleted file mode 100644 index 82d7a26c56..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresListByRootScope.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Dapr/secretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Dapr/secretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters": { - "foo": "bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Dapr/secretStores?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresPut.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresPut.json deleted file mode 100644 index e0690b1884..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStoresPut.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprSecretStoreName": "daprsecretstore0", - "api-version": "2022-03-15-privatepreview", - "DaprSecretStoreParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Dapr/secretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "kind": "generic", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore1", - "name": "daprSecretStore1", - "type": "Applications.Dapr/secretStores", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdate.json new file mode 100644 index 0000000000..7cdd6b3396 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_CreateOrUpdate.json @@ -0,0 +1,63 @@ +{ + "operationId": "SecretStores_CreateOrUpdate", + "title": "Create or update an SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "daprsecretstore0", + "api-version": "2022-03-15-privatepreview", + "SecretStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "kind": "generic", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore1", + "name": "daprSecretStore1", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Delete.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Delete.json new file mode 100644 index 0000000000..d00bd593fe --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "SecretStores_Delete", + "title": "Delete a SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "daprsecretstore0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Get.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Get.json new file mode 100644 index 0000000000..38340c89f7 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Get.json @@ -0,0 +1,30 @@ +{ + "operationId": "SecretStores_Get", + "title": "Get a SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "daprsecretstore0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprsecretstore0", + "name": "daprsecretstore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_List.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_List.json new file mode 100644 index 0000000000..4c2a74ee3e --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_List.json @@ -0,0 +1,51 @@ +{ + "operationId": "SecretStores_ListByScope", + "title": "List SecretStore resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_ListByRootScope.json new file mode 100644 index 0000000000..b66685650b --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_ListByRootScope.json @@ -0,0 +1,51 @@ +{ + "operationId": "SecretStores_ListByScope", + "title": "List SecretStore resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Dapr/secretStores?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Update.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Update.json new file mode 100644 index 0000000000..974e788940 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/SecretStores_Update.json @@ -0,0 +1,63 @@ +{ + "operationId": "SecretStores_Update", + "title": "Update an SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "daprsecretstore0", + "api-version": "2022-03-15-privatepreview", + "SecretStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "kind": "generic", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore1", + "name": "daprSecretStore1", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresDelete.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresDelete.json deleted file mode 100644 index 75d4d9010d..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprStateStoreName": "daprstatestore0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresGet.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresGet.json deleted file mode 100644 index be78c9533a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresGet.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview", - "daprStateStoreName": "daprstatestore0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", - "name": "daprstatestore0", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresList.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresList.json deleted file mode 100644 index 83778da283..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresList.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" - } - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore1", - "name": "daprStateStore1", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" - } - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore2", - "name": "daprStateStore2", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore3", - "name": "daprStateStore3", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "recipe-test" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresListByRootScope.json deleted file mode 100644 index 63926bc563..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresListByRootScope.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Dapr/stateStores/daprStateStore1", - "name": "daprStateStore1", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore2", - "name": "daprStateStore2", - "type": "Applications.Dapr/stateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Dapr/stateStores?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresPut.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresPut.json deleted file mode 100644 index 65247b4965..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresPut.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprStateStoreName": "daprstatestore0", - "api-version": "2022-03-15-privatepreview", - "DaprStateStoreParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ] - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Dapr/stateStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "kind": "state.sqlserver", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" - } - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprStateStore1", - "name": "daprStateStore1", - "type": "Applications.Dapr/stateStores", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" - } - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresPutWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresPutWithRecipe.json deleted file mode 100644 index b6f54e3d3a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStoresPutWithRecipe.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprStateStoreName": "daprstatestore0", - "api-version": "2022-03-15-privatepreview", - "DaprStateStoreParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "recipe-test" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", - "name": "daprstatestore0", - "type": "Applications.Dapr/stateStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "kind": "state.sqlserver", - "recipe": { - "name": "recipe-test" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", - "name": "daprstatestore0", - "type": "Applications.Dapr/stateStores", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "recipe": { - "name": "recipe-test" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_CreateOrUpdate.json new file mode 100644 index 0000000000..48912c2186 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_CreateOrUpdate.json @@ -0,0 +1,73 @@ +{ + "operationId": "StateStores_CreateOrUpdate", + "title": "Create or update a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview", + "StateStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "kind": "state.sqlserver", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_CreateOrUpdateWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_CreateOrUpdateWithRecipe.json new file mode 100644 index 0000000000..df781c63f4 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_CreateOrUpdateWithRecipe.json @@ -0,0 +1,55 @@ +{ + "operationId": "StateStores_CreateOrUpdate", + "title": "Create or update a StateStore resource with recipe", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview", + "StateStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "recipe-test" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", + "name": "daprstatestore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "kind": "state.sqlserver", + "recipe": { + "name": "recipe-test" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", + "name": "daprstatestore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "recipe": { + "name": "recipe-test" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Delete.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Delete.json new file mode 100644 index 0000000000..f65fe45f3a --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "StateStores_Delete", + "title": "Delete a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Get.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Get.json new file mode 100644 index 0000000000..f3c635f3ae --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Get.json @@ -0,0 +1,26 @@ +{ + "operationId": "StateStores_Get", + "title": "Get a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "stateStoreName": "daprstatestore0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", + "name": "daprstatestore0", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_List.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_List.json new file mode 100644 index 0000000000..c6a84c66f8 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_List.json @@ -0,0 +1,92 @@ +{ + "operationId": "StateStores_ListByScope", + "title": "List StateStore resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore2", + "name": "stateStore2", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore3", + "name": "stateStore3", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "recipe-test" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_ListByRootScope.json new file mode 100644 index 0000000000..faa2d33d60 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_ListByRootScope.json @@ -0,0 +1,78 @@ +{ + "operationId": "StateStores_ListByScope", + "title": "List StateStore resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore2", + "name": "stateStore2", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Dapr/stateStores?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Update.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Update.json new file mode 100644 index 0000000000..a93dca0ae8 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/examples/StateStores_Update.json @@ -0,0 +1,73 @@ +{ + "operationId": "StateStores_Update", + "title": "Update a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview", + "StateStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "kind": "state.sqlserver", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/openapi.json b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/openapi.json index cde4084aaa..d80cf1e782 100644 --- a/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/openapi.json +++ b/swagger/specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/openapi.json @@ -1,12 +1,12 @@ { "swagger": "2.0", "info": { - "title": "Applications.Dapr Management APIs", + "title": "Applications.Dapr Resource Management APIs", "version": "2022-03-15-privatepreview", - "description": "REST APIs for Applications.Dapr", - "x-cadl-generated": [ + "description": "REST API for Applications.Dapr", + "x-typespec-generated": [ { - "emitter": "@azure-tools/cadl-autorest" + "emitter": "@azure-tools/typespec-autorest" } ] }, @@ -43,29 +43,29 @@ "name": "Operations" }, { - "name": "DaprPubSubBroker" + "name": "SecretStores" }, { - "name": "DaprSecretStore" + "name": "StateStores" }, { - "name": "DaprStateStore" + "name": "PubSubBrokers" } ], "paths": { "/{rootScope}/providers/Applications.Dapr/pubSubBrokers": { "get": { + "operationId": "PubSubBrokers_ListByScope", "tags": [ - "DaprPubSubBroker" + "PubSubBrokers" ], - "operationId": "DaprPubSubBroker_ListByRootScope", - "description": "Lists information about all DaprPubSubBrokerResources in the given root scope", + "description": "List DaprPubSubBrokerResource resources by Scope", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" } ], "responses": { @@ -82,34 +82,41 @@ } } }, + "x-ms-examples": { + "List a PubSubBroker resource by resource group": { + "$ref": "./examples/PubSubBrokers_List.json" + }, + "List a PubSubBroker resource by rootScope": { + "$ref": "./examples/PubSubBrokers_ListByRootScope.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } } }, - "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{daprPubSubBrokerName}": { + "/{rootScope}/providers/Applications.Dapr/pubSubBrokers/{pubSubBrokerName}": { "get": { + "operationId": "PubSubBrokers_Get", "tags": [ - "DaprPubSubBroker" + "PubSubBrokers" ], - "operationId": "DaprPubSubBroker_Get", - "description": "Retrieves information about a DaprPubSubBrokerResource", + "description": "Get a DaprPubSubBrokerResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprPubSubBrokerName", + "name": "pubSubBrokerName", "in": "path", + "description": "PubSubBroker name", "required": true, - "description": "Dapr PubSubBroker name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -125,36 +132,40 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a PubSubBroker resource": { + "$ref": "./examples/PubSubBrokers_Get.json" + } } }, "put": { + "operationId": "PubSubBrokers_CreateOrUpdate", "tags": [ - "DaprPubSubBroker" + "PubSubBrokers" ], - "operationId": "DaprPubSubBroker_CreateOrUpdate", - "description": "Creates or updates a DaprPubSubBrokerResource", + "description": "Create a DaprPubSubBrokerResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprPubSubBrokerName", + "name": "pubSubBrokerName", "in": "path", + "description": "PubSubBroker name", "required": true, - "description": "Dapr PubSubBroker name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/DaprPubSubBrokerResource" } @@ -162,54 +173,135 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'DaprPubSubBrokerResource' update operation succeeded", "schema": { "$ref": "#/definitions/DaprPubSubBrokerResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'DaprPubSubBrokerResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/DaprPubSubBrokerResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a PubSubBroker resource": { + "$ref": "./examples/PubSubBrokers_CreateOrUpdate.json" + }, + "Create or update a PubSubBroker resource with recipe": { + "$ref": "./examples/PubSubBrokers_CreateOrUpdateWithRecipe.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "PubSubBrokers_Update", + "tags": [ + "PubSubBrokers" + ], + "description": "Update a DaprPubSubBrokerResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "pubSubBrokerName", + "in": "path", + "description": "PubSubBroker name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/DaprPubSubBrokerResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", "schema": { "$ref": "#/definitions/DaprPubSubBrokerResource" } }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Update a PubSubBroker resource": { + "$ref": "./examples/PubSubBrokers_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true }, "delete": { + "operationId": "PubSubBrokers_Delete", "tags": [ - "DaprPubSubBroker" + "PubSubBrokers" ], - "operationId": "DaprPubSubBroker_Delete", - "description": "Deletes an existing DaprPubSubBrokerResource", + "description": "Delete a DaprPubSubBrokerResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprPubSubBrokerName", + "name": "pubSubBrokerName", "in": "path", + "description": "PubSubBroker name", "required": true, - "description": "Dapr PubSubBroker name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -220,9 +312,13 @@ "description": "Resource deletion accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -236,25 +332,30 @@ } } }, + "x-ms-examples": { + "Delete a PubSubBroker resource": { + "$ref": "./examples/PubSubBrokers_Delete.json" + } + }, "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" + "final-state-via": "location" }, "x-ms-long-running-operation": true } }, "/{rootScope}/providers/Applications.Dapr/secretStores": { "get": { + "operationId": "SecretStores_ListByScope", "tags": [ - "DaprSecretStore" + "SecretStores" ], - "operationId": "DaprSecretStore_ListByRootScope", - "description": "Lists information about all DaprSecretStoreResources in the given root scope", + "description": "List DaprSecretStoreResource resources by Scope", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" } ], "responses": { @@ -271,34 +372,41 @@ } } }, + "x-ms-examples": { + "List SecretStore resources by resource group": { + "$ref": "./examples/SecretStores_List.json" + }, + "List SecretStore resources by rootScope": { + "$ref": "./examples/SecretStores_ListByRootScope.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } } }, - "/{rootScope}/providers/Applications.Dapr/secretStores/{daprSecretStoreName}": { + "/{rootScope}/providers/Applications.Dapr/secretStores/{secretStoreName}": { "get": { + "operationId": "SecretStores_Get", "tags": [ - "DaprSecretStore" + "SecretStores" ], - "operationId": "DaprSecretStore_Get", - "description": "Retrieves information about a DaprSecretStoreResource", + "description": "Get a DaprSecretStoreResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprSecretStoreName", + "name": "secretStoreName", "in": "path", + "description": "SecretStore name", "required": true, - "description": "Dapr SecretStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -314,36 +422,40 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a SecretStore resource": { + "$ref": "./examples/SecretStores_Get.json" + } } }, "put": { + "operationId": "SecretStores_CreateOrUpdate", "tags": [ - "DaprSecretStore" + "SecretStores" ], - "operationId": "DaprSecretStore_CreateOrUpdate", - "description": "Creates or updates a DaprSecretStoreResource", + "description": "Create a DaprSecretStoreResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprSecretStoreName", + "name": "secretStoreName", "in": "path", + "description": "SecretStore name", "required": true, - "description": "Dapr SecretStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/DaprSecretStoreResource" } @@ -351,54 +463,132 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'DaprSecretStoreResource' update operation succeeded", "schema": { "$ref": "#/definitions/DaprSecretStoreResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'DaprSecretStoreResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/DaprSecretStoreResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update an SecretStore resource": { + "$ref": "./examples/SecretStores_CreateOrUpdate.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "SecretStores_Update", + "tags": [ + "SecretStores" + ], + "description": "Update a DaprSecretStoreResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "secretStoreName", + "in": "path", + "description": "SecretStore name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/DaprSecretStoreResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", "schema": { "$ref": "#/definitions/DaprSecretStoreResource" } }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Update an SecretStore resource": { + "$ref": "./examples/SecretStores_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true }, "delete": { + "operationId": "SecretStores_Delete", "tags": [ - "DaprSecretStore" + "SecretStores" ], - "operationId": "DaprSecretStore_Delete", - "description": "Deletes an existing DaprSecretStoreResource", + "description": "Delete a DaprSecretStoreResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprSecretStoreName", + "name": "secretStoreName", "in": "path", + "description": "SecretStore name", "required": true, - "description": "Dapr SecretStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -409,9 +599,13 @@ "description": "Resource deletion accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -424,22 +618,31 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Delete a SecretStore resource": { + "$ref": "./examples/SecretStores_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true } }, "/{rootScope}/providers/Applications.Dapr/stateStores": { "get": { + "operationId": "StateStores_ListByScope", "tags": [ - "DaprStateStore" + "StateStores" ], - "operationId": "DaprStateStore_ListByRootScope", - "description": "Lists information about all DaprStateStoreResources in the given root scope", + "description": "List DaprStateStoreResource resources by Scope", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" } ], "responses": { @@ -456,34 +659,41 @@ } } }, + "x-ms-examples": { + "List StateStore resources by resource group": { + "$ref": "./examples/StateStores_List.json" + }, + "List StateStore resources by rootScope": { + "$ref": "./examples/StateStores_ListByRootScope.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } } }, - "/{rootScope}/providers/Applications.Dapr/stateStores/{daprStateStoreName}": { + "/{rootScope}/providers/Applications.Dapr/stateStores/{stateStoreName}": { "get": { + "operationId": "StateStores_Get", "tags": [ - "DaprStateStore" + "StateStores" ], - "operationId": "DaprStateStore_Get", - "description": "Retrieves information about a DaprStateStoreResource", + "description": "Get a DaprStateStoreResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprStateStoreName", + "name": "stateStoreName", "in": "path", + "description": "StateStore name", "required": true, - "description": "Dapr StateStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -499,36 +709,40 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a StateStore resource": { + "$ref": "./examples/StateStores_Get.json" + } } }, "put": { + "operationId": "StateStores_CreateOrUpdate", "tags": [ - "DaprStateStore" + "StateStores" ], - "operationId": "DaprStateStore_CreateOrUpdate", - "description": "Creates or updates a DaprStateStoreResource", + "description": "Create a DaprStateStoreResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprStateStoreName", + "name": "stateStoreName", "in": "path", + "description": "StateStore name", "required": true, - "description": "Dapr StateStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/DaprStateStoreResource" } @@ -536,54 +750,135 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'DaprStateStoreResource' update operation succeeded", "schema": { "$ref": "#/definitions/DaprStateStoreResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'DaprStateStoreResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/DaprStateStoreResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a StateStore resource": { + "$ref": "./examples/StateStores_CreateOrUpdate.json" + }, + "Create or update a StateStore resource with recipe": { + "$ref": "./examples/StateStores_CreateOrUpdateWithRecipe.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "StateStores_Update", + "tags": [ + "StateStores" + ], + "description": "Update a DaprStateStoreResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "stateStoreName", + "in": "path", + "description": "StateStore name", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/DaprStateStoreResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", "schema": { "$ref": "#/definitions/DaprStateStoreResource" } }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Update a StateStore resource": { + "$ref": "./examples/StateStores_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true }, "delete": { + "operationId": "StateStores_Delete", "tags": [ - "DaprStateStore" + "StateStores" ], - "operationId": "DaprStateStore_Delete", - "description": "Deletes an existing DaprStateStoreResource", + "description": "Delete a DaprStateStoreResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { - "name": "daprStateStoreName", + "name": "stateStoreName", "in": "path", + "description": "StateStore name", "required": true, - "description": "Dapr StateStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -594,9 +889,13 @@ "description": "Resource deletion accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -610,18 +909,23 @@ } } }, + "x-ms-examples": { + "Delete a StateStore resource": { + "$ref": "./examples/StateStores_Delete.json" + } + }, "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" + "final-state-via": "location" }, "x-ms-long-running-operation": true } }, "/providers/Applications.Dapr/operations": { "get": { + "operationId": "Operations_List", "tags": [ "Operations" ], - "operationId": "Operations_List", "description": "List the operations for the provider", "parameters": [ { @@ -649,94 +953,69 @@ } }, "definitions": { - "Application": { - "type": "string", - "description": "Fully qualified resource ID for the application that the portable resource is consumed by" - }, - "BasicDaprResourceProperties": { - "type": "object", - "properties": { - "componentName": { - "type": "string", - "description": "The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.", - "readOnly": true - } - }, - "description": "Basic properties of a Dapr component object.", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "BasicResourceProperties": { + "DaprPubSubBrokerProperties": { "type": "object", + "description": "Dapr PubSubBroker portable resource properties", "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource.", - "readOnly": true - }, "environment": { "type": "string", "description": "Fully qualified resource ID for the environment that the portable resource is linked to" }, "application": { - "$ref": "#/definitions/Application", - "description": "Fully qualified resource ID for the application that the portable resource is consumed by" - } - }, - "description": "Basic properties of a Radius resource.", - "required": [ - "environment" - ] - }, - "DaprPubSubBrokerProperties": { - "type": "object", - "properties": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, "provisioningState": { "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the Dapr PubSubBroker portable resource at the time the operation was called", + "description": "The status of the asynchronous operation.", "readOnly": true }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "componentName": { + "type": "string", + "description": "The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.", + "readOnly": true }, "metadata": { - "$ref": "#/definitions/object", - "description": "Metadata for the Dapr PubSubBroker resource. This should match the values specified in Dapr component spec" + "type": "object", + "description": "The metadata for Dapr resource which must match the values specified in Dapr component spec", + "properties": {} }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Dapr PubSubBroker portable resource" + "type": { + "type": "string", + "description": "Dapr component type which must matches the format used by Dapr Kubernetes configuration format" + }, + "version": { + "type": "string", + "description": "Dapr component version" }, "resources": { "type": "array", + "description": "A collection of references to resources associated with the pubSubBroker", "items": { "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "A collection of references to resources associated with the Dapr PubSubBroker" + } }, - "type": { - "type": "string", - "description": "Dapr PubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format." + "recipe": { + "$ref": "#/definitions/Recipe", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" }, - "version": { - "type": "string", - "description": "Dapr component version" + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." } }, - "description": "Dapr PubSubBroker portable resource properties", - "allOf": [ - { - "$ref": "#/definitions/BasicDaprResourceProperties" - } + "required": [ + "environment" ] }, "DaprPubSubBrokerResource": { "type": "object", + "description": "Dapr PubSubBroker portable resource", "properties": { "properties": { "$ref": "#/definitions/DaprPubSubBrokerProperties", @@ -748,7 +1027,6 @@ ] } }, - "description": "Dapr PubSubBroker portable resource", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -757,65 +1035,140 @@ }, "DaprPubSubBrokerResourceListResult": { "type": "object", + "description": "The response of a DaprPubSubBrokerResource list operation.", "properties": { "value": { "type": "array", + "description": "The DaprPubSubBrokerResource items on this page", "items": { "$ref": "#/definitions/DaprPubSubBrokerResource" - }, - "x-cadl-name": "DaprPubSubBrokerResource[]", - "description": "The DaprPubSubBrokerResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a DaprPubSubBrokerResource list operation.", "required": [ "value" ] }, + "DaprPubSubBrokerResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the DaprPubSubBrokerResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/DaprPubSubBrokerResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "DaprPubSubBrokerResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the DaprPubSubBrokerResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "metadata": { + "type": "object", + "description": "The metadata for Dapr resource which must match the values specified in Dapr component spec", + "properties": {} + }, + "type": { + "type": "string", + "description": "Dapr component type which must matches the format used by Dapr Kubernetes configuration format" + }, + "version": { + "type": "string", + "description": "Dapr component version" + }, + "resources": { + "type": "array", + "description": "A collection of references to resources associated with the pubSubBroker", + "items": { + "$ref": "#/definitions/ResourceReference" + } + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, "DaprSecretStoreProperties": { "type": "object", + "description": "Dapr SecretStore portable resource properties", "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, "provisioningState": { "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the dapr secret store portable resource at the time the operation was called", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "componentName": { + "type": "string", + "description": "The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.", "readOnly": true }, + "metadata": { + "type": "object", + "description": "The metadata for Dapr resource which must match the values specified in Dapr component spec", + "properties": {} + }, "type": { "type": "string", - "description": "Dapr SecretStore type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/" + "description": "Dapr component type which must matches the format used by Dapr Kubernetes configuration format" }, "version": { "type": "string", "description": "Dapr component version" }, - "metadata": { - "$ref": "#/definitions/object", - "description": "Metadata for the Dapr SecretStore resource. This should match the values specified in Dapr component spec" - }, "recipe": { "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Dapr SecretStore portable resource" + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" }, "resourceProvisioning": { "$ref": "#/definitions/ResourceProvisioning", "description": "Specifies how the underlying service/resource is provisioned and managed." } }, - "description": "Dapr SecretStore portable resource properties", - "allOf": [ - { - "$ref": "#/definitions/BasicDaprResourceProperties" - } + "required": [ + "environment" ] }, "DaprSecretStoreResource": { "type": "object", + "description": "Dapr SecretStore portable resource", "properties": { "properties": { "$ref": "#/definitions/DaprSecretStoreProperties", @@ -827,7 +1180,6 @@ ] } }, - "description": "Dapr SecretStore portable resource", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -836,73 +1188,140 @@ }, "DaprSecretStoreResourceListResult": { "type": "object", + "description": "The response of a DaprSecretStoreResource list operation.", "properties": { "value": { "type": "array", + "description": "The DaprSecretStoreResource items on this page", "items": { "$ref": "#/definitions/DaprSecretStoreResource" - }, - "x-cadl-name": "DaprSecretStoreResource[]", - "description": "The DaprSecretStoreResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a DaprSecretStoreResource list operation.", "required": [ "value" ] }, + "DaprSecretStoreResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the DaprSecretStoreResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/DaprSecretStoreResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "DaprSecretStoreResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the DaprSecretStoreResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "metadata": { + "type": "object", + "description": "The metadata for Dapr resource which must match the values specified in Dapr component spec", + "properties": {} + }, + "type": { + "type": "string", + "description": "Dapr component type which must matches the format used by Dapr Kubernetes configuration format" + }, + "version": { + "type": "string", + "description": "Dapr component version" + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, "DaprStateStoreProperties": { "type": "object", + "description": "Dapr StateStore portable resource properties", "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, "provisioningState": { "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the DaprStateStore portable resource at the time the operation was called", + "description": "The status of the asynchronous operation.", "readOnly": true }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", + "readOnly": true + }, + "componentName": { + "type": "string", + "description": "The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.", + "readOnly": true }, "metadata": { - "$ref": "#/definitions/object", - "description": "Metadata for the Dapr StateStore resource. This should match the values specified in Dapr component spec" + "type": "object", + "description": "The metadata for Dapr resource which must match the values specified in Dapr component spec", + "properties": {} }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Dapr StateStore portable resource" + "type": { + "type": "string", + "description": "Dapr component type which must matches the format used by Dapr Kubernetes configuration format" + }, + "version": { + "type": "string", + "description": "Dapr component version" }, "resources": { "type": "array", + "description": "A collection of references to resources associated with the state store", "items": { "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "A collection of references to resources associated with the Dapr StateStore" + } }, - "type": { - "type": "string", - "description": "Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format." + "recipe": { + "$ref": "#/definitions/Recipe", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" }, - "version": { - "type": "string", - "description": "Dapr component version" + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." } }, - "description": "Dapr StateStore portable resource properties", - "allOf": [ - { - "$ref": "#/definitions/BasicDaprResourceProperties" - } + "required": [ + "environment" ] }, "DaprStateStoreResource": { "type": "object", + "description": "Dapr StateStore portable resource", "properties": { "properties": { "$ref": "#/definitions/DaprStateStoreProperties", @@ -914,7 +1333,6 @@ ] } }, - "description": "Dapr StateStore portable resource", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -923,36 +1341,187 @@ }, "DaprStateStoreResourceListResult": { "type": "object", + "description": "The response of a DaprStateStoreResource list operation.", "properties": { "value": { "type": "array", + "description": "The DaprStateStoreResource items on this page", "items": { "$ref": "#/definitions/DaprStateStoreResource" - }, - "x-cadl-name": "DaprStateStoreResource[]", - "description": "The DaprStateStoreResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a DaprStateStoreResource list operation.", "required": [ "value" ] }, - "OutputResource": { + "DaprStateStoreResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the DaprStateStoreResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/DaprStateStoreResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "DaprStateStoreResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the DaprStateStoreResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "metadata": { + "type": "object", + "description": "The metadata for Dapr resource which must match the values specified in Dapr component spec", + "properties": {} + }, + "type": { + "type": "string", + "description": "Dapr component type which must matches the format used by Dapr Kubernetes configuration format" + }, + "version": { + "type": "string", + "description": "Dapr component version" + }, + "resources": { + "type": "array", + "description": "A collection of references to resources associated with the state store", + "items": { + "$ref": "#/definitions/ResourceReference" + } + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, + "EnvironmentCompute": { + "type": "object", + "description": "Represents backing compute resource", + "properties": { + "kind": { + "type": "string", + "description": "Discriminator property for EnvironmentCompute." + }, + "resourceId": { + "type": "string", + "description": "The resource id of the compute resource for application environment." + }, + "identity": { + "$ref": "#/definitions/IdentitySettings", + "description": "Configuration for supported external identity providers" + } + }, + "discriminator": "kind", + "required": [ + "kind" + ] + }, + "IdentitySettingKind": { + "type": "string", + "description": "IdentitySettingKind is the kind of supported external identity setting", + "enum": [ + "undefined", + "azure.com.workload" + ], + "x-ms-enum": { + "name": "IdentitySettingKind", + "modelAsString": true, + "values": [ + { + "name": "undefined", + "value": "undefined", + "description": "undefined identity" + }, + { + "name": "azure.com.workload", + "value": "azure.com.workload", + "description": "azure ad workload identity" + } + ] + } + }, + "IdentitySettings": { "type": "object", - "properties": {}, - "description": "Properties of an output resource." + "description": "IdentitySettings is the external identity setting.", + "properties": { + "kind": { + "$ref": "#/definitions/IdentitySettingKind", + "description": "kind of identity setting" + }, + "oidcIssuer": { + "type": "string", + "description": "The URI for your compute platform's OIDC issuer" + }, + "resource": { + "type": "string", + "description": "The resource ID of the provisioned identity" + } + }, + "required": [ + "kind" + ] }, - "Parameters": { + "KubernetesCompute": { "type": "object", - "properties": {}, - "description": "Key/value parameters to pass into the recipe at deployment" + "description": "The Kubernetes compute configuration", + "properties": { + "namespace": { + "type": "string", + "description": "The namespace to use for the environment." + } + }, + "required": [ + "namespace" + ], + "allOf": [ + { + "$ref": "#/definitions/EnvironmentCompute" + } + ], + "x-ms-discriminator-value": "kubernetes" + }, + "OutputResource": { + "type": "object", + "description": "Properties of an output resource.", + "properties": { + "localId": { + "type": "string", + "description": "The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships." + }, + "id": { + "type": "string", + "description": "The UCP resource ID of the underlying resource." + }, + "radiusManaged": { + "type": "boolean", + "description": "Determines whether Radius manages the lifecycle of the underlying resource." + } + } }, "ProvisioningState": { "type": "string", @@ -968,26 +1537,80 @@ ], "x-ms-enum": { "name": "ProvisioningState", - "modelAsString": true - } + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + }, + { + "name": "Provisioning", + "value": "Provisioning", + "description": "The resource is being provisioned" + }, + { + "name": "Updating", + "value": "Updating", + "description": "The resource is updating" + }, + { + "name": "Deleting", + "value": "Deleting", + "description": "The resource is being deleted" + }, + { + "name": "Accepted", + "value": "Accepted", + "description": "The resource create request has been accepted" + } + ] + }, + "readOnly": true }, "Recipe": { "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", "properties": { "name": { "type": "string", "description": "The name of the recipe within the environment to use" }, "parameters": { - "$ref": "#/definitions/Parameters", - "description": "Key/value parameters to pass into the recipe at deployment" + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} } }, - "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", "required": [ "name" ] }, + "RecipeUpdate": { + "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", + "properties": { + "name": { + "type": "string", + "description": "The name of the recipe within the environment to use" + }, + "parameters": { + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} + } + } + }, "ResourceProvisioning": { "type": "string", "description": "Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.", @@ -997,52 +1620,81 @@ ], "x-ms-enum": { "name": "ResourceProvisioning", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "recipe", + "value": "recipe", + "description": "The resource lifecycle will be managed by Radius" + }, + { + "name": "manual", + "value": "manual", + "description": "The resource lifecycle will be managed by the user" + } + ] } }, "ResourceReference": { "type": "object", + "description": "Describes a reference to an existing resource", "properties": { "id": { "type": "string", "description": "Resource id of an existing resource" } }, - "description": "Describes a reference to an existing resource", "required": [ "id" ] }, "ResourceStatus": { "type": "object", + "description": "Status of a resource.", "properties": { + "compute": { + "$ref": "#/definitions/EnvironmentCompute", + "description": "The compute resource associated with the resource." + }, "outputResources": { "type": "array", + "description": "Properties of an output resource", "items": { "$ref": "#/definitions/OutputResource" }, - "x-ms-identifiers": [], - "x-cadl-name": "OutputResource[]", - "description": "Properties of an output resource" + "x-ms-identifiers": [] } - }, - "description": "Status of a resource." + } }, - "object": { - "type": "object", - "properties": {} + "Versions": { + "type": "string", + "description": "Supported API versions for the Applications.Dapr resource provider.", + "enum": [ + "2022-03-15-privatepreview" + ], + "x-ms-enum": { + "name": "Versions", + "modelAsString": true, + "values": [ + { + "name": "v2022_03_15_privatepreview", + "value": "2022-03-15-privatepreview", + "description": "2022-03-15-privatepreview" + } + ] + } } }, "parameters": { - "RootScopeParam": { + "RootScopeParameter": { "name": "rootScope", "in": "path", + "description": "The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} and Azure resource scope is /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", "required": true, - "description": "The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", + "type": "string", "minLength": 1, "x-ms-parameter-location": "client", - "x-ms-skip-url-encoding": true, - "type": "string" + "x-ms-skip-url-encoding": true } } } diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesDelete.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesDelete.json deleted file mode 100644 index d4048e1792..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "mongoDatabaseName": "mongo0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesGet.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesGet.json deleted file mode 100644 index d6f0030183..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesGet.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "mongoDatabaseName": "mongo0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" - } - ], - "database": "mongo0", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255 - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesList.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesList.json deleted file mode 100644 index 12fbbaaad0..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesList.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" - } - ], - "database": "mongo0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo0", - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters": { - "foo": "bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesListByRootScope.json deleted file mode 100644 index 8a0338b3df..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesListByRootScope.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" - } - ], - "database": "mongo0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo1", - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo2", - "name": "mongo2", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters": { - "foo": "bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Datastores/mongoDatabases?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesListSecrets.json deleted file mode 100644 index b01ba95aec..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesListSecrets.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "mongoDatabaseName": "mongo0" - }, - "responses": { - "200": { - "body": { - "username": "testUser", - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutRecipe.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutRecipe.json deleted file mode 100644 index 0c89ec2e56..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutRecipe.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "mongoDatabaseName": "mongo0", - "api-version": "2022-03-15-privatepreview", - "MongoDatabaseParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters": { - "foo": "bar" - } - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters": { - "foo": "bar" - } - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters": { - "foo": "bar" - } - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutValues.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutValues.json deleted file mode 100644 index ae4375dd06..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutValues.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "mongoDatabaseName": "mongo0", - "api-version": "2022-03-15-privatepreview", - "MongoDatabaseParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "username": "testUser", - "secrets": { - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - }, - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" - } - ] - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo0" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Datastores/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo0" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_CreateOrUpdateRecipe.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_CreateOrUpdateRecipe.json new file mode 100644 index 0000000000..42e4018d11 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_CreateOrUpdateRecipe.json @@ -0,0 +1,62 @@ +{ + "operationId": "MongoDatabases_CreateOrUpdate", + "title": "Create or update a MongoDatabase resource with recipe", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "mongoDatabaseName": "mongo0", + "api-version": "2022-03-15-privatepreview", + "MongoDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_CreateOrUpdateValues.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_CreateOrUpdateValues.json new file mode 100644 index 0000000000..0d6be4423b --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_CreateOrUpdateValues.json @@ -0,0 +1,65 @@ +{ + "operationId": "MongoDatabases_CreateOrUpdate", + "title": "Create or update a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "mongoDatabaseName": "mongo0", + "api-version": "2022-03-15-privatepreview", + "MongoDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + }, + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Delete.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Delete.json new file mode 100644 index 0000000000..c5f7221cbf --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "MongoDatabases_Delete", + "title": "Delete a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "mongoDatabaseName": "mongo0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Get.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Get.json new file mode 100644 index 0000000000..79e1b7ae90 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Get.json @@ -0,0 +1,33 @@ +{ + "operationId": "MongoDatabases_Get", + "title": "Get a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "mongoDatabaseName": "mongo0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ], + "database": "mongo0", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255 + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_List.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_List.json new file mode 100644 index 0000000000..0739f0cbb0 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_List.json @@ -0,0 +1,73 @@ +{ + "operationId": "MongoDatabases_ListByScope", + "title": "List MongoDatabase resources by resource group", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ], + "database": "mongo0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo1", + "name": "mongo1", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0", + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo1", + "name": "mongo1", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_ListByRootScope.json new file mode 100644 index 0000000000..4113d8a707 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_ListByRootScope.json @@ -0,0 +1,74 @@ +{ + "operationId": "MongoDatabases_ListByScope", + "title": "List MongoDatabase resources by rootScope", + "parameters": { + "rootScope": "planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ], + "database": "mongo0" + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo1", + "name": "mongo1", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo1", + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo2", + "name": "mongo2", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Datastores/mongoDatabases?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_ListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_ListSecrets.json new file mode 100644 index 0000000000..504f90ffb2 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_ListSecrets.json @@ -0,0 +1,18 @@ +{ + "operationId": "MongoDatabases_ListSecrets", + "title": "List the secrets of a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "mongoDatabaseName": "mongo0" + }, + "responses": { + "200": { + "body": { + "username": "testUser", + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + } + } + } +} diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Update.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Update.json new file mode 100644 index 0000000000..d3461506a7 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/MongoDatabases_Update.json @@ -0,0 +1,65 @@ +{ + "operationId": "MongoDatabases_Update", + "title": "Update a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "mongoDatabaseName": "mongo0", + "api-version": "2022-03-15-privatepreview", + "MongoDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + }, + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesDelete.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesDelete.json deleted file mode 100644 index f1198944ae..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesGet.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesGet.json deleted file mode 100644 index 79acf8fafb..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesGet.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "redisCacheName": "redis0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 6380, - "username": "username" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesList.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesList.json deleted file mode 100644 index 9a7a17a8be..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesList.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" - } - ], - "resourceProvisioning": "manual", - "host": "myrediscache.redis.cache.windows.net", - "port": 6380, - "username": "username" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis1", - "name": "redis1", - "type": "Applications.Datastores/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis2", - "name": "redis2", - "type": "Applications.Datastores/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "resourceProvisioning": "manual", - "host": "myrediscache.redis.cache.windows.net", - "port": 6380, - "username": "username" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesListByRootScope.json deleted file mode 100644 index 8fbdf550d2..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesListByRootScope.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 6380 - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis1", - "name": "redis1", - "type": "Applications.Datastores/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/redisCaches/redis2", - "name": "redis2", - "type": "Applications.Datastores/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "resourceProvisioning": "manual", - "host": "myrediscache.redis.cache.windows.net", - "port": 6380, - "username": "username" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Datastores/redisCaches?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesListSecrets.json deleted file mode 100644 index b1f3620fee..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesListSecrets.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroupName": "testGroup", - "api-version": "2022-03-15-privatepreview", - "redisCacheName": "redis0" - }, - "responses": { - "200": { - "body": { - "connectionString": "myrediscache.redis.cache.windows.net:6380", - "password": "testPassword" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutRecipe.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutRecipe.json deleted file mode 100644 index 5775a2f295..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutRecipe.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview", - "RedisCacheParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutResource.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutResource.json deleted file mode 100644 index 2ec88102d9..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutResource.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview", - "RedisCacheParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 6380 - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 6380 - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" - } - ], - "host": "myrediscache.redis.cache.windows.net", - "port": 6380 - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutValues.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutValues.json deleted file mode 100644 index 2a08c560b7..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCachesPutValues.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview", - "RedisCacheParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "myrediscache.redis.cache.windows.net", - "port": 6380, - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "myrediscache.redis.cache.windows.net", - "port": 6380, - "username": "username" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Datastores/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "myrediscache.redis.cache.windows.net", - "port": 6380, - "username": "username" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdate.json new file mode 100644 index 0000000000..003bc22fc3 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdate.json @@ -0,0 +1,68 @@ +{ + "operationId": "RedisCaches_CreateOrUpdate", + "title": "Create or update a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdateRecipe.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdateRecipe.json new file mode 100644 index 0000000000..838f7332d1 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdateRecipe.json @@ -0,0 +1,62 @@ +{ + "operationId": "RedisCaches_CreateOrUpdate", + "title": "Create or update a RedisCache resource with recipe", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdateValues.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdateValues.json new file mode 100644 index 0000000000..417b0a2588 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_CreateOrUpdateValues.json @@ -0,0 +1,59 @@ +{ + "operationId": "RedisCaches_CreateOrUpdate", + "title": "Create or update a RedisCache resource with values", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "secrets": { + "password": "testPassword", + "connectionString": "test-connection-string" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Delete.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Delete.json new file mode 100644 index 0000000000..dbedada922 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "RedisCaches_Delete", + "title": "Delete a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Get.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Get.json new file mode 100644 index 0000000000..0bfe5aad6f --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Get.json @@ -0,0 +1,33 @@ +{ + "operationId": "RedisCaches_Get", + "title": "Get a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "redisCacheName": "redis0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_List.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_List.json new file mode 100644 index 0000000000..20eff8c433 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_List.json @@ -0,0 +1,69 @@ +{ + "operationId": "RedisCaches_ListByScope", + "title": "List RedisCache resources by resource group", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis1", + "name": "redis1", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis2", + "name": "redis2", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_ListByRootScope.json new file mode 100644 index 0000000000..7c74f8ef11 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_ListByRootScope.json @@ -0,0 +1,68 @@ +{ + "operationId": "RedisCaches_ListByScope", + "title": "List RedisCache resources by rootScope", + "parameters": { + "rootScope": "planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis1", + "name": "redis1", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/redisCaches/redis2", + "name": "redis2", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Datastores/redisCaches?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_ListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_ListSecrets.json new file mode 100644 index 0000000000..7e0f2d9547 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_ListSecrets.json @@ -0,0 +1,19 @@ +{ + "operationId": "RedisCaches_ListSecrets", + "title": "List the secrets of a RedisCaches resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroupName": "testGroup", + "api-version": "2022-03-15-privatepreview", + "redisCacheName": "redis0" + }, + "responses": { + "200": { + "body": { + "connectionString": "myrediscache.redis.cache.windows.net:6380", + "password": "testPassword" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Update.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Update.json new file mode 100644 index 0000000000..04d8bed899 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/RedisCaches_Update.json @@ -0,0 +1,68 @@ +{ + "operationId": "RedisCaches_Update", + "title": "Update a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesDelete.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesDelete.json deleted file mode 100644 index 9410434361..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "sqlDatabaseName": "sql0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesGet.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesGet.json deleted file mode 100644 index 2547c41efd..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesGet.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "sqlDatabaseName": "sql0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "sql-database", - "server": "test-server", - "resourceProvisioning": "manual" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesList.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesList.json deleted file mode 100644 index f7b520b9fa..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesList.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", - "name": "sql1", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql2", - "name": "sql2", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "recipe": { - "name": "sqldb", - "parameters": { - "foo": "bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesListByRootScope.json deleted file mode 100644 index bab24558dc..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesListByRootScope.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database": "sql-database", - "server": "test-server", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/sqlDatabases/sql1", - "name": "sql1", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase1" - } - ], - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql2", - "name": "sql2", - "type": "Applications.Datastores/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "recipe": { - "name": "sqldb", - "parameters": { - "foo": "bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Datastores/sqlDatabases?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesPut.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesPut.json deleted file mode 100644 index 11fd33f43f..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabasesPut.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "sqlDatabaseName": "sql0", - "api-version": "2022-03-15-privatepreview", - "SQLDatabaseParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "resourceProvisioning": "manual" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Datastores/sqlDatabases", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", - "name": "sql1", - "type": "Applications.Datastores/sqlDatabases", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_CreateOrUpdate.json new file mode 100644 index 0000000000..fecc16494a --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_CreateOrUpdate.json @@ -0,0 +1,52 @@ +{ + "operationId": "SqlDatabases_CreateOrUpdate", + "title": "Create or update a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "sqlDatabaseName": "sql0", + "api-version": "2022-03-15-privatepreview", + "SQLDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Delete.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Delete.json new file mode 100644 index 0000000000..f703412f87 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "SqlDatabases_Delete", + "title": "Delete a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "sqlDatabaseName": "sql0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Get.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Get.json new file mode 100644 index 0000000000..bf6cc2f581 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Get.json @@ -0,0 +1,32 @@ +{ + "operationId": "SqlDatabases_Get", + "title": "Get a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "sqlDatabaseName": "sql0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "sql-database", + "server": "test-server", + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_List.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_List.json new file mode 100644 index 0000000000..928bbd95f9 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_List.json @@ -0,0 +1,67 @@ +{ + "operationId": "SqlDatabases_ListByScope", + "title": "List SqlDatabases resources by resource group", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql2", + "name": "sql2", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_ListByRootScope.json new file mode 100644 index 0000000000..1f16e6e489 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_ListByRootScope.json @@ -0,0 +1,72 @@ +{ + "operationId": "SqlDatabases_ListByScope", + "title": "List SqlDatabases resources by rootScope", + "parameters": { + "rootScope": "planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "sql-database", + "server": "test-server", + "resourceProvisioning": "manual" + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase1" + } + ], + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql2", + "name": "sql2", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Datastores/sqlDatabases?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Update.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Update.json new file mode 100644 index 0000000000..52e5223523 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/examples/SQLDatabases_Update.json @@ -0,0 +1,52 @@ +{ + "operationId": "SqlDatabases_Update", + "title": "Update a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "sqlDatabaseName": "sql0", + "api-version": "2022-03-15-privatepreview", + "SQLDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/openapi.json b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/openapi.json index fc9f565d0d..dc2fd9552e 100644 --- a/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/openapi.json +++ b/swagger/specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/openapi.json @@ -1,12 +1,12 @@ { "swagger": "2.0", "info": { - "title": "Applications.Datastores Management APIs", + "title": "Applications.Datastores Resource Management APIs", "version": "2022-03-15-privatepreview", "description": "REST APIs for Applications.Datastores", - "x-cadl-generated": [ + "x-typespec-generated": [ { - "emitter": "@azure-tools/cadl-autorest" + "emitter": "@azure-tools/typespec-autorest" } ] }, @@ -46,26 +46,26 @@ "name": "MongoDatabases" }, { - "name": "SqlDatabases" + "name": "RedisCaches" }, { - "name": "RedisCaches" + "name": "SqlDatabases" } ], "paths": { "/{rootScope}/providers/Applications.Datastores/mongoDatabases": { "get": { + "operationId": "MongoDatabases_ListByScope", "tags": [ "MongoDatabases" ], - "operationId": "MongoDatabases_ListByRootScope", - "description": "Lists information about all MongoDatabaseResources in the given root scope", + "description": "List MongoDatabaseResource resources by Scope", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" } ], "responses": { @@ -82,6 +82,14 @@ } } }, + "x-ms-examples": { + "List MongoDatabase resources by resource group": { + "$ref": "./examples/MongoDatabases_List.json" + }, + "List MongoDatabase resources by rootScope": { + "$ref": "./examples/MongoDatabases_ListByRootScope.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -89,27 +97,26 @@ }, "/{rootScope}/providers/Applications.Datastores/mongoDatabases/{mongoDatabaseName}": { "get": { + "operationId": "MongoDatabases_Get", "tags": [ "MongoDatabases" ], - "operationId": "MongoDatabases_Get", - "description": "Retrieves information about a MongoDatabaseResource", + "description": "Get a MongoDatabaseResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "mongoDatabaseName", "in": "path", + "description": "The name of the MongoDatabase portable resource resource", "required": true, - "description": "The name of the Mongo database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -125,36 +132,40 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a MongoDatabase resource": { + "$ref": "./examples/MongoDatabases_Get.json" + } } }, "put": { + "operationId": "MongoDatabases_CreateOrUpdate", "tags": [ "MongoDatabases" ], - "operationId": "MongoDatabases_CreateOrUpdate", - "description": "Creates or updates a MongoDatabaseResource", + "description": "Create a MongoDatabaseResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "mongoDatabaseName", "in": "path", + "description": "The name of the MongoDatabase portable resource resource", "required": true, - "description": "The name of the Mongo database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/MongoDatabaseResource" } @@ -162,54 +173,130 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'MongoDatabaseResource' update operation succeeded", "schema": { "$ref": "#/definitions/MongoDatabaseResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'MongoDatabaseResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/MongoDatabaseResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a MongoDatabase resource with recipe": { + "$ref": "./examples/MongoDatabases_CreateOrUpdateRecipe.json" + }, + "Create or update a MongoDatabase resource": { + "$ref": "./examples/MongoDatabases_CreateOrUpdateValues.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "MongoDatabases_Update", + "tags": [ + "MongoDatabases" + ], + "description": "Update a MongoDatabaseResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "mongoDatabaseName", + "in": "path", + "description": "The name of the MongoDatabase portable resource resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/MongoDatabaseResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", "schema": { "$ref": "#/definitions/MongoDatabaseResource" } }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true }, "delete": { + "operationId": "MongoDatabases_Delete", "tags": [ "MongoDatabases" ], - "operationId": "MongoDatabases_Delete", - "description": "Deletes an existing MongoDatabaseResource", + "description": "Delete a MongoDatabaseResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "mongoDatabaseName", "in": "path", + "description": "The name of the MongoDatabase portable resource resource", "required": true, - "description": "The name of the Mongo database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -220,9 +307,13 @@ "description": "Resource deletion accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -236,8 +327,13 @@ } } }, + "x-ms-examples": { + "Delete a MongoDatabase resource": { + "$ref": "./examples/MongoDatabases_Delete.json" + } + }, "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" + "final-state-via": "location" }, "x-ms-long-running-operation": true } @@ -245,23 +341,35 @@ "/{rootScope}/providers/Applications.Datastores/mongoDatabases/{mongoDatabaseName}/listSecrets": { "post": { "operationId": "MongoDatabases_ListSecrets", - "description": "Lists secrets values for the specified Mongo database resource", + "tags": [ + "MongoDatabases" + ], + "description": "Lists secrets values for the specified MongoDatabases resource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "mongoDatabaseName", "in": "path", + "description": "The name of the MongoDatabase portable resource resource", "required": true, - "description": "The name of the Mongo database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "type": "object", + "properties": {} + } } ], "responses": { @@ -277,22 +385,27 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "List the secrets of a MongoDatabase resource": { + "$ref": "./examples/MongoDatabases_ListSecrets.json" + } } } }, "/{rootScope}/providers/Applications.Datastores/redisCaches": { "get": { + "operationId": "RedisCaches_ListByScope", "tags": [ "RedisCaches" ], - "operationId": "RedisCaches_ListByRootScope", - "description": "Lists information about all RedisCacheResources in the given root scope", + "description": "List RedisCacheResource resources by Scope", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" } ], "responses": { @@ -309,6 +422,14 @@ } } }, + "x-ms-examples": { + "List RedisCache resources by resource group": { + "$ref": "./examples/RedisCaches_List.json" + }, + "List RedisCache resources by rootScope": { + "$ref": "./examples/RedisCaches_ListByRootScope.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -316,26 +437,26 @@ }, "/{rootScope}/providers/Applications.Datastores/redisCaches/{redisCacheName}": { "get": { + "operationId": "RedisCaches_Get", "tags": [ "RedisCaches" ], - "operationId": "RedisCaches_Get", - "description": "Retrieves information about a RedisCacheResource", + "description": "Get a RedisCacheResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "redisCacheName", "in": "path", + "description": "The name of the RedisCache portable resource resource", "required": true, - "description": "The name of the Redis cache portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -351,35 +472,40 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a RedisCache resource": { + "$ref": "./examples/RedisCaches_Get.json" + } } }, "put": { + "operationId": "RedisCaches_CreateOrUpdate", "tags": [ "RedisCaches" ], - "operationId": "RedisCaches_CreateOrUpdate", - "description": "Creates or updates a RedisCacheResource", + "description": "Create a RedisCacheResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "redisCacheName", "in": "path", + "description": "The name of the RedisCache portable resource resource", "required": true, - "description": "The name of the Redis cache portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/RedisCacheResource" } @@ -387,53 +513,138 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'RedisCacheResource' update operation succeeded", "schema": { "$ref": "#/definitions/RedisCacheResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'RedisCacheResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/RedisCacheResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a RedisCache resource": { + "$ref": "./examples/RedisCaches_CreateOrUpdate.json" + }, + "Create or update a RedisCache resource with recipe": { + "$ref": "./examples/RedisCaches_CreateOrUpdateRecipe.json" + }, + "Create or update a RedisCache resource with values": { + "$ref": "./examples/RedisCaches_CreateOrUpdateValues.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "RedisCaches_Update", + "tags": [ + "RedisCaches" + ], + "description": "Update a RedisCacheResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "redisCacheName", + "in": "path", + "description": "The name of the RedisCache portable resource resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/RedisCacheResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", "schema": { "$ref": "#/definitions/RedisCacheResource" } }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Update a RedisCache resource": { + "$ref": "./examples/RedisCaches_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true }, "delete": { + "operationId": "RedisCaches_Delete", "tags": [ "RedisCaches" ], - "operationId": "RedisCaches_Delete", - "description": "Deletes an existing RedisCacheResource", + "description": "Delete a RedisCacheResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "redisCacheName", "in": "path", + "description": "The name of the RedisCache portable resource resource", "required": true, - "description": "The name of the Redis cache portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -444,9 +655,13 @@ "description": "Resource deletion accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -459,29 +674,50 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Delete a RedisCache resource": { + "$ref": "./examples/RedisCaches_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true } }, "/{rootScope}/providers/Applications.Datastores/redisCaches/{redisCacheName}/listSecrets": { "post": { "operationId": "RedisCaches_ListSecrets", - "description": "Lists secrets values for the specified Redis cache resource", + "tags": [ + "RedisCaches" + ], + "description": "Lists secrets values for the specified RedisCache resource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "redisCacheName", "in": "path", + "description": "The name of the RedisCache portable resource resource", "required": true, - "description": "The name of the Redis cache portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "type": "object", + "properties": {} + } } ], "responses": { @@ -497,22 +733,27 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "List the secrets of a RedisCaches resource": { + "$ref": "./examples/RedisCaches_ListSecrets.json" + } } } }, "/{rootScope}/providers/Applications.Datastores/sqlDatabases": { "get": { + "operationId": "SqlDatabases_ListByScope", "tags": [ "SqlDatabases" ], - "operationId": "SqlDatabases_ListByRootScope", - "description": "Lists information about all SqlDatabaseResources in the given root scope", + "description": "List SqlDatabaseResource resources by Scope", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" } ], "responses": { @@ -529,6 +770,14 @@ } } }, + "x-ms-examples": { + "List SqlDatabases resources by resource group": { + "$ref": "./examples/SQLDatabases_List.json" + }, + "List SqlDatabases resources by rootScope": { + "$ref": "./examples/SQLDatabases_ListByRootScope.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -536,27 +785,26 @@ }, "/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}": { "get": { + "operationId": "SqlDatabases_Get", "tags": [ "SqlDatabases" ], - "operationId": "SqlDatabases_Get", - "description": "Retrieves information about a SqlDatabaseResource", + "description": "Get a SqlDatabaseResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "sqlDatabaseName", "in": "path", + "description": "The name of the SqlDatabase portable resource resource", "required": true, - "description": "The name of the SQL database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -572,36 +820,40 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a SqlDatabase resource": { + "$ref": "./examples/SQLDatabases_Get.json" + } } }, "put": { + "operationId": "SqlDatabases_CreateOrUpdate", "tags": [ "SqlDatabases" ], - "operationId": "SqlDatabases_CreateOrUpdate", - "description": "Creates or updates a SqlDatabaseResource", + "description": "Create a SqlDatabaseResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "sqlDatabaseName", "in": "path", + "description": "The name of the SqlDatabase portable resource resource", "required": true, - "description": "The name of the SQL database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/SqlDatabaseResource" } @@ -609,22 +861,22 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'SqlDatabaseResource' update operation succeeded", "schema": { "$ref": "#/definitions/SqlDatabaseResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'SqlDatabaseResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/SqlDatabaseResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, - "schema": { - "$ref": "#/definitions/SqlDatabaseResource" } }, "default": { @@ -633,78 +885,181 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Create or update a SqlDatabase resource": { + "$ref": "./examples/SQLDatabases_CreateOrUpdate.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true }, - "delete": { + "patch": { + "operationId": "SqlDatabases_Update", "tags": [ "SqlDatabases" ], - "operationId": "SqlDatabases_Delete", - "description": "Deletes an existing SqlDatabaseResource", + "description": "Update a SqlDatabaseResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "sqlDatabaseName", "in": "path", + "description": "The name of the SqlDatabase portable resource resource", "required": true, - "description": "The name of the SQL database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/SqlDatabaseResourceUpdate" + } } ], "responses": { "200": { - "description": "Resource deleted successfully." + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/SqlDatabaseResource" + } }, "202": { - "description": "Resource deletion accepted.", + "description": "Resource update request accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, - "204": { - "description": "Resource deleted successfully." - }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } - } - }, - "/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}/listSecrets": { - "post": { - "operationId": "SqlDatabases_ListSecrets", - "description": "Lists secrets values for the specified SQL database resource", + }, + "x-ms-examples": { + "Update a SqlDatabase resource": { + "$ref": "./examples/SQLDatabases_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + }, + "delete": { + "operationId": "SqlDatabases_Delete", + "tags": [ + "SqlDatabases" + ], + "description": "Delete a SqlDatabaseResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "sqlDatabaseName", "in": "path", + "description": "The name of the SqlDatabase portable resource resource", "required": true, - "description": "The name of the SQL database portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." + }, + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, + "204": { + "description": "Resource deleted successfully." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Delete a SqlDatabase resource": { + "$ref": "./examples/SQLDatabases_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + }, + "/{rootScope}/providers/Applications.Datastores/sqlDatabases/{sqlDatabaseName}/listSecrets": { + "post": { + "operationId": "SqlDatabases_ListSecrets", + "tags": [ + "SqlDatabases" + ], + "description": "Lists secrets values for the specified SqlDatabase resource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "sqlDatabaseName", + "in": "path", + "description": "The name of the SqlDatabase portable resource resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "type": "object", + "properties": {} + } } ], "responses": { @@ -725,10 +1080,10 @@ }, "/providers/Applications.Datastores/operations": { "get": { + "operationId": "Operations_List", "tags": [ "Operations" ], - "operationId": "Operations_List", "description": "List the operations for the provider", "parameters": [ { @@ -756,50 +1111,95 @@ } }, "definitions": { - "Application": { - "type": "string", - "description": "Fully qualified resource ID for the application that the portable resource is consumed by" - }, - "BasicDaprResourceProperties": { + "EnvironmentCompute": { "type": "object", + "description": "Represents backing compute resource", "properties": { - "componentName": { + "kind": { "type": "string", - "description": "The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.", - "readOnly": true + "description": "Discriminator property for EnvironmentCompute." + }, + "resourceId": { + "type": "string", + "description": "The resource id of the compute resource for application environment." + }, + "identity": { + "$ref": "#/definitions/IdentitySettings", + "description": "Configuration for supported external identity providers" } }, - "description": "Basic properties of a Dapr component object.", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } + "discriminator": "kind", + "required": [ + "kind" ] }, - "BasicResourceProperties": { + "IdentitySettingKind": { + "type": "string", + "description": "IdentitySettingKind is the kind of supported external identity setting", + "enum": [ + "undefined", + "azure.com.workload" + ], + "x-ms-enum": { + "name": "IdentitySettingKind", + "modelAsString": true, + "values": [ + { + "name": "undefined", + "value": "undefined", + "description": "undefined identity" + }, + { + "name": "azure.com.workload", + "value": "azure.com.workload", + "description": "azure ad workload identity" + } + ] + } + }, + "IdentitySettings": { "type": "object", + "description": "IdentitySettings is the external identity setting.", "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource.", - "readOnly": true + "kind": { + "$ref": "#/definitions/IdentitySettingKind", + "description": "kind of identity setting" }, - "environment": { + "oidcIssuer": { "type": "string", - "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + "description": "The URI for your compute platform's OIDC issuer" }, - "application": { - "$ref": "#/definitions/Application", - "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + "resource": { + "type": "string", + "description": "The resource ID of the provisioned identity" } }, - "description": "Basic properties of a Radius resource.", "required": [ - "environment" + "kind" ] }, + "KubernetesCompute": { + "type": "object", + "description": "The Kubernetes compute configuration", + "properties": { + "namespace": { + "type": "string", + "description": "The namespace to use for the environment." + } + }, + "required": [ + "namespace" + ], + "allOf": [ + { + "$ref": "#/definitions/EnvironmentCompute" + } + ], + "x-ms-discriminator-value": "kubernetes" + }, "MongoDatabaseListSecretsResult": { "type": "object", + "description": "The secret values for the given MongoDatabase resource", "properties": { "password": { "type": "string", @@ -809,15 +1209,28 @@ "type": "string", "description": "Connection string used to connect to the target Mongo database" } - }, - "description": "The secret values for the given Mongo database resource" + } }, "MongoDatabaseProperties": { "type": "object", + "description": "MongoDatabase portable resource properties", "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, "provisioningState": { "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the Mongo database portable resource at the time the operation was called", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", "readOnly": true }, "secrets": { @@ -837,36 +1250,33 @@ "type": "string", "description": "Database name of the target Mongo database" }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Mongo database portable resource" - }, "resources": { "type": "array", + "description": "List of the resource IDs that support the MongoDB resource", "items": { "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the Mongo database resource" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." + } }, "username": { "type": "string", "description": "Username to use when connecting to the target Mongo database" + }, + "recipe": { + "$ref": "#/definitions/Recipe", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." } }, - "description": "Mongo database portable resource properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } + "required": [ + "environment" ] }, "MongoDatabaseResource": { "type": "object", + "description": "MongoDatabase portable resource", "properties": { "properties": { "$ref": "#/definitions/MongoDatabaseProperties", @@ -878,7 +1288,6 @@ ] } }, - "description": "Mongo database portable resource", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -887,29 +1296,95 @@ }, "MongoDatabaseResourceListResult": { "type": "object", + "description": "The response of a MongoDatabaseResource list operation.", "properties": { "value": { "type": "array", + "description": "The MongoDatabaseResource items on this page", "items": { "$ref": "#/definitions/MongoDatabaseResource" - }, - "x-cadl-name": "MongoDatabaseResource[]", - "description": "The MongoDatabaseResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a MongoDatabaseResource list operation.", "required": [ "value" ] }, + "MongoDatabaseResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the MongoDatabaseResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/MongoDatabaseResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "MongoDatabaseResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the MongoDatabaseResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "secrets": { + "$ref": "#/definitions/MongoDatabaseSecrets", + "description": "Secret values provided for the resource" + }, + "host": { + "type": "string", + "description": "Host name of the target Mongo database" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "Port value of the target Mongo database" + }, + "database": { + "type": "string", + "description": "Database name of the target Mongo database" + }, + "resources": { + "type": "array", + "description": "List of the resource IDs that support the MongoDB resource", + "items": { + "$ref": "#/definitions/ResourceReference" + } + }, + "username": { + "type": "string", + "description": "Username to use when connecting to the target Mongo database" + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, "MongoDatabaseSecrets": { "type": "object", + "description": "The secret values for the given MongoDatabase resource", "properties": { "password": { "type": "string", @@ -919,18 +1394,25 @@ "type": "string", "description": "Connection string used to connect to the target Mongo database" } - }, - "description": "The secret values for the given Mongo database resource" + } }, "OutputResource": { "type": "object", - "properties": {}, - "description": "Properties of an output resource." - }, - "Parameters": { - "type": "object", - "properties": {}, - "description": "Key/value parameters to pass into the recipe at deployment" + "description": "Properties of an output resource.", + "properties": { + "localId": { + "type": "string", + "description": "The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships." + }, + "id": { + "type": "string", + "description": "The UCP resource ID of the underlying resource." + }, + "radiusManaged": { + "type": "boolean", + "description": "Determines whether Radius manages the lifecycle of the underlying resource." + } + } }, "ProvisioningState": { "type": "string", @@ -946,28 +1428,83 @@ ], "x-ms-enum": { "name": "ProvisioningState", - "modelAsString": true - } + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + }, + { + "name": "Provisioning", + "value": "Provisioning", + "description": "The resource is being provisioned" + }, + { + "name": "Updating", + "value": "Updating", + "description": "The resource is updating" + }, + { + "name": "Deleting", + "value": "Deleting", + "description": "The resource is being deleted" + }, + { + "name": "Accepted", + "value": "Accepted", + "description": "The resource create request has been accepted" + } + ] + }, + "readOnly": true }, "Recipe": { "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", "properties": { "name": { "type": "string", "description": "The name of the recipe within the environment to use" }, "parameters": { - "$ref": "#/definitions/Parameters", - "description": "Key/value parameters to pass into the recipe at deployment" + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} } }, - "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", "required": [ "name" ] }, + "RecipeUpdate": { + "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", + "properties": { + "name": { + "type": "string", + "description": "The name of the recipe within the environment to use" + }, + "parameters": { + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} + } + } + }, "RedisCacheListSecretsResult": { "type": "object", + "description": "The secret values for the given RedisCache resource", "properties": { "connectionString": { "type": "string", @@ -981,15 +1518,28 @@ "type": "string", "description": "The URL used to connect to the Redis cache" } - }, - "description": "The secret values for the given Redis cache resource" + } }, "RedisCacheProperties": { "type": "object", + "description": "RedisCache portable resource properties", "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, "provisioningState": { "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the redis cache portable at the time the operation was called", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", "readOnly": true }, "secrets": { @@ -1013,32 +1563,29 @@ "type": "boolean", "description": "Specifies whether to enable SSL connections to the Redis cache" }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Redis cache portable resource" - }, "resources": { "type": "array", + "description": "List of the resource IDs that support the Redis resource", "items": { "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the Redis resource" + } + }, + "recipe": { + "$ref": "#/definitions/Recipe", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" }, "resourceProvisioning": { "$ref": "#/definitions/ResourceProvisioning", "description": "Specifies how the underlying service/resource is provisioned and managed." } }, - "description": "Redis cache portable resource properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } + "required": [ + "environment" ] }, "RedisCacheResource": { "type": "object", + "description": "RedisCache portable resource", "properties": { "properties": { "$ref": "#/definitions/RedisCacheProperties", @@ -1050,7 +1597,6 @@ ] } }, - "description": "Redis cache portable resource", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -1059,29 +1605,95 @@ }, "RedisCacheResourceListResult": { "type": "object", + "description": "The response of a RedisCacheResource list operation.", "properties": { "value": { "type": "array", + "description": "The RedisCacheResource items on this page", "items": { "$ref": "#/definitions/RedisCacheResource" - }, - "x-cadl-name": "RedisCacheResource[]", - "description": "The RedisCacheResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a RedisCacheResource list operation.", "required": [ "value" ] }, + "RedisCacheResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the RedisCacheResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/RedisCacheResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "RedisCacheResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the RedisCacheResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "secrets": { + "$ref": "#/definitions/RedisCacheSecrets", + "description": "Secrets provided by resource" + }, + "host": { + "type": "string", + "description": "The host name of the target Redis cache" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "The port value of the target Redis cache" + }, + "username": { + "type": "string", + "description": "The username for Redis cache" + }, + "tls": { + "type": "boolean", + "description": "Specifies whether to enable SSL connections to the Redis cache" + }, + "resources": { + "type": "array", + "description": "List of the resource IDs that support the Redis resource", + "items": { + "$ref": "#/definitions/ResourceReference" + } + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, "RedisCacheSecrets": { "type": "object", + "description": "The secret values for the given RedisCache resource", "properties": { "connectionString": { "type": "string", @@ -1095,8 +1707,7 @@ "type": "string", "description": "The URL used to connect to the Redis cache" } - }, - "description": "The secret values for the given Redis cache resource" + } }, "ResourceProvisioning": { "type": "string", @@ -1107,106 +1718,132 @@ ], "x-ms-enum": { "name": "ResourceProvisioning", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "recipe", + "value": "recipe", + "description": "The resource lifecycle will be managed by Radius" + }, + { + "name": "manual", + "value": "manual", + "description": "The resource lifecycle will be managed by the user" + } + ] } }, "ResourceReference": { "type": "object", + "description": "Describes a reference to an existing resource", "properties": { "id": { "type": "string", "description": "Resource id of an existing resource" } }, - "description": "Describes a reference to an existing resource", "required": [ "id" ] }, "ResourceStatus": { "type": "object", + "description": "Status of a resource.", "properties": { + "compute": { + "$ref": "#/definitions/EnvironmentCompute", + "description": "The compute resource associated with the resource." + }, "outputResources": { "type": "array", + "description": "Properties of an output resource", "items": { "$ref": "#/definitions/OutputResource" }, - "x-ms-identifiers": [], - "x-cadl-name": "OutputResource[]", - "description": "Properties of an output resource" + "x-ms-identifiers": [] } - }, - "description": "Status of a resource." + } }, "SqlDatabaseListSecretsResult": { "type": "object", + "description": "The secret values for the given SqlDatabase resource", "properties": { "password": { "type": "string", - "description": "Password to use when connecting to the target SQL database" + "description": "Password to use when connecting to the target Sql database" }, "connectionString": { "type": "string", - "description": "Connection string used to connect to the target SQL database" + "description": "Connection string used to connect to the target Sql database" } - }, - "description": "The secret values for the given SQL database resource" + } }, "SqlDatabaseProperties": { "type": "object", + "description": "SqlDatabase properties", "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, "provisioningState": { "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the SQL database portable resource at the time the operation was called", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", "readOnly": true }, "database": { "type": "string", - "description": "The name of the SQL database." + "description": "The name of the Sql database." }, "server": { "type": "string", - "description": "The fully qualified domain name of the target SQL database." + "description": "The fully qualified domain name of the Sql database." }, "port": { "type": "integer", "format": "int32", - "description": "Port value of the target SQL database" + "description": "Port value of the target Sql database" }, "username": { "type": "string", - "description": "Username to use when connecting to the target SQL database" - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the SQL database portable resource" + "description": "Username to use when connecting to the target Sql database" }, "resources": { "type": "array", + "description": "List of the resource IDs that support the SqlDatabase resource", "items": { "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the SQL database resource" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." + } }, "secrets": { "$ref": "#/definitions/SqlDatabaseSecrets", "description": "Secret values provided for the resource" + }, + "recipe": { + "$ref": "#/definitions/Recipe", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." } }, - "description": "Sql database properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } + "required": [ + "environment" ] }, "SqlDatabaseResource": { "type": "object", + "description": "SqlDatabase portable resource", "properties": { "properties": { "$ref": "#/definitions/SqlDatabaseProperties", @@ -1218,7 +1855,6 @@ ] } }, - "description": "Sql database portable resource", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -1227,52 +1863,135 @@ }, "SqlDatabaseResourceListResult": { "type": "object", + "description": "The response of a SqlDatabaseResource list operation.", "properties": { "value": { "type": "array", + "description": "The SqlDatabaseResource items on this page", "items": { "$ref": "#/definitions/SqlDatabaseResource" - }, - "x-cadl-name": "SqlDatabaseResource[]", - "description": "The SqlDatabaseResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a SqlDatabaseResource list operation.", "required": [ "value" ] }, + "SqlDatabaseResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the SqlDatabaseResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/SqlDatabaseResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "SqlDatabaseResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the SqlDatabaseResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "database": { + "type": "string", + "description": "The name of the Sql database." + }, + "server": { + "type": "string", + "description": "The fully qualified domain name of the Sql database." + }, + "port": { + "type": "integer", + "format": "int32", + "description": "Port value of the target Sql database" + }, + "username": { + "type": "string", + "description": "Username to use when connecting to the target Sql database" + }, + "resources": { + "type": "array", + "description": "List of the resource IDs that support the SqlDatabase resource", + "items": { + "$ref": "#/definitions/ResourceReference" + } + }, + "secrets": { + "$ref": "#/definitions/SqlDatabaseSecrets", + "description": "Secret values provided for the resource" + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, "SqlDatabaseSecrets": { "type": "object", + "description": "The secret values for the given SqlDatabase resource", "properties": { "password": { "type": "string", - "description": "Password to use when connecting to the target SQL database" + "description": "Password to use when connecting to the target Sql database" }, "connectionString": { "type": "string", - "description": "Connection string used to connect to the target SQL database" + "description": "Connection string used to connect to the target Sql database" } - }, - "description": "The secret values for the given SQL database resource" + } + }, + "Versions": { + "type": "string", + "description": "Supported API versions for the Applications.Databases resource provider.", + "enum": [ + "2022-03-15-privatepreview" + ], + "x-ms-enum": { + "name": "Versions", + "modelAsString": true, + "values": [ + { + "name": "v2022_03_15_privatepreview", + "value": "2022-03-15-privatepreview", + "description": "2022-03-15-privatepreview" + } + ] + } } }, "parameters": { - "RootScopeParam": { + "RootScopeParameter": { "name": "rootScope", "in": "path", + "description": "The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} and Azure resource scope is /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", "required": true, - "description": "The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", + "type": "string", "minLength": 1, "x-ms-parameter-location": "client", - "x-ms-skip-url-encoding": true, - "type": "string" + "x-ms-skip-url-encoding": true } } } diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersDelete.json deleted file mode 100644 index 4e11215d4b..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprPubSubBrokerName": "daprpubsub0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersGet.json deleted file mode 100644 index 5f0af81249..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersGet.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "daprPubSubBrokerName": "daprpub.sub0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprpub.sub0", - "name": "daprpub.sub0", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersList.json deleted file mode 100644 index 2e1ace3a05..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersList.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "parameters": { - "rootScope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub0", - "name": "daprPubSub0", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub1", - "name": "daprPubSub1", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "pubsub.kafka", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub2", - "name": "daprPubSub2", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersListByRootScope.json deleted file mode 100644 index f378bd7ee6..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersListByRootScope.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub0", - "name": "daprPubSub0", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Link/daprPubSubBrokers/daprPubSub1", - "name": "daprPubSub1", - "type": "Applications.Link/daprPubSubBrokers", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "pubsub.kafka", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/daprPubSubBrokers?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersPut.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersPut.json deleted file mode 100644 index 4e71c31975..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersPut.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprPubSubBrokerName": "daprpubsub0", - "api-version": "2022-03-15-privatepreview", - "DaprPubSubBrokerParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub0", - "name": "daprPubSub0", - "type": "Applications.Link/daprPubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub1", - "name": "daprPubSub1", - "type": "Applications.Link/daprPubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" - } - ], - "type": "pubsub.azure.servicebus", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersPutWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersPutWithRecipe.json deleted file mode 100644 index d9872b4fc4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprPubSubBrokersPutWithRecipe.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprPubSubBrokerName": "daprpubsub0", - "api-version": "2022-03-15-privatepreview", - "DaprPubSubBrokerParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub0", - "name": "daprPubSub0", - "type": "Applications.Link/daprPubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "recipe", - "type": "pubsub.azure.servicebus", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprPubSubBrokers/daprPubSub1", - "name": "daprPubSub1", - "type": "Applications.Link/daprPubSubBrokers", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "recipe", - "type": "pubsub.azure.servicebus", - "recipe": { - "name": "pubsub-test", - "parameters": { - "port": 6081 - } - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresDelete.json deleted file mode 100644 index c05de28c3c..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprSecretStoreName": "daprsecretstore0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresGet.json deleted file mode 100644 index bd2b645675..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresGet.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "daprSecretStoreName": "daprsecretstore0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Link/daprSecretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresList.json deleted file mode 100644 index 26574f5f3b..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresList.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Link/daprSecretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores/daprSecretStore1", - "name": "daprSecretStore1", - "type": "Applications.Link/daprSecretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresListByRootScope.json deleted file mode 100644 index 04091b8b57..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresListByRootScope.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Link/daprSecretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores/daprSecretStore1", - "name": "daprSecretStore1", - "type": "Applications.Link/daprSecretStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/daprSecretStores?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresPut.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresPut.json deleted file mode 100644 index 448efed7cb..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprSecretStoresPut.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprSecretStoreName": "daprsecretstore0", - "api-version": "2022-03-15-privatepreview", - "DaprSecretStoreParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores/daprSecretStore0", - "name": "daprSecretStore0", - "type": "Applications.Link/daprSecretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "kind": "generic", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprSecretStores/daprSecretStore1", - "name": "daprSecretStore1", - "type": "Applications.Link/daprSecretStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "secretstores.hashicorp.vault", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresDelete.json deleted file mode 100644 index b1d39394d8..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprStateStoreName": "daprstatestore0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresGet.json deleted file mode 100644 index 3450b5fb4b..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresGet.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview", - "daprStateStoreName": "daprstatestore0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresList.json deleted file mode 100644 index 04eb1b5885..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresList.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable"} - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore1", - "name": "daprStateStore1", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable"} - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore2", - "name": "daprStateStore2", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore3", - "name": "daprStateStore3", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "recipe-test" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresListByRootScope.json deleted file mode 100644 index 3a2dc7e6a3..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresListByRootScope.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase"} - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Link/daprStateStores/daprStateStore1", - "name": "daprStateStore1", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [ - {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase"} - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore2", - "name": "daprStateStore2", - "type": "Applications.Link/daprStateStores", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/daprStateStores?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresPut.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresPut.json deleted file mode 100644 index 3e0ae0f135..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresPut.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprStateStoreName": "daprstatestore0", - "api-version": "2022-03-15-privatepreview", - "DaprStateStoreParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "mode": "resource", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "kind": "state.sqlserver", - "resources": [ - {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable"} - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore1", - "name": "daprStateStore1", - "type": "Applications.Link/daprStateStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [ - {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable"} - ], - "type": "state.zookeeper", - "version": "v1", - "metadata": { - "foo": "bar" - }, - "resourceProvisioning": "manual" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresPutWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresPutWithRecipe.json deleted file mode 100644 index 9c6f14d5b9..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/DaprStateStoresPutWithRecipe.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "daprStateStoreName": "daprstatestore0", - "api-version": "2022-03-15-privatepreview", - "DaprStateStoreParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "recipe-test" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore0", - "name": "daprStateStore0", - "type": "Applications.Link/daprStateStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "kind": "state.sqlserver", - "recipe": { - "name": "recipe-test" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/daprStateStores/daprStateStore1", - "name": "daprStateStore1", - "type": "Applications.Link/daprStateStores", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "mode": "recipe", - "recipe": { - "name": "recipe-test" - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersDelete.json deleted file mode 100644 index 67c09ee3ea..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "extenderName": "extender0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersGet.json deleted file mode 100644 index 621e5709ae..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersGet.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview", - "extenderName": "extender0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersList.json deleted file mode 100644 index 49e1381f3f..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersList.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersListByRootScope.json deleted file mode 100644 index 0c54b9e4ba..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersListByRootScope.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/extenders?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersListSecrets.json deleted file mode 100644 index 56abae506a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersListSecrets.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroupName": "testGroup", - "api-version": "2022-03-15-privatepreview", - "extenderName": "extender0" - }, - "responses": { - "200": { - "body": { - "accountSid": "sid", - "authToken:": "token" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersPut.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersPut.json deleted file mode 100644 index 1b2adaf31a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersPut.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "extenderName": "extender0", - "api-version": "2022-03-15-privatepreview", - "ExtenderParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders/extender1", - "name": "extender1", - "type": "Applications.Link/extenders", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "fromNumber": "222-222-2222", - "secrets": { - "accountSid": "sid", - "authToken:": "token" - }, - "resourceProvisioning": "manual" - } - } - } - } -} - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersPutWithRecipe.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersPutWithRecipe.json deleted file mode 100644 index dd2e7caa16..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/ExtendersPutWithRecipe.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "extenderName": "extender0", - "api-version": "2022-03-15-privatepreview", - "ExtenderParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "s3" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders/extender0", - "name": "extender0", - "type": "Applications.Link/extenders", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "s3" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/extenders/extender1", - "name": "extender1", - "type": "Applications.Link/extenders", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "s3" - } - } - } - } - } -} - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesDelete.json deleted file mode 100644 index 46a6c0bff2..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "mongoDatabaseName": "mongo0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesGet.json deleted file mode 100644 index 74a8055467..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesGet.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "mongoDatabaseName": "mongo0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning":"manual", - "resources": [ - {"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"} - ], - "database": "mongo0", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255 - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesList.json deleted file mode 100644 index e8bc669634..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesList.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "resources": [ - {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"} - ], - "database": "mongo0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo0", - "secrets": { - "username": "testUser", - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Link/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesListByRootScope.json deleted file mode 100644 index c0bc5ce59a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesListByRootScope.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"}], - "database": "mongo0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Link/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo0", - "secrets": { - "username": "testUser", - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Link/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/mongoDatabases?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesListSecrets.json deleted file mode 100644 index b01ba95aec..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesListSecrets.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "mongoDatabaseName": "mongo0" - }, - "responses": { - "200": { - "body": { - "username": "testUser", - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutRecipe.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutRecipe.json deleted file mode 100644 index 8c1516b880..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutRecipe.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "mongoDatabaseName": "mongo0", - "api-version": "2022-03-15-privatepreview", - "MongoDatabaseParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters":{ - "foo":"bar" - } - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters":{ - "foo":"bar" - } - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "cosmosdb", - "parameters":{ - "foo":"bar" - } - } - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutValues.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutValues.json deleted file mode 100644 index c4de8b52e5..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/MongoDatabasesPutValues.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "mongoDatabaseName": "mongo0", - "api-version": "2022-03-15-privatepreview", - "MongoDatabaseParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning":"manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "secrets": { - "username": "testUser", - "password": "testPassword", - "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" - }, - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db"}] - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo0", - "name": "mongo0", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning":"manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo0" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/mongoDatabases/mongo1", - "name": "mongo1", - "type": "Applications.Link/mongoDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning":"manual", - "host": "testAccount1.mongo.cosmos.azure.com", - "port": 10255, - "database": "mongo1" - } - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/OperationsList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/OperationsList.json deleted file mode 100644 index f5a5bff1f8..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/OperationsList.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "parameters": { - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "name": "Applications.Link/operations/read", - "isDataAction": false, - "display": { - "provider": "Applications.Link", - "resource": "Operations", - "operation": "Get operations", - "description": "Gets the list of Operations" - } - }, - { - "name": "Applications.Link/mongoDatabases/read", - "isDataAction": false, - "display": { - "provider": "Applications.Link", - "resource": "mongoDatabases", - "operation": "Get/List mongoDatabases", - "description": "Gets/Lists mongo database link(s)" - } - }, - { - "name": "Applications.Link/mongoDatabases/write", - "isDataAction": false, - "display": { - "provider": "Applications.Link", - "resource": "mongoDatabases", - "operation": "Create/Update mongoDatabases", - "description": "Creates or updates a mongo database link" - } - }, - { - "name": "Applications.Link/mongoDatabases/delete", - "isDataAction": false, - "display": { - "provider": "Applications.Link", - "resource": "mongoDatabases", - "operation": "Delete mongoDatabases", - "description": "Deletes a mongo database link" - } - }, - { - "name": "Applications.Link/register/action", - "isDataAction": false, - "display": { - "provider": "Applications.Link", - "resource": "Applications.Link", - "operation": "Register 'Applications.Link' resource provider", - "description": "Registers the 'Applications.Link' resource provider with a subscription" - } - }, - { - "name": "Applications.Link/unregister/action", - "isDataAction": false, - "display": { - "provider": "Applications.Link", - "resource": "Applications.Link", - "operation": "Unregister 'Applications.Link' resource provider", - "description": "Unregisters the 'Applications.Link' resource provider with a subscription" - } - } - ] - } - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesDelete.json deleted file mode 100644 index d4951bcf32..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "rabbitMQMessageQueueName": "rabbitmq0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesGet.json deleted file mode 100644 index 3c91597618..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesGet.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "rabbitMQMessageQueueName": "rabbitmq0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesList.json deleted file mode 100644 index 8201de777d..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesList.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq1", - "name": "rabbitmq1", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesListByRootScope.json deleted file mode 100644 index abacb89868..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesListByRootScope.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq1", - "name": "rabbitmq1", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/rabbitMQMessageQueues?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesListSecrets.json deleted file mode 100644 index 5a329dbcdf..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesListSecrets.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroupName": "testGroup", - "api-version": "2022-03-15-privatepreview", - "rabbitMQMessageQueueName": "rabbitmq0" - }, - "responses": { - "200": { - "body": { - "connectionString": "connection://string" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesPut.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesPut.json deleted file mode 100644 index d92b63188e..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RabbitMQMessageQueuesPut.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "rabbitMQMessageQueueName": "rabbitmq0", - "api-version": "2022-03-15-privatepreview", - "RabbitMQMessageQueueParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/rabbitMQMessageQueues/rabbitmq1", - "name": "rabbitmq1", - "type": "Applications.Link/rabbitMQMessageQueues", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesDelete.json deleted file mode 100644 index 62e9b296b4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesGet.json deleted file mode 100644 index 2d190a157e..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesGet.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "redisCacheName": "redis0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning":"manual", - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache"}], - "host": "myrediscache.redis.cache.windows.net", - "port":6380, - "username": "username" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesList.json deleted file mode 100644 index 5d364cb289..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesList.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache"}], - "resourceProvisioning":"manual", - "host": "myrediscache.redis.cache.windows.net", - "port":6380, - "username": "username" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis1", - "name": "redis1", - "type": "Applications.Link/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "resourceProvisioning":"manual", - "host":"myrediscache.redis.cache.windows.net", - "port":6380, - "username": "username" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesListByRootScope.json deleted file mode 100644 index 454526560e..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesListByRootScope.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache"}], - "host":"myrediscache.redis.cache.windows.net", - "port":6380 - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Link/redisCaches/redis1", - "name": "redis1", - "type": "Applications.Link/redisCaches", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "resourceProvisioning": "manual", - "host":"myrediscache.redis.cache.windows.net", - "port":6380, - "username": "username" - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/redisCaches?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesListSecrets.json deleted file mode 100644 index 223cf35a41..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesListSecrets.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroupName": "testGroup", - "api-version": "2022-03-15-privatepreview", - "redisCacheName": "redis0" - }, - "responses": { - "200": { - "body": { - "connectionString": "myrediscache.redis.cache.windows.net:6380", - "password": "testPassword" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutRecipe.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutRecipe.json deleted file mode 100644 index 11d94052e4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutRecipe.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview", - "RedisCacheParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis1", - "name": "redis1", - "type": "Applications.Link/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "redis", - "parameters": { - "port": 2334 - } - } - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutResource.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutResource.json deleted file mode 100644 index 96e0d7ac5f..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutResource.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview", - "RedisCacheParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache"}], - "host": "myrediscache.redis.cache.windows.net", - "port":6380 - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache"}], - "host": "myrediscache.redis.cache.windows.net", - "port":6380 - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis1", - "name": "redis1", - "type": "Applications.Link/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "resources": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache"}], - "host": "myrediscache.redis.cache.windows.net", - "port": 6380 - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutValues.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutValues.json deleted file mode 100644 index 5cc56836d7..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/RedisCachesPutValues.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "redisCacheName": "redis0", - "api-version": "2022-03-15-privatepreview", - "RedisCacheParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host":"myrediscache.redis.cache.windows.net", - "port":6380, - "secrets": { - "password": "testPassword", - "connectionString": "test-connection-string" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis0", - "name": "redis0", - "type": "Applications.Link/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host":"myrediscache.redis.cache.windows.net", - "port":6380, - "username": "username" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/redisCaches/redis1", - "name": "redis1", - "type": "Applications.Link/redisCaches", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "host":"myrediscache.redis.cache.windows.net", - "port":6380, - "username": "username" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesDelete.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesDelete.json deleted file mode 100644 index c73e910e4d..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "sqlDatabaseName": "sql0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesGet.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesGet.json deleted file mode 100644 index d8f66ca63c..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesGet.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "sqlDatabaseName": "sql0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources":[ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database":"sql-database", - "server":"test-server", - "resourceProvisioning": "manual" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesList.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesList.json deleted file mode 100644 index 1d0b1564f8..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesList.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources":[ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database":"testDatabase", - "server":"testAccount1.sql.cosmos.azure.com", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql1", - "name": "sql1", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql2", - "name": "sql2", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesListByRootScope.json deleted file mode 100644 index 498f97fffe..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesListByRootScope.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resources":[ - { - "id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" - } - ], - "database":"sql-database", - "server":"test-server", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Link/sqlDatabases/sql1", - "name": "sql1", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "database": "testDatabase", - "server": "testAccount1.sql.cosmos.azure.com", - "resourceProvisioning": "manual" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql2", - "name": "sql2", - "type": "Applications.Link/sqlDatabases", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env1", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Link/sqlDatabases?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesPut.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesPut.json deleted file mode 100644 index 11b97d11e4..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/examples/SQLDatabasesPut.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "sqlDatabaseName": "sql0", - "api-version": "2022-03-15-privatepreview", - "SQLDatabaseParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase", - "mode":"resource" - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql0", - "name": "sql0", - "type": "Applications.Link/sqlDatabases", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase", - "mode":"resource" - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Link/sqlDatabases/sql1", - "name": "sql1", - "type": "Applications.Link/sqlDatabases", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase", - "mode":"resource" - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/extenders.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/extenders.json deleted file mode 100644 index 9402612d40..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/extenders.json +++ /dev/null @@ -1,385 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Link Management APIs", - "description": "REST APIs for Applications.Link/extenders", - "version": "2022-03-15-privatepreview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/{rootScope}/providers/Applications.Link/extenders": { - "get": { - "description": "Lists information about all extender resources in the given root scope", - "operationId": "Extenders_ListByRootScope", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersListByRootScope": { - "$ref": "./examples/ExtendersListByRootScope.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "openapi.json#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "List of Extender resources", - "schema": { - "$ref": "#/definitions/ExtenderList" - } - }, - "default": { - "description": "Error response describing the reason for operation failure", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "deprecated": false, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/extenders/{extenderName}": { - "get": { - "description": "Retrieves information about a extender resource", - "operationId": "Extenders_Get", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersGet": { - "$ref": "./examples/ExtendersGet.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "openapi.json#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - } - ], - "responses": { - "200": { - "description": "Extender resource", - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "default": { - "description": "Error response describing the reason for operation failure", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "description": "Creates or updates a Extender resource", - "operationId": "Extenders_CreateOrUpdate", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersPut": { - "$ref": "./examples/ExtendersPut.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "openapi.json#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - }, - { - "name": "ExtenderParameters", - "description": "extender create parameters", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - } - ], - "responses": { - "200": { - "description": "The request was successful; response contains the extender resource", - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "201": { - "description": "The request was successful, resource will be updated asynchronously", - "schema": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "default": { - "description": "Error response describing the reason for operation failure", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "description": "Deletes an existing extender resource", - "operationId": "Extenders_Delete", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersDelete": { - "$ref": "./examples/ExtendersDelete.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "openapi.json#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - } - ], - "responses": { - "200": { - "description": "The Extender link was successfully deleted." - }, - "202": { - "description": "The Extender link will be deleted asynchronously." - }, - "204": { - "description": "The Extender link does not exist." - }, - "default": { - "description": "Error response describing the reason for operation failure", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/extenders/{extenderName}/listSecrets": { - "post": { - "description": "Lists secrets values for the specified Extender resource", - "operationId": "Extenders_listSecrets", - "produces": [ - "application/json" - ], - "x-ms-examples": { - "ExtendersGet": { - "$ref": "./examples/ExtendersListSecrets.json" - } - }, - "tags": [ - "Extenders" - ], - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "openapi.json#/parameters/RootScopeParam" - }, - { - "$ref": "#/parameters/ExtenderNameParameter" - } - ], - "responses": { - "200": { - "description": "Extender secrets", - "schema": { - "$ref": "#/definitions/ExtenderListSecretsResult" - } - }, - "default": { - "description": "Error response describing the reason for operation failure", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - } - }, - "definitions": { - "Recipe": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The name of the recipe within the environment to use" - }, - "parameters": { - "$ref": "openapi.json#/definitions/Parameters", - "description": "Key/value parameters to pass into the recipe at deployment" - } - }, - "description": "The recipe used to automatically deploy underlying infrastructure for a link", - "required": [ - "name" - ] - }, - "ResourceProvisioning": { - "type": "string", - "description": "Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.", - "enum": [ - "recipe", - "manual" - ], - "x-ms-enum": { - "name": "ResourceProvisioning", - "modelAsString": true - } - }, - "ExtenderList": { - "description": "Object that includes an array of Extender and a possible link for next set", - "type": "object", - "properties": { - "value": { - "description": "List of Extender resources", - "type": "array", - "items": { - "$ref": "#/definitions/ExtenderResource" - } - }, - "nextLink": { - "description": "The link used to fetch the next page of Extender list.", - "type": "string" - } - } - }, - "ExtenderResource": { - "description": "Extender link", - "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "systemData": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/systemData" - }, - "properties": { - "x-ms-client-flatten": true, - "$ref": "#/definitions/ExtenderProperties" - } - } - }, - "ExtenderListSecretsResult": { - "description": "The secret values for the given Extender resource", - "$ref": "#/definitions/ExtenderSecrets" - }, - "ExtenderSecrets": { - "description": "The secret values for the given Extender resource", - "additionalProperties": true, - "properties": {} - }, - "ExtenderProperties": { - "description": "Extender link properties", - "type": "object", - "allOf": [ - { - "$ref": "openapi.json#/definitions/BasicResourceProperties" - } - ], - "additionalProperties": true, - "properties": { - "provisioningState": { - "readOnly": true, - "$ref": "openapi.json#/definitions/ProvisioningState", - "description": "Provisioning state of the extender link at the time the operation was called" - }, - "secrets": { - "additionalProperties": true, - "$ref": "#/definitions/ExtenderSecrets" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Extender link" - } - }, - "required": [ - "environment" - ] - } - }, - "parameters": { - "ExtenderNameParameter": { - "description": "The name of the Extender link resource", - "name": "extenderName", - "in": "path", - "required": true, - "type": "string", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/openapi.json b/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/openapi.json deleted file mode 100644 index 42eb546b25..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/openapi.json +++ /dev/null @@ -1,2462 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Applications.Link Management APIs", - "version": "2022-03-15-privatepreview", - "description": "REST APIs for Applications.Link DaprPubSubBroker Resource", - "x-cadl-generated": [ - { - "emitter": "@azure-tools/cadl-autorest" - } - ] - }, - "schemes": [ - "https" - ], - "host": "management.azure.com", - "produces": [ - "application/json" - ], - "consumes": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "description": "Azure Active Directory OAuth2 Flow.", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "tags": [ - { - "name": "MongoDatabases" - }, - { - "name": "Operations" - }, - { - "name": "SqlDatabases" - }, - { - "name": "RedisCaches" - }, - { - "name": "RabbitMQMessageQueues" - }, - { - "name": "DaprSecretStore" - }, - { - "name": "DaprStateStore" - }, - { - "name": "DaprPubSubBroker" - } - ], - "paths": { - "/{rootScope}/providers/Applications.Link/daprPubSubBrokers": { - "get": { - "tags": [ - "DaprPubSubBroker" - ], - "operationId": "DaprPubSubBroker_ListByRootScope", - "description": "Lists information about all DaprPubSubBrokerResources in the given root scope", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprPubSubBrokerResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/daprPubSubBrokers/{daprPubSubBrokerName}": { - "get": { - "tags": [ - "DaprPubSubBroker" - ], - "operationId": "DaprPubSubBroker_Get", - "description": "Retrieves information about a DaprPubSubBrokerResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprPubSubBrokerName", - "in": "path", - "required": true, - "description": "DaprPubSubBroker name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprPubSubBrokerResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "DaprPubSubBroker" - ], - "operationId": "DaprPubSubBroker_CreateOrUpdate", - "description": "Creates or updates a DaprPubSubBrokerResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprPubSubBrokerName", - "in": "path", - "required": true, - "description": "DaprPubSubBroker name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/DaprPubSubBrokerResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprPubSubBrokerResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/DaprPubSubBrokerResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "DaprPubSubBroker" - ], - "operationId": "DaprPubSubBroker_Delete", - "description": "Deletes an existing DaprPubSubBrokerResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprPubSubBrokerName", - "in": "path", - "required": true, - "description": "DaprPubSubBroker name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - } - }, - "/{rootScope}/providers/Applications.Link/daprSecretStores": { - "get": { - "tags": [ - "DaprSecretStore" - ], - "operationId": "DaprSecretStore_ListByRootScope", - "description": "Lists information about all DaprSecretStoreResources in the given root scope", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprSecretStoreResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/daprSecretStores/{daprSecretStoreName}": { - "get": { - "tags": [ - "DaprSecretStore" - ], - "operationId": "DaprSecretStore_Get", - "description": "Retrieves information about a DaprSecretStoreResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprSecretStoreName", - "in": "path", - "required": true, - "description": "DaprSecretStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprSecretStoreResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "DaprSecretStore" - ], - "operationId": "DaprSecretStore_CreateOrUpdate", - "description": "Creates or updates a DaprSecretStoreResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprSecretStoreName", - "in": "path", - "required": true, - "description": "DaprSecretStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/DaprSecretStoreResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprSecretStoreResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/DaprSecretStoreResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "DaprSecretStore" - ], - "operationId": "DaprSecretStore_Delete", - "description": "Deletes an existing DaprSecretStoreResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprSecretStoreName", - "in": "path", - "required": true, - "description": "DaprSecretStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/daprStateStores": { - "get": { - "tags": [ - "DaprStateStore" - ], - "operationId": "DaprStateStore_ListByRootScope", - "description": "Lists information about all DaprStateStoreResources in the given root scope", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprStateStoreResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/daprStateStores/{daprStateStoreName}": { - "get": { - "tags": [ - "DaprStateStore" - ], - "operationId": "DaprStateStore_Get", - "description": "Retrieves information about a DaprStateStoreResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprStateStoreName", - "in": "path", - "required": true, - "description": "DaprStateStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprStateStoreResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "DaprStateStore" - ], - "operationId": "DaprStateStore_CreateOrUpdate", - "description": "Creates or updates a DaprStateStoreResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprStateStoreName", - "in": "path", - "required": true, - "description": "DaprStateStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/DaprStateStoreResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/DaprStateStoreResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/DaprStateStoreResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "DaprStateStore" - ], - "operationId": "DaprStateStore_Delete", - "description": "Deletes an existing DaprStateStoreResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "daprStateStoreName", - "in": "path", - "required": true, - "description": "DaprStateStore name", - "pattern": "^[A-Za-z]([-A-Za-z0-9\\.]*[A-Za-z0-9\\.])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - } - }, - "/{rootScope}/providers/Applications.Link/mongoDatabases": { - "get": { - "tags": [ - "MongoDatabases" - ], - "operationId": "MongoDatabases_ListByRootScope", - "description": "Lists information about all MongoDatabaseResources in the given root scope", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/MongoDatabaseResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/mongoDatabases/{mongoDatabaseName}": { - "get": { - "tags": [ - "MongoDatabases" - ], - "operationId": "MongoDatabases_Get", - "description": "Retrieves information about a MongoDatabaseResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "mongoDatabaseName", - "in": "path", - "required": true, - "description": "The name of the MongoDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/MongoDatabaseResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "MongoDatabases" - ], - "operationId": "MongoDatabases_CreateOrUpdate", - "description": "Creates or updates a MongoDatabaseResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "mongoDatabaseName", - "in": "path", - "required": true, - "description": "The name of the MongoDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/MongoDatabaseResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/MongoDatabaseResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/MongoDatabaseResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "MongoDatabases" - ], - "operationId": "MongoDatabases_Delete", - "description": "Deletes an existing MongoDatabaseResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "mongoDatabaseName", - "in": "path", - "required": true, - "description": "The name of the MongoDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" - }, - "x-ms-long-running-operation": true - } - }, - "/{rootScope}/providers/Applications.Link/mongoDatabases/{mongoDatabaseName}/listSecrets": { - "post": { - "operationId": "MongoDatabases_ListSecrets", - "description": "Lists secrets values for the specified MongoDatabase resource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "mongoDatabaseName", - "in": "path", - "required": true, - "description": "The name of the MongoDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/MongoDatabaseListSecretsResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues": { - "get": { - "tags": [ - "RabbitMQMessageQueues" - ], - "operationId": "RabbitMqMessageQueues_ListByRootScope", - "description": "Lists information about all RabbitMQMessageQueueResources in the given root scope", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RabbitMQMessageQueueResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues/{rabbitMQMessageQueueName}": { - "get": { - "tags": [ - "RabbitMQMessageQueues" - ], - "operationId": "RabbitMqMessageQueues_Get", - "description": "Retrieves information about a RabbitMQMessageQueueResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "rabbitMQMessageQueueName", - "in": "path", - "required": true, - "description": "The name of the RabbitMQMessageQueue link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RabbitMQMessageQueueResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "RabbitMQMessageQueues" - ], - "operationId": "RabbitMqMessageQueues_CreateOrUpdate", - "description": "Creates or updates a RabbitMQMessageQueueResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "rabbitMQMessageQueueName", - "in": "path", - "required": true, - "description": "The name of the RabbitMQMessageQueue link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/RabbitMQMessageQueueResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RabbitMQMessageQueueResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/RabbitMQMessageQueueResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "RabbitMQMessageQueues" - ], - "operationId": "RabbitMqMessageQueues_Delete", - "description": "Deletes an existing RabbitMQMessageQueueResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "rabbitMQMessageQueueName", - "in": "path", - "required": true, - "description": "The name of the RabbitMQMessageQueue link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/rabbitMQMessageQueues/{rabbitMQMessageQueueName}/listSecrets": { - "post": { - "operationId": "RabbitMqMessageQueues_ListSecrets", - "description": "Lists secrets values for the specified RabbitMQMessageQueue resource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "rabbitMQMessageQueueName", - "in": "path", - "required": true, - "description": "The name of the RabbitMQMessageQueue link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RabbitMQListSecretsResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/redisCaches": { - "get": { - "tags": [ - "RedisCaches" - ], - "operationId": "RedisCaches_ListByRootScope", - "description": "Lists information about all RedisCacheResources in the given root scope", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RedisCacheResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/redisCaches/{redisCacheName}": { - "get": { - "tags": [ - "RedisCaches" - ], - "operationId": "RedisCaches_Get", - "description": "Retrieves information about a RedisCacheResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "redisCacheName", - "in": "path", - "required": true, - "description": "The name of the RedisCache link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RedisCacheResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "RedisCaches" - ], - "operationId": "RedisCaches_CreateOrUpdate", - "description": "Creates or updates a RedisCacheResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "redisCacheName", - "in": "path", - "required": true, - "description": "The name of the RedisCache link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/RedisCacheResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RedisCacheResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/RedisCacheResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "RedisCaches" - ], - "operationId": "RedisCaches_Delete", - "description": "Deletes an existing RedisCacheResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "redisCacheName", - "in": "path", - "required": true, - "description": "The name of the RedisCache link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "type": "string" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/redisCaches/{redisCacheName}/listSecrets": { - "post": { - "operationId": "RedisCaches_ListSecrets", - "description": "Lists secrets values for the specified RedisCache resource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "redisCacheName", - "in": "path", - "required": true, - "description": "The name of the RedisCache link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/RedisCacheListSecretsResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/sqlDatabases": { - "get": { - "tags": [ - "SqlDatabases" - ], - "operationId": "SqlDatabases_ListByRootScope", - "description": "Lists information about all SqlDatabaseResources in the given root scope", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/SqlDatabaseResourceListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - }, - "/{rootScope}/providers/Applications.Link/sqlDatabases/{sqlDatabaseName}": { - "get": { - "tags": [ - "SqlDatabases" - ], - "operationId": "SqlDatabases_Get", - "description": "Retrieves information about a SqlDatabaseResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "sqlDatabaseName", - "in": "path", - "required": true, - "description": "The name of the SqlDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/SqlDatabaseResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "put": { - "tags": [ - "SqlDatabases" - ], - "operationId": "SqlDatabases_CreateOrUpdate", - "description": "Creates or updates a SqlDatabaseResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "sqlDatabaseName", - "in": "path", - "required": true, - "description": "The name of the SqlDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - }, - { - "name": "resource", - "in": "body", - "required": true, - "description": "Resource create parameters.", - "schema": { - "$ref": "#/definitions/SqlDatabaseResource" - } - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/SqlDatabaseResource" - } - }, - "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, - "schema": { - "$ref": "#/definitions/SqlDatabaseResource" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - }, - "delete": { - "tags": [ - "SqlDatabases" - ], - "operationId": "SqlDatabases_Delete", - "description": "Deletes an existing SqlDatabaseResource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "sqlDatabaseName", - "in": "path", - "required": true, - "description": "The name of the SqlDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - } - }, - "204": { - "description": "Resource deleted successfully." - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/{rootScope}/providers/Applications.Link/sqlDatabases/{sqlDatabaseName}/listSecrets": { - "post": { - "operationId": "SqlDatabases_ListSecrets", - "description": "Lists secrets values for the specified SqlDatabase resource", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/RootScopeParam" - }, - { - "name": "sqlDatabaseName", - "in": "path", - "required": true, - "description": "The name of the SqlDatabase link resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", - "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "#/definitions/SqlDatabaseListSecretsResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - } - } - }, - "/providers/Applications.Link/operations": { - "get": { - "tags": [ - "Operations" - ], - "operationId": "Operations_List", - "description": "List the operations for the provider", - "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "ARM operation completed successfully.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/OperationListResult" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" - } - } - }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - } - } - } - }, - "definitions": { - "Application": { - "type": "string", - "description": "Fully qualified resource ID for the application that the link is consumed by" - }, - "BasicDaprResourceProperties": { - "type": "object", - "properties": { - "componentName": { - "type": "string", - "description": "The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.", - "readOnly": true - } - }, - "description": "Basic properties of a Dapr component object.", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "BasicResourceProperties": { - "type": "object", - "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource.", - "readOnly": true - }, - "environment": { - "type": "string", - "description": "Fully qualified resource ID for the environment that the link is linked to" - }, - "application": { - "$ref": "#/definitions/Application", - "description": "Fully qualified resource ID for the application that the link is consumed by" - } - }, - "description": "Basic properties of a Radius resource.", - "required": [ - "environment" - ] - }, - "DaprPubSubBrokerProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the daprPubSubBroker resource at the time the operation was called", - "readOnly": true - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - }, - "metadata": { - "$ref": "#/definitions/object", - "description": "Metadata for the daprPubSubBroker resource. This should match the values specified in Dapr component spec" - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the daprPubSubBroker link" - }, - "resources": { - "type": "array", - "items": { - "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "A collection of references to resources associated with the daprPubSubBroker" - }, - "type": { - "type": "string", - "description": "DaprPubSubBroker type. These strings match the format used by Dapr Kubernetes configuration format." - }, - "version": { - "type": "string", - "description": "Dapr component version" - } - }, - "description": "DaprPubSubBroker link properties", - "allOf": [ - { - "$ref": "#/definitions/BasicDaprResourceProperties" - } - ] - }, - "DaprPubSubBrokerResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/DaprPubSubBrokerProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] - } - }, - "description": "DaprPubSubBroker link", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "DaprPubSubBrokerResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/DaprPubSubBrokerResource" - }, - "x-cadl-name": "DaprPubSubBrokerResource[]", - "description": "The DaprPubSubBrokerResource items on this page" - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a DaprPubSubBrokerResource list operation.", - "required": [ - "value" - ] - }, - "DaprSecretStoreProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the dapr secret store link at the time the operation was called", - "readOnly": true - }, - "type": { - "type": "string", - "description": "Dapr Secret Store type. These strings match the types defined in Dapr Component format: https://docs.dapr.io/reference/components-reference/supported-secret-stores/" - }, - "version": { - "type": "string", - "description": "Dapr component version" - }, - "metadata": { - "$ref": "#/definitions/object", - "description": "Metadata for the Secret Store resource. This should match the values specified in Dapr component spec" - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the daprSecretStore link" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - } - }, - "description": "DaprSecretStore link properties", - "allOf": [ - { - "$ref": "#/definitions/BasicDaprResourceProperties" - } - ] - }, - "DaprSecretStoreResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/DaprSecretStoreProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] - } - }, - "description": "DaprSecretStore link", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "DaprSecretStoreResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/DaprSecretStoreResource" - }, - "x-cadl-name": "DaprSecretStoreResource[]", - "description": "The DaprSecretStoreResource items on this page" - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a DaprSecretStoreResource list operation.", - "required": [ - "value" - ] - }, - "DaprStateStoreProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the DaprStateStore link at the time the operation was called", - "readOnly": true - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - }, - "metadata": { - "$ref": "#/definitions/object", - "description": "Metadata for the state store resource. This should match the values specified in Dapr component spec" - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the daprStateStore link" - }, - "resources": { - "type": "array", - "items": { - "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "A collection of references to resources associated with the state store" - }, - "type": { - "type": "string", - "description": "Dapr StateStore type. These strings match the format used by Dapr Kubernetes configuration format." - }, - "version": { - "type": "string", - "description": "Dapr component version" - } - }, - "description": "DaprStateStore link properties", - "allOf": [ - { - "$ref": "#/definitions/BasicDaprResourceProperties" - } - ] - }, - "DaprStateStoreResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/DaprStateStoreProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] - } - }, - "description": "DaprStateStore link", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "DaprStateStoreResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/DaprStateStoreResource" - }, - "x-cadl-name": "DaprStateStoreResource[]", - "description": "The DaprStateStoreResource items on this page" - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a DaprStateStoreResource list operation.", - "required": [ - "value" - ] - }, - "MongoDatabaseListSecretsResult": { - "type": "object", - "properties": { - "password": { - "type": "string", - "description": "Password to use when connecting to the target Mongo database" - }, - "connectionString": { - "type": "string", - "description": "Connection string used to connect to the target Mongo database" - } - }, - "description": "The secret values for the given MongoDatabase resource" - }, - "MongoDatabaseProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the mongo database link at the time the operation was called", - "readOnly": true - }, - "secrets": { - "$ref": "#/definitions/MongoDatabaseSecrets", - "description": "Secret values provided for the resource" - }, - "host": { - "type": "string", - "description": "Host name of the target Mongo database" - }, - "port": { - "type": "integer", - "format": "int32", - "description": "Port value of the target Mongo database" - }, - "database": { - "type": "string", - "description": "Database name of the target Mongo database" - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the MongoDB link" - }, - "resources": { - "type": "array", - "items": { - "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the MongoDB resource" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - }, - "username": { - "type": "string", - "description": "Username to use when connecting to the target Mongo database" - } - }, - "description": "MongoDatabase link properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "MongoDatabaseResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/MongoDatabaseProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] - } - }, - "description": "MongoDatabase link", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "MongoDatabaseResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/MongoDatabaseResource" - }, - "x-cadl-name": "MongoDatabaseResource[]", - "description": "The MongoDatabaseResource items on this page" - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a MongoDatabaseResource list operation.", - "required": [ - "value" - ] - }, - "MongoDatabaseSecrets": { - "type": "object", - "properties": { - "password": { - "type": "string", - "description": "Password to use when connecting to the target Mongo database" - }, - "connectionString": { - "type": "string", - "description": "Connection string used to connect to the target Mongo database" - } - }, - "description": "The secret values for the given MongoDatabase resource" - }, - "OutputResource": { - "type": "object", - "properties": {}, - "description": "Properties of an output resource." - }, - "Parameters": { - "type": "object", - "properties": {}, - "description": "Key/value parameters to pass into the recipe at deployment" - }, - "ProvisioningState": { - "type": "string", - "description": "Provisioning state of the link at the time the operation was called", - "enum": [ - "Succeeded", - "Failed", - "Canceled", - "Provisioning", - "Updating", - "Deleting", - "Accepted" - ], - "x-ms-enum": { - "name": "ProvisioningState", - "modelAsString": true - } - }, - "RabbitMQListSecretsResult": { - "type": "object", - "properties": { - "password": { - "type": "string", - "description": "The password used to connect to the RabbitMQ instance" - }, - "uri": { - "type": "string", - "description": "The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value" - } - }, - "description": "The secret values for the given RabbitMQMessageQueue resource" - }, - "RabbitMQMessageQueueProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the rabbitMQ message queue link at the time the operation was called", - "readOnly": true - }, - "secrets": { - "$ref": "#/definitions/RabbitMQSecrets", - "description": "Secrets provided by resources," - }, - "queue": { - "type": "string", - "description": "The name of the queue" - }, - "host": { - "type": "string", - "description": "The hostname of the RabbitMQ instance" - }, - "port": { - "type": "integer", - "format": "int32", - "description": "The port of the RabbitMQ instance. Defaults to 5672" - }, - "vHost": { - "type": "string", - "description": "The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost." - }, - "username": { - "type": "string", - "description": "The username to use when connecting to the RabbitMQ instance" - }, - "resources": { - "type": "array", - "items": { - "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the rabbitMQ resource" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the rabbitMQ link" - }, - "tls": { - "type": "boolean", - "description": "Specifies whether to use SSL when connecting to the RabbitMQ instance" - } - }, - "description": "RabbitMQMessageQueue link properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "RabbitMQMessageQueueResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/RabbitMQMessageQueueProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] - } - }, - "description": "RabbitMQMessageQueue link", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "RabbitMQMessageQueueResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/RabbitMQMessageQueueResource" - }, - "x-cadl-name": "RabbitMQMessageQueueResource[]", - "description": "The RabbitMQMessageQueueResource items on this page" - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a RabbitMQMessageQueueResource list operation.", - "required": [ - "value" - ] - }, - "RabbitMQSecrets": { - "type": "object", - "properties": { - "password": { - "type": "string", - "description": "The password used to connect to the RabbitMQ instance" - }, - "uri": { - "type": "string", - "description": "The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value" - } - }, - "description": "The secret values for the given RabbitMQMessageQueue resource" - }, - "Recipe": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "The name of the recipe within the environment to use" - }, - "parameters": { - "$ref": "#/definitions/Parameters", - "description": "Key/value parameters to pass into the recipe at deployment" - } - }, - "description": "The recipe used to automatically deploy underlying infrastructure for a link", - "required": [ - "name" - ] - }, - "RedisCacheListSecretsResult": { - "type": "object", - "properties": { - "connectionString": { - "type": "string", - "description": "The connection string used to connect to the Redis cache" - }, - "password": { - "type": "string", - "description": "The password for this Redis cache instance" - }, - "url": { - "type": "string", - "description": "The URL used to connect to the Redis cache" - } - }, - "description": "The secret values for the given RedisCache resource" - }, - "RedisCacheProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the redis cache link at the time the operation was called", - "readOnly": true - }, - "secrets": { - "$ref": "#/definitions/RedisCacheSecrets", - "description": "Secrets provided by resource" - }, - "host": { - "type": "string", - "description": "The host name of the target Redis cache" - }, - "port": { - "type": "integer", - "format": "int32", - "description": "The port value of the target Redis cache" - }, - "username": { - "type": "string", - "description": "The username for Redis cache" - }, - "tls": { - "type": "boolean", - "description": "Specifies whether to enable SSL connections to the Redis cache" - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the Redis caches link" - }, - "resources": { - "type": "array", - "items": { - "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the Redis resource" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - } - }, - "description": "RedisCache link properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "RedisCacheResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/RedisCacheProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] - } - }, - "description": "RedisCache link", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "RedisCacheResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/RedisCacheResource" - }, - "x-cadl-name": "RedisCacheResource[]", - "description": "The RedisCacheResource items on this page" - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a RedisCacheResource list operation.", - "required": [ - "value" - ] - }, - "RedisCacheSecrets": { - "type": "object", - "properties": { - "connectionString": { - "type": "string", - "description": "The connection string used to connect to the Redis cache" - }, - "password": { - "type": "string", - "description": "The password for this Redis cache instance" - }, - "url": { - "type": "string", - "description": "The URL used to connect to the Redis cache" - } - }, - "description": "The secret values for the given RedisCache resource" - }, - "ResourceProvisioning": { - "type": "string", - "description": "Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.", - "enum": [ - "recipe", - "manual" - ], - "x-ms-enum": { - "name": "ResourceProvisioning", - "modelAsString": true - } - }, - "ResourceReference": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "Resource id of an existing resource" - } - }, - "description": "Describes a reference to an existing resource", - "required": [ - "id" - ] - }, - "ResourceStatus": { - "type": "object", - "properties": { - "outputResources": { - "type": "array", - "items": { - "$ref": "#/definitions/OutputResource" - }, - "x-ms-identifiers": [], - "x-cadl-name": "OutputResource[]", - "description": "Properties of an output resource" - } - }, - "description": "Status of a resource." - }, - "SqlDatabaseListSecretsResult": { - "type": "object", - "properties": { - "password": { - "type": "string", - "description": "Password to use when connecting to the target Sql database" - }, - "connectionString": { - "type": "string", - "description": "Connection string used to connect to the target Sql database" - } - }, - "description": "The secret values for the given SqlDatabase resource" - }, - "SqlDatabaseProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the Sql database link at the time the operation was called", - "readOnly": true - }, - "database": { - "type": "string", - "description": "The name of the Sql database." - }, - "server": { - "type": "string", - "description": "The fully qualified domain name of the Sql database." - }, - "port": { - "type": "integer", - "format": "int32", - "description": "Port value of the target Sql database" - }, - "username": { - "type": "string", - "description": "Username to use when connecting to the target Sql database" - }, - "recipe": { - "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the sqldatabases link" - }, - "resources": { - "type": "array", - "items": { - "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the SqlDatabase resource" - }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." - }, - "secrets": { - "$ref": "#/definitions/SqlDatabaseSecrets", - "description": "Secret values provided for the resource" - } - }, - "description": "SqlDatabase properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } - ] - }, - "SqlDatabaseResource": { - "type": "object", - "properties": { - "properties": { - "$ref": "#/definitions/SqlDatabaseProperties", - "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] - } - }, - "description": "SqlDatabase link", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" - } - ] - }, - "SqlDatabaseResourceListResult": { - "type": "object", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/SqlDatabaseResource" - }, - "x-cadl-name": "SqlDatabaseResource[]", - "description": "The SqlDatabaseResource items on this page" - }, - "nextLink": { - "type": "string", - "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" - } - }, - "description": "The response of a SqlDatabaseResource list operation.", - "required": [ - "value" - ] - }, - "SqlDatabaseSecrets": { - "type": "object", - "properties": { - "password": { - "type": "string", - "description": "Password to use when connecting to the target Sql database" - }, - "connectionString": { - "type": "string", - "description": "Connection string used to connect to the target Sql database" - } - }, - "description": "The secret values for the given SqlDatabase resource" - }, - "object": { - "type": "object", - "properties": {} - } - }, - "parameters": { - "RootScopeParam": { - "name": "rootScope", - "in": "path", - "required": true, - "description": "The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", - "minLength": 1, - "x-ms-parameter-location": "client", - "x-ms-skip-url-encoding": true, - "type": "string" - } - } -} diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesDelete.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesDelete.json deleted file mode 100644 index d4951bcf32..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesDelete.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "rabbitMQMessageQueueName": "rabbitmq0", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": {}, - "202": {}, - "204": {} - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesGet.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesGet.json deleted file mode 100644 index a3ba86102a..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesGet.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview", - "rabbitMQMessageQueueName": "rabbitmq0" - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Messaging/rabbitMQQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesList.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesList.json deleted file mode 100644 index 29cfdb4d75..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesList.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Messaging/rabbitMQQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0" - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", - "name": "rabbitmq1", - "type": "Applications.Messaging/rabbitMQQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesListByRootScope.json deleted file mode 100644 index 04651a266e..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesListByRootScope.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000", - "api-version": "2022-03-15-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Messaging/rabbitMQQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - }, - { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", - "name": "rabbitmq1", - "type": "Applications.Messaging/rabbitMQQueues", - "location": "global", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "recipe": { - "name": "sqldb", - "parameters":{ - "foo":"bar" - } - } - } - } - ], - "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Messaging/rabbitMQQueues?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesListSecrets.json deleted file mode 100644 index 5a329dbcdf..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesListSecrets.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "resourceGroupName": "testGroup", - "api-version": "2022-03-15-privatepreview", - "rabbitMQMessageQueueName": "rabbitmq0" - }, - "responses": { - "200": { - "body": { - "connectionString": "connection://string" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesPut.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesPut.json deleted file mode 100644 index c86b57ef4b..0000000000 --- a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueuesPut.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "parameters": { - "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", - "rabbitMQMessageQueueName": "rabbitmq0", - "api-version": "2022-03-15-privatepreview", - "RabbitMQMessageQueueParameters": { - "location": "West US", - "properties": { - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", - "name": "rabbitmq0", - "type": "Applications.Messaging/rabbitMQQueues", - "location": "West US", - "properties": { - "provisioningState": "Succeeded", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - }, - "201": { - "body": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", - "name": "rabbitmq1", - "type": "Applications.Messaging/rabbitMQQueues", - "location": "West US", - "properties": { - "provisioningState": "Accepted", - "application": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", - "environment": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Core/environments/env0", - "resourceProvisioning": "manual", - "queue": "rabbitmq0", - "secrets": { - "connectionString": "connection://string" - } - } - } - } - } - } - \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_CreateOrUpdate.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_CreateOrUpdate.json new file mode 100644 index 0000000000..cdec52a79e --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_CreateOrUpdate.json @@ -0,0 +1,59 @@ +{ + "operationId": "RabbitMqQueues_CreateOrUpdate", + "title": "Create Or Update a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "rabbitMQQueueName": "rabbitmq0", + "api-version": "2022-03-15-privatepreview", + "RabbitMQQueueParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Delete.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Delete.json new file mode 100644 index 0000000000..03da6f1c26 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "RabbitMqQueues_Delete", + "title": "Delete a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "rabbitMQQueueName": "rabbitmq0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Get.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Get.json new file mode 100644 index 0000000000..d3e9364fc3 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Get.json @@ -0,0 +1,29 @@ +{ + "operationId": "RabbitMqQueues_Get", + "title": "Get a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "rabbitMQQueueName": "rabbitmq0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_List.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_List.json new file mode 100644 index 0000000000..3e1c12abe3 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_List.json @@ -0,0 +1,47 @@ +{ + "operationId": "RabbitMqQueues_ListByScope", + "title": "List RabbitMQQueue resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_ListByRootScope.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_ListByRootScope.json new file mode 100644 index 0000000000..d24590182c --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_ListByRootScope.json @@ -0,0 +1,50 @@ +{ + "operationId": "RabbitMqQueues_ListByScope", + "title": "List RabbitMQQueue resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Messaging/rabbitMQQueues?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_ListSecrets.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_ListSecrets.json new file mode 100644 index 0000000000..e0d24405c6 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_ListSecrets.json @@ -0,0 +1,17 @@ +{ + "operationId": "RabbitMqQueues_ListSecrets", + "title": "List the secrets of a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "resourceGroupName": "testGroup", + "api-version": "2022-03-15-privatepreview", + "rabbitMQQueueName": "rabbitmq0" + }, + "responses": { + "200": { + "body": { + "connectionString": "connection://string" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Update.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Update.json new file mode 100644 index 0000000000..a845925ed0 --- /dev/null +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/examples/RabbitMQQueues_Update.json @@ -0,0 +1,59 @@ +{ + "operationId": "RabbitMqQueues_Update", + "title": "Update a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "rabbitMQQueueName": "rabbitmq0", + "api-version": "2022-03-15-privatepreview", + "rabbitMQQueueParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/openapi.json b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/openapi.json index 1cb8c90519..6d094818df 100644 --- a/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/openapi.json +++ b/swagger/specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/openapi.json @@ -1,12 +1,12 @@ { "swagger": "2.0", "info": { - "title": "Applications.Messaging Management APIs", + "title": "Applications.Messaging Resource Management APIs", "version": "2022-03-15-privatepreview", "description": "REST APIs for Applications.Messaging", - "x-cadl-generated": [ + "x-typespec-generated": [ { - "emitter": "@azure-tools/cadl-autorest" + "emitter": "@azure-tools/typespec-autorest" } ] }, @@ -49,17 +49,17 @@ "paths": { "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues": { "get": { + "operationId": "RabbitMqQueues_ListByScope", "tags": [ "RabbitMQQueues" ], - "operationId": "RabbitMqQueues_ListByRootScope", - "description": "Lists information about all RabbitMQQueueResources in the given root scope", + "description": "List RabbitMQQueueResource resources by Scope", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" } ], "responses": { @@ -76,6 +76,14 @@ } } }, + "x-ms-examples": { + "List RabbitMQQueue resources by resource group": { + "$ref": "./examples/RabbitMQQueues_List.json" + }, + "List RabbitMQQueue resources by rootScope": { + "$ref": "./examples/RabbitMQQueues_ListByRootScope.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -83,26 +91,26 @@ }, "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}": { "get": { + "operationId": "RabbitMqQueues_Get", "tags": [ "RabbitMQQueues" ], - "operationId": "RabbitMqQueues_Get", - "description": "Retrieves information about a RabbitMQQueueResource", + "description": "Get a RabbitMQQueueResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "rabbitMQQueueName", "in": "path", + "description": "The name of the RabbitMQQueue portable resource resource", "required": true, - "description": "The name of the RabbitMQQueue portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -118,35 +126,40 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a RabbitMQQueue resource": { + "$ref": "./examples/RabbitMQQueues_Get.json" + } } }, "put": { + "operationId": "RabbitMqQueues_CreateOrUpdate", "tags": [ "RabbitMQQueues" ], - "operationId": "RabbitMqQueues_CreateOrUpdate", - "description": "Creates or updates a RabbitMQQueueResource", + "description": "Create a RabbitMQQueueResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "rabbitMQQueueName", "in": "path", + "description": "The name of the RabbitMQQueue portable resource resource", "required": true, - "description": "The name of the RabbitMQQueue portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/RabbitMQQueueResource" } @@ -154,53 +167,132 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'RabbitMQQueueResource' update operation succeeded", "schema": { "$ref": "#/definitions/RabbitMQQueueResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'RabbitMQQueueResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/RabbitMQQueueResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create Or Update a RabbitMQQueue resource": { + "$ref": "./examples/RabbitMQQueues_CreateOrUpdate.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "RabbitMqQueues_Update", + "tags": [ + "RabbitMQQueues" + ], + "description": "Update a RabbitMQQueueResource", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/RootScopeParameter" + }, + { + "name": "rabbitMQQueueName", + "in": "path", + "description": "The name of the RabbitMQQueue portable resource resource", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/RabbitMQQueueResourceUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", "schema": { "$ref": "#/definitions/RabbitMQQueueResource" } }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Update a RabbitMQQueue resource": { + "$ref": "./examples/RabbitMQQueues_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true }, "delete": { + "operationId": "RabbitMqQueues_Delete", "tags": [ "RabbitMQQueues" ], - "operationId": "RabbitMqQueues_Delete", - "description": "Deletes an existing RabbitMQQueueResource", + "description": "Delete a RabbitMQQueueResource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "rabbitMQQueueName", "in": "path", + "description": "The name of the RabbitMQQueue portable resource resource", "required": true, - "description": "The name of the RabbitMQQueue portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -211,9 +303,13 @@ "description": "Resource deletion accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -226,29 +322,50 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Delete a RabbitMQQueue resource": { + "$ref": "./examples/RabbitMQQueues_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true } }, "/{rootScope}/providers/Applications.Messaging/rabbitMQQueues/{rabbitMQQueueName}/listSecrets": { "post": { "operationId": "RabbitMqQueues_ListSecrets", + "tags": [ + "RabbitMQQueues" + ], "description": "Lists secrets values for the specified RabbitMQQueue resource", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/RootScopeParam" + "$ref": "#/parameters/RootScopeParameter" }, { "name": "rabbitMQQueueName", "in": "path", + "description": "The name of the RabbitMQQueue portable resource resource", "required": true, - "description": "The name of the RabbitMQQueue portable resource", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "body", + "in": "body", + "description": "The content of the action request", + "required": true, + "schema": { + "type": "object", + "properties": {} + } } ], "responses": { @@ -264,15 +381,20 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "List the secrets of a RabbitMQQueue resource": { + "$ref": "./examples/RabbitMQQueues_ListSecrets.json" + } } } }, "/providers/Applications.Messaging/operations": { "get": { + "operationId": "Operations_List", "tags": [ "Operations" ], - "operationId": "Operations_List", "description": "List the operations for the provider", "parameters": [ { @@ -300,57 +422,109 @@ } }, "definitions": { - "Application": { - "type": "string", - "description": "Fully qualified resource ID for the application that the portable resource is consumed by" - }, - "BasicDaprResourceProperties": { + "EnvironmentCompute": { "type": "object", + "description": "Represents backing compute resource", "properties": { - "componentName": { + "kind": { "type": "string", - "description": "The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.", - "readOnly": true + "description": "Discriminator property for EnvironmentCompute." + }, + "resourceId": { + "type": "string", + "description": "The resource id of the compute resource for application environment." + }, + "identity": { + "$ref": "#/definitions/IdentitySettings", + "description": "Configuration for supported external identity providers" } }, - "description": "Basic properties of a Dapr component object.", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } + "discriminator": "kind", + "required": [ + "kind" ] }, - "BasicResourceProperties": { + "IdentitySettingKind": { + "type": "string", + "description": "IdentitySettingKind is the kind of supported external identity setting", + "enum": [ + "undefined", + "azure.com.workload" + ], + "x-ms-enum": { + "name": "IdentitySettingKind", + "modelAsString": true, + "values": [ + { + "name": "undefined", + "value": "undefined", + "description": "undefined identity" + }, + { + "name": "azure.com.workload", + "value": "azure.com.workload", + "description": "azure ad workload identity" + } + ] + } + }, + "IdentitySettings": { "type": "object", + "description": "IdentitySettings is the external identity setting.", "properties": { - "status": { - "$ref": "#/definitions/ResourceStatus", - "description": "Status of a resource.", - "readOnly": true + "kind": { + "$ref": "#/definitions/IdentitySettingKind", + "description": "kind of identity setting" }, - "environment": { + "oidcIssuer": { "type": "string", - "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + "description": "The URI for your compute platform's OIDC issuer" }, - "application": { - "$ref": "#/definitions/Application", - "description": "Fully qualified resource ID for the application that the portable resource is consumed by" + "resource": { + "type": "string", + "description": "The resource ID of the provisioned identity" } }, - "description": "Basic properties of a Radius resource.", "required": [ - "environment" + "kind" ] }, - "OutputResource": { + "KubernetesCompute": { "type": "object", - "properties": {}, - "description": "Properties of an output resource." + "description": "The Kubernetes compute configuration", + "properties": { + "namespace": { + "type": "string", + "description": "The namespace to use for the environment." + } + }, + "required": [ + "namespace" + ], + "allOf": [ + { + "$ref": "#/definitions/EnvironmentCompute" + } + ], + "x-ms-discriminator-value": "kubernetes" }, - "Parameters": { + "OutputResource": { "type": "object", - "properties": {}, - "description": "Key/value parameters to pass into the recipe at deployment" + "description": "Properties of an output resource.", + "properties": { + "localId": { + "type": "string", + "description": "The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships." + }, + "id": { + "type": "string", + "description": "The UCP resource ID of the underlying resource." + }, + "radiusManaged": { + "type": "boolean", + "description": "Determines whether Radius manages the lifecycle of the underlying resource." + } + } }, "ProvisioningState": { "type": "string", @@ -366,11 +540,50 @@ ], "x-ms-enum": { "name": "ProvisioningState", - "modelAsString": true - } + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + }, + { + "name": "Provisioning", + "value": "Provisioning", + "description": "The resource is being provisioned" + }, + { + "name": "Updating", + "value": "Updating", + "description": "The resource is updating" + }, + { + "name": "Deleting", + "value": "Deleting", + "description": "The resource is being deleted" + }, + { + "name": "Accepted", + "value": "Accepted", + "description": "The resource create request has been accepted" + } + ] + }, + "readOnly": true }, "RabbitMQListSecretsResult": { "type": "object", + "description": "The secret values for the given RabbitMQQueue resource", "properties": { "password": { "type": "string", @@ -380,20 +593,33 @@ "type": "string", "description": "The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value" } - }, - "description": "The secret values for the given RabbitMQQueue resource" + } }, "RabbitMQQueueProperties": { "type": "object", + "description": "RabbitMQQueue portable resource properties", "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, "provisioningState": { "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the rabbitMQ message queue portable resource at the time the operation was called", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, + "status": { + "$ref": "#/definitions/ResourceStatus", + "description": "Status of a resource.", "readOnly": true }, "secrets": { "$ref": "#/definitions/RabbitMQSecrets", - "description": "Secrets provided by resources," + "description": "The secrets to connect to the RabbitMQ instance" }, "queue": { "type": "string", @@ -418,34 +644,31 @@ }, "resources": { "type": "array", + "description": "List of the resource IDs that support the rabbitMQ resource", "items": { "$ref": "#/definitions/ResourceReference" - }, - "x-cadl-name": "ResourceReference[]", - "description": "List of the resource IDs that support the rabbitMQ resource" + } }, - "resourceProvisioning": { - "$ref": "#/definitions/ResourceProvisioning", - "description": "Specifies how the underlying service/resource is provisioned and managed." + "tls": { + "type": "boolean", + "description": "Specifies whether to use SSL when connecting to the RabbitMQ instance" }, "recipe": { "$ref": "#/definitions/Recipe", - "description": "The recipe used to automatically deploy underlying infrastructure for the rabbitMQQueue portable resource" + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" }, - "tls": { - "type": "boolean", - "description": "Specifies whether to use SSL when connecting to the RabbitMQ instance" + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." } }, - "description": "RabbitMQQueue portable resource properties", - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } + "required": [ + "environment" ] }, "RabbitMQQueueResource": { "type": "object", + "description": "RabbitMQQueue portable resource", "properties": { "properties": { "$ref": "#/definitions/RabbitMQQueueProperties", @@ -457,7 +680,6 @@ ] } }, - "description": "RabbitMQQueue portable resource", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -466,29 +688,103 @@ }, "RabbitMQQueueResourceListResult": { "type": "object", + "description": "The response of a RabbitMQQueueResource list operation.", "properties": { "value": { "type": "array", + "description": "The RabbitMQQueueResource items on this page", "items": { "$ref": "#/definitions/RabbitMQQueueResource" - }, - "x-cadl-name": "RabbitMQQueueResource[]", - "description": "The RabbitMQQueueResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a RabbitMQQueueResource list operation.", "required": [ "value" ] }, + "RabbitMQQueueResourceUpdate": { + "type": "object", + "description": "The type used for update operations of the RabbitMQQueueResource.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + }, + "properties": { + "$ref": "#/definitions/RabbitMQQueueResourceUpdateProperties", + "x-ms-client-flatten": true + } + } + }, + "RabbitMQQueueResourceUpdateProperties": { + "type": "object", + "description": "The updatable properties of the RabbitMQQueueResource.", + "properties": { + "environment": { + "type": "string", + "description": "Fully qualified resource ID for the environment that the portable resource is linked to" + }, + "application": { + "type": "string", + "description": "Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)" + }, + "secrets": { + "$ref": "#/definitions/RabbitMQSecrets", + "description": "The secrets to connect to the RabbitMQ instance" + }, + "queue": { + "type": "string", + "description": "The name of the queue" + }, + "host": { + "type": "string", + "description": "The hostname of the RabbitMQ instance" + }, + "port": { + "type": "integer", + "format": "int32", + "description": "The port of the RabbitMQ instance. Defaults to 5672" + }, + "vHost": { + "type": "string", + "description": "The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost." + }, + "username": { + "type": "string", + "description": "The username to use when connecting to the RabbitMQ instance" + }, + "resources": { + "type": "array", + "description": "List of the resource IDs that support the rabbitMQ resource", + "items": { + "$ref": "#/definitions/ResourceReference" + } + }, + "tls": { + "type": "boolean", + "description": "Specifies whether to use SSL when connecting to the RabbitMQ instance" + }, + "recipe": { + "$ref": "#/definitions/RecipeUpdate", + "description": "The recipe used to automatically deploy underlying infrastructure for the resource" + }, + "resourceProvisioning": { + "$ref": "#/definitions/ResourceProvisioning", + "description": "Specifies how the underlying service/resource is provisioned and managed." + } + } + }, "RabbitMQSecrets": { "type": "object", + "description": "The connection secrets properties to the RabbitMQ instance", "properties": { "password": { "type": "string", @@ -498,26 +794,41 @@ "type": "string", "description": "The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value" } - }, - "description": "The secret values for the given RabbitMQQueue resource" + } }, "Recipe": { "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", "properties": { "name": { "type": "string", "description": "The name of the recipe within the environment to use" }, "parameters": { - "$ref": "#/definitions/Parameters", - "description": "Key/value parameters to pass into the recipe at deployment" + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} } }, - "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", "required": [ "name" ] }, + "RecipeUpdate": { + "type": "object", + "description": "The recipe used to automatically deploy underlying infrastructure for a portable resource", + "properties": { + "name": { + "type": "string", + "description": "The name of the recipe within the environment to use" + }, + "parameters": { + "type": "object", + "description": "Key/value parameters to pass into the recipe at deployment", + "properties": {} + } + } + }, "ResourceProvisioning": { "type": "string", "description": "Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.", @@ -527,48 +838,81 @@ ], "x-ms-enum": { "name": "ResourceProvisioning", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "recipe", + "value": "recipe", + "description": "The resource lifecycle will be managed by Radius" + }, + { + "name": "manual", + "value": "manual", + "description": "The resource lifecycle will be managed by the user" + } + ] } }, "ResourceReference": { "type": "object", + "description": "Describes a reference to an existing resource", "properties": { "id": { "type": "string", "description": "Resource id of an existing resource" } }, - "description": "Describes a reference to an existing resource", "required": [ "id" ] }, "ResourceStatus": { "type": "object", + "description": "Status of a resource.", "properties": { + "compute": { + "$ref": "#/definitions/EnvironmentCompute", + "description": "The compute resource associated with the resource." + }, "outputResources": { "type": "array", + "description": "Properties of an output resource", "items": { "$ref": "#/definitions/OutputResource" }, - "x-ms-identifiers": [], - "x-cadl-name": "OutputResource[]", - "description": "Properties of an output resource" + "x-ms-identifiers": [] } - }, - "description": "Status of a resource." + } + }, + "Versions": { + "type": "string", + "description": "Supported API versions for the Applications.Messaging resource provider.", + "enum": [ + "2022-03-15-privatepreview" + ], + "x-ms-enum": { + "name": "Versions", + "modelAsString": true, + "values": [ + { + "name": "v2022_03_15_privatepreview", + "value": "2022-03-15-privatepreview", + "description": "2022-03-15-privatepreview" + } + ] + } } }, "parameters": { - "RootScopeParam": { + "RootScopeParameter": { "name": "rootScope", "in": "path", + "description": "The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} and Azure resource scope is /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", "required": true, - "description": "The scope in which the resource is present. For Azure resource this would be /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}", + "type": "string", "minLength": 1, "x-ms-parameter-location": "client", - "x-ms-skip-url-encoding": true, - "type": "string" + "x-ms-skip-url-encoding": true } } } diff --git a/swagger/specification/applications/resource-manager/readme.csharp.md b/swagger/specification/applications/resource-manager/readme.csharp.md index 7b7ca2b331..fdb375793f 100644 --- a/swagger/specification/applications/resource-manager/readme.csharp.md +++ b/swagger/specification/applications/resource-manager/readme.csharp.md @@ -68,17 +68,7 @@ tag: package-messaging-2022-03-15-privatepreview ``` yaml $(tag) == 'package-core-2022-03-15-privatepreview' output-folder: $(csharp-sdks-folder)/applications/management/2022-03-15-privatepreview/core/src/Generated input-file: -- Applications.Core/preview/2022-03-15-privatepreview/global.json -- Applications.Core/preview/2022-03-15-privatepreview/environments.json -- Applications.Core/preview/2022-03-15-privatepreview/applications.json -``` - -### Tag: package-link-2022-03-15-privatepreview -``` yaml $(tag) == 'package-link-2022-03-15-privatepreview' -output-folder: $(csharp-sdks-folder)/applications/management/2022-03-15-privatepreview/link/src/Generated -input-file: -- Applications.Link/preview/2022-03-15-privatepreview/openapi.json -- Applications.Link/preview/2022-03-15-privatepreview/extenders.json +- Applications.Core/preview/2022-03-15-privatepreview/openapi.json ``` ### Tag: package-dapr-2022-03-15-privatepreview diff --git a/swagger/specification/applications/resource-manager/readme.md b/swagger/specification/applications/resource-manager/readme.md index 72dd1cafe6..d84c42f28e 100644 --- a/swagger/specification/applications/resource-manager/readme.md +++ b/swagger/specification/applications/resource-manager/readme.md @@ -43,25 +43,7 @@ These settings apply only when `--tag=package-core-2022-03-15-privatepreview` is ``` yaml $(tag) == 'package-core-2022-03-15-privatepreview' input-file: - - Applications.Core/preview/2022-03-15-privatepreview/global.json - - Applications.Core/preview/2022-03-15-privatepreview/environments.json - - Applications.Core/preview/2022-03-15-privatepreview/applications.json - - Applications.Core/preview/2022-03-15-privatepreview/httpRoutes.json - - Applications.Core/preview/2022-03-15-privatepreview/gateways.json - - Applications.Core/preview/2022-03-15-privatepreview/containers.json - - Applications.Core/preview/2022-03-15-privatepreview/volumes.json - - Applications.Core/preview/2022-03-15-privatepreview/secretstores.json - - Applications.Core/preview/2022-03-15-privatepreview/extenders.json -``` - -### Tag: package-link-2022-03-15-privatepreview - -These settings apply only when `--tag=package-link-2022-03-15-privatepreview` is specified on the command line. - -``` yaml $(tag) == 'package-link-2022-03-15-privatepreview' -input-file: - - Applications.Link/preview/2022-03-15-privatepreview/openapi.json - - Applications.Link/preview/2022-03-15-privatepreview/extenders.json + - Applications.Core/preview/2022-03-15-privatepreview/openapi.json ``` ### Tag: package-dapr-2022-03-15-privatepreview diff --git a/swagger/specification/applications/resource-manager/readme.python.md b/swagger/specification/applications/resource-manager/readme.python.md index 538f7762a8..85acb122c3 100644 --- a/swagger/specification/applications/resource-manager/readme.python.md +++ b/swagger/specification/applications/resource-manager/readme.python.md @@ -35,19 +35,6 @@ python: output-folder: $(python-sdks-folder)/applications/azure-mgmt-applications/azure/mgmt/applications/core/v2022_03_15_privatepreview ``` -### Tag: package-link-2022-03-15-privatepreview and python - -These settings apply only when `--tag=package-link-2022-03-15-privatepreview --python` is specified on the command line. -Please also specify `--python-sdks-folder=`. - -``` yaml $(tag) == 'package-link-2022-03-15-privatepreview' -namespace: azure.mgmt.applications.link.v2022_03_15_privatepreview -output-folder: $(python-sdks-folder)/applications/azure-mgmt-applications/azure/mgmt/applications/link/v2022_03_15_privatepreview -python: - namespace: azure.mgmt.applications.link.v2022_03_15_privatepreview - output-folder: $(python-sdks-folder)/applications/azure-mgmt-applications/azure/mgmt/applications/link/v2022_03_15_privatepreview -``` - ### Python multi-api Generate all API versions currently shipped for this package diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialDelete.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialDelete.json deleted file mode 100644 index c60afc6aa0..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "aws", - "planeName": "awscloud", - "credentialName": "default" - }, - "responses": { - "200": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialGet.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialGet.json deleted file mode 100644 index b96132b560..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialGet.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "aws", - "planeName": "awscloud", - "credentialName": "default" - }, - "responses": { - "200": { - "body": { - "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", - "name": "default", - "type": "System.AWS/credentials", - "location": "us-west-2", - "properties": { - "kind": "AccessKey", - "storage": { - "kind": "Internal", - "secretName": "aws-awscloud-default" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialList.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialList.json deleted file mode 100644 index 0ecba5c633..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialList.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "aws", - "planeName": "awscloud" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", - "name": "default", - "type": "System.AWS/credentials", - "location": "us-west-2", - "properties": { - "kind": "AccessKey", - "storage": { - "kind": "Internal", - "secretName": "aws-awscloud-default" - } - } - } - ] - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialPut.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialPut.json deleted file mode 100644 index 6ba724a842..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredentialPut.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "aws", - "planeName": "aws", - "credentialName": "default", - "Credential": { - "location": "us-west-2", - "properties": { - "kind": "AccessKey", - "accessKeyId": "enterAccessKeyIdHere", - "secretAccessKey": "enterSecretAccessKey", - "storage": { - "kind": "Internal" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", - "name": "default", - "type": "System.AWS/credentials", - "location": "us-west-2", - "properties": { - "kind": "AccessKey", - "storage": { - "kind": "Internal", - "secretName": "aws-awscloud-default" - } - } - } - }, - "201": { - "body": { - "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", - "name": "default", - "type": "System.AWS/credentials", - "location": "us-west-2", - "properties": { - "kind": "AccessKey", - "storage": { - "kind": "Internal", - "secretName": "aws-awscloud-default" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_CreateOrUpdate.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_CreateOrUpdate.json new file mode 100644 index 0000000000..c7fef81833 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_CreateOrUpdate.json @@ -0,0 +1,53 @@ +{ + "operationId": "AwsCredentials_CreateOrUpdate", + "title": "Create or update a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "aws", + "credentialName": "default", + "Credential": { + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "accessKeyId": "enterAccessKeyIdHere", + "secretAccessKey": "enterSecretAccessKey", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + }, + "201": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Delete.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Delete.json new file mode 100644 index 0000000000..30907afdbe --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "AwsCredentials_Delete", + "title": "Delete a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "awscloud", + "credentialName": "default" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Get.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Get.json new file mode 100644 index 0000000000..1d6b3ee794 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Get.json @@ -0,0 +1,27 @@ +{ + "operationId": "AwsCredentials_Get", + "title": "Get a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "awscloud", + "credentialName": "default" + }, + "responses": { + "200": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_List.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_List.json new file mode 100644 index 0000000000..53baf9b1cb --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_List.json @@ -0,0 +1,30 @@ +{ + "operationId": "AwsCredentials_List", + "title": "List AWS credentials", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "awscloud" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Update.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Update.json new file mode 100644 index 0000000000..f9de8aaac1 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AWSCredential_Update.json @@ -0,0 +1,53 @@ +{ + "operationId": "AwsCredentials_Update", + "title": "Update a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "aws", + "credentialName": "default", + "Credential": { + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "accessKeyId": "enterAccessKeyIdHere", + "secretAccessKey": "enterSecretAccessKey", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + }, + "201": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialDelete.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialDelete.json deleted file mode 100644 index a47138f890..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialDelete.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "azure", - "planeName": "azurecloud", - "credentialName": "default" - }, - "responses": { - "200": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialGet.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialGet.json deleted file mode 100644 index cff9c5853f..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialGet.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "azure", - "planeName": "azurecloud", - "credentialName": "default" - }, - "responses": { - "200": { - "body": { - "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", - "name": "default", - "type": "System.Azure/credentials", - "location": "west-us-2", - "properties": { - "kind": "ServicePrincipal", - "tenantId": "00000000-0000-0000-0000-000000000000", - "clientId": "00000000-0000-0000-0000-000000000000", - "storage": { - "kind": "Internal", - "secretName": "azure-azurecloud-default" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialList.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialList.json deleted file mode 100644 index 94e104644d..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialList.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "azure", - "planeName": "azurecloud" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", - "name": "default", - "type": "System.Azure/credentials", - "location": "west-us-2", - "properties": { - "kind": "ServicePrincipal", - "tenantId": "00000000-0000-0000-0000-000000000000", - "clientId": "00000000-0000-0000-0000-000000000000", - "storage": { - "kind": "Internal", - "secretName": "azure-azurecloud-default" - } - } - } - ] - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialPut.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialPut.json deleted file mode 100644 index 92779ffd52..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredentialPut.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "azure", - "planeName": "azurecloud", - "credentialName": "default", - "Credential": { - "location": "west-us-2", - "properties": { - "kind": "ServicePrincipal", - "clientId": "00000000-0000-0000-0000-000000000000", - "clientSecret": "secretString", - "tenantId": "00000000-0000-0000-0000-000000000000", - "storage": { - "kind": "Internal" - } - } - } - }, - "responses": { - "200": { - "body": { - "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", - "name": "default", - "type": "System.Azure/credentials", - "location": "west-us-2", - "properties": { - "kind": "ServicePrincipal", - "tenantId": "00000000-0000-0000-0000-000000000000", - "clientId": "00000000-0000-0000-0000-000000000000", - "storage": { - "kind": "Internal" - } - } - } - }, - "201": { - "body": { - "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", - "name": "default", - "type": "System.Azure/credentials", - "location": "west-us-2", - "properties": { - "kind": "ServicePrincipal", - "tenantId": "00000000-0000-0000-0000-000000000000", - "clientId": "00000000-0000-0000-0000-000000000000", - "storage": { - "kind": "Internal", - "secretName": "azure-azurecloud-default" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_CreateOrUpdate.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_CreateOrUpdate.json new file mode 100644 index 0000000000..f2aad4bdc4 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_CreateOrUpdate.json @@ -0,0 +1,57 @@ +{ + "operationId": "AzureCredentials_CreateOrUpdate", + "title": "Create or update a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default", + "Credential": { + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "clientId": "00000000-0000-0000-0000-000000000000", + "clientSecret": "secretString", + "tenantId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "201": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Delete.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Delete.json new file mode 100644 index 0000000000..6d034d1e3b --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "AzureCredentials_Delete", + "title": "Delete a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Get.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Get.json new file mode 100644 index 0000000000..90eede6d4a --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Get.json @@ -0,0 +1,29 @@ +{ + "operationId": "AzureCredentials_Get", + "title": "Get a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default" + }, + "responses": { + "200": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_List.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_List.json new file mode 100644 index 0000000000..4f6ab2d815 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_List.json @@ -0,0 +1,32 @@ +{ + "operationId": "AzureCredentials_List", + "title": "List Azure credentials", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Update.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Update.json new file mode 100644 index 0000000000..916dff73b8 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/AzureCredential_Update.json @@ -0,0 +1,57 @@ +{ + "operationId": "AzureCredentials_Update", + "title": "Update a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default", + "Credential": { + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "clientId": "00000000-0000-0000-0000-000000000000", + "clientSecret": "secretString", + "tenantId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "201": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesDeletePlaneLocal.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesDeletePlaneLocal.json deleted file mode 100644 index 44b422c728..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesDeletePlaneLocal.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "radius", - "planeName": "local" - }, - "responses": { - "200": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesGetPlaneLocal.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesGetPlaneLocal.json deleted file mode 100644 index a72c5cac66..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesGetPlaneLocal.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeName": "local", - "planeType": "radius" - }, - "responses": { - "200": { - "body": { - "id": "/planes/radius/local", - "name": "local", - "type": "System.Planes/radius", - "location": "global", - "properties": { - "resourceProviders": { - "Applications.Link": "http://applications-rp.radius-system:5444", - "Applications.Core": "http://applications-rp.radius-system:5443" - }, - "kind": "UCPNative" - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesList.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesList.json deleted file mode 100644 index e0a301e0d6..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesList.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/planes/radius/local", - "name": "local", - "type": "System.Planes/radius", - "location": "global", - "properties": { - "resourceProviders": { - "Applications.Link": "http://applications-rp.radius-system:5444", - "Applications.Core": "http://applications-rp.radius-system:5443", - "Microsoft.Resources": "http://bicep-de.radius-system:6443" - }, - "kind": "UCPNative" - } - } - ] - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesPutPlaneLocal.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesPutPlaneLocal.json deleted file mode 100644 index 776abac3e3..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesPutPlaneLocal.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeName": "local", - "planeType": "radius", - "Plane": { - "location": "global", - "properties": { - "kind": "UCPNative", - "resourceProviders": { - "Applications.Core": "http://localhost:7443" - } - } - } - }, - "responses": { - "200": { - "body": { - "location": "global", - "id": "/planes/radius/local", - "name": "local", - "type": "System.Planes/radius", - "properties": { - "kind": "UCPNative", - "resourceProviders": { - "Applications.Core": "http://localhost:7443" - } - } - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesTypeList.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesTypeList.json deleted file mode 100644 index ced82b43bb..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/PlanesTypeList.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "parameters": { - "planeType": "radius", - "api-version": "2022-09-01-privatepreview" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/planes/radius/local", - "name": "local", - "type": "System.Planes/radius", - "location": "global", - "properties": { - "resourceProviders": { - "Applications.Link": "http://applications-rp.radius-system:5444", - "Applications.Core": "http://applications-rp.radius-system:5443" - }, - "kind": "UCPNative" - } - } - ] - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_CreateOrUpdate.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_CreateOrUpdate.json new file mode 100644 index 0000000000..12de0f2d68 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_CreateOrUpdate.json @@ -0,0 +1,34 @@ +{ + "operationId": "Planes_CreateOrUpdate", + "title": "Create or update a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "Plane": { + "location": "global", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_Delete.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_Delete.json new file mode 100644 index 0000000000..9467f217ba --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_Delete.json @@ -0,0 +1,13 @@ +{ + "operationId": "Planes_Delete", + "title": "Delete a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "radius", + "planeName": "local" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_GetPlaneLocal.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_GetPlaneLocal.json new file mode 100644 index 0000000000..ba3efe8c02 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_GetPlaneLocal.json @@ -0,0 +1,26 @@ +{ + "operationId": "Planes_Get", + "title": "Get a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "location": "global", + "properties": { + "resourceProviders": { + "Applications.Datastores": "http://applications-rp.radius-system:5444", + "Applications.Core": "http://applications-rp.radius-system:5443" + }, + "kind": "UCPNative" + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_List.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_List.json new file mode 100644 index 0000000000..2f22f7beb5 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_List.json @@ -0,0 +1,29 @@ +{ + "operationId": "Planes_ListPlanes", + "title": "List planes", + "parameters": { + "api-version": "2022-09-01-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "location": "global", + "properties": { + "resourceProviders": { + "Applications.Datastores": "http://applications-rp.radius-system:5444", + "Applications.Core": "http://applications-rp.radius-system:5443", + "Microsoft.Resources": "http://bicep-de.radius-system:6443" + }, + "kind": "UCPNative" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_ListPlanesByType.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_ListPlanesByType.json new file mode 100644 index 0000000000..1544d77af2 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_ListPlanesByType.json @@ -0,0 +1,29 @@ +{ + "operationId": "Planes_ListByType", + "title": "List planes by planeType", + "parameters": { + "planeType": "radius", + "api-version": "2022-09-01-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "location": "global", + "properties": { + "resourceProviders": { + "Applications.Datastores": "http://applications-rp.radius-system:5444", + "Applications.Core": "http://applications-rp.radius-system:5443" + }, + "kind": "UCPNative" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_Update.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_Update.json new file mode 100644 index 0000000000..08b77b42ca --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Planes_Update.json @@ -0,0 +1,34 @@ +{ + "operationId": "Planes_Update", + "title": "Update a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "Plane": { + "location": "global", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsDeleteResourceGroupRG1.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsDeleteResourceGroupRG1.json deleted file mode 100644 index 87a04e79fa..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsDeleteResourceGroupRG1.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "resourceGroupName": "rg1", - "planeType": "radius", - "planeName": "local" - }, - "responses": { - "200": {}, - "204": {} - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsGetResourceGroupRG1.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsGetResourceGroupRG1.json deleted file mode 100644 index 2721aaa286..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsGetResourceGroupRG1.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeName": "local", - "planeType": "radius", - "resourceGroupName": "rg1" - }, - "responses": { - "200": { - "body": { - "id": "/planes/radius/local/resourcegroups/rg1", - "name": "rg1", - "location": "global" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsList.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsList.json deleted file mode 100644 index a6e89ac3ce..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsList.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeName": "local", - "planeType": "radius" - }, - "responses": { - "200": { - "body": { - "value": [ - { - "id": "/planes/radius/local/resourcegroups/rg1", - "name": "rg1", - "location": "global" - }, - { - "id": "/planes/radius/local/resourcegroups/rg2", - "name": "rg2", - "location": "global" - } - ] - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsPutResourceGroupRG1.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsPutResourceGroupRG1.json deleted file mode 100644 index 0bb0706a77..0000000000 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroupsPutResourceGroupRG1.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "parameters": { - "api-version": "2022-09-01-privatepreview", - "planeType": "radius", - "planeName": "local", - "resourceGroupName": "rg1", - "ResourceGroup": { - "location": "global" - } - }, - "responses": { - "200": { - "body": { - "location": "global", - "id": "/planes/radius/local/resourcegroups/rg1", - "name": "rg1" - } - } - } -} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_CreateOrUpdate.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_CreateOrUpdate.json new file mode 100644 index 0000000000..889ee27bb1 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_CreateOrUpdate.json @@ -0,0 +1,22 @@ +{ + "operationId": "ResourceGroups_CreateOrUpdate", + "title": "Create or update a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "radius", + "planeName": "local", + "resourceGroupName": "rg1", + "ResourceGroup": { + "location": "global" + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Delete.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Delete.json new file mode 100644 index 0000000000..df56306964 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "ResourceGroups_Delete", + "title": "Delete a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "resourceGroupName": "rg1", + "planeType": "radius", + "planeName": "local" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Get.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Get.json new file mode 100644 index 0000000000..c64ec98f63 --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Get.json @@ -0,0 +1,19 @@ +{ + "operationId": "ResourceGroups_Get", + "title": "Get a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "resourceGroupName": "rg1" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1", + "location": "global" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_List.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_List.json new file mode 100644 index 0000000000..3e67b7150c --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_List.json @@ -0,0 +1,27 @@ +{ + "operationId": "ResourceGroups_List", + "title": "List resource groups", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1", + "location": "global" + }, + { + "id": "/planes/radius/local/resourcegroups/rg2", + "name": "rg2", + "location": "global" + } + ] + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Update.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Update.json new file mode 100644 index 0000000000..abcd61906a --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/ResourceGroups_Update.json @@ -0,0 +1,22 @@ +{ + "operationId": "ResourceGroups_Update", + "title": "Update a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "radius", + "planeName": "local", + "resourceGroupName": "rg1", + "ResourceGroup": { + "location": "global" + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1" + } + } + } +} \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Resources_List.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Resources_List.json new file mode 100644 index 0000000000..47836a988a --- /dev/null +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/examples/Resources_List.json @@ -0,0 +1,30 @@ +{ + "operationId": "Resources_List", + "title": "List resources in a resource group.", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "resourceGroupName": "rg1" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourcegroups/rg1/providers/Applications.Core/containers/my-container", + "name": "my-container", + "location": "global", + "type": "Applications.Core/containers" + }, + { + "id": "/planes/radius/local/resourcegroups/rg1/providers/Applications.Core/applications/my-application", + "name": "my-application", + "location": "global", + "type": "Applications.Core/applications" + } + ] + } + } + } + } \ No newline at end of file diff --git a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/openapi.json b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/openapi.json index 6f7ca2f469..a1a88fa46c 100644 --- a/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/openapi.json +++ b/swagger/specification/ucp/resource-manager/UCP/preview/2022-09-01-privatepreview/openapi.json @@ -1,12 +1,12 @@ { "swagger": "2.0", "info": { - "title": "UCP Management APIs", + "title": "Universal Control Plane Resource Management APIs", "version": "2022-09-01-privatepreview", - "description": "REST APIs for UCP", - "x-cadl-generated": [ + "description": "REST APIs for Universal Control Plane", + "x-typespec-generated": [ { - "emitter": "@azure-tools/cadl-autorest" + "emitter": "@azure-tools/typespec-autorest" } ] }, @@ -43,26 +43,26 @@ "name": "Planes" }, { - "name": "PlaneTypes" + "name": "ResourceGroups" }, { - "name": "ResourceGroups" + "name": "Resources" }, { - "name": "AzureCredential" + "name": "AwsCredentials" }, { - "name": "AWSCredential" + "name": "AzureCredentials" } ], "paths": { "/planes": { "get": { + "operationId": "Planes_ListPlanes", "tags": [ "Planes" ], - "operationId": "Planes_ListByRootScope", - "description": "Lists information about all PlaneResources in the given plane", + "description": "List all planes", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -82,6 +82,11 @@ } } }, + "x-ms-examples": { + "List planes": { + "$ref": "./examples/Planes_List.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -89,11 +94,11 @@ }, "/planes/{planeType}": { "get": { + "operationId": "Planes_ListByType", "tags": [ - "PlaneTypes" + "Planes" ], - "operationId": "PlaneTypes_Get", - "description": "Retrieves information about a PlaneResource", + "description": "List planes by type", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -101,8 +106,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" } ], @@ -110,7 +115,7 @@ "200": { "description": "ARM operation completed successfully.", "schema": { - "$ref": "#/definitions/PlaneResource" + "$ref": "#/definitions/PlaneResourceListResult" } }, "default": { @@ -119,16 +124,24 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "List planes by planeType": { + "$ref": "./examples/Planes_ListPlanesByType.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" } } }, "/planes/{planeType}/{planeName}": { "get": { + "operationId": "Planes_Get", "tags": [ "Planes" ], - "operationId": "Planes_Get", - "description": "Retrieves information about a PlaneResource", + "description": "Get a plane by name", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -136,8 +149,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" }, { @@ -157,14 +170,19 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a plane": { + "$ref": "./examples/Planes_GetPlaneLocal.json" + } } }, "put": { + "operationId": "Planes_CreateOrUpdate", "tags": [ "Planes" ], - "operationId": "Planes_CreateOrUpdate", - "description": "Creates or updates a PlaneResource", + "description": "Create or update a plane", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -172,8 +190,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" }, { @@ -182,8 +200,8 @@ { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/PlaneResource" } @@ -191,38 +209,115 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'PlaneResource' update operation succeeded", "schema": { "$ref": "#/definitions/PlaneResource" } }, "201": { - "description": "ARM create operation completed successfully.", + "description": "Resource 'PlaneResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/PlaneResource" + }, "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." } - }, + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "Create or update a plane": { + "$ref": "./examples/Planes_CreateOrUpdate.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Planes_Update", + "tags": [ + "Planes" + ], + "description": "Update a plane", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "name": "planeType", + "in": "path", + "description": "The plane type.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/PlaneNameParameter" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/PlaneResourceTagsUpdate" + } + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", "schema": { "$ref": "#/definitions/PlaneResource" } }, + "202": { + "description": "Resource update request accepted.", + "headers": { + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + } + } + }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Update a plane": { + "$ref": "./examples/Planes_Update.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true }, "delete": { + "operationId": "Planes_Delete", "tags": [ "Planes" ], - "operationId": "Planes_Delete", - "description": "Deletes an existing PlaneResource", + "description": "Delete a plane", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -230,8 +325,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" }, { @@ -246,9 +341,13 @@ "description": "Resource deletion accepted.", "headers": { "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", "type": "integer", - "format": "int32" + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + }, + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." } } }, @@ -261,16 +360,25 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "Delete a plane": { + "$ref": "./examples/Planes_Delete.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true } }, "/planes/{planeType}/{planeName}/resourcegroups": { "get": { + "operationId": "ResourceGroups_List", "tags": [ "ResourceGroups" ], - "operationId": "ResourceGroups_ListByRootScope", - "description": "Lists information about all ResourceGroupResource", + "description": "List resource groups", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -278,8 +386,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" }, { @@ -300,6 +408,11 @@ } } }, + "x-ms-examples": { + "List resource groups": { + "$ref": "./examples/ResourceGroups_List.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -307,11 +420,11 @@ }, "/planes/{planeType}/{planeName}/resourcegroups/{resourceGroupName}": { "get": { + "operationId": "ResourceGroups_Get", "tags": [ "ResourceGroups" ], - "operationId": "ResourceGroups_Get", - "description": "Retrieves information about a ResourceGroupResource", + "description": "Get a resource group", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -319,8 +432,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" }, { @@ -329,12 +442,11 @@ { "name": "resourceGroupName", "in": "path", + "description": "The name of resource group", "required": true, - "description": "UCP resourcegroup name", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -350,14 +462,19 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a resource group": { + "$ref": "./examples/ResourceGroups_Get.json" + } } }, "put": { + "operationId": "ResourceGroups_CreateOrUpdate", "tags": [ "ResourceGroups" ], - "operationId": "ResourceGroups_CreateOrUpdate", - "description": "Creates or updates a ResourceGroupResource", + "description": "Create or update a resource group", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -365,8 +482,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" }, { @@ -375,18 +492,17 @@ { "name": "resourceGroupName", "in": "path", + "description": "The name of resource group", "required": true, - "description": "UCP resourcegroup name", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/ResourceGroupResource" } @@ -394,20 +510,13 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'ResourceGroupResource' update operation succeeded", "schema": { "$ref": "#/definitions/ResourceGroupResource" } }, "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, + "description": "Resource 'ResourceGroupResource' create operation succeeded", "schema": { "$ref": "#/definitions/ResourceGroupResource" } @@ -418,14 +527,19 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Create or update a resource group": { + "$ref": "./examples/ResourceGroups_CreateOrUpdate.json" + } } }, - "delete": { + "patch": { + "operationId": "ResourceGroups_Update", "tags": [ "ResourceGroups" ], - "operationId": "ResourceGroups_Delete", - "description": "Deletes an existing ResourceGroupResource", + "description": "Update a resource group", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -433,8 +547,8 @@ { "name": "planeType", "in": "path", - "required": true, "description": "The plane type.", + "required": true, "type": "string" }, { @@ -443,27 +557,75 @@ { "name": "resourceGroupName", "in": "path", + "description": "The name of resource group", "required": true, - "description": "UCP resourcegroup name", - "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", + "type": "string", "maxLength": 63, - "x-ms-parameter-location": "method", - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/ResourceGroupResourceTagsUpdate" + } } ], "responses": { "200": { - "description": "Resource deleted successfully." + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/ResourceGroupResource" + } }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } + } + }, + "x-ms-examples": { + "Update a resource group": { + "$ref": "./examples/ResourceGroups_Update.json" + } + } + }, + "delete": { + "operationId": "ResourceGroups_Delete", + "tags": [ + "ResourceGroups" + ], + "description": "Delete a resource group", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "name": "planeType", + "in": "path", + "description": "The plane type.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/PlaneNameParameter" + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "The name of resource group", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." }, "204": { "description": "Resource deleted successfully." @@ -474,29 +636,89 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Delete a resource group": { + "$ref": "./examples/ResourceGroups_Delete.json" + } + } + } + }, + "/planes/{planeType}/{planeName}/resourcegroups/{resourceGroupName}/resources": { + "get": { + "operationId": "Resources_List", + "tags": [ + "Resources" + ], + "description": "List resources in a resource group", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "name": "planeType", + "in": "path", + "description": "The plane type.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/PlaneNameParameter" + }, + { + "name": "resourceGroupName", + "in": "path", + "description": "The name of resource group", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/GenericResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-examples": { + "List resources in a resource group.": { + "$ref": "./examples/Resources_List.json" + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" } } }, "/planes/aws/{planeName}/providers/System.AWS/credentials": { "get": { + "operationId": "AwsCredentials_List", "tags": [ - "AWSCredential" + "AwsCredentials" ], - "operationId": "AwsCredential_ListByRootScope", - "description": "Lists information about all AWSCredentialResource", + "description": "List AWS credentials", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/AWSPlaneNameParameter" + "$ref": "#/parameters/AwsPlaneNameParameter" } ], "responses": { "200": { "description": "ARM operation completed successfully.", "schema": { - "$ref": "#/definitions/AWSCredentialResourceListResult" + "$ref": "#/definitions/AwsCredentialResourceListResult" } }, "default": { @@ -506,6 +728,11 @@ } } }, + "x-ms-examples": { + "List AWS credentials": { + "$ref": "./examples/AWSCredential_List.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -513,33 +740,33 @@ }, "/planes/aws/{planeName}/providers/System.AWS/credentials/{credentialName}": { "get": { + "operationId": "AwsCredentials_Get", "tags": [ - "AWSCredential" + "AwsCredentials" ], - "operationId": "AwsCredential_Get", - "description": "Retrieves information about a AWSCredentialResource", + "description": "Get an AWS credential", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/AWSPlaneNameParameter" + "$ref": "#/parameters/AwsPlaneNameParameter" }, { "name": "credentialName", "in": "path", - "required": true, "description": "The AWS credential name.", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { "200": { "description": "ARM operation completed successfully.", "schema": { - "$ref": "#/definitions/AWSCredentialResource" + "$ref": "#/definitions/AwsCredentialResource" } }, "default": { @@ -548,58 +775,56 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a AWS credential": { + "$ref": "./examples/AWSCredential_Get.json" + } } }, "put": { + "operationId": "AwsCredentials_CreateOrUpdate", "tags": [ - "AWSCredential" + "AwsCredentials" ], - "operationId": "AwsCredential_CreateOrUpdate", - "description": "Creates or updates a AWSCredentialResource", + "description": "Create or update an AWS credential", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/AWSPlaneNameParameter" + "$ref": "#/parameters/AwsPlaneNameParameter" }, { "name": "credentialName", "in": "path", - "required": true, "description": "The AWS credential name.", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { - "$ref": "#/definitions/AWSCredentialResource" + "$ref": "#/definitions/AwsCredentialResource" } } ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'AwsCredentialResource' update operation succeeded", "schema": { - "$ref": "#/definitions/AWSCredentialResource" + "$ref": "#/definitions/AwsCredentialResource" } }, "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, + "description": "Resource 'AwsCredentialResource' create operation succeeded", "schema": { - "$ref": "#/definitions/AWSCredentialResource" + "$ref": "#/definitions/AwsCredentialResource" } }, "default": { @@ -608,44 +833,91 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Create or update a AWS credential": { + "$ref": "./examples/AWSCredential_CreateOrUpdate.json" + } } }, - "delete": { + "patch": { + "operationId": "AwsCredentials_Update", "tags": [ - "AWSCredential" + "AwsCredentials" ], - "operationId": "AwsCredential_Delete", - "description": "Deletes an existing AWSCredentialResource", + "description": "Update an AWS credential", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/AWSPlaneNameParameter" + "$ref": "#/parameters/AwsPlaneNameParameter" }, { "name": "credentialName", "in": "path", - "required": true, "description": "The AWS credential name.", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/AwsCredentialResourceTagsUpdate" + } } ], "responses": { "200": { - "description": "Resource deleted successfully." - }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/AwsCredentialResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } + } + }, + "x-ms-examples": { + "Update a AWS credential": { + "$ref": "./examples/AWSCredential_Update.json" + } + } + }, + "delete": { + "operationId": "AwsCredentials_Delete", + "tags": [ + "AwsCredentials" + ], + "description": "Delete an AWS credential", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/AwsPlaneNameParameter" + }, + { + "name": "credentialName", + "in": "path", + "description": "The AWS credential name.", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." }, "204": { "description": "Resource deleted successfully." @@ -656,16 +928,21 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Delete a AWS credential": { + "$ref": "./examples/AWSCredential_Delete.json" + } } } }, "/planes/azure/{planeName}/providers/System.Azure/credentials": { "get": { + "operationId": "AzureCredentials_List", "tags": [ - "AzureCredential" + "AzureCredentials" ], - "operationId": "AzureCredential_ListByRootScope", - "description": "Lists information about all AzureCredentialResource", + "description": "List Azure credentials", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -688,6 +965,11 @@ } } }, + "x-ms-examples": { + "List Azure credentials": { + "$ref": "./examples/AzureCredential_List.json" + } + }, "x-ms-pageable": { "nextLinkName": "nextLink" } @@ -695,11 +977,11 @@ }, "/planes/azure/{planeName}/providers/System.Azure/credentials/{credentialName}": { "get": { + "operationId": "AzureCredentials_Get", "tags": [ - "AzureCredential" + "AzureCredentials" ], - "operationId": "AzureCredential_Get", - "description": "Retrieves information about a AzureCredentialResource", + "description": "Get an Azure credential", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -710,11 +992,11 @@ { "name": "credentialName", "in": "path", - "required": true, "description": "The Azure credential name.", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" } ], "responses": { @@ -730,14 +1012,19 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Get a Azure credential": { + "$ref": "./examples/AzureCredential_Get.json" + } } }, "put": { + "operationId": "AzureCredentials_CreateOrUpdate", "tags": [ - "AzureCredential" + "AzureCredentials" ], - "operationId": "AzureCredential_CreateOrUpdate", - "description": "Creates or updates a AzureCredentialResource", + "description": "Create or update an Azure credential", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -748,17 +1035,17 @@ { "name": "credentialName", "in": "path", - "required": true, "description": "The Azure credential name.", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" }, { "name": "resource", "in": "body", - "required": true, "description": "Resource create parameters.", + "required": true, "schema": { "$ref": "#/definitions/AzureCredentialResource" } @@ -766,20 +1053,13 @@ ], "responses": { "200": { - "description": "ARM operation completed successfully.", + "description": "Resource 'AzureCredentialResource' update operation succeeded", "schema": { "$ref": "#/definitions/AzureCredentialResource" } }, "201": { - "description": "ARM create operation completed successfully.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } - }, + "description": "Resource 'AzureCredentialResource' create operation succeeded", "schema": { "$ref": "#/definitions/AzureCredentialResource" } @@ -790,14 +1070,19 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Create or update a Azure credential": { + "$ref": "./examples/AzureCredential_CreateOrUpdate.json" + } } }, - "delete": { + "patch": { + "operationId": "AzureCredentials_Update", "tags": [ - "AzureCredential" + "AzureCredentials" ], - "operationId": "AzureCredential_Delete", - "description": "Deletes an existing AzureCredentialResource", + "description": "Update an Azure credential", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -808,26 +1093,68 @@ { "name": "credentialName", "in": "path", - "required": true, "description": "The Azure credential name.", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, - "type": "string" + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/AzureCredentialResourceTagsUpdate" + } } ], "responses": { "200": { - "description": "Resource deleted successfully." + "description": "ARM operation completed successfully.", + "schema": { + "$ref": "#/definitions/AzureCredentialResource" + } }, - "202": { - "description": "Resource deletion accepted.", - "headers": { - "Retry-After": { - "description": "The Retry-After header can indicate how long the client should wait before polling the operation status.", - "type": "integer", - "format": "int32" - } + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } + } + }, + "x-ms-examples": { + "Update a Azure credential": { + "$ref": "./examples/AzureCredential_Update.json" + } + } + }, + "delete": { + "operationId": "AzureCredentials_Delete", + "tags": [ + "AzureCredentials" + ], + "description": "Delete an Azure credential", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/AzurePlaneNameParameter" + }, + { + "name": "credentialName", + "in": "path", + "description": "The Azure credential name.", + "required": true, + "type": "string", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + } + ], + "responses": { + "200": { + "description": "Resource deleted successfully." }, "204": { "description": "Resource deleted successfully." @@ -838,21 +1165,47 @@ "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } + }, + "x-ms-examples": { + "Delete a Azure credential": { + "$ref": "./examples/AzureCredential_Delete.json" + } } } } }, "definitions": { - "AWSAccessKeyCredentialProperties": { + "AWSCredentialKind": { + "type": "string", + "description": "AWS credential kind", + "enum": [ + "AccessKey" + ], + "x-ms-enum": { + "name": "AWSCredentialKind", + "modelAsString": true, + "values": [ + { + "name": "AccessKey", + "value": "AccessKey", + "description": "The AWS Access Key credential" + } + ] + } + }, + "AwsAccessKeyCredentialProperties": { "type": "object", + "description": "AWS credential storage properties", "properties": { "accessKeyId": { "type": "string", + "format": "password", "description": "Access key ID for AWS identity", "x-ms-secret": true }, "secretAccessKey": { "type": "string", + "format": "password", "description": "Secret Access Key for AWS identity", "x-ms-secret": true }, @@ -861,7 +1214,6 @@ "description": "The storage properties" } }, - "description": "AWS credential storage properties", "required": [ "accessKeyId", "secretAccessKey", @@ -869,46 +1221,36 @@ ], "allOf": [ { - "$ref": "#/definitions/AWSCredentialProperties" + "$ref": "#/definitions/AwsCredentialProperties" } ], "x-ms-discriminator-value": "AccessKey" }, - "AWSCredentialKind": { - "type": "string", - "description": "AWS credential kinds supported.", - "enum": [ - "AccessKey" - ], - "x-ms-enum": { - "name": "AWSCredentialKind", - "modelAsString": true - } - }, - "AWSCredentialProperties": { + "AwsCredentialProperties": { "type": "object", + "description": "AWS Credential properties", "properties": { "kind": { - "type": "string", - "description": "Discriminator property for AWSCredentialProperties." + "$ref": "#/definitions/AWSCredentialKind", + "description": "The AWS credential kind" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true } }, - "description": "AWS Credential properties", "discriminator": "kind", "required": [ "kind" - ], - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } ] }, - "AWSCredentialResource": { + "AwsCredentialResource": { "type": "object", + "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", "properties": { "properties": { - "$ref": "#/definitions/AWSCredentialProperties", + "$ref": "#/definitions/AwsCredentialProperties", "description": "The resource-specific properties for this resource.", "x-ms-client-flatten": true, "x-ms-mutability": [ @@ -917,40 +1259,45 @@ ] } }, - "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" } ] }, - "AWSCredentialResourceListResult": { + "AwsCredentialResourceListResult": { "type": "object", + "description": "The response of a AwsCredentialResource list operation.", "properties": { "value": { "type": "array", + "description": "The AwsCredentialResource items on this page", "items": { - "$ref": "#/definitions/AWSCredentialResource" - }, - "x-cadl-name": "AWSCredentialResource[]", - "description": "The AWSCredentialResource items on this page" + "$ref": "#/definitions/AwsCredentialResource" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a AWSCredentialResource list operation.", "required": [ "value" ] }, - "AWSPlaneNameParameter": { + "AwsCredentialResourceTagsUpdate": { "type": "object", - "properties": {}, - "description": "Custom root scope" + "description": "The type used for updating tags in AwsCredentialResource resources.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + } + } }, "AzureCredentialKind": { "type": "string", @@ -960,30 +1307,38 @@ ], "x-ms-enum": { "name": "AzureCredentialKind", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "ServicePrincipal", + "value": "ServicePrincipal", + "description": "The Service Principal Credential" + } + ] } }, "AzureCredentialProperties": { "type": "object", + "description": "The base properties of Azure Credential", "properties": { "kind": { - "type": "string", - "description": "Discriminator property for AzureCredentialProperties." + "$ref": "#/definitions/AzureCredentialKind", + "description": "The kind of Azure credential" + }, + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true } }, - "description": "Azure Credential properties", "discriminator": "kind", "required": [ "kind" - ], - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } ] }, "AzureCredentialResource": { "type": "object", + "description": "Represents Azure Credential Resource", "properties": { "properties": { "$ref": "#/definitions/AzureCredentialProperties", @@ -995,7 +1350,6 @@ ] } }, - "description": "Concrete tracked resource types can be created by aliasing this type using a specific property type.", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -1004,34 +1358,41 @@ }, "AzureCredentialResourceListResult": { "type": "object", + "description": "The response of a AzureCredentialResource list operation.", "properties": { "value": { "type": "array", + "description": "The AzureCredentialResource items on this page", "items": { "$ref": "#/definitions/AzureCredentialResource" - }, - "x-cadl-name": "AzureCredentialResource[]", - "description": "The AzureCredentialResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a AzureCredentialResource list operation.", "required": [ "value" ] }, - "AzurePlaneNameParameter": { + "AzureCredentialResourceTagsUpdate": { "type": "object", - "properties": {}, - "description": "Custom root scope" + "description": "The type used for updating tags in AzureCredentialResource resources.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + } + } }, "AzureServicePrincipalProperties": { "type": "object", + "description": "The properties of Service Principal credential storage", "properties": { "clientId": { "type": "string", @@ -1051,7 +1412,6 @@ "description": "The storage properties" } }, - "description": "Service Principal credential storage properties", "required": [ "clientId", "clientSecret", @@ -1065,17 +1425,6 @@ ], "x-ms-discriminator-value": "ServicePrincipal" }, - "BasicResourceProperties": { - "type": "object", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "Provisioning state of the resource at the time the operation was called", - "readOnly": true - } - }, - "description": "Basic properties of a UCP resource." - }, "CredentialStorageKind": { "type": "string", "description": "Credential store kinds supported.", @@ -1084,25 +1433,90 @@ ], "x-ms-enum": { "name": "CredentialStorageKind", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "Internal", + "value": "Internal", + "description": "Internal credential storage" + } + ] } }, "CredentialStorageProperties": { "type": "object", + "description": "The base credential storage properties", "properties": { "kind": { - "type": "string", - "description": "Discriminator property for CredentialStorageProperties." + "$ref": "#/definitions/CredentialStorageKind", + "description": "The kind of credential storage" } }, - "description": "Credential storage properties", "discriminator": "kind", "required": [ "kind" ] }, + "GenericResource": { + "type": "object", + "description": "Represents resource data.", + "properties": { + "name": { + "$ref": "#/definitions/ResourceNameString", + "description": "The name of resource", + "readOnly": true + } + }, + "required": [ + "name" + ], + "allOf": [ + { + "type": "object", + "description": "Concrete proxy resource types can be created by aliasing this type using a specific property type.", + "properties": { + "properties": { + "$ref": "#/definitions/ResourceProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + } + }, + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/ProxyResource" + } + ] + } + ] + }, + "GenericResourceListResult": { + "type": "object", + "description": "The response of a GenericResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The GenericResource items on this page", + "items": { + "$ref": "#/definitions/GenericResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, "InternalCredentialStorageProperties": { "type": "object", + "description": "Internal credential storage properties", "properties": { "secretName": { "type": "string", @@ -1110,7 +1524,6 @@ "readOnly": true } }, - "description": "Internal credential storage properties", "required": [ "secretName" ], @@ -1131,16 +1544,29 @@ ], "x-ms-enum": { "name": "PlaneKind", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "UCPNative", + "value": "UCPNative", + "description": "UCP Native Plane" + }, + { + "name": "Azure", + "value": "Azure", + "description": "Azure Plane" + }, + { + "name": "AWS", + "value": "AWS", + "description": "AWS Plane" + } + ] } }, - "PlaneNameParameter": { - "type": "object", - "properties": {}, - "description": "Custom root scope" - }, "PlaneResource": { "type": "object", + "description": "The plane resource", "properties": { "properties": { "$ref": "#/definitions/PlaneResourceProperties", @@ -1152,7 +1578,6 @@ ] } }, - "description": "UCP PlaneResource.", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -1161,30 +1586,34 @@ }, "PlaneResourceListResult": { "type": "object", + "description": "The response of a PlaneResource list operation.", "properties": { "value": { "type": "array", + "description": "The PlaneResource items on this page", "items": { "$ref": "#/definitions/PlaneResource" - }, - "x-cadl-name": "PlaneResource[]", - "description": "The PlaneResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a PlaneResource list operation.", "required": [ "value" ] }, "PlaneResourceProperties": { "type": "object", + "description": "The Plane properties.", "properties": { + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + }, "kind": { "$ref": "#/definitions/PlaneKind", "description": "The kind of plane" @@ -1195,26 +1624,32 @@ }, "resourceProviders": { "type": "object", + "description": "Resource Providers for UCP Native Plane", "additionalProperties": { "type": "string" - }, - "x-cadl-name": "Record", - "description": "Resource Providers for UCP Native Plane" + } } }, - "description": "Plane properties.", "required": [ "kind" - ], - "allOf": [ - { - "$ref": "#/definitions/BasicResourceProperties" - } ] }, + "PlaneResourceTagsUpdate": { + "type": "object", + "description": "The type used for updating tags in PlaneResource resources.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + } + } + }, "ProvisioningState": { "type": "string", - "description": "Provisioning state of the link at the time the operation was called", + "description": "Provisioning state of the portable resource at the time the operation was called", "enum": [ "Succeeded", "Failed", @@ -1226,14 +1661,64 @@ ], "x-ms-enum": { "name": "ProvisioningState", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + }, + { + "name": "Provisioning", + "value": "Provisioning", + "description": "The resource is being provisioned" + }, + { + "name": "Updating", + "value": "Updating", + "description": "The resource is updating" + }, + { + "name": "Deleting", + "value": "Deleting", + "description": "The resource is being deleted" + }, + { + "name": "Accepted", + "value": "Accepted", + "description": "The resource create request has been accepted" + } + ] + }, + "readOnly": true + }, + "ResourceGroupProperties": { + "type": "object", + "description": "The resource group resource properties", + "properties": { + "provisioningState": { + "$ref": "#/definitions/ProvisioningState", + "description": "The status of the asynchronous operation.", + "readOnly": true + } } }, "ResourceGroupResource": { "type": "object", + "description": "The resource group resource", "properties": { "properties": { - "$ref": "#/definitions/BasicResourceProperties", + "$ref": "#/definitions/ResourceGroupProperties", "description": "The resource-specific properties for this resource.", "x-ms-client-flatten": true, "x-ms-mutability": [ @@ -1242,7 +1727,6 @@ ] } }, - "description": "UCP ResourceGroup.", "allOf": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/TrackedResource" @@ -1251,61 +1735,101 @@ }, "ResourceGroupResourceListResult": { "type": "object", + "description": "The response of a ResourceGroupResource list operation.", "properties": { "value": { "type": "array", + "description": "The ResourceGroupResource items on this page", "items": { "$ref": "#/definitions/ResourceGroupResource" - }, - "x-cadl-name": "ResourceGroupResource[]", - "description": "The ResourceGroupResource items on this page" + } }, "nextLink": { "type": "string", "format": "uri", - "description": "The link to the next page of items", - "x-cadl-name": "Rest.ResourceLocation" + "description": "The link to the next page of items" } }, - "description": "The response of a ResourceGroupResource list operation.", "required": [ "value" ] + }, + "ResourceGroupResourceTagsUpdate": { + "type": "object", + "description": "The type used for updating tags in ResourceGroupResource resources.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + } + } + }, + "ResourceNameString": { + "type": "string", + "description": "The resource name", + "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$" + }, + "ResourceProperties": { + "type": "object", + "description": "The resource properties", + "properties": {} + }, + "Versions": { + "type": "string", + "description": "Supported API versions for Universal Control Plane resource provider.", + "enum": [ + "2022-09-01-privatepreview" + ], + "x-ms-enum": { + "name": "Versions", + "modelAsString": true, + "values": [ + { + "name": "v2022_09_01_privatepreview", + "value": "2022-09-01-privatepreview", + "description": "2022-09-01-privatepreview" + } + ] + } } }, "parameters": { - "AWSPlaneNameParameter": { + "AwsPlaneNameParameter": { "name": "planeName", "in": "path", + "description": "The name of AWS plane", "required": true, - "description": "The name of the plane", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "type": "string", "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", "x-ms-parameter-location": "method", - "x-ms-skip-url-encoding": true, - "type": "string" + "x-ms-skip-url-encoding": true }, "AzurePlaneNameParameter": { "name": "planeName", "in": "path", - "required": true, "description": "The name of the plane", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", "x-ms-parameter-location": "method", - "x-ms-skip-url-encoding": true, - "type": "string" + "x-ms-skip-url-encoding": true }, "PlaneNameParameter": { "name": "planeName", "in": "path", - "required": true, "description": "The name of the plane", - "pattern": "^[a-z]([-a-z0-9]*[a-z0-9])?$", + "required": true, + "type": "string", "maxLength": 63, + "pattern": "^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$", "x-ms-parameter-location": "method", - "x-ms-skip-url-encoding": true, - "type": "string" + "x-ms-skip-url-encoding": true } } } diff --git a/swagger/specs.go b/swagger/specs.go index 256a42aa32..5b3a80ea5c 100644 --- a/swagger/specs.go +++ b/swagger/specs.go @@ -28,8 +28,7 @@ var ( //go:embed specification/applications/resource-manager/Applications.Datastores/preview/2022-03-15-privatepreview/*.json //go:embed specification/applications/resource-manager/Applications.Dapr/preview/2022-03-15-privatepreview/*.json //go:embed specification/applications/resource-manager/Applications.Messaging/preview/2022-03-15-privatepreview/*.json - //go:embed specification/applications/resource-manager/Applications.Link/preview/2022-03-15-privatepreview/*.json - //go:embed specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/*.json + //go:embed specification/applications/resource-manager/Applications.Core/preview/2022-03-15-privatepreview/openapi.json //go:embed specification/common-types/resource-management/v2/types.json //go:embed specification/common-types/resource-management/v3/types.json SpecFiles embed.FS diff --git a/test/functional/daprrp/dapr_component_name_conflict_test.go b/test/functional/daprrp/dapr_component_name_conflict_test.go deleted file mode 100644 index efa715f397..0000000000 --- a/test/functional/daprrp/dapr_component_name_conflict_test.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprComponentNameConflict(t *testing.T) { - template := "resources/testdata/daprrp-resources-component-name-conflict.bicep" - name := "daprrp-rs-component-name-conflict" - - validate := step.ValidateSingleDetail("DeploymentFailed", step.DeploymentErrorDetail{ - Code: "ResourceDeploymentFailure", - Details: []step.DeploymentErrorDetail{ - { - Code: v1.CodeInternal, - MessageContains: "the Dapr component name '\"dapr-component\"' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again", - }, - }, - }) - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployErrorExecutor(template, validate), - SkipKubernetesOutputResourceValidation: true, - K8sObjects: &validation.K8sObjectSet{}, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} diff --git a/test/functional/daprrp/dapr_pubsub_test.go b/test/functional/daprrp/dapr_pubsub_test.go deleted file mode 100644 index d14ec499ea..0000000000 --- a/test/functional/daprrp/dapr_pubsub_test.go +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "fmt" - "testing" - - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprPubSubBroker_Manual(t *testing.T) { - template := "resources/testdata/daprrp-resources-pubsub-broker-manual.bicep" - name := "dpsb-manual-app" - appNamespace := "default-dpsb-manual-app" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "dpsb-manual-app", - Type: validation.ApplicationsResource, - }, - { - Name: "dpsb-manual-app-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dpsb-manual", - Type: validation.DaprPubSubBrokersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dpsb-manual-app-ctnr"), - validation.NewK8sPodForResource(name, "dpsb-manual-redis").ValidateLabels(false), - validation.NewK8sServiceForResource(name, "dpsb-manual-redis").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} - -func Test_DaprPubSubBroker_Recipe(t *testing.T) { - template := "resources/testdata/daprrp-resources-pubsub-broker-recipe.bicep" - name := "dpsb-recipe-app" - appNamespace := "dpsb-recipe-env" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "dpsb-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: "dpsb-recipe-app", - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "dpsb-recipe-app-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dpsb-recipe", - Type: validation.DaprPubSubBrokersResource, - App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource1", - }, - }, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dpsb-recipe-ctnr").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} diff --git a/test/functional/daprrp/dapr_secretstore_test.go b/test/functional/daprrp/dapr_secretstore_test.go deleted file mode 100644 index adc708d1ad..0000000000 --- a/test/functional/daprrp/dapr_secretstore_test.go +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprSecretStore_Manual(t *testing.T) { - template := "resources/testdata/daprrp-resources-secretstore-manual.bicep" - name := "daprrp-rs-secretstore-manual" - appNamespace := "default-daprrp-rs-secretstore-manual" - - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "gnrc-scs-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "gnrc-scs-manual", - Type: validation.DaprSecretStoresResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "gnrc-scs-ctnr"), - }, - }, - }, - }, - }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} - -func Test_DaprSecretStore_Recipe(t *testing.T) { - template := "resources/testdata/daprrp-resources-secretstore-recipe.bicep" - name := "daprrp-rs-secretstore-recipe" - appNamespace := "daprrp-rs-secretstore-recipe" - - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "gnrc-scs-ctnr-recipe", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "gnrc-scs-recipe", - Type: validation.DaprSecretStoresResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "gnrc-scs-ctnr-recipe").ValidateLabels(false), - }, - }, - }, - }, - }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} diff --git a/test/functional/daprrp/dapr_serviceinvocation_test.go b/test/functional/daprrp/dapr_serviceinvocation_test.go deleted file mode 100644 index 6deeff3a2e..0000000000 --- a/test/functional/daprrp/dapr_serviceinvocation_test.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprServiceInvocation(t *testing.T) { - template := "resources/testdata/daprrp-resources-serviceinvocation.bicep" - name := "dapr-serviceinvocation" - appNamespace := "default-dapr-serviceinvocation" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "dapr-frontend", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dapr-backend", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dapr-frontend"), - validation.NewK8sPodForResource(name, "dapr-backend"), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} diff --git a/test/functional/daprrp/dapr_statestore_test.go b/test/functional/daprrp/dapr_statestore_test.go deleted file mode 100644 index ea77a4b32b..0000000000 --- a/test/functional/daprrp/dapr_statestore_test.go +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "fmt" - "testing" - - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprStateStore_Manual(t *testing.T) { - template := "resources/testdata/daprrp-resources-statestore-manual.bicep" - name := "daprrp-rs-statestore-manual" - appNamespace := "default-daprrp-rs-statestore-manual" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "daprrp-rs-statestore-manual", - Type: validation.ApplicationsResource, - }, - { - Name: "dapr-sts-manual-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dapr-sts-manual", - Type: validation.DaprStateStoresResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dapr-sts-manual-ctnr"), - - // Deployed as supporting resources using Kubernetes Bicep extensibility. - validation.NewK8sPodForResource(name, "dapr-sts-manual-redis").ValidateLabels(false), - validation.NewK8sServiceForResource(name, "dapr-sts-manual-redis").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} - -func Test_DaprStateStore_Recipe(t *testing.T) { - template := "resources/testdata/daprrp-resources-statestore-recipe.bicep" - name := "daprrp-rs-sts-recipe" - appNamespace := "daprrp-env-recipes-env" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "daprrp-env-recipes-env", - Type: validation.EnvironmentsResource, - }, - { - Name: "daprrp-rs-sts-recipe", - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "dapr-sts-recipe-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dapr-sts-recipe", - Type: validation.DaprStateStoresResource, - App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource1", - }, - }, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dapr-sts-recipe-ctnr").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} diff --git a/test/functional/daprrp/resources/common.go b/test/functional/daprrp/resources/common.go new file mode 100644 index 0000000000..866a921d04 --- /dev/null +++ b/test/functional/daprrp/resources/common.go @@ -0,0 +1,53 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "context" + "testing" + + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/test/functional/shared" + + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/dynamic" +) + +func verifyDaprComponentsDeleted(ctx context.Context, t *testing.T, test shared.RPTest, resourceType, resourceName, namespace string) { + resource, err := test.Options.ManagementClient.ShowResource(ctx, resourceType, resourceName) + require.Error(t, err) + require.True(t, clients.Is404Error(err)) + require.Equal(t, generated.GenericResource{}, resource) + + dynamicClient, err := dynamic.NewForConfig(test.Options.K8sConfig) + require.NoError(t, err) + + gvr := schema.GroupVersionResource{ + Group: "dapr.io", + Version: "v1alpha1", + Resource: "components", + } + + resourceList, err := dynamicClient.Resource(gvr).Namespace(namespace).List(ctx, metav1.ListOptions{ + LabelSelector: "radius.dev/resource=" + resourceName, + }) + require.NoError(t, err) + require.Equal(t, 0, len(resourceList.Items)) +} diff --git a/test/functional/daprrp/resources/dapr_component_name_conflict_test.go b/test/functional/daprrp/resources/dapr_component_name_conflict_test.go new file mode 100644 index 0000000000..acdd7049a2 --- /dev/null +++ b/test/functional/daprrp/resources/dapr_component_name_conflict_test.go @@ -0,0 +1,52 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "testing" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" +) + +func Test_DaprComponentNameConflict(t *testing.T) { + template := "testdata/daprrp-resources-component-name-conflict.bicep" + name := "daprrp-rs-component-name-conflict" + + validate := step.ValidateSingleDetail("DeploymentFailed", step.DeploymentErrorDetail{ + Code: "ResourceDeploymentFailure", + Details: []step.DeploymentErrorDetail{ + { + Code: v1.CodeInternal, + MessageContains: "the Dapr component name '\"dapr-component\"' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again", + }, + }, + }) + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployErrorExecutor(template, validate), + SkipKubernetesOutputResourceValidation: true, + K8sObjects: &validation.K8sObjectSet{}, + }, + }) + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.Test(t) +} diff --git a/test/functional/daprrp/resources/dapr_pubsub_test.go b/test/functional/daprrp/resources/dapr_pubsub_test.go new file mode 100644 index 0000000000..f53b039e5e --- /dev/null +++ b/test/functional/daprrp/resources/dapr_pubsub_test.go @@ -0,0 +1,134 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "context" + "fmt" + "testing" + + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" +) + +func Test_DaprPubSubBroker_Manual(t *testing.T) { + template := "testdata/daprrp-resources-pubsub-broker-manual.bicep" + name := "dpsb-manual-app" + appNamespace := "default-dpsb-manual-app" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "dpsb-manual-app", + Type: validation.ApplicationsResource, + }, + { + Name: "dpsb-manual-app-ctnr", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "dpsb-manual", + Type: validation.DaprPubSubBrokersResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "dpsb-manual-app-ctnr"), + validation.NewK8sPodForResource(name, "dpsb-manual-redis"). + ValidateLabels(false), + validation.NewK8sServiceForResource(name, "dpsb-manual-redis"). + ValidateLabels(false), + + validation.NewDaprComponent(name, "dpsb-manual"). + ValidateLabels(false), + }, + }, + }, + }, + }) + + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/pubSubBrokers", "dpsb-manual", appNamespace) + } + + test.Test(t) +} + +func Test_DaprPubSubBroker_Recipe(t *testing.T) { + template := "testdata/daprrp-resources-pubsub-broker-recipe.bicep" + name := "dpsb-recipe-app" + appNamespace := "dpsb-recipe-env" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "dpsb-recipe-env", + Type: validation.EnvironmentsResource, + }, + { + Name: "dpsb-recipe-app", + Type: validation.ApplicationsResource, + App: name, + }, + { + Name: "dpsb-recipe-app-ctnr", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "dpsb-recipe", + Type: validation.DaprPubSubBrokersResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "dpsb-recipe-ctnr"). + ValidateLabels(false), + + validation.NewDaprComponent(name, "dpsb-recipe"). + ValidateLabels(false), + }, + }, + }, + }, + }) + + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/pubSubBrokers", "dpsb-recipe", appNamespace) + } + + test.Test(t) +} diff --git a/test/functional/daprrp/resources/dapr_secretstore_test.go b/test/functional/daprrp/resources/dapr_secretstore_test.go new file mode 100644 index 0000000000..a7ac14ed7a --- /dev/null +++ b/test/functional/daprrp/resources/dapr_secretstore_test.go @@ -0,0 +1,125 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "context" + "testing" + + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" +) + +func Test_DaprSecretStore_Manual(t *testing.T) { + template := "testdata/daprrp-resources-secretstore-manual.bicep" + name := "daprrp-rs-secretstore-manual" + appNamespace := "default-daprrp-rs-secretstore-manual" + + test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "gnrc-scs-ctnr", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "gnrc-scs-manual", + Type: validation.DaprSecretStoresResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "gnrc-scs-ctnr"), + + // Not sure why we skip validating the labels + validation.NewDaprComponent(name, "gnrc-scs-manual"). + ValidateLabels(false), + }, + }, + }, + }, + }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) + + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/secretStores", "gnrc-scs-manual", appNamespace) + } + + test.Test(t) +} + +func Test_DaprSecretStore_Recipe(t *testing.T) { + template := "testdata/daprrp-resources-secretstore-recipe.bicep" + name := "daprrp-rs-secretstore-recipe" + appNamespace := "daprrp-rs-secretstore-recipe" + + test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "gnrc-scs-ctnr-recipe", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "gnrc-scs-recipe", + Type: validation.DaprSecretStoresResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "gnrc-scs-ctnr-recipe"). + ValidateLabels(false), + + validation.NewDaprComponent(name, "gnrc-scs-recipe"). + ValidateLabels(false), + }, + }, + }, + }, + }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) + + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/secretStores", "gnrc-scs-recipe", appNamespace) + } + + test.Test(t) +} diff --git a/test/functional/daprrp/resources/dapr_serviceinvocation_test.go b/test/functional/daprrp/resources/dapr_serviceinvocation_test.go new file mode 100644 index 0000000000..b20f663922 --- /dev/null +++ b/test/functional/daprrp/resources/dapr_serviceinvocation_test.go @@ -0,0 +1,67 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "testing" + + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" +) + +func Test_DaprServiceInvocation(t *testing.T) { + template := "testdata/daprrp-resources-serviceinvocation.bicep" + name := "dapr-serviceinvocation" + appNamespace := "default-dapr-serviceinvocation" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "dapr-frontend", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "dapr-backend", + Type: validation.ContainersResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "dapr-frontend"), + validation.NewK8sPodForResource(name, "dapr-backend"), + }, + }, + }, + }, + }) + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.Test(t) +} diff --git a/test/functional/daprrp/resources/dapr_statestore_test.go b/test/functional/daprrp/resources/dapr_statestore_test.go new file mode 100644 index 0000000000..50b80d1e5b --- /dev/null +++ b/test/functional/daprrp/resources/dapr_statestore_test.go @@ -0,0 +1,136 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "context" + "fmt" + "testing" + + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" +) + +func Test_DaprStateStore_Manual(t *testing.T) { + template := "testdata/daprrp-resources-statestore-manual.bicep" + name := "daprrp-rs-statestore-manual" + appNamespace := "default-daprrp-rs-statestore-manual" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "daprrp-rs-statestore-manual", + Type: validation.ApplicationsResource, + }, + { + Name: "dapr-sts-manual-ctnr", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "dapr-sts-manual", + Type: validation.DaprStateStoresResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "dapr-sts-manual-ctnr"), + + // Deployed as supporting resources using Kubernetes Bicep extensibility. + validation.NewK8sPodForResource(name, "dapr-sts-manual-redis"). + ValidateLabels(false), + validation.NewK8sServiceForResource(name, "dapr-sts-manual-redis"). + ValidateLabels(false), + + validation.NewDaprComponent(name, "dapr-sts-manual"). + ValidateLabels(false), + }, + }, + }, + }, + }) + + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/stateStores", "dapr-sts-manual", appNamespace) + } + + test.Test(t) +} + +func Test_DaprStateStore_Recipe(t *testing.T) { + template := "testdata/daprrp-resources-statestore-recipe.bicep" + name := "daprrp-rs-sts-recipe" + appNamespace := "daprrp-env-recipes-env" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: "daprrp-env-recipes-env", + Type: validation.EnvironmentsResource, + }, + { + Name: "daprrp-rs-sts-recipe", + Type: validation.ApplicationsResource, + App: name, + }, + { + Name: "dapr-sts-recipe-ctnr", + Type: validation.ContainersResource, + App: name, + }, + { + Name: "dapr-sts-recipe", + Type: validation.DaprStateStoresResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "dapr-sts-recipe-ctnr"). + ValidateLabels(false), + + validation.NewDaprComponent(name, "dapr-sts-recipe"). + ValidateLabels(false), + }, + }, + }, + }, + }) + + test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + verifyDaprComponentsDeleted(ctx, t, test, "Applications.Dapr/stateStores", "dapr-sts-recipe", appNamespace) + } + + test.Test(t) +} diff --git a/test/functional/datastoresrp/resources/microsoftsql_test.go b/test/functional/datastoresrp/resources/microsoftsql_test.go index 7f09ace4a3..fe1c70ea40 100644 --- a/test/functional/datastoresrp/resources/microsoftsql_test.go +++ b/test/functional/datastoresrp/resources/microsoftsql_test.go @@ -20,10 +20,10 @@ import ( "os" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_MicrosoftSQL_Manual(t *testing.T) { diff --git a/test/functional/datastoresrp/resources/mongodb_test.go b/test/functional/datastoresrp/resources/mongodb_test.go index d3ac23d228..f46369ad1e 100644 --- a/test/functional/datastoresrp/resources/mongodb_test.go +++ b/test/functional/datastoresrp/resources/mongodb_test.go @@ -20,11 +20,10 @@ import ( "os" "testing" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) // Opt-out case for manual resource provisioning @@ -126,11 +125,11 @@ func Test_MongoDB_Recipe(t *testing.T) { } // Test_MongoDB_Recipe_Parameters validates the creation of a mongoDB from recipe with parameters passed by operator while linking recipe -// and developer while creating the mongoDatabase link. +// and developer while creating the mongoDatabase resource. // If the same parameters are set by the developer and the operator then the developer parameters are applied in to resolve conflicts. -// Container uses the mongoDB link to connect to the mongoDB resource +// Container uses the mongoDB resource to connect to the mongoDB resource func Test_MongoDB_RecipeParameters(t *testing.T) { - t.Skip("Skipping test as creating/deleting cosmosdb resource is unreliable - https://github.com/project-radius/radius/issues/5929") + t.Skip("Skipping test as creating/deleting cosmosdb resource is unreliable - https://github.com/radius-project/radius/issues/5929") template := "testdata/datastoresrp-resources-mongodb-recipe-parameters.bicep" name := "dsrp-resources-mongodb-recipe-parameters" @@ -165,16 +164,6 @@ func Test_MongoDB_RecipeParameters(t *testing.T) { Name: "mdb-recipe-param-db", Type: validation.MongoDatabasesResource, App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource1", - }, - }, }, }, }, @@ -192,10 +181,10 @@ func Test_MongoDB_RecipeParameters(t *testing.T) { } // Test_MongoDB_Recipe_ContextParameter validates creation of a mongoDB from -// a default recipe using the context parameter generated and set by linkRP, -// and container using the mongoDB link to connect to the underlying mongoDB resource. +// a default recipe using the context parameter generated and set by DatastoresRP, +// and container using the mongoDatabases portable resource to connect to the underlying mongoDB resource. func Test_MongoDB_Recipe_ContextParameter(t *testing.T) { - t.Skip("Skipping test as creating/deleting cosmosdb resource is unreliable - https://github.com/project-radius/radius/issues/5929") + t.Skip("Skipping test as creating/deleting cosmosdb resource is unreliable - https://github.com/radius-project/radius/issues/5929") template := "testdata/datastoresrp-resources-mongodb-recipe-context.bicep" name := "dsrp-resources-mongodb-recipe-context" @@ -230,16 +219,6 @@ func Test_MongoDB_Recipe_ContextParameter(t *testing.T) { Name: "mdb-ctx", Type: validation.MongoDatabasesResource, App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource1", - }, - }, }, }, }, diff --git a/test/functional/datastoresrp/resources/redis_test.go b/test/functional/datastoresrp/resources/redis_test.go index 7f1b472069..7dd32a8ca6 100644 --- a/test/functional/datastoresrp/resources/redis_test.go +++ b/test/functional/datastoresrp/resources/redis_test.go @@ -19,10 +19,10 @@ package resource_test import ( "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_Redis_Manual(t *testing.T) { diff --git a/test/functional/datastoresrp/resources/sql_test.go b/test/functional/datastoresrp/resources/sql_test.go index 17855c7039..1f93e3e40b 100644 --- a/test/functional/datastoresrp/resources/sql_test.go +++ b/test/functional/datastoresrp/resources/sql_test.go @@ -20,10 +20,10 @@ import ( "runtime" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_SQLDatabase_Manual(t *testing.T) { @@ -83,7 +83,7 @@ func Test_SQLDatabase_Manual(t *testing.T) { // Test_SQLDatabase_Recipe validates: // the creation of a sql database from recipe -// container using the sql database link to connect to the sql database resource +// container using the sqlDatabases portable resource to connect to the sql database resource func Test_SQLDatabase_Recipe(t *testing.T) { template := "testdata/datastoresrp-resources-sqldb-recipe.bicep" name := "dsrp-resources-sqldb-recipe" diff --git a/test/functional/messagingrp/resources/rabbitmq_test.go b/test/functional/messagingrp/resources/rabbitmq_test.go index 9559889ee9..23e35122ea 100644 --- a/test/functional/messagingrp/resources/rabbitmq_test.go +++ b/test/functional/messagingrp/resources/rabbitmq_test.go @@ -19,10 +19,10 @@ package resource_test import ( "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_RabbitMQ_Manual(t *testing.T) { diff --git a/test/functional/samples/README.md b/test/functional/samples/README.md index c68277e608..0bf4c7421a 100644 --- a/test/functional/samples/README.md +++ b/test/functional/samples/README.md @@ -1,5 +1,5 @@ # Sample validation -This directory contains validation for samples in https://github.com/project-radius/samples. +This directory contains validation for samples in https://github.com/radius-project/samples. These validate that the sample is deployable and can be accessed accordingly via APIs. These flows will include common user actions, like adding items to a Todo list, validating gateway availability, etc. \ No newline at end of file diff --git a/test/functional/samples/testdata/tutorial-environment.bicep b/test/functional/samples/testdata/tutorial-environment.bicep index 421e8adf92..a0ef81ed28 100644 --- a/test/functional/samples/testdata/tutorial-environment.bicep +++ b/test/functional/samples/testdata/tutorial-environment.bicep @@ -12,7 +12,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { namespace: 'tutorial' } recipes: { - 'Applications.Link/redisCaches': { + 'Applications.Datastores/redisCaches': { default: { templateKind: 'bicep' templatePath: '${registry}/test/functional/shared/recipes/redis-recipe-value-backed:${version}' diff --git a/test/functional/samples/tutorial_test.go b/test/functional/samples/tutorial_test.go index 4afb1ae2a8..eee017a112 100644 --- a/test/functional/samples/tutorial_test.go +++ b/test/functional/samples/tutorial_test.go @@ -29,11 +29,11 @@ import ( "testing" "time" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -53,7 +53,7 @@ var samplesRepoAbsPath, samplesRepoEnvVarSet = os.LookupEnv("RADIUS_SAMPLES_REPO // Ex: export PROJECT_RADIUS_SAMPLES_REPO_ABS_PATH=/home/uname/src/samples func Test_FirstApplicationSample(t *testing.T) { if !samplesRepoEnvVarSet { - t.Skipf("Skip samples test execution, to enable you must set env var PROJECT_RADIUS_SAMPLES_REPO_ABS_PATH to the absolute path of the project-radius/samples repository") + t.Skipf("Skip samples test execution, to enable you must set env var PROJECT_RADIUS_SAMPLES_REPO_ABS_PATH to the absolute path of the radius-project/samples repository") } cwd, err := os.Getwd() @@ -85,7 +85,7 @@ func Test_FirstApplicationSample(t *testing.T) { }, { Name: "db", - Type: validation.O_RedisCachesResource, + Type: validation.RedisCachesResource, }, }, }, @@ -105,7 +105,7 @@ func Test_FirstApplicationSample(t *testing.T) { require.Fail(t, fmt.Sprintf("tests failed after %d retries", retries)) }, - // TODO: validation of k8s resources blocked by https://github.com/project-radius/radius/issues/4689 + // TODO: validation of k8s resources blocked by https://github.com/radius-project/radius/issues/4689 K8sOutputResources: []unstructured.Unstructured{}, K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ diff --git a/test/functional/shared/api_test.go b/test/functional/shared/api_test.go index c39701a8f1..44c0f73297 100644 --- a/test/functional/shared/api_test.go +++ b/test/functional/shared/api_test.go @@ -20,13 +20,14 @@ import ( "fmt" "testing" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" ) // Test_ResourceList covers the plane and resource-group scope list APIs for all Radius resource types. @@ -43,7 +44,7 @@ func Test_ResourceList(t *testing.T) { parsed, err := resources.ParseScope("/" + scope) require.NoError(t, err) - require.NotEmpty(t, parsed.FindScope(resources.ResourceGroupsSegment), "workspace scope must contain resource group segment") + require.NotEmpty(t, parsed.FindScope(resources_radius.ScopeResourceGroups), "workspace scope must contain resource group segment") resourceGroupScope := parsed.String() planeScope := parsed.Truncate().String() diff --git a/test/functional/shared/cli/cli_test.go b/test/functional/shared/cli/cli_test.go index eeba2f5e64..a380184825 100644 --- a/test/functional/shared/cli/cli_test.go +++ b/test/functional/shared/cli/cli_test.go @@ -33,19 +33,19 @@ import ( "testing" "time" - "github.com/project-radius/radius/pkg/cli/bicep" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/objectformats" - "github.com/project-radius/radius/pkg/corerp/api/v20220315privatepreview" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/radcli" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/testcontext" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/cli/bicep" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/objectformats" + "github.com/radius-project/radius/pkg/corerp/api/v20220315privatepreview" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/radcli" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" ) const ( @@ -61,12 +61,12 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) { recipeName := "recipeName" recipeTemplate := "testpublicrecipe.azurecr.io/bicep/modules/testTemplate:v1" templateKind := "bicep" - linkType := "Applications.Link/mongoDatabases" + resourceType := "Applications.Datastores/mongoDatabases" file := "testdata/corerp-redis-recipe.bicep" target := fmt.Sprintf("br:radiusdev.azurecr.io/test-bicep-recipes/redis-recipe:%s", generateUniqueTag()) t.Run("Validate rad recipe register", func(t *testing.T) { - output, err := cli.RecipeRegister(ctx, envName, recipeName, templateKind, recipeTemplate, linkType) + output, err := cli.RecipeRegister(ctx, envName, recipeName, templateKind, recipeTemplate, resourceType) require.NoError(t, err) require.Contains(t, output, "Successfully linked recipe") }) @@ -75,12 +75,12 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) { output, err := cli.RecipeList(ctx, envName) require.NoError(t, err) require.Regexp(t, recipeName, output) - require.Regexp(t, linkType, output) + require.Regexp(t, resourceType, output) require.Regexp(t, recipeTemplate, output) }) t.Run("Validate rad recipe unregister", func(t *testing.T) { - output, err := cli.RecipeUnregister(ctx, envName, recipeName, linkType) + output, err := cli.RecipeUnregister(ctx, envName, recipeName, resourceType) require.NoError(t, err) require.Contains(t, output, "Successfully unregistered recipe") }) @@ -88,15 +88,15 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) { t.Run("Validate rad recipe show", func(t *testing.T) { showRecipeName := "mongodbtest" showRecipeTemplate := "radiusdev.azurecr.io/recipes/functionaltest/parameters/mongodatabases/azure:1.0" - showRecipeLinkType := "Applications.Link/mongoDatabases" - output, err := cli.RecipeRegister(ctx, envName, showRecipeName, templateKind, showRecipeTemplate, showRecipeLinkType) + showRecipeResourceType := "Applications.Datastores/mongoDatabases" + output, err := cli.RecipeRegister(ctx, envName, showRecipeName, templateKind, showRecipeTemplate, showRecipeResourceType) require.NoError(t, err) require.Contains(t, output, "Successfully linked recipe") - output, err = cli.RecipeShow(ctx, envName, showRecipeName, linkType) + output, err = cli.RecipeShow(ctx, envName, showRecipeName, resourceType) require.NoError(t, err) require.Contains(t, output, showRecipeName) require.Contains(t, output, showRecipeTemplate) - require.Contains(t, output, showRecipeLinkType) + require.Contains(t, output, showRecipeResourceType) require.Contains(t, output, "mongodbName") require.Contains(t, output, "documentdbName") require.Contains(t, output, "location") @@ -104,6 +104,26 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) { require.Contains(t, output, "resourceGroup().location]") }) + t.Run("Validate rad recipe show - terraform recipe", func(t *testing.T) { + showRecipeName := "redistesttf" + moduleServer := os.Getenv("TF_RECIPE_MODULE_SERVER_URL") + if moduleServer == "" { + moduleServer = "http://localhost:8999" + } + showRecipeTemplate := fmt.Sprintf("%s/kubernetes-redis.zip", moduleServer) + showRecipeResourceType := "Applications.Datastores/redisCaches" + output, err := cli.RecipeRegister(ctx, envName, showRecipeName, "terraform", showRecipeTemplate, showRecipeResourceType) + require.NoError(t, err) + require.Contains(t, output, "Successfully linked recipe") + output, err = cli.RecipeShow(ctx, envName, showRecipeName, showRecipeResourceType) + require.NoError(t, err) + require.Contains(t, output, showRecipeName) + require.Contains(t, output, showRecipeTemplate) + require.Contains(t, output, showRecipeResourceType) + require.Contains(t, output, "redis_cache_name") + require.Contains(t, output, "string") + }) + t.Run("Validate `rad bicep publish` is publishing the file to the given target", func(t *testing.T) { output, err := cli.BicepPublish(ctx, file, target) require.NoError(t, err) @@ -111,7 +131,7 @@ func verifyRecipeCLI(ctx context.Context, t *testing.T, test shared.RPTest) { }) t.Run("Validate rad recipe register with recipe name conflicting with dev recipe", func(t *testing.T) { - output, err := cli.RecipeRegister(ctx, envName, "mongo-azure", templateKind, recipeTemplate, linkType) + output, err := cli.RecipeRegister(ctx, envName, "mongo-azure", templateKind, recipeTemplate, resourceType) require.Contains(t, output, "Successfully linked recipe") require.NoError(t, err) output, err = cli.RecipeList(ctx, envName) @@ -173,7 +193,7 @@ func verifyCLIBasics(ctx context.Context, t *testing.T, test shared.RPTest) { require.Contains(t, output, "Server running at http://localhost:3000") }) t.Run("Validate rad resource expose Container", func(t *testing.T) { - t.Skip("https://github.com/project-radius/radius/issues/3232") + t.Skip("https://github.com/radius-project/radius/issues/3232") port, err := GetAvailablePort() require.NoError(t, err) diff --git a/test/functional/shared/cli/testdata/corerp-resources-recipe-env.bicep b/test/functional/shared/cli/testdata/corerp-resources-recipe-env.bicep index 0941974cf0..e2560b472e 100644 --- a/test/functional/shared/cli/testdata/corerp-resources-recipe-env.bicep +++ b/test/functional/shared/cli/testdata/corerp-resources-recipe-env.bicep @@ -13,7 +13,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { namespace: 'corerp-resources-recipe-env' } recipes: { - 'Applications.Link/mongoDatabases':{ + 'Applications.Datastores/mongoDatabases':{ recipe1: { templateKind: 'bicep' templatePath: 'testpublicrecipe.azurecr.io/bicep/modules/mongodatabases:v1' diff --git a/test/functional/shared/mechanics/aws_mechanics_test.go b/test/functional/shared/mechanics/aws_mechanics_test.go index 5b1d3be0f3..f5a3535809 100644 --- a/test/functional/shared/mechanics/aws_mechanics_test.go +++ b/test/functional/shared/mechanics/aws_mechanics_test.go @@ -21,9 +21,9 @@ import ( "testing" "github.com/google/uuid" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_AWSRedeployWithUpdatedResourceUpdatesResource(t *testing.T) { diff --git a/test/functional/shared/mechanics/k8s_extensibility_test.go b/test/functional/shared/mechanics/k8s_extensibility_test.go index e85b4ca197..747f507dee 100644 --- a/test/functional/shared/mechanics/k8s_extensibility_test.go +++ b/test/functional/shared/mechanics/k8s_extensibility_test.go @@ -22,9 +22,9 @@ import ( "strings" "testing" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "gopkg.in/yaml.v3" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/test/functional/shared/mechanics/mechanics_test.go b/test/functional/shared/mechanics/mechanics_test.go index c22c5dbe85..0cb95087f4 100644 --- a/test/functional/shared/mechanics/mechanics_test.go +++ b/test/functional/shared/mechanics/mechanics_test.go @@ -23,11 +23,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/project-radius/radius/pkg/kubernetes" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/kubernetes" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/labels" ) diff --git a/test/functional/shared/resources/application_environment_test.go b/test/functional/shared/resources/application_environment_test.go index add3c8d9c9..23ee2a1adb 100644 --- a/test/functional/shared/resources/application_environment_test.go +++ b/test/functional/shared/resources/application_environment_test.go @@ -20,9 +20,9 @@ import ( "context" "testing" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/test/functional/shared/resources/application_test.go b/test/functional/shared/resources/application_test.go index d23038b642..c6c21f9616 100644 --- a/test/functional/shared/resources/application_test.go +++ b/test/functional/shared/resources/application_test.go @@ -20,9 +20,9 @@ import ( "context" "testing" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/functional/shared/resources/aws_multi_identifier_resource_test.go b/test/functional/shared/resources/aws_multi_identifier_resource_test.go index 0f794c02e2..6042e26a97 100644 --- a/test/functional/shared/resources/aws_multi_identifier_resource_test.go +++ b/test/functional/shared/resources/aws_multi_identifier_resource_test.go @@ -20,9 +20,9 @@ import ( "testing" "github.com/google/uuid" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_AWS_MultiIdentifier_Resource(t *testing.T) { diff --git a/test/functional/shared/resources/aws_s3_bucket_test.go b/test/functional/shared/resources/aws_s3_bucket_test.go index b6082ddf75..0bb73f858a 100644 --- a/test/functional/shared/resources/aws_s3_bucket_test.go +++ b/test/functional/shared/resources/aws_s3_bucket_test.go @@ -20,9 +20,9 @@ import ( "testing" "github.com/google/uuid" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_AWS_S3Bucket(t *testing.T) { diff --git a/test/functional/shared/resources/azure_connections_test.go b/test/functional/shared/resources/azure_connections_test.go index 78bec54eb6..e341c7b640 100644 --- a/test/functional/shared/resources/azure_connections_test.go +++ b/test/functional/shared/resources/azure_connections_test.go @@ -20,10 +20,10 @@ import ( "os" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_AzureConnections(t *testing.T) { diff --git a/test/functional/shared/resources/container_runtimes_test.go b/test/functional/shared/resources/container_runtimes_test.go new file mode 100644 index 0000000000..82f8a8b5b4 --- /dev/null +++ b/test/functional/shared/resources/container_runtimes_test.go @@ -0,0 +1,199 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource_test + +import ( + "context" + "testing" + + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" + + "github.com/stretchr/testify/require" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +/* +Test_Container_YAMLManifest tests the scenario where the base manifest yaml (./testdata/manifest/basemanifest.yaml) +has Deployment, Service, ServiceAccount, and multiple secrets and configmaps. The deployment resource in the manifest +uses environment varibles from secret and configmap and volume from secret, which are unsupported by +Applications.Core/containers resource. This enables Radius to render kubernetes resources unsupported by containers +resource. +*/ +func Test_Container_YAMLManifest(t *testing.T) { + template := "testdata/corerp-resources-container-manifest.bicep" + name := "corerp-resources-container-manifest" + appNamespace := "corerp-resources-container-manifest" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "ctnr-manifest", + Type: validation.ContainersResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "ctnr-manifest"), + }, + }, + }, + PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + deploy, err := test.Options.K8sClient.AppsV1().Deployments(appNamespace).Get(ctx, "ctnr-manifest", metav1.GetOptions{}) + require.NoError(t, err) + require.Equal(t, "base-manifest-test", deploy.ObjectMeta.Annotations["source"]) + require.ElementsMatch(t, + []string{"TEST_SECRET_KEY", "TEST_CONFIGMAP_KEY"}, + []string{ + deploy.Spec.Template.Spec.Containers[0].Env[0].Name, + deploy.Spec.Template.Spec.Containers[0].Env[1].Name, + }) + + srv, err := test.Options.K8sClient.CoreV1().Services(appNamespace).Get(ctx, "ctnr-manifest", metav1.GetOptions{}) + require.NoError(t, err) + require.Equal(t, "base-manifest-test", srv.ObjectMeta.Annotations["source"]) + + sa, err := test.Options.K8sClient.CoreV1().ServiceAccounts(appNamespace).Get(ctx, "ctnr-manifest", metav1.GetOptions{}) + require.NoError(t, err) + require.Equal(t, "base-manifest-test", sa.ObjectMeta.Annotations["source"]) + + for _, name := range []string{"ctnr-manifest-secret0", "ctnr-manifest-secret1"} { + _, err := test.Options.K8sClient.CoreV1().Secrets(appNamespace).Get(ctx, name, metav1.GetOptions{}) + require.NoError(t, err) + } + + _, err = test.Options.K8sClient.CoreV1().ConfigMaps(appNamespace).Get(ctx, "ctnr-manifest-config", metav1.GetOptions{}) + require.NoError(t, err) + }, + }, + }) + + test.Test(t) +} + +/* +Test_Container_YAMLManifest_SideCar tests the scenario where the base manifest yaml (./testdata/manifest/sidecar.yaml) +has the fluentbit sidecar. Radius injects the application container described in container resource into the given +base deployment. With this, user can add multiple sidecars to their final deployment with application container. +*/ +func Test_Container_YAMLManifest_SideCar(t *testing.T) { + template := "testdata/corerp-resources-container-manifest-sidecar.bicep" + name := "corerp-resources-container-sidecar" + appNamespace := "corerp-resources-container-sidecar" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "ctnr-sidecar", + Type: validation.ContainersResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "ctnr-sidecar"), + }, + }, + }, + PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + deploy, err := test.Options.K8sClient.AppsV1().Deployments(appNamespace).Get(ctx, "ctnr-sidecar", metav1.GetOptions{}) + require.NoError(t, err) + + require.Len(t, deploy.Spec.Template.Spec.Containers, 2) + + // Ensure that Pod includes sidecar. + require.ElementsMatch(t, []string{"ctnr-sidecar", "log-collector"}, []string{ + deploy.Spec.Template.Spec.Containers[0].Name, + deploy.Spec.Template.Spec.Containers[1].Name, + }) + }, + }, + }) + + test.Test(t) +} + +func Test_Container_pod_patching(t *testing.T) { + template := "testdata/corerp-resources-container-pod-patching.bicep" + name := "corerp-resources-container-podpatch" + appNamespace := "corerp-resources-container-podpatch" + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: "ctnr-podpatch", + Type: validation.ContainersResource, + App: name, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{ + Namespaces: map[string][]validation.K8sObject{ + appNamespace: { + validation.NewK8sPodForResource(name, "ctnr-podpatch"), + }, + }, + }, + PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + deploy, err := test.Options.K8sClient.AppsV1().Deployments(appNamespace).Get(ctx, "ctnr-podpatch", metav1.GetOptions{}) + require.NoError(t, err) + + t.Logf("deploy: %+v", deploy) + + require.Len(t, deploy.Spec.Template.Spec.Containers, 2) + + // Ensure that Pod includes sidecar. + require.ElementsMatch(t, []string{"ctnr-podpatch", "log-collector"}, []string{ + deploy.Spec.Template.Spec.Containers[0].Name, + deploy.Spec.Template.Spec.Containers[1].Name, + }) + + require.True(t, deploy.Spec.Template.Spec.HostNetwork) + }, + }, + }) + + test.Test(t) +} diff --git a/test/functional/shared/resources/container_test.go b/test/functional/shared/resources/container_test.go index ce1b9fcb04..ccfa1af3f8 100644 --- a/test/functional/shared/resources/container_test.go +++ b/test/functional/shared/resources/container_test.go @@ -21,10 +21,10 @@ import ( "fmt" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/test/functional/shared/resources/container_versioning_test.go b/test/functional/shared/resources/container_versioning_test.go index 745f1b46ed..ae76cb0c94 100644 --- a/test/functional/shared/resources/container_versioning_test.go +++ b/test/functional/shared/resources/container_versioning_test.go @@ -21,10 +21,10 @@ import ( "fmt" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/functional/shared/resources/dapr_component_name_conflict_test.go b/test/functional/shared/resources/dapr_component_name_conflict_test.go deleted file mode 100644 index 107bbfbdb7..0000000000 --- a/test/functional/shared/resources/dapr_component_name_conflict_test.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprComponentNameConflict(t *testing.T) { - template := "testdata/corerp-resources-dapr-component-name-conflict.bicep" - name := "corerp-resources-dcnc-old" - - validate := step.ValidateSingleDetail("DeploymentFailed", step.DeploymentErrorDetail{ - Code: "ResourceDeploymentFailure", - Details: []step.DeploymentErrorDetail{ - { - Code: v1.CodeInternal, - MessageContains: "the Dapr component name '\"dapr-component-old\"' is already in use by another resource. Dapr component and resource names must be unique across all Dapr types (eg: StateStores, PubSubBrokers, SecretStores, etc.). Please select a new name and try again", - }, - }, - }) - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployErrorExecutor(template, validate), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-dapr-component-name-conflict", - Type: validation.ApplicationsResource, - }, - }, - }, - SkipObjectValidation: true, - SkipKubernetesOutputResourceValidation: true, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} diff --git a/test/functional/shared/resources/dapr_pubsub_test.go b/test/functional/shared/resources/dapr_pubsub_test.go deleted file mode 100644 index 33a73bb08c..0000000000 --- a/test/functional/shared/resources/dapr_pubsub_test.go +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "fmt" - "testing" - - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprPubSubBroker_Manual(t *testing.T) { - template := "testdata/corerp-resources-dapr-pubsub-broker-manual.bicep" - name := "dpsb-mnl-app-old" - appNamespace := "default-dpsb-mnl-app-old" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "dpsb-mnl-app-old", - Type: validation.ApplicationsResource, - }, - { - Name: "dpsb-mnl-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dpsb-mnl-old", - Type: validation.O_DaprPubSubBrokersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dpsb-mnl-app-ctnr-old"), - validation.NewK8sPodForResource(name, "dpsb-mnl-redis-old").ValidateLabels(false), - validation.NewK8sServiceForResource(name, "dpsb-mnl-redis-old").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} - -func Test_DaprPubSubBroker_Recipe(t *testing.T) { - template := "testdata/corerp-resources-dapr-pubsub-broker-recipe.bicep" - name := "dpsb-recipe-app-old" - appNamespace := "dpsb-recipe-env-old" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "dpsb-recipe-env-old", - Type: validation.EnvironmentsResource, - }, - { - Name: "dpsb-recipe-app-old", - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "dpsb-recipe-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dpsb-recipe-old", - Type: validation.O_DaprPubSubBrokersResource, - App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource1", - }, - }, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dpsb-recipe-app-ctnr-old").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} diff --git a/test/functional/shared/resources/dapr_secretstore_test.go b/test/functional/shared/resources/dapr_secretstore_test.go deleted file mode 100644 index 6e5430ed51..0000000000 --- a/test/functional/shared/resources/dapr_secretstore_test.go +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprSecretStore_Manual_Generic(t *testing.T) { - template := "testdata/corerp-resources-dapr-secretstore-manual.bicep" - name := "corerp-resources-dssm-old" - appNamespace := "default-corerp-resources-dssm-old" - - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "gnrc-scs-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "gnrc-scs-manual-old", - Type: validation.O_DaprSecretStoresResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "gnrc-scs-ctnr-old"), - }, - }, - }, - }, - }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} - -func Test_DaprSecretStore_Recipe(t *testing.T) { - template := "testdata/corerp-resources-dapr-secretstore-recipe.bicep" - name := "corerp-resources-dssr-old" - appNamespace := "corerp-resources-dssr-old" - - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "gnrc-scs-ctnr-recipe-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "gnrc-scs-recipe-old", - Type: validation.O_DaprSecretStoresResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "gnrc-scs-ctnr-recipe-old").ValidateLabels(false), - }, - }, - }, - }, - }, shared.K8sSecretResource(appNamespace, "mysecret", "", "fakekey", []byte("fakevalue"))) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} diff --git a/test/functional/shared/resources/dapr_serviceinvocation_test.go b/test/functional/shared/resources/dapr_serviceinvocation_test.go deleted file mode 100644 index 73b582d87e..0000000000 --- a/test/functional/shared/resources/dapr_serviceinvocation_test.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprServiceInvocation(t *testing.T) { - template := "testdata/corerp-resources-dapr-serviceinvocation.bicep" - name := "dapr-si-old" - appNamespace := "default-dapr-si-old" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "dapr-frontend-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dapr-backend-old", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dapr-frontend-old"), - validation.NewK8sPodForResource(name, "dapr-backend-old"), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - - test.Test(t) -} diff --git a/test/functional/shared/resources/dapr_statestore_test.go b/test/functional/shared/resources/dapr_statestore_test.go deleted file mode 100644 index 85f57b6ac7..0000000000 --- a/test/functional/shared/resources/dapr_statestore_test.go +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "fmt" - "testing" - - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_DaprStateStore_Manual(t *testing.T) { - template := "testdata/corerp-resources-dapr-statestore-manual.bicep" - name := "corerp-resources-dsstm-old" - appNamespace := "default-corerp-resources-dsstm-old" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), fmt.Sprintf("namespace=%s", appNamespace)), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-dsstm-old", - Type: validation.ApplicationsResource, - }, - { - Name: "dapr-sts-manual-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dapr-sts-manual-old", - Type: validation.O_DaprStateStoresResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dapr-sts-manual-ctnr-old"), - - // Deployed as supporting resources using Kubernetes Bicep extensibility. - validation.NewK8sPodForResource(name, "dapr-sts-manual-redis-old").ValidateLabels(false), - validation.NewK8sServiceForResource(name, "dapr-sts-manual-redis-old").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} - -func Test_DaprStateStore_Recipe(t *testing.T) { - template := "testdata/corerp-resources-dapr-statestore-recipe.bicep" - name := "corerp-rs-dapr-sts-recipe-old" - appNamespace := "corerp-env-recipes-env-old" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-env-recipes-env-old", - Type: validation.EnvironmentsResource, - }, - { - Name: "corerp-rs-dapr-sts-recipe-old", - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "dapr-sts-recipe-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "dapr-sts-recipe-old", - Type: validation.O_DaprStateStoresResource, - App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderKubernetes, - LocalID: "RecipeResource1", - }, - }, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "dapr-sts-recipe-ctnr-old").ValidateLabels(false), - }, - }, - }, - }, - }) - test.RequiredFeatures = []shared.RequiredFeature{shared.FeatureDapr} - test.Test(t) -} diff --git a/test/functional/shared/resources/environment_test.go b/test/functional/shared/resources/environment_test.go index 1eb7f36179..6c9249785e 100644 --- a/test/functional/shared/resources/environment_test.go +++ b/test/functional/shared/resources/environment_test.go @@ -19,9 +19,9 @@ package resource_test import ( "testing" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_Environment(t *testing.T) { diff --git a/test/functional/shared/resources/extender_test.go b/test/functional/shared/resources/extender_test.go index cec5aef0c7..f42fe2c36c 100644 --- a/test/functional/shared/resources/extender_test.go +++ b/test/functional/shared/resources/extender_test.go @@ -22,11 +22,10 @@ import ( "os" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_Extender_Manual(t *testing.T) { @@ -99,18 +98,19 @@ func Test_Extender_Recipe(t *testing.T) { } func Test_Extender_RecipeAWS(t *testing.T) { - awsAccountId := os.Getenv("AWS_ACCOUNT_ID") + awsAccountID := os.Getenv("AWS_ACCOUNT_ID") awsRegion := os.Getenv("AWS_REGION") // Error the test if the required environment variables are not set // for running locally set the environment variables - if awsAccountId == "" || awsRegion == "" { + if awsAccountID == "" || awsRegion == "" { t.Error("This test needs the env variables AWS_ACCOUNT_ID and AWS_REGION to be set") } - template := "testdata/corerp-resources-extenders-aws-s3-recipe.bicep" + template := "testdata/corerp-resources-extender-aws-s3-recipe.bicep" name := "corerp-resources-extenders-aws-s3-recipe" appName := "corerp-resources-extenders-aws-s3-recipe-app" bucketName := generateS3BucketName() + bucketID := fmt.Sprintf("/planes/aws/aws/accounts/%s/regions/%s/providers/AWS.S3/Bucket/%s", awsAccountID, awsRegion, bucketName) test := shared.NewRPTest(t, name, []shared.TestStep{ { @@ -138,8 +138,7 @@ func Test_Extender_RecipeAWS(t *testing.T) { App: appName, OutputResources: []validation.OutputResourceResponse{ { - Provider: resourcemodel.ProviderAWS, - LocalID: "RecipeResource0", + ID: bucketID, }, }, }, diff --git a/test/functional/shared/resources/gateway_test.go b/test/functional/shared/resources/gateway_test.go index c7fa8edfc1..647a3a9317 100644 --- a/test/functional/shared/resources/gateway_test.go +++ b/test/functional/shared/resources/gateway_test.go @@ -26,11 +26,12 @@ import ( "testing" "time" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) const ( @@ -107,6 +108,8 @@ func Test_Gateway(t *testing.T) { require.NoError(t, err) t.Logf("found root proxy with hostname: {%s} and status: {%s}", metadata.Hostname, metadata.Status) + require.Equal(t, "Valid HTTPProxy", metadata.Status) + // Set up pod port-forwarding for contour-envoy t.Logf("Setting up portforward") @@ -369,6 +372,50 @@ func Test_Gateway_TLSTermination(t *testing.T) { test.Test(t) } +func Test_Gateway_Failure(t *testing.T) { + template := "testdata/corerp-resources-gateway-failure.bicep" + name := "corerp-resources-gateway-failure" + secret := "secret" + + // We might see either of these states depending on the timing. + validateFn := step.ValidateAnyDetails("DeploymentFailed", []step.DeploymentErrorDetail{ + { + Code: "ResourceDeploymentFailure", + Details: []step.DeploymentErrorDetail{ + { + Code: "Internal", + MessageContains: "invalid TLS certificate", + }, + }, + }, + }) + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployErrorExecutor(template, validateFn), + SkipObjectValidation: true, + SkipKubernetesOutputResourceValidation: true, + }, + }, + unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Secret", + "metadata": map[string]interface{}{ + "name": secret, + "namespace": "mynamespace", + }, + "type": "Opaque", + "data": map[string]interface{}{ + "tls.crt": "", + "tls.key": "", + }, + }, + }) + + test.Test(t) +} + func testGatewayWithPortForward(t *testing.T, ctx context.Context, at shared.RPTest, hostname string, remotePort int, isHttps bool, tests []GatewayTestConfig) error { // stopChan will close the port-forward connection on close stopChan := make(chan struct{}) @@ -454,4 +501,3 @@ func newTestHTTPClient(isHttps bool, hostname string) *http.Client { Transport: transport, } } - diff --git a/test/functional/shared/resources/kubemetadata_container_test.go b/test/functional/shared/resources/kubemetadata_container_test.go index c17dcf619f..7290a9dfb3 100644 --- a/test/functional/shared/resources/kubemetadata_container_test.go +++ b/test/functional/shared/resources/kubemetadata_container_test.go @@ -21,10 +21,10 @@ import ( "fmt" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/test/functional/shared/resources/kubemetadata_gateway_test.go b/test/functional/shared/resources/kubemetadata_gateway_test.go index 9b5151f99d..8e6879b7ff 100644 --- a/test/functional/shared/resources/kubemetadata_gateway_test.go +++ b/test/functional/shared/resources/kubemetadata_gateway_test.go @@ -20,10 +20,10 @@ import ( "context" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" ) diff --git a/test/functional/shared/resources/kubemetadata_httproute_test.go b/test/functional/shared/resources/kubemetadata_httproute_test.go index f6e7471a38..897dbe38f4 100644 --- a/test/functional/shared/resources/kubemetadata_httproute_test.go +++ b/test/functional/shared/resources/kubemetadata_httproute_test.go @@ -20,10 +20,10 @@ import ( "context" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/test/functional/shared/resources/kubmetadata_cascade_test.go b/test/functional/shared/resources/kubmetadata_cascade_test.go index 422e90a44f..19bdb2d04a 100644 --- a/test/functional/shared/resources/kubmetadata_cascade_test.go +++ b/test/functional/shared/resources/kubmetadata_cascade_test.go @@ -21,10 +21,10 @@ import ( "fmt" "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/test/functional/shared/resources/microsoftsql_test.go b/test/functional/shared/resources/microsoftsql_test.go deleted file mode 100644 index 603b34868e..0000000000 --- a/test/functional/shared/resources/microsoftsql_test.go +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "os" - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_MicrosoftSQL(t *testing.T) { - template := "testdata/corerp-resources-microsoft-sql.bicep" - name := "corerp-resources-microsoft-sql" - - var adminUsername, adminPassword string - - if os.Getenv("AZURE_MSSQL_RESOURCE_ID") == "" { - t.Error("AZURE_MSSQL_RESOURCE_ID environment variable must be set to run this test.") - } - if os.Getenv("AZURE_MSSQL_DATABASE") == "" || os.Getenv("AZURE_MSSQL_SERVER") == "" { - t.Error("AZURE_MSSQL_DATABASE and AZURE_MSSQL_SERVER environment variable must be set to run this test.") - } - if os.Getenv("AZURE_MSSQL_USERNAME") != "" && os.Getenv("AZURE_MSSQL_PASSWORD") != "" { - adminUsername = "adminUsername=" + os.Getenv("AZURE_MSSQL_USERNAME") - adminPassword = "adminPassword=" + os.Getenv("AZURE_MSSQL_PASSWORD") - } else { - t.Error("AZURE_MSSQL_USERNAME and AZURE_MSSQL_PASSWORD environment variable must be set to run this test.") - } - mssqlresourceid := "mssqlresourceid=" + os.Getenv("AZURE_MSSQL_RESOURCE_ID") - sqlDatabse := "database=" + os.Getenv("AZURE_MSSQL_DATABASE") - sqlServer := "server=" + os.Getenv("AZURE_MSSQL_SERVER") - appNamespace := "default-corerp-resources-microsoft-sql" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), mssqlresourceid, adminUsername, adminPassword, sqlDatabse, sqlServer), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "mssql-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "mssql-app-ctnr-old"), - }, - }, - }, - }, - }) - - test.Test(t) -} - -// Test_SQLDatabase_Recipe validates: -// the creation of a sql database from recipe -// container using the sql database link to connect to the sql database resource -func Test_SQLDatabase_Recipe(t *testing.T) { - template := "testdata/corerp-resources-sqldb-recipe.bicep" - name := "corerp-resources-sqldb-recipe" - appNamespace := "corerp-resources-sqldb-recipe-app" - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-env-sql-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: "corerp-resources-sqldb-recipe", - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "sql-recipe-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "sql-recipe-app-ctnr").ValidateLabels(false), - validation.NewK8sPodForResource(name, "sql-recipe-resource").ValidateLabels(false), - }, - }, - }, - }, - }) - - test.Test(t) -} diff --git a/test/functional/shared/resources/mongodb_test.go b/test/functional/shared/resources/mongodb_test.go deleted file mode 100644 index 228cd08238..0000000000 --- a/test/functional/shared/resources/mongodb_test.go +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "os" - "testing" - - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -// Opt-out case for manual resource provisioning -func Test_MongoDB_ManualProvisioning(t *testing.T) { - template := "testdata/corerp-resources-mongodb-manual-provisioning.bicep" - name := "corerp-resources-mongodb-mp" - appNamespace := "default-ccorerp-resources-mp" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "mdb-us-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "mdb-us-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "mdb-us-rte-old", - Type: validation.HttpRoutesResource, - App: name, - }, - { - Name: "mdb-us-db-old", - Type: validation.O_MongoDatabasesResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "mdb-us-app-ctnr-old").ValidateLabels(false), - validation.NewK8sPodForResource(name, "mdb-us-ctnr-old").ValidateLabels(false), - validation.NewK8sServiceForResource(name, "mdb-us-rte-old").ValidateLabels(false), - }, - }, - }, - }, - }) - - test.Test(t) -} - -// Test_MongoDB_Recipe validates: -// the creation of a mongoDB from a recipe that uses an Azure resource -func Test_MongoDB_Recipe(t *testing.T) { - template := "testdata/corerp-resources-mongodb-recipe.bicep" - name := "corerp-resources-mongodb-recipe" - appNamespace := "corerp-resources-mongodb-recipe-app" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-mongodb-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: "corerp-resources-mongodb-recipe", - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "mongodb-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "mongodb-db-old", - Type: validation.O_MongoDatabasesResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "mongodb-app-ctnr-old").ValidateLabels(false), - }, - }, - }, - }, - }) - - test.Test(t) -} - -// Test_MongoDB_Recipe_Parameters validates the creation of a mongoDB from recipe with parameters passed by operator while linking recipe -// and developer while creating the mongoDatabase link. -// If the same parameters are set by the developer and the operator then the developer parameters are applied in to resolve conflicts. -// Container uses the mongoDB link to connect to the mongoDB resource -func Test_MongoDB_RecipeParameters(t *testing.T) { - t.Skip("Skipping test as creating/deleting cosmosdb resource is unreliable - https://github.com/project-radius/radius/issues/5929") - - template := "testdata/corerp-resources-mongodb-recipe-parameters.bicep" - name := "corerp-resources-mongodb-recipe-parameters" - appNamespace := "corerp-resources-mongodb-recipe-param-app" - rg := os.Getenv("INTEGRATION_TEST_RESOURCE_GROUP_NAME") - // Error the test if INTEGRATION_TEST_RESOURCE_GROUP_NAME is not set - // for running locally set the INTEGRATION_TEST_RESOURCE_GROUP_NAME with the test resourceGroup - if rg == "" { - t.Error("This test needs the env variable INTEGRATION_TEST_RESOURCE_GROUP_NAME to be set") - } - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-env-recipe-parameters-env", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "mdb-param-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "mdb-recipe-param-db-old", - Type: validation.O_MongoDatabasesResource, - App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource1", - }, - }, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "mdb-param-ctnr-old").ValidateLabels(false), - }, - }, - }, - }, - }) - - test.Test(t) -} - -// Test_MongoDB_Recipe_ContextParameter validates creation of a mongoDB from -// a default recipe using the context parameter generated and set by linkRP, -// and container using the mongoDB link to connect to the underlying mongoDB resource. -func Test_MongoDB_Recipe_ContextParameter(t *testing.T) { - t.Skip("Skipping test as creating/deleting cosmosdb resource is unreliable - https://github.com/project-radius/radius/issues/5929") - - template := "testdata/corerp-resources-mongodb-recipe-context.bicep" - name := "corerp-resources-mongodb-recipe-context" - appNamespace := "corerp-resources-mongodb-recipe-context-app" - rg := os.Getenv("INTEGRATION_TEST_RESOURCE_GROUP_NAME") - // Error the test if INTEGRATION_TEST_RESOURCE_GROUP_NAME is not set - // for running locally set the INTEGRATION_TEST_RESOURCE_GROUP_NAME with the test resourceGroup - if rg == "" { - t.Error("This test needs the env variable INTEGRATION_TEST_RESOURCE_GROUP_NAME to be set") - } - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-env-recipes-context-env", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - App: name, - }, - { - Name: "mdb-ctx-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "mdb-ctx-old", - Type: validation.O_MongoDatabasesResource, - App: name, - OutputResources: []validation.OutputResourceResponse{ - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource0", - }, - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource1", - }, - }, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "mdb-ctx-ctnr-old").ValidateLabels(false), - }, - }, - }, - }, - }) - - test.Test(t) -} diff --git a/test/functional/shared/resources/persistent_volume_test.go b/test/functional/shared/resources/persistent_volume_test.go index c55f5ae235..59f2f21fb9 100644 --- a/test/functional/shared/resources/persistent_volume_test.go +++ b/test/functional/shared/resources/persistent_volume_test.go @@ -19,10 +19,10 @@ package resource_test import ( "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) func Test_PersistentVolume(t *testing.T) { diff --git a/test/functional/shared/resources/rabbitmq_test.go b/test/functional/shared/resources/rabbitmq_test.go deleted file mode 100644 index 7c5284fdcc..0000000000 --- a/test/functional/shared/resources/rabbitmq_test.go +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_RabbitMQ_Manual(t *testing.T) { - template := "testdata/corerp-resources-rabbitmq.bicep" - name := "corerp-resources-rabbitmq-old" - appNamespace := "default-corerp-resources-rabbitmq-old" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), "password=guest"), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "rmq-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "rmq-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "rmq-rte-old", - Type: validation.HttpRoutesResource, - App: name, - }, - { - Name: "rmq-rmq-old", - Type: validation.O_RabbitMQMessageQueuesResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "rmq-app-ctnr-old"), - validation.NewK8sPodForResource(name, "rmq-ctnr-old"), - validation.NewK8sServiceForResource(name, "rmq-rte-old"), - }, - }, - }, - }, - }) - - test.Test(t) -} - -func Test_RabbitMQ_Recipe(t *testing.T) { - template := "testdata/corerp-resources-rabbitmq-recipe.bicep" - name := "corerp-resources-rabbitmq-recipe-old" - appNamespace := "default-corerp-resources-rabbitmq-recipe-old" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage(), "password=guest", functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-environment-rabbitmq-recipe-env-old", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "rmq-recipe-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "rmq-recipe-app-ctnr-old").ValidateLabels(false), - validation.NewK8sPodForResource(name, "rmq-recipe-resource-old").ValidateLabels(false), - }, - }, - }, - }, - }) - - test.Test(t) -} diff --git a/test/functional/shared/resources/recipe_bicep_test.go b/test/functional/shared/resources/recipe_bicep_test.go index acd6021d3e..cfa86848f8 100644 --- a/test/functional/shared/resources/recipe_bicep_test.go +++ b/test/functional/shared/resources/recipe_bicep_test.go @@ -23,12 +23,12 @@ import ( "strings" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" ) @@ -85,7 +85,7 @@ func Test_BicepRecipe_ParametersAndOutputs(t *testing.T) { }, K8sObjects: &validation.K8sObjectSet{}, PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { - resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Link/extenders", name) + resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) require.NoError(t, err) text, err := json.MarshalIndent(resource, "", " ") @@ -192,7 +192,7 @@ func Test_BicepRecipe_ResourceCreation(t *testing.T) { // This currently fails. SkipResourceDeletion: true, PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { - resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Link/extenders", name) + resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) require.NoError(t, err) text, err := json.MarshalIndent(resource, "", " ") @@ -206,27 +206,15 @@ func Test_BicepRecipe_ResourceCreation(t *testing.T) { scope := strings.ReplaceAll(parsed.RootScope(), "resourcegroups", "resourceGroups") expected := []any{ map[string]any{ - "Identity": map[string]any{ - "apiVersion": "unknown", - "kind": "Secret", - "name": name, - "namespace": name + "-app", - }, - "LocalID": "RecipeResource0", - "Provider": "kubernetes", + "id": "/planes/kubernetes/local/namespaces/" + name + "-app/providers/core/Secret/" + name, + "radiusManaged": true, }, map[string]any{ - "Identity": map[string]interface{}{ - "id": scope + "/providers/Applications.Link/extenders/" + name + "-created", - }, - "LocalID": "RecipeResource1", - "Provider": "radius", + "id": scope + "/providers/Applications.Core/extenders/" + name + "-created", + "radiusManaged": true, }, map[string]interface{}{ - "Identity": map[string]interface{}{ - "id": scope + "/providers/Applications.Link/extenders/" + name + "-module", - }, - "LocalID": "RecipeResource2", - "Provider": "radius", + "id": scope + "/providers/Applications.Core/extenders/" + name + "-module", + "radiusManaged": true, }, } actual := resource.Properties["status"].(map[string]any)["outputResources"].([]any) @@ -266,11 +254,11 @@ func Test_BicepRecipe_ParameterNotDefined(t *testing.T) { Code: "ResourceDeploymentFailure", Details: []step.DeploymentErrorDetail{ { - Code: v1.CodeInternal, + Code: recipes.RecipeDeploymentFailed, // NOTE: There is a bug in our error handling for deployements. We return the JSON text of the deployment error inside the message // of our error. This is wrong. // - // See: https://github.com/project-radius/radius/issues/6045 + // See: https://github.com/radius-project/radius/issues/6045 MessageContains: "Deployment template validation failed: 'The template parameters 'a, b' in the parameters file are not valid", }, @@ -312,7 +300,7 @@ func Test_BicepRecipe_WrongOutput(t *testing.T) { Code: "ResourceDeploymentFailure", Details: []step.DeploymentErrorDetail{ { - Code: v1.CodeInternal, + Code: recipes.InvalidRecipeOutputs, MessageContains: "failed to read the recipe output \"result\": json: unknown field \"error\"", }, }, @@ -353,11 +341,11 @@ func Test_BicepRecipe_LanguageFailure(t *testing.T) { Code: "ResourceDeploymentFailure", Details: []step.DeploymentErrorDetail{ { - Code: v1.CodeInternal, + Code: recipes.RecipeDeploymentFailed, // NOTE: There is a bug in our error handling for deployements. We return the JSON text of the deployment error inside the message // of our error. This is wrong. // - // See: https://github.com/project-radius/radius/issues/6046 + // See: https://github.com/radius-project/radius/issues/6046 MessageContains: "Unable to process template language expressions for resource", }, @@ -399,11 +387,11 @@ func Test_BicepRecipe_ResourceCreationFailure(t *testing.T) { Code: "ResourceDeploymentFailure", Details: []step.DeploymentErrorDetail{ { - Code: v1.CodeInternal, + Code: recipes.RecipeDeploymentFailed, // NOTE: There is a bug in our error handling for deployements. We return the JSON text of the deployment error inside the message // of our error. This is wrong. // - // See: https://github.com/project-radius/radius/issues/6047 + // See: https://github.com/radius-project/radius/issues/6047 MessageContains: "'not an id, just deal with it' is not a valid resource id", }, diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index 55a0e1cb7c..ea4368c500 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -26,19 +26,30 @@ package resource_test import ( "context" + "crypto/sha1" "encoding/base64" + "encoding/json" + "fmt" "strings" "testing" "github.com/stretchr/testify/require" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/recipes" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_radius "github.com/radius-project/radius/pkg/ucp/resources/radius" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" +) + +var ( + secretNamespace = "radius-system" + secretPrefix = "tfstate-default-" ) // Test_TerraformRecipe_Redis covers the following terraform recipe scenario: @@ -49,15 +60,19 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) { template := "testdata/corerp-resources-terraform-redis.bicep" name := "corerp-resources-terraform-redis" appName := "corerp-resources-terraform-redis-app" + envName := "corerp-resources-terraform-redis-env" redisCacheName := "tf-redis-cache" + secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, envName, appName) + require.NoError(t, err) + test := shared.NewRPTest(t, name, []shared.TestStep{ { Executor: step.NewDeployExecutor(template, functional.GetTerraformRecipeModuleServerURL(), "appName="+appName, "redisCacheName="+redisCacheName), RPResources: &validation.RPResourceSet{ Resources: []validation.RPResource{ { - Name: "corerp-resources-terraform-redis-env", + Name: envName, Type: validation.EnvironmentsResource, }, { @@ -65,7 +80,7 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) { Type: validation.ApplicationsResource, }, { - Name: "corerp-resources-terraform-redis", + Name: name, Type: validation.ExtendersResource, App: appName, OutputResources: []validation.OutputResourceResponse{}, // No output resources because Terraform Recipe outputs aren't integreted yet. @@ -75,22 +90,41 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appName: { - validation.NewK8sServiceForResource(appName, redisCacheName).ValidateLabels(false), + validation.NewK8sServiceForResource(appName, redisCacheName). + ValidateLabels(false), + }, + secretNamespace: { + validation.NewK8sSecretForResourceWithResourceName(secretPrefix + secretSuffix). + ValidateLabels(false), }, }, }, - SkipResourceDeletion: true, // Skip deletion because Terraform Recipe deletion isn't supported yet. + PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). + Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) + require.NoError(t, err) + require.Equal(t, secretNamespace, secret.Namespace) + require.Equal(t, secretPrefix+secretSuffix, secret.Name) + }, }, }) + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name + testSecretDeletion(t, ctx, test, appName, envName, resourceID) + } + test.Test(t) } func Test_TerraformRecipe_Context(t *testing.T) { template := "testdata/corerp-resources-terraform-context.bicep" name := "corerp-resources-terraform-context" - appNamespace := "corerp-resources-terraform-context-app" + secretSuffix, err := getSecretSuffix("/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/"+name, name, name) + require.NoError(t, err) + test := shared.NewRPTest(t, name, []shared.TestStep{ { Executor: step.NewDeployExecutor(template, functional.GetTerraformRecipeModuleServerURL()), @@ -111,6 +145,10 @@ func Test_TerraformRecipe_Context(t *testing.T) { appNamespace: { validation.NewK8sSecretForResource(name, name), }, + secretNamespace: { + validation.NewK8sSecretForResourceWithResourceName(secretPrefix + secretSuffix). + ValidateLabels(false), + }, }, }, PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { @@ -123,7 +161,7 @@ func Test_TerraformRecipe_Context(t *testing.T) { r, err := resources.ParseResource(string(decoded)) require.NoError(t, err) - rgName := r.FindScope(resources.ResourceGroupsSegment) + rgName := r.FindScope(resources_radius.ScopeResourceGroups) tests := []struct { key string @@ -131,7 +169,7 @@ func Test_TerraformRecipe_Context(t *testing.T) { }{ { key: "resource.type", - expected: "Applications.Link/extenders", + expected: "Applications.Core/extenders", }, { key: "azure.subscription_id", @@ -139,7 +177,7 @@ func Test_TerraformRecipe_Context(t *testing.T) { }, { key: "recipe_context", - expected: "{\"application\":{\"id\":\"/planes/radius/local/resourcegroups/radiusGroup/providers/Applications.Core/applications/corerp-resources-terraform-context\",\"name\":\"corerp-resources-terraform-context\"},\"aws\":null,\"azure\":{\"resourceGroup\":{\"id\":\"/subscriptions/00000000-0000-0000-0000-100000000000/resourceGroups/rg-terraform-context\",\"name\":\"rg-terraform-context\"},\"subscription\":{\"id\":\"/subscriptions/00000000-0000-0000-0000-100000000000\",\"subscriptionId\":\"00000000-0000-0000-0000-100000000000\"}},\"environment\":{\"id\":\"/planes/radius/local/resourcegroups/radiusGroup/providers/Applications.Core/environments/corerp-resources-terraform-context\",\"name\":\"corerp-resources-terraform-context\"},\"resource\":{\"id\":\"/planes/radius/local/resourcegroups/radiusGroup/providers/Applications.Link/extenders/corerp-resources-terraform-context\",\"name\":\"corerp-resources-terraform-context\",\"type\":\"Applications.Link/extenders\"},\"runtime\":{\"kubernetes\":{\"environmentNamespace\":\"corerp-resources-terraform-context-env\",\"namespace\":\"corerp-resources-terraform-context-app\"}}}", + expected: "{\"application\":{\"id\":\"/planes/radius/local/resourcegroups/radiusGroup/providers/Applications.Core/applications/corerp-resources-terraform-context\",\"name\":\"corerp-resources-terraform-context\"},\"aws\":null,\"azure\":{\"resourceGroup\":{\"id\":\"/subscriptions/00000000-0000-0000-0000-100000000000/resourceGroups/rg-terraform-context\",\"name\":\"rg-terraform-context\"},\"subscription\":{\"id\":\"/subscriptions/00000000-0000-0000-0000-100000000000\",\"subscriptionId\":\"00000000-0000-0000-0000-100000000000\"}},\"environment\":{\"id\":\"/planes/radius/local/resourcegroups/radiusGroup/providers/Applications.Core/environments/corerp-resources-terraform-context\",\"name\":\"corerp-resources-terraform-context\"},\"resource\":{\"id\":\"/planes/radius/local/resourcegroups/radiusGroup/providers/Applications.Core/extenders/corerp-resources-terraform-context\",\"name\":\"corerp-resources-terraform-context\",\"type\":\"Applications.Core/extenders\"},\"runtime\":{\"kubernetes\":{\"environmentNamespace\":\"corerp-resources-terraform-context-env\",\"namespace\":\"corerp-resources-terraform-context-app\"}}}", }, } @@ -150,10 +188,21 @@ func Test_TerraformRecipe_Context(t *testing.T) { replaced := strings.ReplaceAll(string(decoded), "resourcegroups/"+rgName, "resourcegroups/radiusGroup") require.Equalf(t, tc.expected, replaced, "secret data mismatch, key: %s", tc.key) } + + secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). + Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) + require.NoError(t, err) + require.Equal(t, secretNamespace, secret.Namespace) + require.Equal(t, secretPrefix+secretSuffix, secret.Name) }, - SkipResourceDeletion: true, }, }) + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name + testSecretDeletion(t, ctx, test, name, name, resourceID) + } + test.Test(t) } @@ -162,6 +211,7 @@ func Test_TerraformRecipe_AzureStorage(t *testing.T) { template := "testdata/corerp-resources-terraform-azurestorage.bicep" name := "corerp-resources-terraform-azstorage" appName := "corerp-resources-terraform-azstorage-app" + envName := "corerp-resources-terraform-azstorage-env" test := shared.NewRPTest(t, name, []shared.TestStep{ { @@ -169,7 +219,7 @@ func Test_TerraformRecipe_AzureStorage(t *testing.T) { RPResources: &validation.RPResourceSet{ Resources: []validation.RPResource{ { - Name: "corerp-resources-terraform-azstorage-env", + Name: envName, Type: validation.EnvironmentsResource, }, { @@ -177,22 +227,179 @@ func Test_TerraformRecipe_AzureStorage(t *testing.T) { Type: validation.ApplicationsResource, }, { - Name: "corerp-resources-terraform-azstorage", + Name: name, Type: validation.ExtendersResource, App: appName, - OutputResources: []validation.OutputResourceResponse{ - // Azure storage account. - { - Provider: resourcemodel.ProviderAzure, - LocalID: "RecipeResource0", - }, - }, }, }, }, SkipObjectValidation: true, - SkipResourceDeletion: true, // Skip deletion because Terraform Recipe deletion isn't supported yet. + PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name + secretSuffix, err := getSecretSuffix(resourceID, envName, appName) + require.NoError(t, err) + + secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). + Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) + require.NoError(t, err) + require.Equal(t, secretNamespace, secret.Namespace) + require.Equal(t, secretPrefix+secretSuffix, secret.Name) + }, + }, + }) + + test.PostDeleteVerify = func(ctx context.Context, t *testing.T, test shared.RPTest) { + resourceID := "/planes/radius/local/resourcegroups/kind-radius/providers/Applications.Core/extenders/" + name + testSecretDeletion(t, ctx, test, appName, envName, resourceID) + } + + test.Test(t) +} + +// Test_TerraformRecipe_ParametersAndOutputs Validates input parameters correctly set and output values/secrets are populated. +func Test_TerraformRecipe_ParametersAndOutputs(t *testing.T) { + template := "testdata/corerp-resources-terraform-recipe-terraform.bicep" + name := "corerp-resources-terraform-parametersandoutputs" + + // Best way to pass complex parameters is to use JSON. + parametersFilePath := functional.WriteBicepParameterFile(t, map[string]any{ + // These will be set on the environment as part of the recipe + "environmentParameters": map[string]any{ + "a": "environment", + "d": "environment", + }, + + // These will be set on the extender resource + "resourceParameters": map[string]any{ + "c": 42, + "d": "resource", + }, + }) + + parameters := []string{ + functional.GetTerraformRecipeModuleServerURL(), + fmt.Sprintf("basename=%s", name), + fmt.Sprintf("moduleName=%s", "parameter-outputs"), + "@" + parametersFilePath, + } + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployExecutor(template, parameters...), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.EnvironmentsResource, + }, + { + Name: name, + Type: validation.ApplicationsResource, + }, + { + Name: name, + Type: validation.ExtendersResource, + }, + }, + }, + K8sObjects: &validation.K8sObjectSet{}, + PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { + resource, err := test.Options.ManagementClient.ShowResource(ctx, "Applications.Core/extenders", name) + require.NoError(t, err) + + text, err := json.MarshalIndent(resource, "", " ") + require.NoError(t, err) + t.Logf("resource data:\n %s", text) + + require.Equal(t, "environment", resource.Properties["a"]) + require.Equal(t, "default value", resource.Properties["b"]) + require.Equal(t, 42.0, resource.Properties["c"]) + require.Equal(t, "resource", resource.Properties["d"]) + + response, err := test.Options.CustomAction.InvokeCustomAction(ctx, *resource.ID, "2022-03-15-privatepreview", "listSecrets") + require.NoError(t, err) + + expected := map[string]any{"e": "secret value"} + require.Equal(t, expected, response.Body) + }, + }, + }) + test.Test(t) +} + +// Test_TerraformRecipe_WrongOutput validates that a Terraform recipe with invalid "result" output schema returns an error. +func Test_TerraformRecipe_WrongOutput(t *testing.T) { + template := "testdata/corerp-resources-terraform-recipe-terraform.bicep" + name := "corerp-resources-terraform-wrong-output" + + parameters := []string{ + functional.GetTerraformRecipeModuleServerURL(), + fmt.Sprintf("basename=%s", name), + fmt.Sprintf("moduleName=%s", "wrong-output"), + } + + validate := step.ValidateSingleDetail("DeploymentFailed", step.DeploymentErrorDetail{ + Code: "ResourceDeploymentFailure", + Details: []step.DeploymentErrorDetail{ + { + Code: recipes.InvalidRecipeOutputs, + MessageContains: "failed to read the recipe output \"result\": json: unknown field \"error\"", + }, + }, + }) + + test := shared.NewRPTest(t, name, []shared.TestStep{ + { + Executor: step.NewDeployErrorExecutor(template, validate, parameters...), + RPResources: &validation.RPResourceSet{ + Resources: []validation.RPResource{ + { + Name: name, + Type: validation.EnvironmentsResource, + }, + { + Name: name, + Type: validation.ApplicationsResource, + }, + }, + }, + SkipObjectValidation: true, }, }) + test.Test(t) } + +func testSecretDeletion(t *testing.T, ctx context.Context, test shared.RPTest, appName, envName, resourceID string) { + secretSuffix, err := getSecretSuffix(resourceID, envName, appName) + require.NoError(t, err) + + secret, err := test.Options.K8sClient.CoreV1().Secrets(secretNamespace). + Get(ctx, secretPrefix+secretSuffix, metav1.GetOptions{}) + require.Error(t, err) + require.True(t, apierrors.IsNotFound(err)) + require.Equal(t, secret, &corev1.Secret{}) +} + +func getSecretSuffix(resourceID, envName, appName string) (string, error) { + parsedResourceID, err := resources.Parse(resourceID) + if err != nil { + return "", err + } + + prefix := fmt.Sprintf("%s-%s-%s", envName, appName, parsedResourceID.Name()) + maxResourceNameLen := 22 + if len(prefix) >= maxResourceNameLen { + prefix = prefix[:maxResourceNameLen] + } + + hasher := sha1.New() + _, err = hasher.Write([]byte(strings.ToLower(fmt.Sprintf("%s-%s-%s", envName, appName, parsedResourceID.String())))) + if err != nil { + return "", err + } + hash := hasher.Sum(nil) + + // example: env-app-redis.ec291e26078b7ea8a74abfac82530005a0ecbf15 + return fmt.Sprintf("%s.%x", prefix, hash), nil +} diff --git a/test/functional/shared/resources/recipe_test.go b/test/functional/shared/resources/recipe_test.go index 982d15862c..d367fd1e1a 100644 --- a/test/functional/shared/resources/recipe_test.go +++ b/test/functional/shared/resources/recipe_test.go @@ -20,10 +20,10 @@ import ( "fmt" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) // This file contains tests for general recipe engine functionality - covering general behaviors that should @@ -34,7 +34,7 @@ import ( // behaviors. Some functionality needs to be tested for each driver. func Test_Recipe_NotFound(t *testing.T) { - t.Skip("Blocked by https://github.com/project-radius/radius/issues/6040") + t.Skip("Blocked by https://github.com/radius-project/radius/issues/6040") template := "testdata/corerp-resources-recipe-notfound.bicep" name := "corerp-resources-recipe-notfound" diff --git a/test/functional/shared/resources/redis_test.go b/test/functional/shared/resources/redis_test.go deleted file mode 100644 index e299d462cb..0000000000 --- a/test/functional/shared/resources/redis_test.go +++ /dev/null @@ -1,139 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_RedisManualProvisioning(t *testing.T) { - template := "testdata/corerp-resources-redis-manualprovisioning.bicep" - name := "corerp-resources-redis-mp" - appNamespace := "default-corerp-resources-redis-mp" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "rds-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "rds-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "rds-rte-old", - Type: validation.HttpRoutesResource, - App: name, - }, - { - Name: "rds-rds-old", - Type: validation.O_RedisCachesResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "rds-app-ctnr-old"), - validation.NewK8sPodForResource(name, "rds-ctnr-old"), - validation.NewK8sServiceForResource(name, "rds-rte-old"), - }, - }, - }, - }, - }) - - test.Test(t) -} - -func Test_RedisRecipe(t *testing.T) { - template := "testdata/corerp-resources-redis-recipe.bicep" - name := "corerp-resources-redis-recipe" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-environment-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "rds-recipe-old", - Type: validation.O_RedisCachesResource, - App: name, - }, - }, - }, - SkipObjectValidation: true, - }, - }) - - test.Test(t) -} - -func Test_RedisDefaultRecipe(t *testing.T) { - template := "testdata/corerp-resources-redis-default-recipe.bicep" - name := "corerp-resources-redis-default-recipe" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: "corerp-resources-environment-default-recipe-env", - Type: validation.EnvironmentsResource, - }, - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "rds-default-recipe-old", - Type: validation.O_RedisCachesResource, - App: name, - }, - }, - }, - SkipObjectValidation: true, - }, - }) - - test.Test(t) -} diff --git a/test/functional/shared/resources/secretstore_test.go b/test/functional/shared/resources/secretstore_test.go deleted file mode 100644 index 9231a622a1..0000000000 --- a/test/functional/shared/resources/secretstore_test.go +++ /dev/null @@ -1,115 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "context" - "testing" - - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" - "github.com/stretchr/testify/require" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func Test_SecretStore_CreateSecret(t *testing.T) { - template := "testdata/corerp-resources-secretstore-new.bicep" - appName := "corerp-resources-secretstore" - appNamespace := "corerp-resources-secretstore-app" - - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, "@testdata/parameters/test-tls-cert.parameters.json"), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: appName, - Type: validation.ApplicationsResource, - }, - { - Name: "appcert", - Type: validation.SecretStoresResource, - App: appName, - }, - { - Name: "appsecret", - Type: validation.SecretStoresResource, - App: appName, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sSecretForResource(appName, "appcert"), - validation.NewK8sSecretForResource(appName, "appsecret"), - }, - }, - }, - PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { - secret, err := test.Options.K8sClient.CoreV1().Secrets(appNamespace).Get(ctx, "appcert", metav1.GetOptions{}) - require.NoError(t, err) - - for _, key := range []string{"tls.key", "tls.crt"} { - _, ok := secret.Data[key] - require.True(t, ok) - } - - secret, err = test.Options.K8sClient.CoreV1().Secrets(appNamespace).Get(ctx, "appsecret", metav1.GetOptions{}) - require.NoError(t, err) - - for _, key := range []string{"servicePrincipalPassword", "appId", "tenantId"} { - _, ok := secret.Data[key] - require.True(t, ok) - } - }, - }, - }) - - test.Test(t) -} - -func Test_SecretStore_ReferenceSecret(t *testing.T) { - template := "testdata/corerp-resources-secretstore-ref.bicep" - appName := "corerp-resources-secretstore-ref" - appNamespace := "corerp-resources-secretstore-ref" - - secret := shared.K8sSecretResource("default", "secret-app-existing-secret", "kubernetes.io/tls", "tls.crt", "fakecertval", "tls.key", "fakekeyval") - - test := shared.NewRPTest(t, appNamespace, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: appName, - Type: validation.ApplicationsResource, - }, - { - Name: "existing-appcert", - Type: validation.SecretStoresResource, - App: appName, - }, - }, - }, - SkipObjectValidation: true, - }, - }, secret) - - test.Test(t) -} diff --git a/test/functional/shared/resources/sql_test.go b/test/functional/shared/resources/sql_test.go deleted file mode 100644 index 8eaa4d1216..0000000000 --- a/test/functional/shared/resources/sql_test.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2023 The Radius Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package resource_test - -import ( - "runtime" - "testing" - - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" -) - -func Test_SQL(t *testing.T) { - // https://github.com/microsoft/mssql-docker/issues/668 - if runtime.GOARCH == "arm64" { - t.Skip("skipping Test_SQL, unsupported architecture") - } - template := "testdata/corerp-resources-sql.bicep" - name := "corerp-resources-sql" - appNamespace := "default-corerp-resources-sql" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "sql-app-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "sql-db-old", - Type: validation.O_SQLDatabasesResource, - App: name, - }, - { - Name: "sql-rte-old", - Type: validation.HttpRoutesResource, - App: name, - }, - { - Name: "sql-ctnr-old", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "sql-app-ctnr-old"), - validation.NewK8sPodForResource(name, "sql-ctnr-old"), - validation.NewK8sServiceForResource(name, "sql-rte-old"), - }, - }, - }, - }, - }) - - test.Test(t) -} diff --git a/test/functional/shared/resources/storage_test.go b/test/functional/shared/resources/storage_test.go index 1726361526..574f93ce42 100644 --- a/test/functional/shared/resources/storage_test.go +++ b/test/functional/shared/resources/storage_test.go @@ -19,10 +19,10 @@ package resource_test import ( "testing" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/functional/shared" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/functional/shared" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/validation" ) // Test_Storage tests if a container can be created and then deleted by the magpiego with the workload identity. diff --git a/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep b/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep index 7ae908c36a..dfd90e4c4f 100644 --- a/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep +++ b/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep @@ -61,7 +61,7 @@ resource redisRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { } } -resource redis 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { +resource redis 'Applications.Datastores/redisCaches@2022-03-15-privatepreview' = { name: 'friendly-rds-rds' location: 'global' properties: { diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-manifest-sidecar.bicep b/test/functional/shared/resources/testdata/corerp-resources-container-manifest-sidecar.bicep new file mode 100644 index 0000000000..8f9fbac81e --- /dev/null +++ b/test/functional/shared/resources/testdata/corerp-resources-container-manifest-sidecar.bicep @@ -0,0 +1,52 @@ +import radius as radius + +@description('Specifies the location for resources.') +param location string = 'global' + +@description('Specifies the image of the container resource.') +param magpieimage string + +@description('Specifies the port of the container resource.') +param port int = 3000 + +@description('Specifies the environment for resources.') +param environment string + +var manifest = loadTextContent('manifest/sidecar.yaml') + +resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { + name: 'corerp-resources-container-sidecar' + location: location + properties: { + environment: environment + extensions: [ + { + kind: 'kubernetesNamespace' + namespace: 'corerp-resources-container-sidecar' + } + ] + } +} + +resource container 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'ctnr-sidecar' + location: location + properties: { + application: app.id + container: { + image: magpieimage + ports: { + web: { + containerPort: port + } + } + } + connections: {} + runtimes: { + kubernetes: { + base: manifest + } + } + } +} + diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-manifest.bicep b/test/functional/shared/resources/testdata/corerp-resources-container-manifest.bicep new file mode 100644 index 0000000000..513c5a1d53 --- /dev/null +++ b/test/functional/shared/resources/testdata/corerp-resources-container-manifest.bicep @@ -0,0 +1,52 @@ +import radius as radius + +@description('Specifies the location for resources.') +param location string = 'global' + +@description('Specifies the image of the container resource.') +param magpieimage string + +@description('Specifies the port of the container resource.') +param port int = 3000 + +@description('Specifies the environment for resources.') +param environment string + +var manifest = loadTextContent('manifest/basemanifest.yaml') + +resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { + name: 'corerp-resources-container-manifest' + location: location + properties: { + environment: environment + extensions: [ + { + kind: 'kubernetesNamespace' + namespace: 'corerp-resources-container-manifest' + } + ] + } +} + +resource container 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'ctnr-manifest' + location: location + properties: { + application: app.id + container: { + image: magpieimage + ports: { + web: { + containerPort: port + } + } + } + connections: {} + runtimes: { + kubernetes: { + base: manifest + } + } + } +} + diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-pod-patching.bicep b/test/functional/shared/resources/testdata/corerp-resources-container-pod-patching.bicep new file mode 100644 index 0000000000..7dd27bd62a --- /dev/null +++ b/test/functional/shared/resources/testdata/corerp-resources-container-pod-patching.bicep @@ -0,0 +1,58 @@ +import radius as radius + +@description('Specifies the location for resources.') +param location string = 'global' + +@description('Specifies the image of the container resource.') +param magpieimage string + +@description('Specifies the port of the container resource.') +param port int = 3000 + +@description('Specifies the environment for resources.') +param environment string + +resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { + name: 'corerp-resources-container-podpatch' + location: location + properties: { + environment: environment + extensions: [ + { + kind: 'kubernetesNamespace' + namespace: 'corerp-resources-container-podpatch' + } + ] + } +} + +resource container 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'ctnr-podpatch' + location: location + properties: { + application: app.id + container: { + image: magpieimage + ports: { + web: { + containerPort: port + } + } + } + connections: {} + runtimes: { + kubernetes: { + pod: { + containers: [ + { + name: 'log-collector' + image: 'radiusdev.azurecr.io/fluent/fluent-bit:2.1.8' + } + ] + hostNetwork: true + } + } + } + } +} + diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-component-name-conflict.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-component-name-conflict.bicep deleted file mode 100644 index a753d4c1ed..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-component-name-conflict.bicep +++ /dev/null @@ -1,43 +0,0 @@ -import radius as radius - -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-dcnc-old' - location: 'global' - properties: { - environment: environment - } -} - -// Dapr Component #1 -resource pubsub 'Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview' = { - name: 'dapr-component-old' - location: 'global' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'pubsub.azure.servicebus' - version: 'v1' - metadata: { - name: 'example' - } - } -} - -// Dapr Component #2 -resource secretstore 'Applications.Link/daprSecretStores@2022-03-15-privatepreview' = { - name: 'dapr-component-old' - location: 'global' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'secretstores.kubernetes' - metadata: { - vaultName: 'test' - } - version: 'v1' - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-pubsub-broker-manual.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-pubsub-broker-manual.bicep deleted file mode 100644 index d6ceb56610..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-pubsub-broker-manual.bicep +++ /dev/null @@ -1,64 +0,0 @@ -import radius as radius - -param magpieimage string -param environment string -param namespace string = 'default' - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dpsb-mnl-app-old' - properties: { - environment: environment - } -} - -resource myapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'dpsb-mnl-app-ctnr-old' - properties: { - application: app.id - connections: { - daprpubsub: { - source: pubsubBroker.id - } - } - container: { - image: magpieimage - readinessProbe: { - kind: 'httpGet' - containerPort: 3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'dpsb-mnl-app-ctnr-old' - appPort: 3000 - } - ] - } -} - -module redis 'modules/redis-selfhost.bicep' = { - name: 'dpsb-mnl-redis-old-deployment' - params: { - name: 'dpsb-mnl-redis-old' - namespace: namespace - application: app.name - } -} - - -resource pubsubBroker 'Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview' = { - name: 'dpsb-mnl-old' - properties: { - application: app.id - environment: environment - resourceProvisioning: 'manual' - type: 'pubsub.redis' - metadata: { - redisHost: '${redis.outputs.host}:${redis.outputs.port}' - redisPassword: '' - } - version: 'v1' - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-pubsub-broker-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-pubsub-broker-recipe.bicep deleted file mode 100644 index 65ee52cd57..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-pubsub-broker-recipe.bicep +++ /dev/null @@ -1,72 +0,0 @@ -import radius as radius - -param magpieimage string -param registry string -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'dpsb-recipe-env-old' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'dpsb-recipe-env-old' - } - recipes: { - 'Applications.Link/daprPubSubBrokers': { - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/dapr-pubsub-broker:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dpsb-recipe-app-old' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'dpsb-recipe-app-old' - } - ] - } -} - -resource myapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'dpsb-recipe-app-ctnr-old' - properties: { - application: app.id - connections: { - daprpubsub: { - source: pubsubBroker.id - } - } - container: { - image: magpieimage - readinessProbe: { - kind: 'httpGet' - containerPort: 3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'dpsb-recipe-app-ctnr-old' - appPort: 3000 - } - ] - } -} - -resource pubsubBroker 'Applications.Link/daprPubSubBrokers@2022-03-15-privatepreview' = { - name: 'dpsb-recipe-old' - properties: { - application: app.id - environment: env.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-secretstore-manual.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-secretstore-manual.bicep deleted file mode 100644 index e3cd924c1d..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-secretstore-manual.bicep +++ /dev/null @@ -1,57 +0,0 @@ -import radius as radius - -param magpieimage string - -param environment string - -param location string = resourceGroup().location - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-dssm-old' - location: location - properties: { - environment: environment - } -} - -resource myapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'gnrc-scs-ctnr-old' - properties: { - application: app.id - connections: { - daprsecretstore: { - source: secretstore.id - } - } - container: { - image: magpieimage - readinessProbe:{ - kind:'httpGet' - containerPort:3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'gnrc-ss-ctnr-old' - appPort: 3000 - } - ] - } -} - -resource secretstore 'Applications.Link/daprSecretStores@2022-03-15-privatepreview' = { - name: 'gnrc-scs-manual-old' - location: location - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - type: 'secretstores.kubernetes' - metadata: { - vaultName: 'test' - } - version: 'v1' - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-secretstore-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-secretstore-recipe.bicep deleted file mode 100644 index ab2f020fc2..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-secretstore-recipe.bicep +++ /dev/null @@ -1,76 +0,0 @@ -import radius as radius - -param magpieimage string - -param location string = resourceGroup().location -param registry string -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-dssr-env-old' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-dssr-env-old' - } - recipes: { - 'Applications.Link/daprSecretStores': { - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/dapr-secret-store:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-dssr-old' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-dssr-old' - } - ] - } -} - -resource myapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'gnrc-scs-ctnr-recipe-old' - location: location - properties: { - application: app.id - connections: { - daprsecretstore: { - source: secretstore.id - } - } - container: { - image: magpieimage - readinessProbe: { - kind: 'httpGet' - containerPort: 3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'gnrc-ss-ctnr-recipe-old' - appPort: 3000 - } - ] - } -} - -resource secretstore 'Applications.Link/daprSecretStores@2022-03-15-privatepreview' = { - name: 'gnrc-scs-recipe-old' - location: location - properties: { - environment: env.id - application: app.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-serviceinvocation.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-serviceinvocation.bicep deleted file mode 100644 index af208f7ae3..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-serviceinvocation.bicep +++ /dev/null @@ -1,68 +0,0 @@ -import radius as radius - -param location string = resourceGroup().location -param environment string -param magpieimage string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'dapr-si-old' - location: location - properties: { - environment: environment - } -} - -resource frontend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'dapr-frontend-old' - location: location - properties: { - application: app.id - container: { - image: magpieimage - env: { - // Used by magpie to communicate with the backend. - CONNECTION_DAPRHTTPROUTE_APPID: 'backend-old' - } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'frontend-old' - } - ] - } -} - -resource backend 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'dapr-backend-old' - location: location - properties: { - application: app.id - container: { - image: magpieimage - ports: { - orders: { - containerPort: 3000 - } - } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'backend-old' - appPort: 3000 - } - ] - } -} - diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-statestore-manual.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-statestore-manual.bicep deleted file mode 100644 index 7c173bd5d1..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-statestore-manual.bicep +++ /dev/null @@ -1,65 +0,0 @@ -import radius as radius - -param magpieimage string -param environment string -param namespace string = 'default' - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-dsstm-old' - properties: { - environment: environment - } -} - -resource myapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'dapr-sts-manual-ctnr-old' - properties: { - application: app.id - connections: { - daprstatestore: { - source: statestore.id - } - } - container: { - image: magpieimage - readinessProbe: { - kind: 'httpGet' - containerPort: 3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'gnrc-sts-ctnr-old' - appPort: 3000 - } - ] - } -} - - -module redis 'modules/redis-selfhost.bicep' = { - name: 'dapr-sts-manual-redis-old-deployment' - params: { - name: 'dapr-sts-manual-redis-old' - namespace: namespace - application: app.name - } -} - - -resource statestore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'dapr-sts-manual-old' - properties: { - application: app.id - environment: environment - resourceProvisioning: 'manual' - type: 'state.redis' - metadata: { - redisHost: '${redis.outputs.host}:${redis.outputs.port}' - redisPassword: '' - } - version: 'v1' - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-dapr-statestore-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-dapr-statestore-recipe.bicep deleted file mode 100644 index c53837af77..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-dapr-statestore-recipe.bicep +++ /dev/null @@ -1,72 +0,0 @@ -import radius as radius - -param magpieimage string -param registry string -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-env-recipes-env-old' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-env-recipes-env-old' - } - recipes: { - 'Applications.Link/daprStateStores': { - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/dapr-state-store:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-rs-dapr-sts-recipe-old' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-rs-dapr-sts-recipe-old' - } - ] - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'dapr-sts-recipe-ctnr-old' - properties: { - application: app.id - connections: { - daprstatestore: { - source: statestore.id - } - } - container: { - image: magpieimage - readinessProbe: { - kind: 'httpGet' - containerPort: 3000 - path: '/healthz' - } - } - extensions: [ - { - kind: 'daprSidecar' - appId: 'dapr-sts-recipe-ctnr-old' - appPort: 3000 - } - ] - } -} - -resource statestore 'Applications.Link/daprStateStores@2022-03-15-privatepreview' = { - name: 'dapr-sts-recipe-old' - properties: { - application: app.id - environment: env.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep new file mode 100644 index 0000000000..e16692c321 --- /dev/null +++ b/test/functional/shared/resources/testdata/corerp-resources-extender-aws-s3-recipe.bicep @@ -0,0 +1,63 @@ +import radius as rad + +param bucketName string +param awsAccountId string +param awsRegion string +param registry string +param version string + +resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { + name: 'corerp-resources-extenders-aws-s3-recipe-env' + location: 'global' + properties: { + compute: { + kind: 'kubernetes' + resourceId: 'self' + namespace: 'corerp-resources-extenders-aws-s3-recipe-env' + } + providers: { + aws: { + scope: '/planes/aws/aws/accounts/${awsAccountId}/regions/${awsRegion}' + } + } + recipes: { + 'Applications.Core/extenders': { + s3: { + templateKind: 'bicep' + templatePath: '${registry}/test/functional/shared/recipes/extenders-aws-s3-recipe:${version}' + parameters: { + bucketName: bucketName + } + } + } + } + } +} + +resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { + name: 'corerp-resources-extenders-aws-s3-recipe-app' + location: 'global' + properties: { + environment: env.id + extensions: [ + { + kind: 'kubernetesNamespace' + namespace: 'corerp-resources-extenders-aws-s3-recipe-app' + } + ] + } +} + +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { + name: 'corerp-resources-extenders-aws-s3-recipe' + properties: { + environment: env.id + application: app.id + recipe: { + name: 's3' + parameters: { + bucketName: bucketName + } + } + } +} diff --git a/test/functional/shared/resources/testdata/corerp-resources-extender-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-extender-recipe.bicep index e9e94ad4c9..cde129c0b4 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-extender-recipe.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-extender-recipe.bicep @@ -14,7 +14,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { namespace: 'corerp-resources-extender-recipe-env' } recipes: { - 'Applications.Link/extenders':{ + 'Applications.Core/extenders':{ default: { templateKind: 'bicep' templatePath: '${registry}/test/functional/shared/recipes/extender-recipe:${version}' @@ -41,7 +41,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { } } -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: 'extender-recipe' properties: { environment: env.id diff --git a/test/functional/shared/resources/testdata/corerp-resources-extender.bicep b/test/functional/shared/resources/testdata/corerp-resources-extender.bicep index c3de618a5d..f71897fa79 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-extender.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-extender.bicep @@ -11,7 +11,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { } } -resource twilio 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource twilio 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: 'extr-twilio' properties: { environment: environment diff --git a/test/functional/shared/resources/testdata/corerp-resources-extenders-aws-s3-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-extenders-aws-s3-recipe.bicep deleted file mode 100644 index f8d3c78adf..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-extenders-aws-s3-recipe.bicep +++ /dev/null @@ -1,63 +0,0 @@ -import radius as rad - -param bucketName string -param awsAccountId string -param awsRegion string -param registry string -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-extenders-aws-s3-recipe-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-extenders-aws-s3-recipe-env' - } - providers: { - aws: { - scope: '/planes/aws/aws/accounts/${awsAccountId}/regions/${awsRegion}' - } - } - recipes: { - 'Applications.Link/extenders': { - s3: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/extenders-aws-s3-recipe:${version}' - parameters: { - bucketName: bucketName - } - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-extenders-aws-s3-recipe-app' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-extenders-aws-s3-recipe-app' - } - ] - } -} - -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { - name: 'corerp-resources-extenders-aws-s3-recipe' - properties: { - environment: env.id - application: app.id - recipe: { - name: 's3' - parameters: { - bucketName: bucketName - } - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep b/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep new file mode 100644 index 0000000000..ef7a22b8a5 --- /dev/null +++ b/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep @@ -0,0 +1,54 @@ +import radius as radius + +@description('ID of the Radius environment. Passed in automatically via the rad CLI') +param environment string + +resource demoApplication 'Applications.Core/applications@2022-03-15-privatepreview' = { + name: 'corerp-resources-gateway-failure-app' + properties: { + environment: environment + } +} + +resource demoSecretStore 'Applications.Core/secretStores@2022-03-15-privatepreview' = { + name: 'corerp-resources-gateway-failure-secretstore' + properties: { + application: demoApplication.id + type: 'certificate' + + // Reference the existing mynamespace/secret Kubernetes secret + resource: 'mynamespace/secret' + data: { + // Make the tls.crt and tls.key secrets available to the application + 'tls.crt': {} + 'tls.key': {} + } + } +} + +resource demoGateway 'Applications.Core/gateways@2022-03-15-privatepreview' = { + name: 'corerp-resources-gateway-failure-gateway' + properties: { + application: demoApplication.id + hostname: { + fullyQualifiedHostname: 'a.example.com' // Replace with your domain name. + } + routes: [ + { + path: '/' + destination: demoRoute.id + } + ] + tls: { + certificateFrom: demoSecretStore.id + minimumProtocolVersion: '1.2' + } + } +} + +resource demoRoute 'Applications.Core/httpRoutes@2022-03-15-privatepreview' = { + name: 'corerp-resources-gateway-failure-route' + properties: { + application: demoApplication.id + } +} diff --git a/test/functional/shared/resources/testdata/corerp-resources-microsoft-sql.bicep b/test/functional/shared/resources/testdata/corerp-resources-microsoft-sql.bicep deleted file mode 100644 index 48e3bbaf20..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-microsoft-sql.bicep +++ /dev/null @@ -1,80 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'East US' - -@description('Specifies the image for the container resource.') -param magpieImage string - -@description('Specifies the port for the container resource.') -param magpiePort int = 3000 - -@description('Specifies the environment for resources.') -param environment string = 'test' - -@description('Specifies the SQL username.') -param adminUsername string - -@description('Specifies the SQL password.') -@secure() -param adminPassword string - -param mssqlresourceid string - -param database string - -param server string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-microsoft-sql' - location: location - properties: { - environment: environment - } -} - -resource sqlapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'mssql-app-ctnr-old' - location: location - properties: { - application: app.id - connections: { - sql: { - source: db.id - } - } - container: { - image: magpieImage - env: { - CONNECTION_SQL_CONNECTIONSTRING: db.connectionString() - } - readinessProbe: { - kind: 'httpGet' - containerPort: magpiePort - path: '/healthz' - } - } - } -} - -resource db 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'mssql-db-old' - location: location - properties: { - application: app.id - environment: environment - resourceProvisioning: 'manual' - resources:[ - { - id:mssqlresourceid - } - ] - database: database - server: server - port:1433 - username: adminUsername - secrets: { - password: adminPassword - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-mongodb-manual-provisioning.bicep b/test/functional/shared/resources/testdata/corerp-resources-mongodb-manual-provisioning.bicep deleted file mode 100644 index cf244df971..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-mongodb-manual-provisioning.bicep +++ /dev/null @@ -1,88 +0,0 @@ -import radius as radius - -@description('Admin username for the Mongo database. Default is "admin"') -param username string = 'admin' - -@description('Admin password for the Mongo database') -@secure() -param password string = newGuid() - -param environment string - -param magpieimage string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-mongodb-mp' - location: 'global' - properties: { - environment: environment - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'mdb-us-app-ctnr-old' - location: 'global' - properties: { - application: app.id - connections: { - mongodb: { - source: mongo.id - } - } - container: { - image: magpieimage - } - } -} - - -// https://hub.docker.com/_/mongo/ -resource mongoContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'mdb-us-ctnr-old' - location: 'global' - properties: { - application: app.id - container: { - image: 'mongo:4.2' - env: { - DBCONNECTION: mongo.connectionString() - MONGO_INITDB_ROOT_USERNAME: username - MONGO_INITDB_ROOT_PASSWORD: password - } - ports: { - mongo: { - containerPort: 27017 - provides: mongoRoute.id - } - } - } - connections: {} - } -} - -resource mongoRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'mdb-us-rte-old' - location: 'global' - properties: { - application: app.id - port: 27017 - } -} - -resource mongo 'Applications.Link/mongoDatabases@2022-03-15-privatepreview' = { - name: 'mdb-us-db-old' - location: 'global' - properties: { - application: app.id - environment: environment - resourceProvisioning: 'manual' - host: mongoRoute.properties.hostname - port: mongoRoute.properties.port - database: 'mongodb-o-${app.name}' - username: username - secrets: { - connectionString: 'mongodb://${username}:${password}@${mongoRoute.properties.hostname}:${mongoRoute.properties.port}/mongodb-o-${app.name}' - password: password - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe-context.bicep b/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe-context.bicep deleted file mode 100644 index 6f42ad2c04..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe-context.bicep +++ /dev/null @@ -1,83 +0,0 @@ -import radius as radius - -param rg string = resourceGroup().name - -param sub string = subscription().subscriptionId - -param registry string - -param version string - -param magpieimage string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-env-recipes-context-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-env-recipes-context-env' - } - providers: { - azure: { - scope: '/subscriptions/${sub}/resourceGroups/${rg}' - } - } - recipes: { - 'Applications.Link/mongoDatabases':{ - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/mongodb-recipe-context:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-mongodb-recipe-context' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-mongodb-recipe-context-app' - } - ] - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'mdb-ctx-ctnr-old' - location: 'global' - properties: { - application: app.id - connections: { - mongodb: { - source: recipedb.id - } - } - container: { - image: magpieimage - env: { - DBCONNECTION: recipedb.connectionString() - } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 - path: '/healthz' - } - } - } -} - -resource recipedb 'Applications.Link/mongoDatabases@2022-03-15-privatepreview' = { - name: 'mdb-ctx-old' - location: 'global' - properties: { - application: app.id - environment: env.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe-parameters.bicep b/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe-parameters.bicep deleted file mode 100644 index 3ec630ede8..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe-parameters.bicep +++ /dev/null @@ -1,93 +0,0 @@ -import radius as radius - -param rg string = resourceGroup().name - -param sub string = subscription().subscriptionId - -param registry string - -param version string - -param magpieimage string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-env-recipe-parameters-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-env-recipe-parameters-env' - } - providers: { - azure: { - scope: '/subscriptions/${sub}/resourceGroups/${rg}' - } - } - recipes: { - 'Applications.Link/mongoDatabases' :{ - mongodb: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/mongodb-recipe-parameter:${version}' - parameters: { - documentdbName: 'acnt-operator-o-${rg}' - mongodbName: 'mdb-operator-o-${rg}' - } - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-rs-mongodb-recipe-parameters-old' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-rs-mongodb-recipe-param-app-old' - } - ] - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'mdb-param-ctnr-old' - location: 'global' - properties: { - application: app.id - connections: { - mongodb: { - source: recipedb.id - } - } - container: { - image: magpieimage - env: { - DBCONNECTION: recipedb.connectionString() - } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 - path: '/healthz' - } - } - } -} - -resource recipedb 'Applications.Link/mongoDatabases@2022-03-15-privatepreview' = { - name: 'mdb-recipe-param-db-old' - location: 'global' - properties: { - application: app.id - environment: env.id - recipe: { - name: 'mongodb' - parameters: { - documentdbName: 'acnt-developer-o-${rg}' - } - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe.bicep deleted file mode 100644 index 450465f2c5..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-mongodb-recipe.bicep +++ /dev/null @@ -1,86 +0,0 @@ -import radius as radius - -param rg string = resourceGroup().name - -param sub string = subscription().subscriptionId - -param registry string - -param version string - -param magpieimage string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-mongodb-recipe-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-mongodb-recipe-env' - } - providers: { - azure: { - scope: '/subscriptions/${sub}/resourceGroups/${rg}' - } - } - recipes: { - 'Applications.Link/mongoDatabases':{ - mongoazure: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/mongodb-recipe-kubernetes:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-mongodb-recipe' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-mongodb-recipe-app' - } - ] - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'mongodb-app-ctnr-old' - location: 'global' - properties: { - application: app.id - connections: { - mongodb: { - source: recipedb.id - } - } - container: { - image: magpieimage - env: { - DBCONNECTION: recipedb.connectionString() - } - readinessProbe:{ - kind:'httpGet' - containerPort:3000 - path: '/healthz' - } - } - } -} - -resource recipedb 'Applications.Link/mongoDatabases@2022-03-15-privatepreview' = { - name: 'mongodb-db-old' - location: 'global' - properties: { - application: app.id - environment: env.id - recipe: { - name: 'mongoazure' - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-rabbitmq-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-rabbitmq-recipe.bicep deleted file mode 100644 index c1f6280f8b..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-rabbitmq-recipe.bicep +++ /dev/null @@ -1,85 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'global' - -@description('Specifies the image for the container resource.') -param magpieImage string - -@description('Specifies the port for the container resource.') -param magpiePort int = 3000 - -@description('Specifies the RabbitMQ password.') -@secure() -param password string - -param registry string - -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-environment-rabbitmq-recipe-env-old' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-environment-rabbitmq-recipe-env-old' - } - recipes: { - 'Applications.Link/rabbitMQMessageQueues': { - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/rabbitmq-recipe:${version}' - parameters: { - password: password - } - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-rabbitmq-recipe-old' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-rabbitmq-default-recipe-app-old' - } - ] - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rmq-recipe-app-ctnr-old' - location: location - properties: { - application: app.id - container: { - image: magpieImage - readinessProbe: { - kind: 'httpGet' - containerPort: magpiePort - path: '/healthz' - } - } - connections: { - rabbitmq: { - source: rabbitmq.id - } - } - } -} - -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' = { - name: 'rmq-recipe-resource-old' - location: location - properties: { - application: app.id - environment: env.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-rabbitmq.bicep b/test/functional/shared/resources/testdata/corerp-resources-rabbitmq.bicep deleted file mode 100644 index fee5908957..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-rabbitmq.bicep +++ /dev/null @@ -1,98 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'global' - -@description('Specifies the image for the container resource.') -param magpieImage string - -@description('Specifies the port for the container resource.') -param magpiePort int = 3000 - -@description('Specifies the environment for resources.') -param environment string = 'test' - -@description('Specifies the image for the RabbitMQ container resource.') -param rabbitmqImage string = 'rabbitmq:3.10' - -@description('Specifies the port for the container resource.') -param rabbitmqPort int = 5672 - -@description('Specifies the RabbitMQ username.') -param username string = 'guest' - -@description('Specifies the RabbitMQ password.') -@secure() -param password string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-rabbitmq-old' - location: location - properties: { - environment: environment - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rmq-app-ctnr-old' - location: location - properties: { - application: app.id - container: { - image: magpieImage - readinessProbe: { - kind: 'httpGet' - containerPort: magpiePort - path: '/healthz' - } - } - connections: { - rabbitmq: { - source: rabbitmq.id - } - } - } -} - -resource rabbitmqContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rmq-ctnr-old' - location: location - properties: { - application: app.id - container: { - image: rabbitmqImage - ports: { - rabbitmq: { - containerPort: rabbitmqPort - provides: rabbitmqRoute.id - } - } - } - } -} - -resource rabbitmqRoute 'Applications.Core/httpRoutes@2022-03-15-privatepreview' = { - name: 'rmq-rte-old' - location: location - properties: { - application: app.id - port: rabbitmqPort - } -} - -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' = { - name: 'rmq-rmq-old' - location: location - properties: { - application: app.id - environment: environment - resourceProvisioning: 'manual' - queue: 'queue' - host: rabbitmqRoute.properties.hostname - port:rabbitmqRoute.properties.port - username:username - secrets: { - password: password - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep b/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep index aaf1d2a978..9b2a4c6da8 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step0.bicep @@ -23,7 +23,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { namespace: '${basename}-env' } recipes: { - 'Applications.Link/extenders': { + 'Applications.Core/extenders': { '${environmentRecipeName}': { templateKind: 'bicep' templatePath: '${registry}/test/functional/shared/recipes/${recipe}:${version}' @@ -49,7 +49,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { // This resources is intentionally NOT using a recipe. It's being created so we can reference // it inside a recipe in the next step. -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: '${basename}-existing' properties: { application: app.id diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep b/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep index 67abf7b5a3..ffd637a24c 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep-resourcecreation.step1.bicep @@ -13,7 +13,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' existing name: basename } -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: basename properties: { application: app.id diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep.bicep b/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep.bicep index ebe11880de..fb2f560f4d 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-recipe-bicep.bicep @@ -27,7 +27,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { namespace: '${basename}-env' } recipes: { - 'Applications.Link/extenders': { + 'Applications.Core/extenders': { '${environmentRecipeName}': { templateKind: 'bicep' templatePath: '${registry}/test/functional/shared/recipes/${recipe}:${version}' @@ -51,7 +51,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { } } -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: basename properties: { application: app.id diff --git a/test/functional/shared/resources/testdata/corerp-resources-recipe-notfound.bicep b/test/functional/shared/resources/testdata/corerp-resources-recipe-notfound.bicep index afd356ba4c..2396a1dd0e 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-recipe-notfound.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-recipe-notfound.bicep @@ -29,7 +29,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { } } -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: basename properties: { application: app.id diff --git a/test/functional/shared/resources/testdata/corerp-resources-redis-default-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-redis-default-recipe.bicep deleted file mode 100644 index 2e278a4e60..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-redis-default-recipe.bicep +++ /dev/null @@ -1,55 +0,0 @@ -import radius as radius - -param scope string = resourceGroup().id - -param registry string - -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-environment-default-recipe-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-environment-default-recipe-env' - } - providers: { - azure: { - scope: scope - } - } - recipes: { - 'Applications.Link/redisCaches': { - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/redis-recipe-value-backed:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-redis-default-recipe' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-redis-default-recipe-app' - } - ] - } -} - -resource redis 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'rds-default-recipe-old' - location: 'global' - properties: { - environment: env.id - application: app.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-redis-manualprovisioning.bicep b/test/functional/shared/resources/testdata/corerp-resources-redis-manualprovisioning.bicep deleted file mode 100644 index 5c3833678f..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-redis-manualprovisioning.bicep +++ /dev/null @@ -1,78 +0,0 @@ -import radius as radius - -param magpieimage string -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-redis-mp' - location: 'global' - properties:{ - environment: environment - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rds-app-ctnr-old' - location: 'global' - properties: { - application: app.id - container: { - image: magpieimage - env: { - DBCONNECTION: redis.connectionString() - } - readinessProbe:{ - kind: 'httpGet' - containerPort: 3000 - path: '/healthz' - } - } - connections: { - redis: { - source: redis.id - } - } - } -} - -resource redisContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rds-ctnr-old' - location: 'global' - properties: { - application: app.id - container: { - image: 'redis:6.2' - ports: { - redis: { - containerPort: 6379 - provides: redisRoute.id - } - } - } - connections: {} - } -} - -resource redisRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'rds-rte-old' - location: 'global' - properties: { - application: app.id - } -} - -resource redis 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'rds-rds-old' - location: 'global' - properties: { - environment: environment - application: app.id - resourceProvisioning: 'manual' - host: redisRoute.properties.hostname - port: redisRoute.properties.port - secrets: { - connectionString: '${redisRoute.properties.hostname}:${redisRoute.properties.port}' - password: '' - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-redis-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-redis-recipe.bicep deleted file mode 100644 index df508da14b..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-redis-recipe.bicep +++ /dev/null @@ -1,58 +0,0 @@ -import radius as radius - -param scope string = resourceGroup().id - -param registry string - -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-environment-recipe-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-environment-recipe-env' - } - providers: { - azure: { - scope: scope - } - } - recipes: { - 'Applications.Link/redisCaches':{ - rediscache: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/redis-recipe-value-backed:${version}' - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-redis-recipe' - location: 'global' - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-redis-recipe-app' - } - ] - } -} - -resource redis 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'rds-recipe-old' - location: 'global' - properties: { - environment: env.id - application: app.id - recipe: { - name: 'rediscache' - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-secretstore-new.bicep b/test/functional/shared/resources/testdata/corerp-resources-secretstore-new.bicep deleted file mode 100644 index be58c12e26..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-secretstore-new.bicep +++ /dev/null @@ -1,64 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'global' - -@description('Specifies the environment for resources.') -param environment string - -@description('Specifies tls cert secret values.') -@secure() -param tlscrt string -@secure() -param tlskey string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-secretstore' - location: location - properties: { - environment: environment - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-secretstore-app' - } - ] - } -} - -// Create new certificate type appcert secret. -resource appCert 'Applications.Core/secretStores@2022-03-15-privatepreview' = { - name: 'appcert' - properties:{ - application: app.id - type: 'certificate' - data: { - 'tls.key': { - value: tlskey - } - 'tls.crt': { - value: tlscrt - } - } - } -} - -// Create new generic type appSecret. -resource appSecret 'Applications.Core/secretStores@2022-03-15-privatepreview' = { - name: 'appsecret' - properties:{ - application: app.id - data: { - servicePrincipalPassword: { - value: '10000000-1000-1000-0000-000000000000' - } - appId: { - value: '00000000-0000-0000-0000-000000000001' - } - tenantId: { - encoding: 'raw' - value: '00000000-0000-0000-0000-000000000002' - } - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-secretstore-ref.bicep b/test/functional/shared/resources/testdata/corerp-resources-secretstore-ref.bicep deleted file mode 100644 index 13462a2a81..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-secretstore-ref.bicep +++ /dev/null @@ -1,35 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'global' - -@description('Specifies the environment for resources.') -param environment string - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-secretstore-ref' - location: location - properties: { - environment: environment - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-secretstore-ref' - } - ] - } -} - -// Reference the existing `secret-app-existing-secret` secret. -resource existingAppCert 'Applications.Core/secretStores@2022-03-15-privatepreview' = { - name: 'existing-appcert' - properties:{ - application: app.id - type: 'certificate' - data: { - 'tls.crt': {} - 'tls.key': {} - } - resource: 'default/secret-app-existing-secret' - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-sql.bicep b/test/functional/shared/resources/testdata/corerp-resources-sql.bicep deleted file mode 100644 index ab20aa935a..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-sql.bicep +++ /dev/null @@ -1,106 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'global' - -@description('Specifies the image for the container resource.') -param magpieImage string - -@description('Specifies the port for the container resource.') -param magpiePort int = 3000 - -@description('Specifies the environment for resources.') -param environment string = 'test' - -@description('Specifies the image for the sql container resource.') -param sqlImage string = 'mcr.microsoft.com/mssql/server:2019-latest' - -@description('Specifies the port for the container resource.') -param sqlPort int = 1433 - -@description('Specifies the SQL username.') -param username string = 'sa' - -@description('Specifies the SQL password.') -@secure() -param password string = newGuid() - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-sql' - location: location - properties: { - environment: environment - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-app-ctnr-old' - location: location - properties: { - application: app.id - connections: { - sql: { - source: db.id - } - } - container: { - image: magpieImage - env: { - CONNECTION_SQL_CONNECTIONSTRING: db.connectionString() - } - readinessProbe: { - kind: 'httpGet' - containerPort: magpiePort - path: '/healthz' - } - } - } -} - -resource db 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'sql-db-old' - location: location - properties: { - application: app.id - environment: environment - server: sqlRoute.properties.hostname - database: 'master' - resourceProvisioning: 'manual' - port: sqlRoute.properties.port - username: username - secrets:{ - password: password - } - } -} - -resource sqlRoute 'Applications.Core/httpRoutes@2022-03-15-privatepreview' = { - name: 'sql-rte-old' - location: location - properties: { - application: app.id - port: sqlPort - } -} - -resource sqlContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-ctnr-old' - location: location - properties: { - application: app.id - container: { - image: sqlImage - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: password - } - ports: { - sql: { - containerPort: sqlPort - provides: sqlRoute.id - } - } - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-sqldb-recipe.bicep b/test/functional/shared/resources/testdata/corerp-resources-sqldb-recipe.bicep deleted file mode 100644 index c92036c882..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-sqldb-recipe.bicep +++ /dev/null @@ -1,91 +0,0 @@ -import radius as radius -@description('Specifies the location for resources.') -param location string = 'global' - -@description('Specifies the image for the container resource.') -param magpieImage string - -@description('Specifies the port for the container resource.') -param magpiePort int = 3000 - -@description('Specifies the SQL username.') -param username string = 'sa' - -@description('Specifies the SQL password.') -@secure() -param password string = newGuid() - -param registry string - -param version string - -resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { - name: 'corerp-resources-env-sql-recipe-env' - location: 'global' - properties: { - compute: { - kind: 'kubernetes' - resourceId: 'self' - namespace: 'corerp-resources-env-sql-recipe-env' - } - recipes: { - 'Applications.Link/sqlDatabases': { - default: { - templateKind: 'bicep' - templatePath: '${registry}/test/functional/shared/recipes/sqldb-recipe:${version}' - parameters: { - username: username - password: password - } - } - } - } - } -} - -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'corerp-resources-sqldb-recipe' - location: location - properties: { - environment: env.id - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-sqldb-recipe-app' - } - ] - } -} - -resource webapp 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-recipe-app-ctnr-old' - location: location - properties: { - application: app.id - connections: { - sql: { - source: db.id - } - } - container: { - image: magpieImage - env: { - CONNECTION_SQL_CONNECTIONSTRING: db.connectionString() - } - readinessProbe: { - kind: 'httpGet' - containerPort: magpiePort - path: '/healthz' - } - } - } -} - -resource db 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'sql-db-recipe-old' - location: location - properties: { - application: app.id - environment: env.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep index 18d2b458b4..0bf9aa8fb6 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-azurestorage.bicep @@ -22,7 +22,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { } } recipes: { - 'Applications.Link/extenders': { + 'Applications.Core/extenders': { default: { templateKind: 'terraform' templatePath: '${moduleServer}/azure-storage.zip' @@ -50,7 +50,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { } } -resource webapp 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource webapp 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: 'corerp-resources-terraform-azstorage' properties: { application: app.id diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-context.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-context.bicep index ad191b7dee..f2334ee6e4 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-terraform-context.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-context.bicep @@ -18,7 +18,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { } } recipes: { - 'Applications.Link/extenders': { + 'Applications.Core/extenders': { default: { templateKind: 'terraform' templatePath: '${moduleServer}/k8ssecret-context.zip' @@ -41,7 +41,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { } } -resource webapp 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource webapp 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: 'corerp-resources-terraform-context' properties: { application: app.id diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-recipe-terraform.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-recipe-terraform.bicep new file mode 100644 index 0000000000..dea8afd4df --- /dev/null +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-recipe-terraform.bicep @@ -0,0 +1,67 @@ +import radius as radius + +@description('The URL of the server hosting test Terraform modules.') +param moduleServer string + +@description('The Terraform recipe module to test. eg: kubernetes-redis') +param moduleName string + +@description('The base name of the test, used to qualify resources and namespaces. eg: corerp-resources-terraform-helloworld') +param basename string + +@description('The recipe name used to register the recipe. eg: default') +param environmentRecipeName string = 'default' + +@description('The recipe name used to invoke the recipe. eg: default') +param resourceRecipeName string = 'default' + +@description('The environment parameters to pass to the recipe. eg: {"message": "Hello World"}') +param environmentParameters object = {} + +@description('The resource parameters to pass to the recipe. eg: {"name": "hello-world"}') +param resourceParameters object = {} + +resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { + name: basename + properties: { + compute: { + kind: 'kubernetes' + resourceId: 'self' + namespace: '${basename}-env' + } + recipes: { + 'Applications.Core/extenders': { + '${environmentRecipeName}': { + templateKind: 'terraform' + templatePath: '${moduleServer}/${moduleName}.zip' + parameters: environmentParameters + } + } + } + } +} + +resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { + name: basename + properties: { + environment: env.id + extensions: [ + { + kind: 'kubernetesNamespace' + namespace: '${basename}-app' + } + ] + } +} + +resource webapp 'Applications.Core/extenders@2022-03-15-privatepreview' = { + name: basename + properties: { + application: app.id + environment: env.id + recipe: { + name: resourceRecipeName + parameters: resourceParameters + } + } +} diff --git a/test/functional/shared/resources/testdata/corerp-resources-terraform-redis.bicep b/test/functional/shared/resources/testdata/corerp-resources-terraform-redis.bicep index b07f916c9a..310ef9c9ef 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-terraform-redis.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-terraform-redis.bicep @@ -18,7 +18,7 @@ resource env 'Applications.Core/environments@2022-03-15-privatepreview' = { namespace: 'corerp-resources-terraform-redis-env' } recipes: { - 'Applications.Link/extenders': { + 'Applications.Core/extenders': { default: { templateKind: 'terraform' templatePath: '${moduleServer}/kubernetes-redis.zip' @@ -41,7 +41,7 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { } } -resource webapp 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource webapp 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: 'corerp-resources-terraform-redis' properties: { application: app.id diff --git a/test/functional/shared/resources/testdata/manifest/basemanifest.yaml b/test/functional/shared/resources/testdata/manifest/basemanifest.yaml new file mode 100644 index 0000000000..1ef37562b9 --- /dev/null +++ b/test/functional/shared/resources/testdata/manifest/basemanifest.yaml @@ -0,0 +1,93 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ctnr-manifest + labels: + app: ctnr-manifest + annotations: + source: base-manifest-test +spec: + replicas: 3 + selector: + matchLabels: + app: ctnr-manifest + template: + metadata: + labels: + app: ctnr-manifest + spec: + serviceAccountName: ctnr-manifest + volumes: + - name: secret-vol + secret: + secretName: ctnr-manifest-secret0 + containers: + - name: ctnr-manifest + ports: + - containerPort: 80 + protocol: TCP + volumeMounts: + - name: secret-vol + readOnly: true + mountPath: /etc/secret-vol + env: + - name: TEST_SECRET_KEY + valueFrom: + secretKeyRef: + name: ctnr-manifest-secret1 + key: secret1 + - name: TEST_CONFIGMAP_KEY + valueFrom: + configMapKeyRef: + name: ctnr-manifest-config + key: TEST_CONFIGMAP +--- +apiVersion: v1 +kind: Service +metadata: + name: ctnr-manifest + annotations: + source: base-manifest-test +spec: + selector: + app.kubernetes.io/name: ctnr-manifest + ports: + - protocol: TCP + port: 3000 + targetPort: 3000 +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: ctnr-manifest + annotations: + source: base-manifest-test +--- +apiVersion: v1 +kind: Secret +metadata: + name: ctnr-manifest-secret0 + annotations: + source: base-manifest-test +type: Opaque +stringData: + 'secret0': test-secret-0 +--- +apiVersion: v1 +kind: Secret +metadata: + name: ctnr-manifest-secret1 + annotations: + source: base-manifest-test +type: Opaque +stringData: + 'secret1': test-secret-1 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: ctnr-manifest-config + annotations: + source: base-manifest-test +data: + TEST_CONFIGMAP: test-configmap diff --git a/test/functional/shared/resources/testdata/manifest/sidecar.yaml b/test/functional/shared/resources/testdata/manifest/sidecar.yaml new file mode 100644 index 0000000000..25d164474b --- /dev/null +++ b/test/functional/shared/resources/testdata/manifest/sidecar.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ctnr-sidecar + labels: + app: ctnr-sidecar + annotations: + source: base-manifest-test +spec: + replicas: 1 + selector: + matchLabels: + app: ctnr-sidecar + template: + metadata: + labels: + app: ctnr-sidecar + spec: + containers: + - name: log-collector + # TODO: change it to ghcr.io/radius-project/fluent-bit:2.1.8 + image: radiusdev.azurecr.io/fluent/fluent-bit:2.1.8 diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/_resource-creation.bicep b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/_resource-creation.bicep index 18022b53bf..13c5a601c5 100644 --- a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/_resource-creation.bicep +++ b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/_resource-creation.bicep @@ -6,7 +6,7 @@ var basename = context.resource.name // This is not a realistic user scenario (creating a Radius resource in a recipe). We're // doing things this way to test the UCP functionality without using cloud resources. -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: '${basename}-module' properties: { application: context.application.id diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/language-failure.bicep b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/language-failure.bicep index 4446b0bd00..1ca9e662a9 100644 --- a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/language-failure.bicep +++ b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/language-failure.bicep @@ -6,7 +6,7 @@ var basename = context.resource.name // This is not a realistic user scenario (creating a Radius resource in a recipe). We're // doing things this way to test a bicep language failure without using cloud resources. -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: '${basename}-failure' properties: { application: context.application.id diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation-failure.bicep b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation-failure.bicep index 0291ed86dd..f626178d2c 100644 --- a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation-failure.bicep +++ b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation-failure.bicep @@ -6,7 +6,7 @@ var basename = context.resource.name // This is not a realistic user scenario (creating a Radius resource in a recipe). We're // doing things this way to test a provisioning failure without using cloud resources. -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: '${basename}-failure' properties: { application: 'not an id, just deal with it' diff --git a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation.bicep b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation.bicep index c282f5ee29..f5dbd70712 100644 --- a/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation.bicep +++ b/test/functional/shared/resources/testdata/recipes/test-bicep-recipes/resource-creation.bicep @@ -6,7 +6,7 @@ var basename = context.resource.name // This is not a realistic user scenario (creating a Radius resource in a recipe). We're // doing things this way to test the UCP functionality without using cloud resources. -resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource extender 'Applications.Core/extenders@2022-03-15-privatepreview' = { name: '${basename}-created' properties: { application: context.application.id @@ -17,7 +17,7 @@ resource extender 'Applications.Link/extenders@2022-03-15-privatepreview' = { } #disable-next-line no-unused-existing-resources -resource existing 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { +resource existing 'Applications.Core/extenders@2022-03-15-privatepreview' existing = { name: '${basename}-existing' } diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/radius.tf b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/variables.tf similarity index 100% rename from test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/radius.tf rename to test/functional/shared/resources/testdata/recipes/test-terraform-recipes/k8ssecret-context/variables.tf diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/output.tf b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/output.tf new file mode 100644 index 0000000000..5626bb1d38 --- /dev/null +++ b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/output.tf @@ -0,0 +1,13 @@ +output "result" { + value = { + values = { + a = var.a + b = var.b + c = var.c + d = var.d + } + secrets = { + e = "secret value" + } + } +} \ No newline at end of file diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/variables.tf b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/variables.tf new file mode 100644 index 0000000000..6600d3db7a --- /dev/null +++ b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/parameter-outputs/variables.tf @@ -0,0 +1,17 @@ +variable "a" { + type = string +} + +variable "b" { + type = string + default = "default value" +} + +variable "c" { + type = number +} + +variable "d" { + type = string + default = "default value" +} diff --git a/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/wrong-output/output.tf b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/wrong-output/output.tf new file mode 100644 index 0000000000..38e2767a9e --- /dev/null +++ b/test/functional/shared/resources/testdata/recipes/test-terraform-recipes/wrong-output/output.tf @@ -0,0 +1,7 @@ +output "result" { + value = { + error = { + message = "error is not a valid recipe output" + } + } +} \ No newline at end of file diff --git a/test/functional/shared/rptest.go b/test/functional/shared/rptest.go index 312494d93f..42a2865532 100644 --- a/test/functional/shared/rptest.go +++ b/test/functional/shared/rptest.go @@ -32,12 +32,12 @@ import ( "k8s.io/client-go/discovery" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/test" - "github.com/project-radius/radius/test/radcli" - "github.com/project-radius/radius/test/step" - "github.com/project-radius/radius/test/testcontext" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/test" + "github.com/radius-project/radius/test/radcli" + "github.com/radius-project/radius/test/step" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/validation" ) var radiusControllerLogSync sync.Once @@ -163,6 +163,9 @@ func (ct RPTest) CreateInitialResources(ctx context.Context) error { } for _, r := range ct.InitialResources { + if err := kubernetes.EnsureNamespace(ctx, ct.Options.K8sClient, r.GetNamespace()); err != nil { + return fmt.Errorf("failed to create namespace %s: %w", ct.Name, err) + } if err := ct.Options.Client.Create(ctx, &r); err != nil { return fmt.Errorf("failed to create resource %#v: %w", r, err) } diff --git a/test/functional/shared/test.go b/test/functional/shared/test.go index a0cf80f5e3..f0e172cea4 100644 --- a/test/functional/shared/test.go +++ b/test/functional/shared/test.go @@ -24,16 +24,16 @@ import ( "github.com/stretchr/testify/require" awsconfig "github.com/aws/aws-sdk-go-v2/config" - "github.com/project-radius/radius/pkg/azure/clientv2" - aztoken "github.com/project-radius/radius/pkg/azure/tokencredentials" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/test" - "github.com/project-radius/radius/test/functional" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/azure/clientv2" + aztoken "github.com/radius-project/radius/pkg/azure/tokencredentials" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/test" + "github.com/radius-project/radius/test/functional" + "github.com/radius-project/radius/test/testcontext" ) // NewRPTestOptions sets up the test environment by loading configs, creating a test context, creating an diff --git a/test/functional/ucp/aws_credential_test.go b/test/functional/ucp/aws_credential_test.go index 8733143d48..c0c79abd92 100644 --- a/test/functional/ucp/aws_credential_test.go +++ b/test/functional/ucp/aws_credential_test.go @@ -25,7 +25,7 @@ import ( "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" "github.com/stretchr/testify/require" ) @@ -40,7 +40,7 @@ func Test_AWS_Credential_Operations(t *testing.T) { test.Test(t) } -func runAWSCredentialTests(t *testing.T, resourceUrl string, collectionUrl string, roundTripper http.RoundTripper, createCredential ucp.AWSCredentialResource, expectedCredential ucp.AWSCredentialResource) { +func runAWSCredentialTests(t *testing.T, resourceUrl string, collectionUrl string, roundTripper http.RoundTripper, createCredential ucp.AwsCredentialResource, expectedCredential ucp.AwsCredentialResource) { // Create credential operation createAWSTestCredential(t, roundTripper, resourceUrl, createCredential) @@ -71,7 +71,7 @@ func runAWSCredentialTests(t *testing.T, resourceUrl string, collectionUrl strin require.Equal(t, http.StatusNoContent, statusCode) } -func createAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url string, credential ucp.AWSCredentialResource) { +func createAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url string, credential ucp.AwsCredentialResource) { body, err := json.Marshal(credential) require.NoError(t, err) createRequest, err := NewUCPRequest(http.MethodPut, url, bytes.NewBuffer(body)) @@ -84,7 +84,7 @@ func createAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url s t.Logf("Credential: %s created/updated successfully", url) } -func getAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url string) (ucp.AWSCredentialResource, int) { +func getAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url string) (ucp.AwsCredentialResource, int) { getCredentialRequest, err := NewUCPRequest(http.MethodGet, url, nil) require.NoError(t, err) @@ -96,7 +96,7 @@ func getAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url stri payload, err := io.ReadAll(body) require.NoError(t, err) - credential := ucp.AWSCredentialResource{} + credential := ucp.AwsCredentialResource{} err = json.Unmarshal(payload, &credential) require.NoError(t, err) @@ -111,7 +111,7 @@ func deleteAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url s return res.StatusCode, err } -func listAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url string) []ucp.AWSCredentialResource { +func listAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url string) []ucp.AwsCredentialResource { listCredentialRequest, err := NewUCPRequest(http.MethodGet, url, nil) require.NoError(t, err) @@ -120,7 +120,7 @@ func listAWSTestCredential(t *testing.T, roundTripper http.RoundTripper, url str return getAWSTestCredentialList(t, res) } -func getAWSTestCredentialList(t *testing.T, res *http.Response) []ucp.AWSCredentialResource { +func getAWSTestCredentialList(t *testing.T, res *http.Response) []ucp.AwsCredentialResource { body := res.Body defer body.Close() @@ -129,11 +129,11 @@ func getAWSTestCredentialList(t *testing.T, res *http.Response) []ucp.AWSCredent require.NoError(t, err) list, ok := data["value"].([]any) require.Equal(t, ok, true) - var credentialList []ucp.AWSCredentialResource + var credentialList []ucp.AwsCredentialResource for _, item := range list { s, err := json.Marshal(item) require.NoError(t, err) - credential := ucp.AWSCredentialResource{} + credential := ucp.AwsCredentialResource{} err = json.Unmarshal(s, &credential) require.NoError(t, err) credentialList = append(credentialList, credential) @@ -141,8 +141,8 @@ func getAWSTestCredentialList(t *testing.T, res *http.Response) []ucp.AWSCredent return credentialList } -func getAWSTestCredentialObject() ucp.AWSCredentialResource { - return ucp.AWSCredentialResource{ +func getAWSTestCredentialObject() ucp.AwsCredentialResource { + return ucp.AwsCredentialResource{ Location: to.Ptr("global"), ID: to.Ptr("/planes/aws/awstest/providers/System.AWS/credentials/default"), Name: to.Ptr("default"), @@ -150,20 +150,20 @@ func getAWSTestCredentialObject() ucp.AWSCredentialResource { Tags: map[string]*string{ "env": to.Ptr("dev"), }, - Properties: &ucp.AWSAccessKeyCredentialProperties{ + Properties: &ucp.AwsAccessKeyCredentialProperties{ AccessKeyID: to.Ptr("00000000-0000-0000-0000-000000000000"), SecretAccessKey: to.Ptr("00000000-0000-0000-0000-000000000000"), - Kind: to.Ptr("AccessKey"), + Kind: to.Ptr(ucp.AWSCredentialKindAccessKey), Storage: &ucp.InternalCredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), SecretName: to.Ptr("aws-awstest-default"), }, }, } } -func getExpectedAWSTestCredentialObject() ucp.AWSCredentialResource { - return ucp.AWSCredentialResource{ +func getExpectedAWSTestCredentialObject() ucp.AwsCredentialResource { + return ucp.AwsCredentialResource{ Location: to.Ptr("global"), ID: to.Ptr("/planes/aws/awstest/providers/System.AWS/credentials/default"), Name: to.Ptr("default"), @@ -171,18 +171,18 @@ func getExpectedAWSTestCredentialObject() ucp.AWSCredentialResource { Tags: map[string]*string{ "env": to.Ptr("dev"), }, - Properties: &ucp.AWSAccessKeyCredentialProperties{ + Properties: &ucp.AwsAccessKeyCredentialProperties{ AccessKeyID: to.Ptr("00000000-0000-0000-0000-000000000000"), - Kind: to.Ptr("AccessKey"), + Kind: to.Ptr(ucp.AWSCredentialKindAccessKey), Storage: &ucp.InternalCredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), SecretName: to.Ptr("aws-awstest-default"), }, }, } } -func getIndexOfAWSTestCredential(testCredentialId string, credentialList []ucp.AWSCredentialResource) (int, error) { +func getIndexOfAWSTestCredential(testCredentialId string, credentialList []ucp.AwsCredentialResource) (int, error) { found := false foundCredentials := make([]string, len(credentialList)) testCredentialIndex := -1 diff --git a/test/functional/ucp/aws_test.go b/test/functional/ucp/aws_test.go index 943028b5e0..25657113bb 100644 --- a/test/functional/ucp/aws_test.go +++ b/test/functional/ucp/aws_test.go @@ -31,10 +31,10 @@ import ( awsconfig "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/google/uuid" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/frontend/controller/awsproxy" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/frontend/controller/awsproxy" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" ) @@ -44,7 +44,7 @@ var ( ) func Test_AWS_DeleteResource(t *testing.T) { - t.Skip("https://github.com/project-radius/radius/issues/5967") + t.Skip("https://github.com/radius-project/radius/issues/5967") ctx := context.Background() bucketName := generateS3BucketName() @@ -106,7 +106,7 @@ func Test_AWS_DeleteResource(t *testing.T) { } func Test_AWS_ListResources(t *testing.T) { - t.Skip("https://github.com/project-radius/radius/issues/5967") + t.Skip("https://github.com/radius-project/radius/issues/5967") ctx := context.Background() var bucketName = generateS3BucketName() diff --git a/test/functional/ucp/azure_credential_test.go b/test/functional/ucp/azure_credential_test.go index d29206cfd5..718b8a2203 100644 --- a/test/functional/ucp/azure_credential_test.go +++ b/test/functional/ucp/azure_credential_test.go @@ -24,8 +24,8 @@ import ( "net/http" "testing" - "github.com/project-radius/radius/pkg/to" - ucp "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/to" + ucp "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" "github.com/stretchr/testify/require" ) @@ -152,9 +152,9 @@ func getAzureTestCredentialObject() ucp.AzureCredentialResource { ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), ClientSecret: to.Ptr("00000000-0000-0000-0000-000000000000"), - Kind: to.Ptr("ServicePrincipal"), + Kind: to.Ptr(ucp.AzureCredentialKindServicePrincipal), Storage: &ucp.InternalCredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), SecretName: to.Ptr("azure-azuretest-default"), }, }, @@ -173,9 +173,9 @@ func getExpectedAzureTestCredentialObject() ucp.AzureCredentialResource { Properties: &ucp.AzureServicePrincipalProperties{ ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - Kind: to.Ptr("ServicePrincipal"), + Kind: to.Ptr(ucp.AzureCredentialKindServicePrincipal), Storage: &ucp.InternalCredentialStorageProperties{ - Kind: to.Ptr(string(ucp.CredentialStorageKindInternal)), + Kind: to.Ptr(ucp.CredentialStorageKindInternal), SecretName: to.Ptr("azure-azuretest-default"), }, }, diff --git a/test/functional/ucp/plane_test.go b/test/functional/ucp/plane_test.go index c216306fe6..0cf26ddfb3 100644 --- a/test/functional/ucp/plane_test.go +++ b/test/functional/ucp/plane_test.go @@ -24,10 +24,10 @@ import ( "net/http" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/rest" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/rest" "github.com/stretchr/testify/require" ) diff --git a/test/functional/ucp/proxy_test.go b/test/functional/ucp/proxy_test.go index 845eacf1ba..2f934ca797 100644 --- a/test/functional/ucp/proxy_test.go +++ b/test/functional/ucp/proxy_test.go @@ -24,10 +24,10 @@ import ( "testing" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/to" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/to" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" diff --git a/test/functional/ucp/resourcegroup_test.go b/test/functional/ucp/resourcegroup_test.go index 4b8fcced71..af5b2e425e 100644 --- a/test/functional/ucp/resourcegroup_test.go +++ b/test/functional/ucp/resourcegroup_test.go @@ -25,10 +25,10 @@ import ( "strings" "testing" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/to" - v20220901privatepreview "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" - "github.com/project-radius/radius/pkg/ucp/frontend/controller/resourcegroups" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/to" + v20220901privatepreview "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" + "github.com/radius-project/radius/pkg/ucp/frontend/controller/resourcegroups" "github.com/stretchr/testify/require" ) diff --git a/test/functional/ucp/ucptest.go b/test/functional/ucp/ucptest.go index 6180a59b99..85bea2f774 100644 --- a/test/functional/ucp/ucptest.go +++ b/test/functional/ucp/ucptest.go @@ -23,11 +23,11 @@ import ( "sync" "testing" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/sdk" - "github.com/project-radius/radius/test" - "github.com/project-radius/radius/test/testcontext" - "github.com/project-radius/radius/test/validation" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/sdk" + "github.com/radius-project/radius/test" + "github.com/radius-project/radius/test/testcontext" + "github.com/radius-project/radius/test/validation" "github.com/stretchr/testify/require" ) diff --git a/test/k8sutil/fake.go b/test/k8sutil/fake.go index 3eb1c259ca..ea45baba19 100644 --- a/test/k8sutil/fake.go +++ b/test/k8sutil/fake.go @@ -25,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" k8sfake "k8s.io/client-go/kubernetes/fake" clienttesting "k8s.io/client-go/testing" @@ -97,3 +98,34 @@ func (c *testClient) Patch(ctx context.Context, obj client.Object, patch client. return c.WithWatch.Update(ctx, obj) } } + +type DiscoveryClient struct { + Groups *metav1.APIGroupList + Resources []*metav1.APIResourceList + APIGroup []*metav1.APIGroup +} + +// ServerGroups returns a list of API groups supported by the server. +func (d *DiscoveryClient) ServerGroups() (*metav1.APIGroupList, error) { + return d.Groups, nil +} + +// This function returns a slice of API resource lists. +func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error) { + return d.Resources, nil +} + +// This function returns a slice of API resource lists. +func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) { + return d.Resources, nil +} + +// ServerGroupsAndResources returns a list of API groups and resources associated with the discovery client. +func (d *DiscoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { + return d.APIGroup, d.Resources, nil +} + +// ServerResourcesForGroupVersion returns nil for the API resource list. +func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) { + return nil, nil +} diff --git a/test/k8sutil/fakeresources.go b/test/k8sutil/fakeresources.go new file mode 100644 index 0000000000..5369263007 --- /dev/null +++ b/test/k8sutil/fakeresources.go @@ -0,0 +1,99 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package k8sutil + +// YAMLSeparater is the separater for fake YAML. +const YAMLSeparater = "\n---\n" + +// FakeDeploymentTemplate is the template for fake deployment. +const FakeDeploymentTemplate = ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: %s + %s + labels: + app: magpie +spec: + replicas: 3 + selector: + matchLabels: + app: magpie + template: + metadata: + labels: + app: magpie + spec: + serviceAccountName: %s + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 +` + +// FakeServiceTemplate is the template for fake service. +const FakeServiceTemplate = ` +apiVersion: v1 +kind: Service +metadata: + name: %s + %s +spec: + selector: + app.kubernetes.io/name: magpie + ports: + - protocol: TCP + port: 80 + targetPort: 9376 +` + +// FakeServiceAccountTemplate is the template for fake service account. +const FakeServiceAccountTemplate = ` +apiVersion: v1 +kind: ServiceAccount +metadata: + name: %s + labels: + app.kubernetes.io/name: magpie + app.kubernetes.io/part-of: radius +` + +// FakeSecretTemplate is the template for fake secret. +const FakeSecretTemplate = ` +apiVersion: v1 +kind: Secret +metadata: + name: %s +type: Opaque +stringData: + username: admin + password: password +` + +// FakeConfigMapTemplate is the template for fake config map. +const FakeConfigMapTemplate = ` +apiVersion: v1 +kind: ConfigMap +metadata: + name: %s + labels: + app.kubernetes.io/name: magpie + app.kubernetes.io/part-of: radius +data: + appsettings.Production.json: config +` diff --git a/test/magpiego/go.mod b/test/magpiego/go.mod index 5da9853095..94ef20a305 100644 --- a/test/magpiego/go.mod +++ b/test/magpiego/go.mod @@ -1,4 +1,4 @@ -module github.com/project-radius/radius/test/magpiego +module github.com/radius-project/radius/test/magpiego go 1.20 diff --git a/test/magpiego/server.go b/test/magpiego/server.go index bb9d147f6f..cc4f78104c 100644 --- a/test/magpiego/server.go +++ b/test/magpiego/server.go @@ -7,7 +7,7 @@ import ( "net/http" "github.com/go-chi/chi/v5" - "github.com/project-radius/radius/test/magpiego/bindings" + "github.com/radius-project/radius/test/magpiego/bindings" ) var server *http.Server diff --git a/test/options.go b/test/options.go index f050ef5ad4..77c12a1405 100644 --- a/test/options.go +++ b/test/options.go @@ -25,8 +25,8 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/project-radius/radius/pkg/cli" - "github.com/project-radius/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli" + "github.com/radius-project/radius/pkg/cli/kubernetes" ) type TestOptions struct { diff --git a/test/radcli/cli.go b/test/radcli/cli.go index b3c287a998..4ba7989969 100644 --- a/test/radcli/cli.go +++ b/test/radcli/cli.go @@ -28,7 +28,7 @@ import ( "testing" "time" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" ) const ( @@ -307,8 +307,8 @@ func (cli *CLI) RecipeList(ctx context.Context, envName string) (string, error) } // RecipeRegister runs a command to register a recipe with the given environment, template kind, template path and -// link type, and returns the output string or an error. -func (cli *CLI) RecipeRegister(ctx context.Context, envName, recipeName, templateKind, templatePath, linkType string) (string, error) { +// resource type, and returns the output string or an error. +func (cli *CLI) RecipeRegister(ctx context.Context, envName, recipeName, templateKind, templatePath, resourceType string) (string, error) { args := []string{ "recipe", "register", @@ -316,32 +316,32 @@ func (cli *CLI) RecipeRegister(ctx context.Context, envName, recipeName, templat "--environment", envName, "--template-kind", templateKind, "--template-path", templatePath, - "--link-type", linkType, + "--resource-type", resourceType, } return cli.RunCommand(ctx, args) } -// RecipeUnregister runs a command to unregister a recipe from an environment, given the recipe name and link type. +// RecipeUnregister runs a command to unregister a recipe from an environment, given the recipe name and resource type. // It returns a string and an error if the command fails. -func (cli *CLI) RecipeUnregister(ctx context.Context, envName, recipeName, linkType string) (string, error) { +func (cli *CLI) RecipeUnregister(ctx context.Context, envName, recipeName, resourceType string) (string, error) { args := []string{ "recipe", "unregister", recipeName, - "--link-type", linkType, + "--resource-type", resourceType, "--environment", envName, } return cli.RunCommand(ctx, args) } -// RecipeShow runs a command to show a recipe with the given environment name, recipe name and link type, and returns the +// RecipeShow runs a command to show a recipe with the given environment name, recipe name and resource type, and returns the // output string or an error. -func (cli *CLI) RecipeShow(ctx context.Context, envName, recipeName string, linkType string) (string, error) { +func (cli *CLI) RecipeShow(ctx context.Context, envName, recipeName string, resourceType string) (string, error) { args := []string{ "recipe", "show", recipeName, - "--link-type", linkType, + "--resource-type", resourceType, "--environment", envName, } return cli.RunCommand(ctx, args) diff --git a/test/radcli/shared.go b/test/radcli/shared.go index 2cb53afe63..b0a85de67d 100644 --- a/test/radcli/shared.go +++ b/test/radcli/shared.go @@ -27,19 +27,19 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/golang/mock/gomock" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/pkg/cli/aws" - "github.com/project-radius/radius/pkg/cli/azure" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/clients_new/generated" - "github.com/project-radius/radius/pkg/cli/cmd/env/namespace" - "github.com/project-radius/radius/pkg/cli/connections" - "github.com/project-radius/radius/pkg/cli/framework" - "github.com/project-radius/radius/pkg/cli/helm" - "github.com/project-radius/radius/pkg/cli/kubernetes" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/cli/prompt" - "github.com/project-radius/radius/pkg/ucp/api/v20220901privatepreview" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/pkg/cli/aws" + "github.com/radius-project/radius/pkg/cli/azure" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/clients_new/generated" + "github.com/radius-project/radius/pkg/cli/cmd/env/namespace" + "github.com/radius-project/radius/pkg/cli/connections" + "github.com/radius-project/radius/pkg/cli/framework" + "github.com/radius-project/radius/pkg/cli/helm" + "github.com/radius-project/radius/pkg/cli/kubernetes" + "github.com/radius-project/radius/pkg/cli/output" + "github.com/radius-project/radius/pkg/cli/prompt" + "github.com/radius-project/radius/pkg/ucp/api/v20220901privatepreview" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" diff --git a/test/step/deployerrorexecutor.go b/test/step/deployerrorexecutor.go index 9c0c1bcdae..0132c7c994 100644 --- a/test/step/deployerrorexecutor.go +++ b/test/step/deployerrorexecutor.go @@ -27,9 +27,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - v1 "github.com/project-radius/radius/pkg/armrpc/api/v1" - "github.com/project-radius/radius/test" - "github.com/project-radius/radius/test/radcli" + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" + "github.com/radius-project/radius/test" + "github.com/radius-project/radius/test/radcli" ) var _ Executor = (*DeployErrorExecutor)(nil) diff --git a/test/step/deployexecutor.go b/test/step/deployexecutor.go index c31705639f..b5e7377c02 100644 --- a/test/step/deployexecutor.go +++ b/test/step/deployexecutor.go @@ -25,8 +25,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/project-radius/radius/test" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/test" + "github.com/radius-project/radius/test/radcli" ) var _ Executor = (*DeployExecutor)(nil) diff --git a/test/step/interface.go b/test/step/interface.go index 3a530bcec0..a32f7268a6 100644 --- a/test/step/interface.go +++ b/test/step/interface.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/project-radius/radius/test" + "github.com/radius-project/radius/test" ) type Executor interface { diff --git a/test/testcontext/testcontext.go b/test/testcontext/testcontext.go index 372b4a3f28..6f6a65a330 100644 --- a/test/testcontext/testcontext.go +++ b/test/testcontext/testcontext.go @@ -48,7 +48,8 @@ func Wrap(t *testing.T, ctx context.Context) (context.Context, context.CancelFun ctx = context.Background() } - ctx = logr.NewContext(ctx, testr.New(t)) + // Setting verbosity so that everything gets logged. + ctx = logr.NewContext(ctx, testr.NewWithOptions(t, testr.Options{LogTimestamp: true, Verbosity: 10000})) deadline, ok := t.Deadline() if ok { return context.WithDeadline(ctx, deadline) diff --git a/test/testutil/resourcetypeutil/types.go b/test/testutil/resourcetypeutil/types.go new file mode 100644 index 0000000000..a0f3776312 --- /dev/null +++ b/test/testutil/resourcetypeutil/types.go @@ -0,0 +1,77 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resourcetypeutil + +import ( + "encoding/json" + + v1 "github.com/radius-project/radius/pkg/armrpc/api/v1" +) + +// FakeResource is a fake resource type. +type FakeResource struct{} + +// Always returns "FakeResource" as the name. +func (f *FakeResource) ResourceTypeName() string { + return "FakeResource" +} + +func (f *FakeResource) GetSystemData() *v1.SystemData { + return nil +} + +func (f *FakeResource) GetBaseResource() *v1.BaseResource { + return nil +} + +func (f *FakeResource) ProvisioningState() v1.ProvisioningState { + return v1.ProvisioningStateAccepted +} + +func (f *FakeResource) SetProvisioningState(state v1.ProvisioningState) { +} + +func (f *FakeResource) UpdateMetadata(ctx *v1.ARMRequestContext, oldResource *v1.BaseResource) { +} + +// MustPopulateResourceStatus populates a ResourceStatus object with an output resource commonly used in our +// test fixtures. +// +// Example usage (in a converter test): +// +// ..ResourceStatus: resourcetypeutil.MustPopulateResourceStatus(&myapiversion.ResourceStatus{}) +func MustPopulateResourceStatus[T any](obj T) T { + data := map[string]any{ + "outputResources": []map[string]any{ + { + "id": "/planes/test/local/providers/Test.Namespace/testResources/test-resource", + }, + }, + } + + b, err := json.Marshal(data) + if err != nil { + panic(err) + } + + err = json.Unmarshal(b, obj) + if err != nil { + panic(err) + } + + return obj +} diff --git a/test/testutil/util.go b/test/testutil/util.go index adf86dd691..01ed6931b1 100644 --- a/test/testutil/util.go +++ b/test/testutil/util.go @@ -19,6 +19,7 @@ package testutil import ( "encoding/json" "os" + "path" ) // MustGetTestData reads testdata and unmarshals it to the given type, panicking if an error occurs. @@ -32,8 +33,16 @@ func MustGetTestData[T any](file string) *T { } // ReadFixture reads testdata fixtures, panicking if an error occurs. +// +// The prefix `./testdata/` is automatically added to the filename. Tests can 'escape' the testdata directory by +// prefixing the filename with `../`. +// +// Example: +// +// ReadFixture("foo.json") -> ./testdata/foo.json func ReadFixture(filename string) []byte { - raw, err := os.ReadFile("./testdata/" + filename) + p := path.Clean("./testdata/" + filename) + raw, err := os.ReadFile(p) if err != nil { panic(err) } diff --git a/test/ucp/kubeenv/testenv.go b/test/ucp/kubeenv/testenv.go index d2ab0a2dcc..a800c309c9 100644 --- a/test/ucp/kubeenv/testenv.go +++ b/test/ucp/kubeenv/testenv.go @@ -23,7 +23,7 @@ import ( "os" "os/exec" - ucpv1alpha1 "github.com/project-radius/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" + ucpv1alpha1 "github.com/radius-project/radius/pkg/ucp/store/apiserverstore/api/ucp.dev/v1alpha1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" diff --git a/test/ucp/queuetest/shared.go b/test/ucp/queuetest/shared.go index 46ff944999..dbe640e06f 100644 --- a/test/ucp/queuetest/shared.go +++ b/test/ucp/queuetest/shared.go @@ -24,8 +24,8 @@ import ( "testing" "time" - "github.com/project-radius/radius/pkg/ucp/queue/client" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/ucp/queue/client" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) diff --git a/test/ucp/storetest/shared.go b/test/ucp/storetest/shared.go index e02fca2309..f0ccd5cefa 100644 --- a/test/ucp/storetest/shared.go +++ b/test/ucp/storetest/shared.go @@ -21,10 +21,10 @@ import ( "encoding/json" "testing" - "github.com/project-radius/radius/pkg/ucp/resources" - "github.com/project-radius/radius/pkg/ucp/store" - "github.com/project-radius/radius/pkg/ucp/util/etag" - "github.com/project-radius/radius/test/testcontext" + "github.com/radius-project/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/ucp/store" + "github.com/radius-project/radius/pkg/ucp/util/etag" + "github.com/radius-project/radius/test/testcontext" "github.com/stretchr/testify/require" ) diff --git a/test/validation/aws.go b/test/validation/aws.go index 10f4fbd91f..fb731db981 100644 --- a/test/validation/aws.go +++ b/test/validation/aws.go @@ -23,13 +23,14 @@ import ( "testing" "time" - "github.com/project-radius/radius/pkg/to" + "github.com/radius-project/radius/pkg/to" "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/service/cloudcontrol" "github.com/aws/aws-sdk-go-v2/service/sts" - awsclient "github.com/project-radius/radius/pkg/ucp/aws" - "github.com/project-radius/radius/pkg/ucp/resources" + awsclient "github.com/radius-project/radius/pkg/ucp/aws" + "github.com/radius-project/radius/pkg/ucp/resources" + resources_aws "github.com/radius-project/radius/pkg/ucp/resources/aws" "github.com/stretchr/testify/require" ) @@ -175,7 +176,7 @@ func GetResourceTypeName(ctx context.Context, resource *AWSResource) (string, er return "", err } - resourceType := resources.ToAWSResourceType(resourceID) + resourceType := resources_aws.ToAWSResourceType(resourceID) return resourceType, nil } diff --git a/test/validation/k8s.go b/test/validation/k8s.go index 77835c49c2..a75c33d177 100644 --- a/test/validation/k8s.go +++ b/test/validation/k8s.go @@ -24,7 +24,7 @@ import ( "testing" "time" - kuberneteskeys "github.com/project-radius/radius/pkg/kubernetes" + kuberneteskeys "github.com/radius-project/radius/pkg/kubernetes" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -60,6 +60,7 @@ type K8sObject struct { Labels map[string]string Kind string SkipLabelValidation bool + ResourceName string } // NewK8sPodForResource creates a new K8sObject with Kind set to "Pod" and the selector labels for the pod @@ -124,6 +125,19 @@ func NewK8sSecretForResource(application string, name string) K8sObject { } } +// NewK8sSecretForResourceWithResourceName creates a K8sObject for a secret with the Labels set to the application and name. +func NewK8sSecretForResourceWithResourceName(resourceName string) K8sObject { + return K8sObject{ + GroupVersionResource: schema.GroupVersionResource{ + Group: "", + Version: "v1", + Resource: "secrets", + }, + Kind: "Secret", + ResourceName: resourceName, + } +} + // ValidateDeploymentsRunning checks if the expected deployments have been created in the given namespace and logs any // unrecognized deployments. If all expected deployments have been created, it returns, otherwise it retries until the // context is done. @@ -404,7 +418,7 @@ func ValidateNoPodsInApplication(ctx context.Context, t *testing.T, k8s *kuberne } func listPodsWithRetries(t *testing.T, k8s *kubernetes.Clientset, labelset map[string]string, namespace, application string) (*corev1.PodList, error) { - // Need to retry because of AKS error: https://github.com/project-radius/radius/issues/2484 + // Need to retry because of AKS error: https://github.com/radius-project/radius/issues/2484 retries := 3 for i := 1; i <= retries; i++ { actualPods, err := k8s.CoreV1().Pods(namespace).List(context.Background(), metav1.ListOptions{ @@ -522,15 +536,23 @@ func matchesActualLabels(expectedResources []K8sObject, actualResources []unstru remaining := []K8sObject{} for _, expectedResource := range expectedResources { - if expectedResource.SkipLabelValidation { + if expectedResource.SkipLabelValidation && expectedResource.Kind != "Secret" { continue } resourceExists := false for idx, actualResource := range actualResources { - if labelsEqual(expectedResource.Labels, actualResource.GetLabels()) { - resourceExists = true - actualResources = append(actualResources[:idx], actualResources[idx+1:]...) - break + if expectedResource.SkipLabelValidation { + if actualResource.GetName() == expectedResource.ResourceName { + resourceExists = true + actualResources = append(actualResources[:idx], actualResources[idx+1:]...) + break + } + } else { + if labelsEqual(expectedResource.Labels, actualResource.GetLabels()) { + resourceExists = true + actualResources = append(actualResources[:idx], actualResources[idx+1:]...) + break + } } } if !resourceExists { @@ -571,3 +593,16 @@ func labelsEqual(expectedLabels map[string]string, actualLabels map[string]strin } return true } + +// NewDaprComponent creates a K8sObject for a Dapr component with the Labels set to the application and name. +func NewDaprComponent(application string, name string) K8sObject { + return K8sObject{ + GroupVersionResource: schema.GroupVersionResource{ + Group: "dapr.io", + Version: "v1alpha1", + Resource: "components", + }, + Kind: "Component", + Labels: kuberneteskeys.MakeSelectorLabels(application, name), + } +} diff --git a/test/validation/shared.go b/test/validation/shared.go index 2ecd6f6a9b..768be879c0 100644 --- a/test/validation/shared.go +++ b/test/validation/shared.go @@ -24,13 +24,11 @@ import ( "testing" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/project-radius/radius/pkg/cli/clients" - "github.com/project-radius/radius/pkg/cli/output" - "github.com/project-radius/radius/pkg/resourcemodel" - "github.com/project-radius/radius/pkg/ucp/resources" + "github.com/radius-project/radius/pkg/cli/clients" + "github.com/radius-project/radius/pkg/cli/output" "github.com/stretchr/testify/require" - "github.com/project-radius/radius/test/radcli" + "github.com/radius-project/radius/test/radcli" ) const ( @@ -42,16 +40,6 @@ const ( VolumesResource = "applications.core/volumes" SecretStoresResource = "applications.core/secretStores" - O_MongoDatabasesResource = "applications.link/mongoDatabases" - O_RabbitMQMessageQueuesResource = "applications.link/rabbitMQMessageQueues" - O_RedisCachesResource = "applications.link/redisCaches" - O_SQLDatabasesResource = "applications.link/sqlDatabases" - O_DaprPubSubBrokersResource = "applications.link/daprPubSubBrokers" - O_DaprSecretStoresResource = "applications.link/daprSecretStores" - O_DaprStateStoresResource = "applications.link/daprStateStores" - ExtendersResource = "applications.link/extenders" - - // New resources after splitting LinkRP namespace RabbitMQQueuesResource = "applications.messaging/rabbitMQQueues" DaprPubSubBrokersResource = "applications.dapr/pubSubBrokers" DaprSecretStoresResource = "applications.dapr/secretStores" @@ -59,6 +47,7 @@ const ( MongoDatabasesResource = "applications.datastores/mongoDatabases" RedisCachesResource = "applications.datastores/redisCaches" SQLDatabasesResource = "applications.datastores/sqlDatabases" + ExtendersResource = "applications.core/extenders" ) type RPResource struct { @@ -68,13 +57,10 @@ type RPResource struct { OutputResources []OutputResourceResponse } -// Output resource fields returned as a part of get/list response payload for Radius resources -// https://github.com/project-radius/radius/blob/main/pkg/rp/types.go#L173 +// Output resource fields returned as a part of get/list response payload for Radius resources. type OutputResourceResponse struct { - LocalID string - Provider string - Identity any - Name string // Name of the underlying resource within its platform (Azure/AWS/Kubernetes) + // ID is the resource ID of the output resource. + ID string } type RPResourceSet struct { @@ -91,12 +77,15 @@ func DeleteRPResource(ctx context.Context, t *testing.T, cli *radcli.CLI, client ctxWithResp := runtime.WithCaptureResponse(ctx, &respFromCtx) _, err := client.DeleteEnv(ctxWithResp, resource.Name) + if err != nil { + return err + } if respFromCtx.StatusCode == 204 { output.LogInfo("Environment '%s' does not exist or has already been deleted.", resource.Name) } - return err + return nil // TODO: this should probably call the CLI, but if you create an // environment via bicep deployment, it will not be reflected in the @@ -152,6 +141,7 @@ func ValidateRPResources(ctx context.Context, t *testing.T, expected *RPResource // Validate expected output resources are present in the response if len(expectedResource.OutputResources) > 0 { + t.Log("validating output resources") bytes, err := json.Marshal(res.Properties["status"]) require.NoError(t, err) @@ -159,27 +149,15 @@ func ValidateRPResources(ctx context.Context, t *testing.T, expected *RPResource err = json.Unmarshal(bytes, &outputResourcesMap) require.NoError(t, err) outputResources := outputResourcesMap["outputResources"] + for _, outputResource := range outputResources { + t.Logf("Found output resource: %+v", outputResource) + } require.Equalf(t, len(expectedResource.OutputResources), len(outputResources), "expected output resources: %v, actual: %v", expectedResource.OutputResources, outputResources) for _, expectedOutputResource := range expectedResource.OutputResources { found := false for _, actualOutputResource := range outputResources { - if expectedOutputResource.LocalID == actualOutputResource.LocalID && expectedOutputResource.Provider == actualOutputResource.Provider { + if strings.EqualFold(expectedOutputResource.ID, actualOutputResource.ID) { found = true - // if the test has the OutputResourceResponse.Name set then validate - // the actual outputresource name with the expected resource name based on the provider type. - if expectedOutputResource.Name != "" { - if expectedOutputResource.Provider == resourcemodel.ProviderAzure { - identity := actualOutputResource.Identity.(map[string]interface{}) - actualID := identity["id"].(string) - actualResource, err := resources.ParseResource(actualID) - require.NoError(t, err) - require.Equal(t, expectedOutputResource.Name, actualResource.Name()) - } - if expectedOutputResource.Provider == resourcemodel.ProviderKubernetes { - identity := actualOutputResource.Identity.(map[string]interface{}) - require.Equal(t, expectedOutputResource.Name, identity["name"].(string)) - } - } break } } diff --git a/typespec/Applications.Core/applications.tsp b/typespec/Applications.Core/applications.tsp new file mode 100644 index 0000000000..4e53665781 --- /dev/null +++ b/typespec/Applications.Core/applications.tsp @@ -0,0 +1,97 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; +import "./extensions.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +@doc("Radius Application resource") +model ApplicationResource is TrackedResource { + @doc("The application name") + @path + @key("applicationName") + @segment("applications") + name: ResourceNameString; +} + +@doc("Application properties") +model ApplicationProperties { + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; + + @doc("Fully qualified resource ID for the environment that the portable resource is linked to") + environment: string; + + @doc("The application extension.") + @extension("x-ms-identifiers", []) + extensions?: Array; + + @doc("Status of a resource.") + @visibility("read") + status?: ResourceStatus; +} + +#suppress "@azure-tools/typespec-azure-core/casing-style" +@armResourceOperations +interface Applications { + get is ArmResourceRead< + ApplicationResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceSync< + ApplicationResource, + UCPBaseParameters + >; + + update is ArmResourcePatchSync< + ApplicationResource, + EnvironmentProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteSync< + ApplicationResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + ApplicationResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Core/common.tsp b/typespec/Applications.Core/common.tsp new file mode 100644 index 0000000000..13aac0cadd --- /dev/null +++ b/typespec/Applications.Core/common.tsp @@ -0,0 +1,19 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/openapi"; + +using OpenAPI; diff --git a/typespec/Applications.Core/containers.tsp b/typespec/Applications.Core/containers.tsp new file mode 100644 index 0000000000..27e8b11e1b --- /dev/null +++ b/typespec/Applications.Core/containers.tsp @@ -0,0 +1,312 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; +import "./extensions.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +model ContainerResource is TrackedResource { + @doc("Container name") + @path + @key("containerName") + @segment("containers") + name: ResourceNameString; +} + +@doc("Container properties") +model ContainerProperties { + ...ApplicationScopedResource; + + @doc("Definition of a container.") + container: Container; + + @doc("Specifies a connection to another resource.") + connections?: Record; + + @doc("Configuration for supported external identity providers") + identity?: IdentitySettings; + + @doc("Extensions spec of the resource") + @extension("x-ms-identifiers", []) + extensions?: Extension[]; + + @doc("Specifies Runtime-specific functionality") + runtimes?: RuntimesProperties; +} + +@doc("The properties for runtime configuration") +model RuntimesProperties { + @doc("The runtime configuration properties for Kubernetes") + kubernetes?: KubernetesRuntimeProperties; +} + +#suppress "@azure-tools/typespec-azure-core/bad-record-type" +@doc("A strategic merge patch that will be applied to the PodSpec object when this container is being deployed.") +model KubernetesPodSpec is Record; + +@doc("The runtime configuration properties for Kubernetes") +model KubernetesRuntimeProperties { + @doc("The serialized YAML manifest which represents the base Kubernetes resources to deploy, such as Deployment, Service, ServiceAccount, Secrets, and ConfigMaps.") + base?: string; + + #suppress "@azure-tools/typespec-azure-core/bad-record-type" + @doc("A strategic merge patch that will be applied to the PodSpec object when this container is being deployed.") + pod?: KubernetesPodSpec; +} + +@doc("Specifies a listening port for the container") +model ContainerPortProperties { + @doc("The listening port number") + containerPort: int32; + + @doc("Protocol in use by the port") + protocol?: PortProtocol; + + @doc("Specifies a route provided by this port") + provides?: string; + + @doc("Specifies the URL scheme of the communication protocol. Consumers can use the scheme to construct a URL. The value defaults to 'http' or 'https' depending on the port value") + scheme?: string; + + @doc("Specifies the port that will be exposed by this container. Must be set when value different from containerPort is desired") + port?: int32; +} + +@doc("Properties for readiness/liveness probe") +@discriminator("kind") +model HealthProbeProperties { + @doc("Initial delay in seconds before probing for readiness/liveness") + initialDelaySeconds?: float32; + + @doc("Threshold number of times the probe fails after which a failure would be reported") + failureThreshold?: float32; + + @doc("Interval for the readiness/liveness probe in seconds") + periodSeconds?: float32; + + @doc("Number of seconds after which the readiness/liveness probe times out. Defaults to 5 seconds") + timeoutSeconds?: float32 = 5.0; +} + +@doc("Specifies the properties for readiness/liveness probe using HTTP Get") +model HttpGetHealthProbeProperties extends HealthProbeProperties { + @doc("The HealthProbeProperties kind") + kind: "httpGet"; + + @doc("The listening port number") + containerPort: int32; + + @doc("The route to make the HTTP request on") + path: string; + + @doc("Custom HTTP headers to add to the get request") + headers?: Record; +} + +@doc("Specifies the properties for readiness/liveness probe using TCP") +model TcpHealthProbeProperties extends HealthProbeProperties { + @doc("The HealthProbeProperties kind") + kind: "tcp"; + + @doc("The listening port number") + containerPort: int32; +} + +@doc("Specifies the properties for readiness/liveness probe using an executable") +model ExecHealthProbeProperties extends HealthProbeProperties { + @doc("The HealthProbeProperties kind") + kind: "exec"; + + @doc("Command to execute to probe readiness/liveness") + command: string; +} + +@discriminator("kind") +@doc("Specifies a volume for a container") +model Volume { + @doc("The path where the volume is mounted") + mountPath?: string; +} + +@doc("Specifies an ephemeral volume for a container") +model EphemeralVolume extends Volume { + @doc("The Volume kind") + kind: "ephemeral"; + + @doc("Backing store for the ephemeral volume") + managedStore: ManagedStore; +} + +@doc("Specifies a persistent volume for a container") +model PersistentVolume extends Volume { + @doc("The Volume kind") + kind: "persistent"; + + @doc("Container read/write access to the volume") + permission?: VolumePermission; + + @doc("The source of the volume") + source: string; +} + +@doc("IAM properties") +model IamProperties { + @doc("The kind of IAM provider to configure") + kind: IAMKind; + + @doc("RBAC permissions to be assigned on the source resource") + roles?: string[]; +} + +@doc("Connection Properties") +model ConnectionProperties { + @doc("The source of the connection") + source: string; + + @doc("default environment variable override") + disableDefaultEnvVars?: boolean = false; + + @doc("iam properties") + iam?: IamProperties; +} + +@doc("Definition of a container") +model Container { + @doc("The registry and image to download and run in your container") + image: string; + + @doc("The pull policy for the container image") + imagePullPolicy?: ImagePullPolicy; + + @doc("environment") + env?: Record; + + @doc("container ports") + ports?: Record; + + @doc("readiness probe properties") + readinessProbe?: HealthProbeProperties; + + @doc("liveness probe properties") + livenessProbe?: HealthProbeProperties; + + @doc("container volumes") + volumes?: Record; + + @doc("Entrypoint array. Overrides the container image's ENTRYPOINT") + command?: string[]; + + @doc("Arguments to the entrypoint. Overrides the container image's CMD") + args?: string[]; + + @doc("Working directory for the container") + workingDir?: string; +} + +@doc("The image pull policy for the container") +enum ImagePullPolicy { + @doc("Always") + Always, + + @doc("IfNotPresent") + IfNotPresent, + + @doc("Never") + Never, +} + +@doc("The protocol in use by the port") +enum PortProtocol { + @doc("TCP protocol") + TCP, + + @doc("UDP protocol") + UDP, +} + +@doc("The managed store for the ephemeral volume") +enum ManagedStore { + @doc("Memory store") + memory, + + @doc("Disk store") + disk, +} + +@doc("The persistent volume permission") +enum VolumePermission { + @doc("Read only") + read, + + @doc("Read and write") + write, +} + +@doc("The kind of IAM provider to configure") +enum IAMKind { + @doc("Azure Active Directory") + azure, +} + +@armResourceOperations +interface Containers { + get is ArmResourceRead< + ContainerResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + ContainerResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + ContainerResource, + ContainerProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + ContainerResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + ContainerResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Core/environments.tsp b/typespec/Applications.Core/environments.tsp new file mode 100644 index 0000000000..cb97def854 --- /dev/null +++ b/typespec/Applications.Core/environments.tsp @@ -0,0 +1,177 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; +import "./extensions.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +@doc("The environment resource") +model EnvironmentResource is TrackedResource { + @doc("environment name") + @key("environmentName") + @path + @segment("environments") + name: ResourceNameString; +} + +@doc("Environment properties") +model EnvironmentProperties { + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; + + @doc("The compute resource used by application environment.") + compute: EnvironmentCompute; + + @doc("Cloud providers configuration for the environment.") + providers?: Providers; + + @doc("Specifies Recipes linked to the Environment.") + recipes?: Record>; + + @doc("The environment extension.") + @extension("x-ms-identifiers", []) + extensions?: Array; +} + +@doc("The Cloud providers configuration") +model Providers { + @doc("The Azure cloud provider configuration") + azure?: ProvidersAzure; + + @doc("The AWS cloud provider configuration") + aws?: ProvidersAws; +} + +@doc("The Azure cloud provider definition") +model ProvidersAzure { + @doc("Target scope for Azure resources to be deployed into. For example: '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup'") + scope: string; +} + +@doc("The AWS cloud provider definition") +model ProvidersAws { + @doc("Target scope for AWS resources to be deployed into. For example: '/planes/aws/aws/accounts/000000000000/regions/us-west-2'") + scope: string; +} + +@doc("Format of the template provided by the recipe. Allowed values: bicep, terraform.") +@discriminator("templateKind") +model RecipeProperties { + @doc("Path to the template provided by the recipe. Currently only link to Azure Container Registry is supported.") + templatePath: string; + + @doc("Key/value parameters to pass to the recipe template at deployment") + parameters?: {}; +} + +@doc("Represents Bicep recipe properties.") +model BicepRecipeProperties extends RecipeProperties { + @doc("The Bicep template kind.") + templateKind: "bicep"; +} + +@doc("Represents Terraform recipe properties.") +model TerraformRecipeProperties extends RecipeProperties { + @doc("The Terraform template kind.") + templateKind: "terraform"; + + @doc("Version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources.") + templateVersion?: string; +} + +@doc("Represents the request body of the getmetadata action.") +model RecipeGetMetadata { + @doc("Type of the resource this recipe can be consumed by. For example: 'Applications.Datastores/mongoDatabases'") + resourceType: string; + + @doc("The name of the recipe registered to the environment") + name: string; +} + +@doc("The properties of a Recipe linked to an Environment.") +model RecipeGetMetadataResponse { + @doc("The format of the template provided by the recipe. Allowed values: bicep, terraform.") + templateKind: string; + + @doc("The path to the template provided by the recipe. Currently only link to Azure Container Registry is supported.") + templatePath: string; + + @doc("The version of the template to deploy. For Terraform recipes using a module registry this is required, but must be omitted for other module sources.") + templateVersion?: string; + + @doc("The key/value parameters to pass to the recipe template at deployment.") + parameters: {}; +} + +@armResourceOperations +interface Environments { + get is ArmResourceRead< + EnvironmentResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceSync< + EnvironmentResource, + UCPBaseParameters + >; + + update is ArmResourcePatchSync< + EnvironmentResource, + EnvironmentProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteSync< + EnvironmentResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + EnvironmentResource, + UCPBaseParameters, + "Scope", + "Scope" + >; + + @doc("Gets recipe metadata including parameters and any constraints on the parameters.") + @action("getMetadata") + getMetadata is ArmResourceActionSync< + EnvironmentResource, + RecipeGetMetadata, + RecipeGetMetadataResponse, + UCPBaseParameters + >; +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_CreateOrUpdate.json new file mode 100644 index 0000000000..14c050a927 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_CreateOrUpdate.json @@ -0,0 +1,62 @@ +{ + "operationId": "Applications_CreateOrUpdate", + "title": "Create or update an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "applicationName": "app0", + "api-version": "2022-03-15-privatepreview", + "ApplicationResource": { + "location": "West US", + "properties": { + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Delete.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Delete.json new file mode 100644 index 0000000000..fb1d0bce84 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Applications_Delete", + "title": "Delete an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "applicationName": "app0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Get.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Get.json new file mode 100644 index 0000000000..ff352ff388 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Get.json @@ -0,0 +1,39 @@ +{ + "operationId": "Applications_Get", + "title": "Get an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "applicationName": "app0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_List.json new file mode 100644 index 0000000000..a043784e0d --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_List.json @@ -0,0 +1,52 @@ +{ + "operationId": "Applications_ListByScope", + "title": "Get applications by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/app1", + "name": "app1", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_ListByScope.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_ListByScope.json new file mode 100644 index 0000000000..0367e5fb54 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_ListByScope.json @@ -0,0 +1,35 @@ +{ + "operationId": "Applications_ListByScope", + "title": "Get applications by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/app1", + "name": "app1", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/applications?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Update.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Update.json new file mode 100644 index 0000000000..b4dc7bc7d5 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Applications_Update.json @@ -0,0 +1,62 @@ +{ + "operationId": "Applications_Update", + "title": "Update (Patch) an application resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "applicationName": "app0", + "api-version": "2022-03-15-privatepreview", + "ApplicationResource": { + "location": "West US", + "properties": { + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "name": "app0", + "type": "Applications.Core/applications", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + }, + { + "kind": "kubernetesNamespace", + "namespace": "app-ns" + } + ] + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_CreateOrUpdate.json new file mode 100644 index 0000000000..e565785399 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_CreateOrUpdate.json @@ -0,0 +1,66 @@ +{ + "operationId": "Containers_CreateOrUpdate", + "title": "Create or update an container resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "containerName": "app0", + "api-version": "2022-03-15-privatepreview", + "ContainerResource": { + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_CreateOrUpdate_BaseManifest.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_CreateOrUpdate_BaseManifest.json new file mode 100644 index 0000000000..c9198a6a57 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_CreateOrUpdate_BaseManifest.json @@ -0,0 +1,76 @@ +{ + "operationId": "Containers_CreateOrUpdate", + "title": "Create or update an container resource with base manifest", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "containerName": "app0", + "api-version": "2022-03-15-privatepreview", + "ContainerResource": { + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "runtimes": { + "kubernetes": { + "base": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: webserver\n namespace: app-scoped\n labels:\n app: webserver\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: webserver\n template:\n metadata:\n labels:\n app: webserver\n spec:\n containers:\n - name: nginx\n image: nginx:1.14.2\n ports:\n - containerPort: 80\n" + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "runtimes": { + "kubernetes": { + "base": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: webserver\n namespace: app-scoped\n labels:\n app: webserver\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: webserver\n template:\n metadata:\n labels:\n app: webserver\n spec:\n containers:\n - name: nginx\n image: nginx:1.14.2\n ports:\n - containerPort: 80\n" + } + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Delete.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Delete.json new file mode 100644 index 0000000000..9a9bf28c14 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Containers_Delete", + "title": "Delete an container resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "containerName": "app0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Get.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Get.json new file mode 100644 index 0000000000..371b16c101 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Get.json @@ -0,0 +1,44 @@ +{ + "operationId": "Containers_Get", + "title": "Get an container resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "containerName": "container0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_List.json new file mode 100644 index 0000000000..a19eab3370 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_List.json @@ -0,0 +1,103 @@ +{ + "operationId": "Containers_ListByScope", + "title": "List containers at resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container1", + "name": "container1", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app1", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 + }, + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" + }, + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_ListByScope.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_ListByScope.json new file mode 100644 index 0000000000..48084fdec0 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_ListByScope.json @@ -0,0 +1,106 @@ +{ + "operationId": "Containers_ListByScope", + "title": "List containers at root scope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 + }, + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http", + "provides": "provides", + "port": 443, + "scheme": "https" + }, + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container1", + "name": "container1", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app1", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/containers?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Update.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Update.json new file mode 100644 index 0000000000..b923bd1ed6 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Containers_Update.json @@ -0,0 +1,84 @@ +{ + "operationId": "Containers_Patch", + "title": "Update an container resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "containerName": "container0", + "api-version": "2022-03-15-privatepreview", + "ContainerResource": { + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/containers/container0", + "name": "container0", + "type": "Applications.Core/containers", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "connections": { + "inventory": { + "kind": "dapr.io/InvokeHttp", + "source": "inventory_route_id" + } + }, + "container": { + "image": "radius.azurecr.io/webapptutorial-todoapp", + "command": [ + "/bin/sh" + ], + "args": [ + "-c", + "while true; do echo hello; sleep 10;done" + ], + "workingDir": "/app" + }, + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/app0-container0" + }, + "extensions": [ + { + "kind": "manualScaling", + "replicas": 2 + }, + { + "kind": "daprSidecar", + "appId": "app-id", + "appPort": 80, + "config": "config", + "protocol": "http" + }, + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_CreateOrUpdate.json new file mode 100644 index 0000000000..1f2ba81c85 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_CreateOrUpdate.json @@ -0,0 +1,87 @@ +{ + "operationId": "Environments_CreateOrUpdate", + "title": "Create or Update an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "environmentName": "env0", + "api-version": "2022-03-15-privatepreview", + "EnvironmentResource": { + "location": "West US", + "properties": { + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default" + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_DeleteEnv0.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_DeleteEnv0.json new file mode 100644 index 0000000000..3f57144f67 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_DeleteEnv0.json @@ -0,0 +1,14 @@ +{ + "operationId": "Environments_Delete", + "title": "Delete an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "environmentName": "env0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_GetEnv0.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_GetEnv0.json new file mode 100644 index 0000000000..43070c4772 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_GetEnv0.json @@ -0,0 +1,56 @@ +{ + "operationId": "Environments_Get", + "title": "Get an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "environmentName": "env0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_GetRecipeMetadata.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_GetRecipeMetadata.json new file mode 100644 index 0000000000..d17ab65f66 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_GetRecipeMetadata.json @@ -0,0 +1,29 @@ +{ + "operationId": "Environments_GetMetadata", + "title": "Get recipe metadata from environment", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "environmentName": "env0", + "recipeName": "mongotest" + }, + "responses": { + "200": { + "body": { + "resourceType": "Applications.Datastores/mongoDatabases", + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb", + "parameters": { + "throughput": { + "type" : "int", + "defaultValue" : 400 + }, + "location": { + "type" : "string", + "defaultValue" : "[resourceGroup().location]" + } + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_List.json new file mode 100644 index 0000000000..639bf67f6b --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_List.json @@ -0,0 +1,125 @@ +{ + "operationId": "Environments_ListByScope", + "title": "Get environments by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + }, + "default":{ + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/mongo" + } + }, + "Applications.Datastores/redisCaches":{ + "redis-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/rediscache" + }, + "default":{ + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/redis" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "aws" : { + "scope":"/planes/aws/aws/accounts/140313373712/regions/us-west-2" + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "name": "env1", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster1", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_ListByScope.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_ListByScope.json new file mode 100644 index 0000000000..cc9fe2cf6d --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_ListByScope.json @@ -0,0 +1,65 @@ +{ + "operationId": "Environments_ListByScope", + "title": "Get environments by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "name": "env1", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster1", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc", + "resource": "/subscriptions/testSub/resourcegroups/testGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/radius-mi-app" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/environments?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_PatchEnv0.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_PatchEnv0.json new file mode 100644 index 0000000000..a12a1ad8e2 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Environments_PatchEnv0.json @@ -0,0 +1,74 @@ +{ + "operationId": "Environments_Update", + "title": "Update an environment resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "environmentName": "env0", + "api-version": "2022-03-15-privatepreview", + "EnvironmentResource": { + "location": "West US", + "properties": { + "compute": { + "kind": "Kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default", + "identity": { + "kind": "azure.com.workload", + "oidcIssuer": "https://oidcissuer/oidc" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "name": "env0", + "type": "Applications.Core/environments", + "properties": { + "provisioningState": "Succeeded", + "compute": { + "kind": "kubernetes", + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ContainerService/managedClusters/radiusTestCluster", + "namespace": "default" + }, + "providers" : { + "azure" : { + "scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup" + } + }, + "recipes": { + "Applications.Datastores/mongoDatabases":{ + "cosmos-recipe": { + "templateKind": "bicep", + "templatePath": "br:sampleregistry.azureacr.io/radius/recipes/cosmosdb" + } + } + }, + "extensions": [ + { + "kind": "kubernetesMetadata", + "annotations": { + "prometheus.io/scrape": "true", + "prometheus.io/port": "80" + }, + "labels": { + "foo/bar/team": "credit", + "foo/bar/contact": "radiususer" + } + } + ] + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_CreateOrUpdate.json new file mode 100644 index 0000000000..36a863f2f1 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_CreateOrUpdate.json @@ -0,0 +1,62 @@ +{ + "operationId": "Extenders_CreateOrUpdate", + "title": "Create or Update an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview", + "ExtenderParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", + "name": "extender1", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + } + } +} + \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_CreateOrUpdateWithRecipe.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_CreateOrUpdateWithRecipe.json new file mode 100644 index 0000000000..f7b994db37 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_CreateOrUpdateWithRecipe.json @@ -0,0 +1,54 @@ +{ + "operationId": "Extenders_CreateOrUpdate", + "title": "Create or Update an extender resource with recipe", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview", + "ExtenderParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "s3" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "s3" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", + "name": "extender1", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "s3" + } + } + } + } + } +} + \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Delete.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Delete.json new file mode 100644 index 0000000000..f8241d9c17 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Extenders_Delete", + "title": "Delete an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Get.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Get.json new file mode 100644 index 0000000000..a6883eaa24 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Get.json @@ -0,0 +1,31 @@ +{ + "operationId": "Extenders_Get", + "title": "Get an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "api-version": "2022-03-15-privatepreview", + "extenderName": "extender0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_List.json new file mode 100644 index 0000000000..544a601a76 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_List.json @@ -0,0 +1,34 @@ +{ + "operationId": "Extenders_ListByScope", + "title": "List extender resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_ListByRootScope.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_ListByRootScope.json new file mode 100644 index 0000000000..29aaa22970 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_ListByRootScope.json @@ -0,0 +1,34 @@ +{ + "operationId": "Extenders_ListByScope", + "title": "List extender resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/extenders?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_ListSecrets.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_ListSecrets.json new file mode 100644 index 0000000000..3ba02d58b5 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_ListSecrets.json @@ -0,0 +1,19 @@ +{ + "operationId": "Extenders_ListSecrets", + "title": "List the secrets from extender resources", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroupName": "testGroup", + "api-version": "2022-03-15-privatepreview", + "extenderName": "extender0" + }, + "responses": { + "200": { + "body": { + "accountSid": "sid", + "authToken:": "token" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Update.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Update.json new file mode 100644 index 0000000000..ebdcfcd21a --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Extenders_Update.json @@ -0,0 +1,61 @@ +{ + "operationId": "Extenders_Update", + "title": "Update an extender resource", + "parameters": { + "rootScope": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", + "extenderName": "extender0", + "api-version": "2022-03-15-privatepreview", + "ExtenderParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender0", + "name": "extender0", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/extenders/extender1", + "name": "extender1", + "type": "Applications.Core/extenders", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "fromNumber": "222-222-2222", + "secrets": { + "accountSid": "sid", + "authToken:": "token" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_CreateOrUpdate.json new file mode 100644 index 0000000000..cecb497c19 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_CreateOrUpdate.json @@ -0,0 +1,50 @@ +{ + "operationId": "Gateways_CreateOrUpdate", + "title": "Create or update a gateway resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "gatewayName": "gateway0", + "api-version": "2022-03-15-privatepreview", + "GatewayResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Delete.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Delete.json new file mode 100644 index 0000000000..10c4503eb1 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Gateways_Delete", + "title": "Delete an gateway resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "gatewayName": "gateway0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Get.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Get.json new file mode 100644 index 0000000000..e71430e547 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Get.json @@ -0,0 +1,33 @@ +{ + "operationId": "Gateways_Get", + "title": "Get an gateway resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "gatewayName": "gateway0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_List.json new file mode 100644 index 0000000000..35f79c6018 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_List.json @@ -0,0 +1,37 @@ +{ + "operationId": "Gateways_ListByScope", + "title": "List gateway resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_ListByScope.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_ListByScope.json new file mode 100644 index 0000000000..7e69b93d1f --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_ListByScope.json @@ -0,0 +1,59 @@ +{ + "operationId": "Gateways_ListByScope", + "title": "List gateway resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte", + "path":"/" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway1", + "name": "gateway1", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-back-rte", + "path":"/backend2" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/gateways?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Update.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Update.json new file mode 100644 index 0000000000..cbf4bb3383 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Gateways_Update.json @@ -0,0 +1,50 @@ +{ + "operationId": "Gateways_Update", + "title": "Update a gateway resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "gatewayName": "gateway0", + "api-version": "2022-03-15-privatepreview", + "GatewayResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": true, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/gateways/gateway0", + "name": "gateway0", + "type": "Applications.Core/gateways", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "routes":[ + { + "destination": "/planes/radius/local/resourcegroups/myawsenv/providers/applications.core/httproutes/gtwy-front-rte" + } + ], + "tls":{ + "sslPassthrough": false, + "hostname": "myapp.radapp.dev", + "minimumProtocolVersion": "1.2", + "certificateFrom": "myapp-tls-cert" + } + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_CreateOrUpdate.json new file mode 100644 index 0000000000..41f0d24102 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_CreateOrUpdate.json @@ -0,0 +1,28 @@ +{ + "operationId": "HttpRoutes_CreateOrUpdate", + "title": "Create or Update httpRoutes resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "httpRouteName": "route0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/routes0", + "name": "routes0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Delete.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Delete.json new file mode 100644 index 0000000000..0a2aa56541 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "HttpRoutes_Delete", + "title": "Delete a httpRoutes resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "httpRouteName": "route0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Get.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Get.json new file mode 100644 index 0000000000..e9e2411461 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Get.json @@ -0,0 +1,22 @@ +{ + "operationId": "HttpRoutes_Get", + "title": "Get a httpRoutes resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "httpRouteName": "route0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_List.json new file mode 100644 index 0000000000..134bef7b10 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_List.json @@ -0,0 +1,35 @@ +{ + "operationId": "HttpRoutes_ListByScope", + "title": "List httpRoutes resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route1", + "name": "route1", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httproutes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_ListByScope.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_ListByScope.json new file mode 100644 index 0000000000..cd929b0da1 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_ListByScope.json @@ -0,0 +1,35 @@ +{ + "operationId": "HttpRoutes_ListByScope", + "title": "List httpRoutes resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route0", + "name": "route0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/route1", + "name": "route1", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/httproutes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Update.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Update.json new file mode 100644 index 0000000000..46cd2cf074 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/HttpRoutes_Update.json @@ -0,0 +1,28 @@ +{ + "operationId": "HttpRoutes_Update", + "title": "Update a httpRoutes resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "httpRouteName": "route0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/httpRoutes/routes0", + "name": "routes0", + "type": "Applications.Core/httpRoutes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Operations_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Operations_List.json new file mode 100644 index 0000000000..d5a1aaa939 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Operations_List.json @@ -0,0 +1,195 @@ +{ + "operationId": "Operations_List", + "title": "Get the operations for the Applications.Core resource provider", + "parameters": { + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "Applications.Core/operations/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "Operations", + "operation": "Get operations", + "description": "Get the list of Operations" + } + }, + { + "name": "Applications.Core/environments/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Get/List environment", + "description": "Get or list of environments." + } + }, + { + "name": "Applications.Core/environments/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Create/Update environment", + "description": "Create or update an environment." + } + }, + { + "name": "Applications.Core/environments/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Delete environment", + "description": "Deletes an environment." + } + }, + { + "name": "Applications.Core/environments/join/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "environments", + "operation": "Join environment", + "description": "Join to application environment." + } + }, + { + "name": "Applications.Core/register/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "Applications.Core", + "operation": "Register the Applications.Core", + "description": "Register the subscription for Applications.Core" + } + }, + { + "name": "Applications.Core/unregister/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "Applications.Core", + "operation": "Unregister the Applications.Core", + "description": "Unregister the subscription for Applications.Core" + } + }, + { + "name": "Applications.Core/applications/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Get/List application", + "description": "Get or list of applications." + } + }, + { + "name": "Applications.Core/applications/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Create/Update application", + "description": "Create or update an application." + } + }, + { + "name": "Applications.Core/applications/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Delete application", + "description": "Deletes an application." + } + }, + { + "name": "Applications.Core/applications/join/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "applications", + "operation": "Join application", + "description": "Join to application." + } + }, + { + "name": "Applications.Core/httpRoutes/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "httpRoutes", + "operation": "Get/List HTTP Route", + "description": "Get or list of HTTP Routes." + } + }, + { + "name": "Applications.Core/httpRoutes/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "httpRoutes", + "operation": "Create/Update HTTP Route", + "description": "Create or update an HTTP Route." + } + }, + { + "name": "Applications.Core/httpRoutes/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "httpRoutes", + "operation": "Delete HTTP Route", + "description": "Deletes an HTTP Route." + } + }, + { + "name": "Applications.Core/gateways/read", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Get/List Gateways", + "description": "Get or list of Gateways." + } + }, + { + "name": "Applications.Core/gateways/write", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Create/Update Gateway", + "description": "Create or update a Gateway." + } + }, + { + "name": "Applications.Core/gateways/delete", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Delete Gateway", + "description": "Deletes a Gateway." + } + }, + { + "name": "Applications.Core/gateways/join/action", + "isDataAction": false, + "display": { + "provider": "Applications.Core", + "resource": "gateways", + "operation": "Join Gateway", + "description": "Join to Gateway." + } + } + ] + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdate.json new file mode 100644 index 0000000000..8350409c65 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdate.json @@ -0,0 +1,51 @@ +{ + "operationId": "SecretStores_CreateOrUpdate", + "title": "Create or Update a secret store resource with azure keyvault", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "secretazkv", + "api-version": "2022-03-15-privatepreview", + "SecretStoreResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "encoding": "base64", + "value": "certificate" + }, + "tls.key": { + "encoding": "base64", + "value": "certificate" + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "encoding": "base64" + }, + "tls.key": { + "encoding": "base64" + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdateValueFrom.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdateValueFrom.json new file mode 100644 index 0000000000..470379feb9 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdateValueFrom.json @@ -0,0 +1,61 @@ +{ + "operationId": "SecretStores_CreateOrUpdate", + "title": "Create or Update a secret store resource with valueFrom", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "secretazkv", + "api-version": "2022-03-15-privatepreview", + "SecretStoreResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Delete.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Delete.json new file mode 100644 index 0000000000..2511b39056 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "SecretStores_Update", + "title": "Update a secret store resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Get.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Get.json new file mode 100644 index 0000000000..4ed53c64f2 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Get.json @@ -0,0 +1,30 @@ +{ + "operationId": "SecretStores_Get", + "title": "Get a secret store", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "secret0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + }, + "tls.key": { + } + } + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Get_AzureKeyVault.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Get_AzureKeyVault.json new file mode 100644 index 0000000000..635c47fbfb --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Get_AzureKeyVault.json @@ -0,0 +1,39 @@ +{ + "operationId": "SecretStores_Get", + "title": "Get a secret store for Azure Keyvault", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "secretazkv" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_List.json new file mode 100644 index 0000000000..3e66a39aba --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_List.json @@ -0,0 +1,60 @@ +{ + "operationId": "SecretStores_ListByScope", + "title": "List secret stores", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secret0", + "name": "secret0", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + }, + "tls.key": { + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_ListSecrets.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_ListSecrets.json new file mode 100644 index 0000000000..b5e9ed9e71 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_ListSecrets.json @@ -0,0 +1,22 @@ +{ + "operationId": "SecretStores_ListSecrets", + "title": "List secret stores", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "secret0" + }, + "responses": { + "200": { + "type": "certificate", + "data": { + "tls.crt": { + "value": "secrets ..." + }, + "tls.key": { + "value": "secrets ..." + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Update.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Update.json new file mode 100644 index 0000000000..c04faeab9e --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/SecretStores_Update.json @@ -0,0 +1,61 @@ +{ + "operationId": "SecretStores_Update", + "title": "Update a secret store", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "secretazkv", + "api-version": "2022-03-15-privatepreview", + "SecretStoreResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/secretStores/secretazkv", + "name": "secretazkv", + "type": "Applications.Core/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "type": "certificate", + "data": { + "tls.crt": { + "valueFrom": { + "name": "secret/public_cert", + "version": "1" + } + }, + "tls.key": { + "valueFrom": { + "name": "secret/private_key", + "version": "1" + } + } + }, + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0" + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_CreateOrUpdate.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_CreateOrUpdate.json new file mode 100644 index 0000000000..db34af3074 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_CreateOrUpdate.json @@ -0,0 +1,61 @@ +{ + "operationId": "Volumes_CreateOrUpdate", + "title": "Create or update a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/routes0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Delete.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Delete.json new file mode 100644 index 0000000000..ec812ffa7e --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "Volumes_Delete", + "title": "Delete a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Get.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Get.json new file mode 100644 index 0000000000..5d3c065c62 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Get.json @@ -0,0 +1,55 @@ +{ + "operationId": "Volumes_Get", + "title": "Get a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "volumeName": "keyvault0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_List.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_List.json new file mode 100644 index 0000000000..f52dc9ae53 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_List.json @@ -0,0 +1,100 @@ +{ + "operationId": "Volumes_ListByScope", + "title": "List volumes by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [{ + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault1", + "name": "keyvault1", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_ListByScope.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_ListByScope.json new file mode 100644 index 0000000000..4d14bacbc3 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_ListByScope.json @@ -0,0 +1,101 @@ +{ + "operationId": "Volumes_ListByScope", + "title": "List volumes by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/keyvault1", + "name": "keyvault1", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Core/volumes?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Update.json b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Update.json new file mode 100644 index 0000000000..413bb773d3 --- /dev/null +++ b/typespec/Applications.Core/examples/2022-03-15-privatepreview/Volumes_Update.json @@ -0,0 +1,61 @@ +{ + "operationId": "Volumes_Update", + "title": "Update a volume", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "volumeName": "keyvault0", + "api-version": "2022-03-15-privatepreview", + "HttpRouteResource": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/volumes/routes0", + "name": "keyvault0", + "type": "Applications.Core/volumes", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "kind": "azure.com.keyvault", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.KeyVault/vaults/vault0", + "secrets": { + "mysecret-1": { + "name": "mysecret-1", + "version": "1" + }, + "mysecret-2": { + "name": "mysecret-2", + "encoding": "base64" + } + }, + "keys": { + "mykey-1": { + "name": "key1", + "version": "1" + }, + "mykey-2": { + "name": "key2" + } + }, + "certificates": { + "mycert-1": { + "name": "cert1", + "certType": "certificate" + }, + "mycert-2": { + "name": "cert2", + "certType": "privatekey", + "format": "pfx", + "encoding": "hex" + } + } + } + } + } + } +} diff --git a/typespec/Applications.Core/extenders.tsp b/typespec/Applications.Core/extenders.tsp new file mode 100644 index 0000000000..8ed9111e86 --- /dev/null +++ b/typespec/Applications.Core/extenders.tsp @@ -0,0 +1,103 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +@doc("Response for list secrets API call") +model ExtenderListSecretResponse {} + +@doc("ExtenderResource portable resource") +model ExtenderResource is TrackedResource { + @path + @doc("The name of the ExtenderResource portable resource") + @key("extenderName") + @segment("extenders") + name: ResourceNameString; +} + +// ExtenderResoruce allows to get the additional properties. To ensure that `additionalProperties` is true, +// we need to extend `Record`. +// Reference: https://github.com/Azure/typespec-azure/blob/main/packages/typespec-autorest/test/additional-properties.test.ts +#suppress "@azure-tools/typespec-azure-core/bad-record-type" +@doc("ExtenderResource portable resource properties") +model ExtenderProperties extends Record { + ...EnvironmentScopedResource; + + @doc("The secrets for referenced resource") + secrets?: {}; + + @doc("The recipe used to automatically deploy underlying infrastructure for the extender portable resource") + recipe?: Recipe; + + @doc("Specifies how the underlying service/resource is provisioned and managed.") + resourceProvisioning?: ResourceProvisioning; +} + +@armResourceOperations +interface Extenders { + get is ArmResourceRead>; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + ExtenderResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + ExtenderResource, + ExtenderProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + ExtenderResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + ExtenderResource, + UCPBaseParameters, + "Scope", + "Scope" + >; + + @doc("Lists secrets values for the specified Extender resource") + @action("listSecrets") + listSecrets is ArmResourceActionSync< + ExtenderResource, + {}, + ExtenderListSecretResponse, + UCPBaseParameters + >; +} diff --git a/typespec/Applications.Core/extensions.tsp b/typespec/Applications.Core/extensions.tsp new file mode 100644 index 0000000000..1d486000f0 --- /dev/null +++ b/typespec/Applications.Core/extensions.tsp @@ -0,0 +1,80 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/openapi"; + +using OpenAPI; + +@doc("Extension of a environment/application resource.") +@discriminator("kind") +model Extension {} + +@doc("Kubernetes namespace extension of a environment/application resource.") +model KubernetesNamespaceExtension extends Extension { + @doc("The kind of the resource.") + kind: "kubernetesNamespace"; + + @doc("The namespace of the application environment.") + `namespace`: string; +} + +@doc("Kubernetes metadata extension of a environment/application resource.") +model KubernetesMetadataExtension extends Extension { + @doc("The kind of the resource.") + kind: "kubernetesMetadata"; + + @doc("Annotations to be applied to the Kubernetes resources output by the resource") + annotations?: Record; + + @doc("Labels to be applied to the Kubernetes resources output by the resource") + labels?: Record; +} + +@doc("ManualScaling Extension") +model ManualScalingExtension extends Extension { + @doc("Specifies the extension of the resource") + kind: "manualScaling"; + + @doc("Replica count.") + replicas: int32; +} + +@doc("Specifies the resource should have a Dapr sidecar injected") +model DaprSidecarExtension extends Extension { + @doc("Specifies the extension of the resource") + kind: "daprSidecar"; + + @doc("The Dapr appPort. Specifies the internal listening port for the application to handle requests from the Dapr sidecar. ") + appPort?: int32; + + @doc("The Dapr appId. Specifies the identifier used by Dapr for service invocation.") + appId: string; + + @doc("Specifies the Dapr configuration to use for the resource.") + config?: string; + + @doc("Specifies the Dapr app-protocol to use for the resource.") + protocol?: DaprSidecarExtensionProtocol; +} + +@doc("The Dapr sidecar extension protocol") +enum DaprSidecarExtensionProtocol { + @doc("HTTP protocol") + http, + + @doc("gRPC protocol") + grpc, +} diff --git a/typespec/Applications.Core/gateways.tsp b/typespec/Applications.Core/gateways.tsp new file mode 100644 index 0000000000..843e54c8a5 --- /dev/null +++ b/typespec/Applications.Core/gateways.tsp @@ -0,0 +1,137 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +model GatewayResource is TrackedResource { + @doc("Gateway name") + @key("gatewayName") + @path + @segment("gateways") + name: ResourceNameString; +} + +@doc("Gateway properties") +model GatewayProperties { + ...ApplicationScopedResource; + + @doc("Sets Gateway to not be exposed externally (no public IP address associated). Defaults to false (exposed to internet).") + internal?: boolean = false; + + @doc("Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io.") + hostname?: GatewayHostname; + + @doc("Routes attached to this Gateway") + @extension("x-ms-identifiers", []) + routes: GatewayRoute[]; + + @doc("TLS configuration for the Gateway.") + tls?: GatewayTls; + + @doc("URL of the gateway resource. Readonly") + @visibility("read") + url?: string; +} + +@doc("Tls Minimum versions for Gateway resource.") +enum TlsMinVersion { + @doc("TLS Version 1.2") + tls12: "1.2", + + @doc("TLS Version 1.3") + tls13: "1.3", +} + +@doc("TLS configuration definition for Gateway resource.") +model GatewayTls { + @doc("If true, gateway lets the https traffic sslPassthrough to the backend servers for decryption.") + sslPassthrough?: boolean = false; + + @doc("TLS minimum protocol version (defaults to 1.2).") + minimumProtocolVersion?: TlsMinVersion = TlsMinVersion.tls12; + + @doc("The resource id for the secret containing the TLS certificate and key for the gateway.") + certificateFrom?: string; +} + +@doc("Declare hostname information for the Gateway. Leaving the hostname empty auto-assigns one: mygateway.myapp.PUBLICHOSTNAMEORIP.nip.io.") +model GatewayHostname { + @doc("Specify a prefix for the hostname: myhostname.myapp.PUBLICHOSTNAMEORIP.nip.io. Mutually exclusive with 'fullyQualifiedHostname' and will be overridden if both are defined.") + prefix?: string; + + @doc("Specify a fully-qualified domain name: myapp.mydomain.com. Mutually exclusive with 'prefix' and will take priority if both are defined.") + fullyQualifiedHostname?: string; +} + +@doc("Route attached to Gateway") +model GatewayRoute { + @doc("The path to match the incoming request path on. Ex - /myservice.") + path?: string; + + @doc("The HttpRoute to route to. Ex - myserviceroute.id.") + destination?: string; + + @doc("Optionally update the prefix when sending the request to the service. Ex - replacePrefix: '/' and path: '/myservice' will transform '/myservice/myroute' to '/myroute'") + replacePrefix?: string; +} + +@armResourceOperations +interface Gateways { + get is ArmResourceRead>; + + create is ArmResourceCreateOrReplaceAsync< + GatewayResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourcePatchAsync< + GatewayResource, + GatewayProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + GatewayResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + GatewayResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Core/httproutes.tsp b/typespec/Applications.Core/httproutes.tsp new file mode 100644 index 0000000000..72192ec790 --- /dev/null +++ b/typespec/Applications.Core/httproutes.tsp @@ -0,0 +1,96 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +@doc("Radius HTTPRoute Resource.") +model HttpRouteResource is TrackedResource { + @doc("HTTPRoute name") + @key("httpRouteName") + @path + @segment("httpRoutes") + name: ResourceNameString; +} + +@doc("HTTPRoute properties") +model HttpRouteProperties { + ...ApplicationScopedResource; + + @doc("The internal hostname accepting traffic for the HTTP Route. Readonly.") + hostname?: string; + + @doc("The port number for the HTTP Route. Defaults to 80. Readonly.") + port?: int32; + + @doc("The scheme used for traffic. Readonly.") + @visibility("read") + scheme?: string; + + @doc("A stable URL that that can be used to route traffic to a resource. Readonly.") + @visibility("read") + url?: string; +} + +@armResourceOperations +interface HttpRoutes { + get is ArmResourceRead< + HttpRouteResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + HttpRouteResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + HttpRouteResource, + HttpRouteProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + HttpRouteResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + HttpRouteResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Core/main.tsp b/typespec/Applications.Core/main.tsp new file mode 100644 index 0000000000..376431ea99 --- /dev/null +++ b/typespec/Applications.Core/main.tsp @@ -0,0 +1,48 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-resource-manager"; + +import "./environments.tsp"; +import "./applications.tsp"; +import "./containers.tsp"; +import "./gateways.tsp"; +import "./httproutes.tsp"; +import "./secretstores.tsp"; +import "./volumes.tsp"; +import "./extenders.tsp"; + +using TypeSpec.Versioning; +using Azure.ResourceManager; + +@armProviderNamespace +@service({ + title: "Applications.Core Management APIs", +}) +@doc("REST APIs for Applications.Core") +@versioned(Versions) +namespace Applications.Core; + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Supported API versions for the Applications.Core resource provider.") +enum Versions { + @doc("2022-03-15-privatepreview") + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + v2022_03_15_privatepreview: "2022-03-15-privatepreview", +} diff --git a/typespec/Applications.Core/secretstores.tsp b/typespec/Applications.Core/secretstores.tsp new file mode 100644 index 0000000000..af9b089024 --- /dev/null +++ b/typespec/Applications.Core/secretstores.tsp @@ -0,0 +1,149 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +model SecretStoreResource is TrackedResource { + @doc("SecretStore name") + @key("secretStoreName") + @path + @segment("secretStores") + name: ResourceNameString; +} + +@doc("The properties of SecretStore") +model SecretStoreProperties { + ...ApplicationScopedResource; + + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property" + @doc("The type of secret store data") + type?: SecretStoreDataType = SecretStoreDataType.generic; + + @doc("An object to represent key-value type secrets") + data: Record; + + @doc("The resource id of external secret store.") + resource?: string; +} + +@doc("The type of SecretStore data") +enum SecretStoreDataType { + @doc("Generic secret data type") + generic, + + @doc("Certificate secret data type") + certificate, +} + +@doc("The type of SecretValue Encoding") +enum SecretValueEncoding { + @doc("The raw secret value") + raw, + + @doc("The base64-encoded secret value") + base64, +} + +@doc("The Secret value source properties") +model ValueFromProperties { + @doc("The name of the referenced secret.") + name: string; + + @doc("The version of the referenced secret.") + version?: string; +} + +@doc("The properties of SecretValue") +model SecretValueProperties { + @doc("The encoding of value") + encoding?: SecretValueEncoding = SecretValueEncoding.raw; + + @doc("The value of secret.") + @secret + value?: string; + + @doc("The referenced secret in properties.resource") + valueFrom?: ValueFromProperties; +} + +@doc("The list of secrets") +model SecretStoreListSecretsResult { + @doc("The type of secret store data") + type: SecretStoreDataType; + + @doc("An object to represent key-value type secrets") + data: Record; +} + +@armResourceOperations +interface SecretStores { + get is ArmResourceRead< + SecretStoreResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + SecretStoreResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + SecretStoreResource, + SecretStoreProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + SecretStoreResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + SecretStoreResource, + UCPBaseParameters, + "Scope", + "Scope" + >; + + @doc("List the secrets of a secret stores.") + @action("listSecrets") + listSecrets is ArmResourceActionSync< + SecretStoreResource, + {}, + SecretStoreListSecretsResult, + UCPBaseParameters + >; +} diff --git a/typespec/Applications.Core/tspconfig.yaml b/typespec/Applications.Core/tspconfig.yaml new file mode 100644 index 0000000000..36ae5ddecf --- /dev/null +++ b/typespec/Applications.Core/tspconfig.yaml @@ -0,0 +1,10 @@ +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + use-read-only-status-schema: true + azure-resource-provider-folder: "resource-manager" + examples-directory: "{project-root}/examples" + emitter-output-dir: "{project-root}/../../swagger/specification/applications" + arm-types-dir: "{project-root}/../../swagger/specification/common-types/resource-management" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" diff --git a/typespec/Applications.Core/volumes.tsp b/typespec/Applications.Core/volumes.tsp new file mode 100644 index 0000000000..0b82fb5b4b --- /dev/null +++ b/typespec/Applications.Core/volumes.tsp @@ -0,0 +1,179 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Core; + +@doc("Radius Volume resource.") +model VolumeResource is TrackedResource { + @doc("Volume name") + @key("volumeName") + @path + @segment("volumes") + name: ResourceNameString; +} + +@doc("Volume properties") +@discriminator("kind") +model VolumeProperties { + ...ApplicationScopedResource; +} + +@doc("Represents Azure Key Vault Volume properties") +model AzureKeyVaultVolumeProperties extends VolumeProperties { + @doc("The Azure Key Vault Volume kind") + kind: "azure.com.keyvault"; + + @doc("The KeyVault certificates that this volume exposes") + certificates?: Record; + + @doc("The KeyVault keys that this volume exposes") + keys?: Record; + + @doc("The ID of the keyvault to use for this volume resource") + resource: string; + + @doc("The KeyVault secrets that this volume exposes") + secrets?: Record; +} + +@doc("Represents certificate object properties") +model CertificateObjectProperties { + @doc("File name when written to disk") + `alias`?: string; + + @doc("Encoding format. Default utf-8") + encoding?: VolumeSecretEncodings = VolumeSecretEncodings.utf8; + + @doc("Certificate format. Default pem") + format?: CertificateFormats = CertificateFormats.pem; + + @doc("The name of the certificate") + name: string; + + @doc("Certificate object type to be downloaded - the certificate itself, private key or public key of the certificate") + certType?: CertificateTypes; + + @doc("Certificate version") + version?: string; +} + +@doc("Represents certificate formats") +enum CertificateFormats { + @doc("PEM Certificate format") + pem: "pem", + + @doc("PFX Certificate format") + pfx: "pfx", +} + +@doc("Represents secret encodings") +enum VolumeSecretEncodings { + @doc("UTF-8 encoding") + utf8: "utf-8", + + @doc("Hex encoding") + hex: "hex", + + @doc("Base64 encoding") + base64: "base64", +} + +@doc("Represents certificate types") +enum CertificateTypes { + @doc("Certificate type") + certificate: "certificate", + + @doc("Private Key type") + privatekey: "privatekey", + + @doc("Public Key type") + publickey: "publickey", +} + +@doc("Represents secret object properties") +model SecretObjectProperties { + @doc("File name when written to disk") + `alias`?: string; + + @doc("Encoding format. Default utf-8") + encoding?: VolumeSecretEncodings = VolumeSecretEncodings.utf8; + + @doc("The name of the secret") + name: string; + + @doc("secret version") + version?: string; +} + +@doc("Represents key object properties") +model KeyObjectProperties { + @doc("File name when written to disk") + `alias`?: string; + + @doc("The name of the key") + name: string; + + @doc("Key version") + version?: string; +} + +@armResourceOperations +interface Volumes { + get is ArmResourceRead>; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + VolumeResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + VolumeResource, + VolumeProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + VolumeResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + VolumeResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Dapr/common.tsp b/typespec/Applications.Dapr/common.tsp new file mode 100644 index 0000000000..c1543172d1 --- /dev/null +++ b/typespec/Applications.Dapr/common.tsp @@ -0,0 +1,36 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/openapi"; + +using OpenAPI; + +@doc("The base properties of a Dapr component object.") +model DaprResourceProperties { + @doc("The name of the Dapr component object. Use this value in your code when interacting with the Dapr client to use the Dapr component.") + @visibility("read") + componentName?: string; + + @doc("The metadata for Dapr resource which must match the values specified in Dapr component spec") + metadata?: {}; + + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property" + @doc("Dapr component type which must matches the format used by Dapr Kubernetes configuration format") + type?: string; + + @doc("Dapr component version") + version?: string; +} diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_CreateOrUpdate.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_CreateOrUpdate.json new file mode 100644 index 0000000000..bcc72c4ab8 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_CreateOrUpdate.json @@ -0,0 +1,77 @@ +{ + "operationId": "PubSubBrokers_CreateOrUpdate", + "title": "Create or update a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview", + "PubSubBrokerParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_CreateOrUpdateWithRecipe.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_CreateOrUpdateWithRecipe.json new file mode 100644 index 0000000000..83391aca67 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_CreateOrUpdateWithRecipe.json @@ -0,0 +1,66 @@ +{ + "operationId": "PubSubBrokers_CreateOrUpdate", + "title": "Create or update a PubSubBroker resource with recipe", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview", + "PubSubBrokerParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "recipe", + "type": "pubsub.azure.servicebus", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "recipe", + "type": "pubsub.azure.servicebus", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Delete.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Delete.json new file mode 100644 index 0000000000..be9fe77463 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "PubSubBrokers_Delete", + "title": "Delete a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Get.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Get.json new file mode 100644 index 0000000000..eaaad281b0 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Get.json @@ -0,0 +1,35 @@ +{ + "operationId": "PubSubBrokers_Get", + "title": "Get a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "pubSubBrokerName": "daprpubsub0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_List.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_List.json new file mode 100644 index 0000000000..28213b5b37 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_List.json @@ -0,0 +1,73 @@ +{ + "operationId": "PubSubBrokers_ListByScope", + "title": "List a PubSubBroker resource by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub0", + "name": "daprPubSub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub1", + "name": "daprPubSub1", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "pubsub.kafka", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub2", + "name": "daprPubSub2", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "pubsub-test", + "parameters": { + "port": 6081 + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_ListByRootScope.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_ListByRootScope.json new file mode 100644 index 0000000000..a10cf160c7 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_ListByRootScope.json @@ -0,0 +1,56 @@ +{ + "operationId": "PubSubBrokers_ListByScope", + "title": "List a PubSubBroker resource by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprPubSub0", + "name": "daprPubSub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Dapr/pubSubBrokers/daprPubSub1", + "name": "daprPubSub1", + "type": "Applications.Dapr/pubSubBrokers", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "pubsub.kafka", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Dapr/pubSubBrokers?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Update.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Update.json new file mode 100644 index 0000000000..f22de30773 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/PubSubBrokers_Update.json @@ -0,0 +1,77 @@ +{ + "operationId": "PubSubBrokers_Update", + "title": "Update a PubSubBroker resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "pubSubBrokerName": "daprpubsub0", + "api-version": "2022-03-15-privatepreview", + "PubSubBrokerParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/pubSubBrokers/daprpubsub0", + "name": "daprpubsub0", + "type": "Applications.Dapr/pubSubBrokers", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.ServiceBus/namespaces/testQueue" + } + ], + "type": "pubsub.azure.servicebus", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdate.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdate.json new file mode 100644 index 0000000000..7cdd6b3396 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_CreateOrUpdate.json @@ -0,0 +1,63 @@ +{ + "operationId": "SecretStores_CreateOrUpdate", + "title": "Create or update an SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "daprsecretstore0", + "api-version": "2022-03-15-privatepreview", + "SecretStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "kind": "generic", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore1", + "name": "daprSecretStore1", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Delete.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Delete.json new file mode 100644 index 0000000000..d00bd593fe --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "SecretStores_Delete", + "title": "Delete a SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "daprsecretstore0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Get.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Get.json new file mode 100644 index 0000000000..38340c89f7 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Get.json @@ -0,0 +1,30 @@ +{ + "operationId": "SecretStores_Get", + "title": "Get a SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "secretStoreName": "daprsecretstore0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprsecretstore0", + "name": "daprsecretstore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_List.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_List.json new file mode 100644 index 0000000000..4c2a74ee3e --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_List.json @@ -0,0 +1,51 @@ +{ + "operationId": "SecretStores_ListByScope", + "title": "List SecretStore resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_ListByRootScope.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_ListByRootScope.json new file mode 100644 index 0000000000..b66685650b --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_ListByRootScope.json @@ -0,0 +1,51 @@ +{ + "operationId": "SecretStores_ListByScope", + "title": "List SecretStore resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Dapr/secretStores?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Update.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Update.json new file mode 100644 index 0000000000..974e788940 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/SecretStores_Update.json @@ -0,0 +1,63 @@ +{ + "operationId": "SecretStores_Update", + "title": "Update an SecretStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "secretStoreName": "daprsecretstore0", + "api-version": "2022-03-15-privatepreview", + "SecretStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore0", + "name": "daprSecretStore0", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "kind": "generic", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/secretStores/daprSecretStore1", + "name": "daprSecretStore1", + "type": "Applications.Dapr/secretStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "secretstores.hashicorp.vault", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_CreateOrUpdate.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_CreateOrUpdate.json new file mode 100644 index 0000000000..48912c2186 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_CreateOrUpdate.json @@ -0,0 +1,73 @@ +{ + "operationId": "StateStores_CreateOrUpdate", + "title": "Create or update a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview", + "StateStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "kind": "state.sqlserver", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_CreateOrUpdateWithRecipe.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_CreateOrUpdateWithRecipe.json new file mode 100644 index 0000000000..df781c63f4 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_CreateOrUpdateWithRecipe.json @@ -0,0 +1,55 @@ +{ + "operationId": "StateStores_CreateOrUpdate", + "title": "Create or update a StateStore resource with recipe", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview", + "StateStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "recipe-test" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", + "name": "daprstatestore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "kind": "state.sqlserver", + "recipe": { + "name": "recipe-test" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", + "name": "daprstatestore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "recipe": { + "name": "recipe-test" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Delete.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Delete.json new file mode 100644 index 0000000000..f65fe45f3a --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "StateStores_Delete", + "title": "Delete a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Get.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Get.json new file mode 100644 index 0000000000..f3c635f3ae --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Get.json @@ -0,0 +1,26 @@ +{ + "operationId": "StateStores_Get", + "title": "Get a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "stateStoreName": "daprstatestore0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/daprstatestore0", + "name": "daprstatestore0", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resource": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_List.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_List.json new file mode 100644 index 0000000000..c6a84c66f8 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_List.json @@ -0,0 +1,92 @@ +{ + "operationId": "StateStores_ListByScope", + "title": "List StateStore resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore2", + "name": "stateStore2", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore3", + "name": "stateStore3", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "recipe-test" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_ListByRootScope.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_ListByRootScope.json new file mode 100644 index 0000000000..faa2d33d60 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_ListByRootScope.json @@ -0,0 +1,78 @@ +{ + "operationId": "StateStores_ListByScope", + "title": "List StateStore resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore2", + "name": "stateStore2", + "type": "Applications.Dapr/stateStores", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Dapr/stateStores?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Update.json b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Update.json new file mode 100644 index 0000000000..a93dca0ae8 --- /dev/null +++ b/typespec/Applications.Dapr/examples/2022-03-15-privatepreview/StateStores_Update.json @@ -0,0 +1,73 @@ +{ + "operationId": "StateStores_Update", + "title": "Update a StateStore resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "stateStoreName": "daprstatestore0", + "api-version": "2022-03-15-privatepreview", + "StateStoreParameters": { + "location": "West US", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore0", + "name": "stateStore0", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "kind": "state.sqlserver", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Dapr/stateStores/stateStore1", + "name": "stateStore1", + "type": "Applications.Dapr/stateStores", + "location": "West US", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Storage/storageAccounts/tableServices/tables/testTable" + } + ], + "type": "state.zookeeper", + "version": "v1", + "metadata": { + "foo": "bar" + }, + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Dapr/main.tsp b/typespec/Applications.Dapr/main.tsp new file mode 100644 index 0000000000..5a31245fa5 --- /dev/null +++ b/typespec/Applications.Dapr/main.tsp @@ -0,0 +1,43 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-resource-manager"; + +import "./secretStores.tsp"; +import "./stateStores.tsp"; +import "./pubSubBrokers.tsp"; + +using TypeSpec.Versioning; +using Azure.ResourceManager; + +@armProviderNamespace +@service({ + title: "Applications.Dapr Resource Management APIs", +}) +@doc("REST API for Applications.Dapr") +@versioned(Versions) +namespace Applications.Dapr; + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Supported API versions for the Applications.Dapr resource provider.") +enum Versions { + @doc("2022-03-15-privatepreview") + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + v2022_03_15_privatepreview: "2022-03-15-privatepreview", +} diff --git a/typespec/Applications.Dapr/pubSubBrokers.tsp b/typespec/Applications.Dapr/pubSubBrokers.tsp new file mode 100644 index 0000000000..1d16d1bcb6 --- /dev/null +++ b/typespec/Applications.Dapr/pubSubBrokers.tsp @@ -0,0 +1,88 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Dapr; + +@doc("Dapr PubSubBroker portable resource") +model DaprPubSubBrokerResource is TrackedResource { + @doc("PubSubBroker name") + @key("pubSubBrokerName") + @path + @segment("pubSubBrokers") + name: ResourceNameString; +} + +@doc("Dapr PubSubBroker portable resource properties") +model DaprPubSubBrokerProperties { + ...EnvironmentScopedResource; + ...DaprResourceProperties; + + @doc("A collection of references to resources associated with the pubSubBroker") + resources?: ResourceReference[]; + + ...RecipeBaseProperties; +} + +@armResourceOperations +interface PubSubBrokers { + get is ArmResourceRead< + DaprPubSubBrokerResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + DaprPubSubBrokerResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + DaprPubSubBrokerResource, + DaprPubSubBrokerProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + DaprPubSubBrokerResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + DaprPubSubBrokerResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Dapr/secretStores.tsp b/typespec/Applications.Dapr/secretStores.tsp new file mode 100644 index 0000000000..f188f87bd3 --- /dev/null +++ b/typespec/Applications.Dapr/secretStores.tsp @@ -0,0 +1,83 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Dapr; + +@doc("Dapr SecretStore portable resource") +model DaprSecretStoreResource is TrackedResource { + @doc("SecretStore name") + @key("secretStoreName") + @path + @segment("secretStores") + name: ResourceNameString; +} + +@doc("Dapr SecretStore portable resource properties") +model DaprSecretStoreProperties { + ...EnvironmentScopedResource; + ...DaprResourceProperties; + ...RecipeBaseProperties; +} + +@armResourceOperations +interface SecretStores { + get is ArmResourceRead< + DaprSecretStoreResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + DaprSecretStoreResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + DaprSecretStoreResource, + DaprSecretStoreProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + DaprSecretStoreResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + DaprSecretStoreResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Dapr/stateStores.tsp b/typespec/Applications.Dapr/stateStores.tsp new file mode 100644 index 0000000000..240efa22dd --- /dev/null +++ b/typespec/Applications.Dapr/stateStores.tsp @@ -0,0 +1,87 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Dapr; + +@doc("Dapr StateStore portable resource") +model DaprStateStoreResource is TrackedResource { + @doc("StateStore name") + @key("stateStoreName") + @path + @segment("stateStores") + name: ResourceNameString; +} + +@doc("Dapr StateStore portable resource properties") +model DaprStateStoreProperties { + ...EnvironmentScopedResource; + ...DaprResourceProperties; + + @doc("A collection of references to resources associated with the state store") + resources?: ResourceReference[]; + + ...RecipeBaseProperties; +} + +@armResourceOperations +interface StateStores { + get is ArmResourceRead< + DaprStateStoreResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + DaprStateStoreResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + DaprStateStoreResource, + DaprStateStoreProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + DaprStateStoreResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + DaprStateStoreResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Applications.Dapr/tspconfig.yaml b/typespec/Applications.Dapr/tspconfig.yaml new file mode 100644 index 0000000000..38f0dc630d --- /dev/null +++ b/typespec/Applications.Dapr/tspconfig.yaml @@ -0,0 +1,10 @@ +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + use-read-only-status-schema: true + azure-resource-provider-folder: "resource-manager" + examples-directory: "examples" + emitter-output-dir: "{project-root}/../../swagger/specification/applications" + arm-types-dir: "{project-root}/../../swagger/specification/common-types/resource-management" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" diff --git a/typespec/Applications.Datastores/common.tsp b/typespec/Applications.Datastores/common.tsp new file mode 100644 index 0000000000..13aac0cadd --- /dev/null +++ b/typespec/Applications.Datastores/common.tsp @@ -0,0 +1,19 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/openapi"; + +using OpenAPI; diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_CreateOrUpdateRecipe.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_CreateOrUpdateRecipe.json new file mode 100644 index 0000000000..42e4018d11 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_CreateOrUpdateRecipe.json @@ -0,0 +1,62 @@ +{ + "operationId": "MongoDatabases_CreateOrUpdate", + "title": "Create or update a MongoDatabase resource with recipe", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "mongoDatabaseName": "mongo0", + "api-version": "2022-03-15-privatepreview", + "MongoDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_CreateOrUpdateValues.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_CreateOrUpdateValues.json new file mode 100644 index 0000000000..0d6be4423b --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_CreateOrUpdateValues.json @@ -0,0 +1,65 @@ +{ + "operationId": "MongoDatabases_CreateOrUpdate", + "title": "Create or update a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "mongoDatabaseName": "mongo0", + "api-version": "2022-03-15-privatepreview", + "MongoDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + }, + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ] + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_Delete.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_Delete.json new file mode 100644 index 0000000000..c5f7221cbf --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "MongoDatabases_Delete", + "title": "Delete a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "mongoDatabaseName": "mongo0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_Get.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_Get.json new file mode 100644 index 0000000000..79e1b7ae90 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_Get.json @@ -0,0 +1,33 @@ +{ + "operationId": "MongoDatabases_Get", + "title": "Get a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "mongoDatabaseName": "mongo0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ], + "database": "mongo0", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255 + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_List.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_List.json new file mode 100644 index 0000000000..0739f0cbb0 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_List.json @@ -0,0 +1,73 @@ +{ + "operationId": "MongoDatabases_ListByScope", + "title": "List MongoDatabase resources by resource group", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ], + "database": "mongo0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo1", + "name": "mongo1", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo0", + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo1", + "name": "mongo1", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_ListByRootScope.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_ListByRootScope.json new file mode 100644 index 0000000000..4113d8a707 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_ListByRootScope.json @@ -0,0 +1,74 @@ +{ + "operationId": "MongoDatabases_ListByScope", + "title": "List MongoDatabase resources by rootScope", + "parameters": { + "rootScope": "planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/mongoDatabases/mongo0", + "name": "mongo0", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.DocumentDB/databaseAccounts/testAccount/mongodbDatabases/db" + } + ], + "database": "mongo0" + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo1", + "name": "mongo1", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "testAccount1.mongo.cosmos.azure.com", + "port": 10255, + "database": "mongo1", + "username": "testUser", + "secrets": { + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/mongoDatabases/mongo2", + "name": "mongo2", + "type": "Applications.Datastores/mongoDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "cosmosdb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Datastores/mongoDatabases?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_ListSecrets.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_ListSecrets.json new file mode 100644 index 0000000000..504f90ffb2 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/MongoDatabases_ListSecrets.json @@ -0,0 +1,18 @@ +{ + "operationId": "MongoDatabases_ListSecrets", + "title": "List the secrets of a MongoDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "mongoDatabaseName": "mongo0" + }, + "responses": { + "200": { + "body": { + "username": "testUser", + "password": "testPassword", + "connectionString": "mongodb://testUser:testPassword@testAccount1.mongo.cosmos.azure.com:10255" + } + } + } +} diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdate.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdate.json new file mode 100644 index 0000000000..003bc22fc3 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdate.json @@ -0,0 +1,68 @@ +{ + "operationId": "RedisCaches_CreateOrUpdate", + "title": "Create or update a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdateRecipe.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdateRecipe.json new file mode 100644 index 0000000000..838f7332d1 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdateRecipe.json @@ -0,0 +1,62 @@ +{ + "operationId": "RedisCaches_CreateOrUpdate", + "title": "Create or update a RedisCache resource with recipe", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdateValues.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdateValues.json new file mode 100644 index 0000000000..417b0a2588 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_CreateOrUpdateValues.json @@ -0,0 +1,59 @@ +{ + "operationId": "RedisCaches_CreateOrUpdate", + "title": "Create or update a RedisCache resource with values", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "secrets": { + "password": "testPassword", + "connectionString": "test-connection-string" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Delete.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Delete.json new file mode 100644 index 0000000000..dbedada922 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "RedisCaches_Delete", + "title": "Delete a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Get.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Get.json new file mode 100644 index 0000000000..0bfe5aad6f --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Get.json @@ -0,0 +1,33 @@ +{ + "operationId": "RedisCaches_Get", + "title": "Get a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "redisCacheName": "redis0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_List.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_List.json new file mode 100644 index 0000000000..20eff8c433 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_List.json @@ -0,0 +1,69 @@ +{ + "operationId": "RedisCaches_ListByScope", + "title": "List RedisCache resources by resource group", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis1", + "name": "redis1", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis2", + "name": "redis2", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_ListByRootScope.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_ListByRootScope.json new file mode 100644 index 0000000000..7c74f8ef11 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_ListByRootScope.json @@ -0,0 +1,68 @@ +{ + "operationId": "RedisCaches_ListByScope", + "title": "List RedisCache resources by rootScope", + "parameters": { + "rootScope": "planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis1", + "name": "redis1", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "redis", + "parameters": { + "port": 2334 + } + } + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/redisCaches/redis2", + "name": "redis2", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "resourceProvisioning": "manual", + "host": "myrediscache.redis.cache.windows.net", + "port": 6380, + "username": "username" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Datastores/redisCaches?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_ListSecrets.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_ListSecrets.json new file mode 100644 index 0000000000..7e0f2d9547 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_ListSecrets.json @@ -0,0 +1,19 @@ +{ + "operationId": "RedisCaches_ListSecrets", + "title": "List the secrets of a RedisCaches resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroupName": "testGroup", + "api-version": "2022-03-15-privatepreview", + "redisCacheName": "redis0" + }, + "responses": { + "200": { + "body": { + "connectionString": "myrediscache.redis.cache.windows.net:6380", + "password": "testPassword" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Update.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Update.json new file mode 100644 index 0000000000..04d8bed899 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/RedisCaches_Update.json @@ -0,0 +1,68 @@ +{ + "operationId": "RedisCaches_Update", + "title": "Update a RedisCache resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "redisCacheName": "redis0", + "api-version": "2022-03-15-privatepreview", + "RedisCacheParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/redisCaches/redis0", + "name": "redis0", + "type": "Applications.Datastores/redisCaches", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Cache/Redis/testCache" + } + ], + "host": "myrediscache.redis.cache.windows.net", + "port": 6380 + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_CreateOrUpdate.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_CreateOrUpdate.json new file mode 100644 index 0000000000..fecc16494a --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_CreateOrUpdate.json @@ -0,0 +1,52 @@ +{ + "operationId": "SqlDatabases_CreateOrUpdate", + "title": "Create or update a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "sqlDatabaseName": "sql0", + "api-version": "2022-03-15-privatepreview", + "SQLDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Delete.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Delete.json new file mode 100644 index 0000000000..f703412f87 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "SqlDatabases_Delete", + "title": "Delete a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "sqlDatabaseName": "sql0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Get.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Get.json new file mode 100644 index 0000000000..bf6cc2f581 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Get.json @@ -0,0 +1,32 @@ +{ + "operationId": "SqlDatabases_Get", + "title": "Get a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "sqlDatabaseName": "sql0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "sql-database", + "server": "test-server", + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_List.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_List.json new file mode 100644 index 0000000000..928bbd95f9 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_List.json @@ -0,0 +1,67 @@ +{ + "operationId": "SqlDatabases_ListByScope", + "title": "List SqlDatabases resources by resource group", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql2", + "name": "sql2", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases?api-version=2022-01-25-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_ListByRootScope.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_ListByRootScope.json new file mode 100644 index 0000000000..1f16e6e489 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_ListByRootScope.json @@ -0,0 +1,72 @@ +{ + "operationId": "SqlDatabases_ListByScope", + "title": "List SqlDatabases resources by rootScope", + "parameters": { + "rootScope": "planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "database": "sql-database", + "server": "test-server", + "resourceProvisioning": "manual" + } + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup1/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase1" + } + ], + "database": "testDatabase", + "server": "testAccount1.sql.cosmos.azure.com", + "resourceProvisioning": "manual" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql2", + "name": "sql2", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env1", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Applications.Datastores/sqlDatabases?api-version=2022-03-15-privatepreview&$skipToken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_ListSecrets.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_ListSecrets.json new file mode 100644 index 0000000000..d7445e926b --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_ListSecrets.json @@ -0,0 +1,19 @@ +{ + "operationId": "SQLDatabases_ListSecrets", + "title": "List the secrets of a SQLDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "resourceGroupName": "testGroup", + "api-version": "2022-03-15-privatepreview", + "redisCacheName": "redis0" + }, + "responses": { + "200": { + "body": { + "connectionString": "sqldatabases:5000", + "password": "testPassword" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Update.json b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Update.json new file mode 100644 index 0000000000..52e5223523 --- /dev/null +++ b/typespec/Applications.Datastores/examples/2022-03-15-privatepreview/SQLDatabases_Update.json @@ -0,0 +1,52 @@ +{ + "operationId": "SqlDatabases_Update", + "title": "Update a SqlDatabase resource", + "parameters": { + "rootScope": "planes/radius/local/resourceGroups/testGroup", + "sqlDatabaseName": "sql0", + "api-version": "2022-03-15-privatepreview", + "SQLDatabaseParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resources": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testServer/databases/testDatabase" + } + ], + "resourceProvisioning": "manual" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql0", + "name": "sql0", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Datastores/sqlDatabases/sql1", + "name": "sql1", + "type": "Applications.Datastores/sqlDatabases", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Datastores/main.tsp b/typespec/Applications.Datastores/main.tsp new file mode 100644 index 0000000000..87e9a31c0e --- /dev/null +++ b/typespec/Applications.Datastores/main.tsp @@ -0,0 +1,43 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-resource-manager"; + +import "./mongoDatabases.tsp"; +import "./redisCaches.tsp"; +import "./sqlDatabases.tsp"; + +using TypeSpec.Versioning; +using Azure.ResourceManager; + +@armProviderNamespace +@service({ + title: "Applications.Datastores Resource Management APIs", +}) +@doc("REST APIs for Applications.Datastores") +@versioned(Versions) +namespace Applications.Datastores; + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Supported API versions for the Applications.Databases resource provider.") +enum Versions { + @doc("2022-03-15-privatepreview") + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + v2022_03_15_privatepreview: "2022-03-15-privatepreview", +} diff --git a/typespec/Applications.Datastores/mongoDatabases.tsp b/typespec/Applications.Datastores/mongoDatabases.tsp new file mode 100644 index 0000000000..11dcaaa65c --- /dev/null +++ b/typespec/Applications.Datastores/mongoDatabases.tsp @@ -0,0 +1,124 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; + +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Datastores; + +@doc("MongoDatabase portable resource") +model MongoDatabaseResource is TrackedResource { + @doc("The name of the MongoDatabase portable resource resource") + @path + @segment("mongoDatabases") + @key("mongoDatabaseName") + name: ResourceNameString; +} + +@doc("The secret values for the given MongoDatabase resource") +model MongoDatabaseListSecretsResult is MongoDatabaseSecrets; + +@doc("The secret values for the given MongoDatabase resource") +model MongoDatabaseSecrets { + @doc("Password to use when connecting to the target Mongo database") + password?: string; + + @doc("Connection string used to connect to the target Mongo database") + connectionString?: string; +} + +@doc("MongoDatabase portable resource properties") +model MongoDatabaseProperties { + ...EnvironmentScopedResource; + + @doc("Secret values provided for the resource") + secrets?: MongoDatabaseSecrets; + + @doc("Host name of the target Mongo database") + host?: string; + + @doc("Port value of the target Mongo database") + port?: int32; + + @doc("Database name of the target Mongo database") + database?: string; + + @doc("List of the resource IDs that support the MongoDB resource") + resources?: ResourceReference[]; + + @doc("Username to use when connecting to the target Mongo database") + username?: string; + + ...RecipeBaseProperties; +} + +#suppress "@azure-tools/typespec-azure-core/casing-style" +@armResourceOperations +interface MongoDatabases { + get is ArmResourceRead< + MongoDatabaseResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + MongoDatabaseResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + MongoDatabaseResource, + MongoDatabaseProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + MongoDatabaseResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + MongoDatabaseResource, + UCPBaseParameters, + "Scope", + "Scope" + >; + + @doc("Lists secrets values for the specified MongoDatabases resource") + @action("listSecrets") + listSecrets is ArmResourceActionSync< + MongoDatabaseResource, + {}, + MongoDatabaseListSecretsResult, + UCPBaseParameters + >; +} diff --git a/typespec/Applications.Datastores/redisCaches.tsp b/typespec/Applications.Datastores/redisCaches.tsp new file mode 100644 index 0000000000..58e69e226a --- /dev/null +++ b/typespec/Applications.Datastores/redisCaches.tsp @@ -0,0 +1,125 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Datastores; + +@doc("RedisCache portable resource") +model RedisCacheResource is TrackedResource { + @path + @doc("The name of the RedisCache portable resource resource") + @key("redisCacheName") + @segment("redisCaches") + name: ResourceNameString; +} + +@doc("The secret values for the given RedisCache resource") +model RedisCacheListSecretsResult is RedisCacheSecrets; + +@doc("The secret values for the given RedisCache resource") +model RedisCacheSecrets { + @doc("The connection string used to connect to the Redis cache") + connectionString?: string; + + @doc("The password for this Redis cache instance") + password?: string; + + @doc("The URL used to connect to the Redis cache") + url?: string; +} + +@doc("RedisCache portable resource properties") +model RedisCacheProperties { + ...EnvironmentScopedResource; + + @doc("Secrets provided by resource") + secrets?: RedisCacheSecrets; + + @doc("The host name of the target Redis cache") + host?: string; + + @doc("The port value of the target Redis cache") + port?: int32; + + @doc("The username for Redis cache") + username?: string; + + @doc("Specifies whether to enable SSL connections to the Redis cache") + tls?: boolean; + + @doc("List of the resource IDs that support the Redis resource") + resources?: ResourceReference[]; + + ...RecipeBaseProperties; +} + +@armResourceOperations +interface RedisCaches { + get is ArmResourceRead< + RedisCacheResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + RedisCacheResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + RedisCacheResource, + RedisCacheProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + RedisCacheResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + RedisCacheResource, + UCPBaseParameters, + "Scope", + "Scope" + >; + + @doc("Lists secrets values for the specified RedisCache resource") + @action("listSecrets") + listSecrets is ArmResourceActionSync< + RedisCacheResource, + {}, + RedisCacheListSecretsResult, + UCPBaseParameters + >; +} diff --git a/typespec/Applications.Datastores/sqlDatabases.tsp b/typespec/Applications.Datastores/sqlDatabases.tsp new file mode 100644 index 0000000000..64cdcdfcea --- /dev/null +++ b/typespec/Applications.Datastores/sqlDatabases.tsp @@ -0,0 +1,123 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Datastores; + +@doc("SqlDatabase portable resource") +model SqlDatabaseResource is TrackedResource { + @doc("The name of the SqlDatabase portable resource resource") + @key("sqlDatabaseName") + @path + @segment("sqlDatabases") + name: ResourceNameString; +} + +@doc("SqlDatabase properties") +model SqlDatabaseProperties { + ...EnvironmentScopedResource; + + @doc("The name of the Sql database.") + database?: string; + + @doc("The fully qualified domain name of the Sql database.") + server?: string; + + @doc("Port value of the target Sql database") + port?: int32; + + @doc("Username to use when connecting to the target Sql database") + username?: string; + + @doc("List of the resource IDs that support the SqlDatabase resource") + resources?: ResourceReference[]; + + @doc("Secret values provided for the resource") + secrets?: SqlDatabaseSecrets; + + ...RecipeBaseProperties; +} + +@doc("The secret values for the given SqlDatabase resource") +model SqlDatabaseListSecretsResult is SqlDatabaseSecrets; + +@doc("The secret values for the given SqlDatabase resource") +model SqlDatabaseSecrets { + @doc("Password to use when connecting to the target Sql database") + password?: string; + + @doc("Connection string used to connect to the target Sql database") + connectionString?: string; +} + +#suppress "@azure-tools/typespec-azure-core/casing-style" +@armResourceOperations +interface SqlDatabases { + get is ArmResourceRead< + SqlDatabaseResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + SqlDatabaseResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + SqlDatabaseResource, + SqlDatabaseProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + SqlDatabaseResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + SqlDatabaseResource, + UCPBaseParameters, + "Scope", + "Scope" + >; + + @doc("Lists secrets values for the specified SqlDatabase resource") + @action("listSecrets") + listSecrets is ArmResourceActionSync< + SqlDatabaseResource, + {}, + SqlDatabaseListSecretsResult, + UCPBaseParameters + >; +} diff --git a/typespec/Applications.Datastores/tspconfig.yaml b/typespec/Applications.Datastores/tspconfig.yaml new file mode 100644 index 0000000000..38f0dc630d --- /dev/null +++ b/typespec/Applications.Datastores/tspconfig.yaml @@ -0,0 +1,10 @@ +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + use-read-only-status-schema: true + azure-resource-provider-folder: "resource-manager" + examples-directory: "examples" + emitter-output-dir: "{project-root}/../../swagger/specification/applications" + arm-types-dir: "{project-root}/../../swagger/specification/common-types/resource-management" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" diff --git a/typespec/Applications.Messaging/common.tsp b/typespec/Applications.Messaging/common.tsp new file mode 100644 index 0000000000..13aac0cadd --- /dev/null +++ b/typespec/Applications.Messaging/common.tsp @@ -0,0 +1,19 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/openapi"; + +using OpenAPI; diff --git a/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_CreateOrUpdate.json b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_CreateOrUpdate.json new file mode 100644 index 0000000000..cdec52a79e --- /dev/null +++ b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_CreateOrUpdate.json @@ -0,0 +1,59 @@ +{ + "operationId": "RabbitMqQueues_CreateOrUpdate", + "title": "Create Or Update a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "rabbitMQQueueName": "rabbitmq0", + "api-version": "2022-03-15-privatepreview", + "RabbitMQQueueParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Delete.json b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Delete.json new file mode 100644 index 0000000000..03da6f1c26 --- /dev/null +++ b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "RabbitMqQueues_Delete", + "title": "Delete a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "rabbitMQQueueName": "rabbitmq0", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Get.json b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Get.json new file mode 100644 index 0000000000..d3e9364fc3 --- /dev/null +++ b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Get.json @@ -0,0 +1,29 @@ +{ + "operationId": "RabbitMqQueues_Get", + "title": "Get a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview", + "rabbitMQQueueName": "rabbitmq0" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_List.json b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_List.json new file mode 100644 index 0000000000..3e1c12abe3 --- /dev/null +++ b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_List.json @@ -0,0 +1,47 @@ +{ + "operationId": "RabbitMqQueues_ListByScope", + "title": "List RabbitMQQueue resources by resource group", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues?api-version=2022-01-25-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_ListByRootScope.json b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_ListByRootScope.json new file mode 100644 index 0000000000..d24590182c --- /dev/null +++ b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_ListByRootScope.json @@ -0,0 +1,50 @@ +{ + "operationId": "RabbitMqQueues_ListByScope", + "title": "List RabbitMQQueue resources by rootScope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "recipe": { + "name": "sqldb", + "parameters": { + "foo": "bar" + } + } + } + } + ], + "nextLink": "https://serviceRoot/00000000-0000-0000-0000-000000000000/providers/Applications.Messaging/rabbitMQQueues?api-version=2022-03-15-privatepreview&$skiptoken=X'12345'" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_ListSecrets.json b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_ListSecrets.json new file mode 100644 index 0000000000..e0d24405c6 --- /dev/null +++ b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_ListSecrets.json @@ -0,0 +1,17 @@ +{ + "operationId": "RabbitMqQueues_ListSecrets", + "title": "List the secrets of a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "resourceGroupName": "testGroup", + "api-version": "2022-03-15-privatepreview", + "rabbitMQQueueName": "rabbitmq0" + }, + "responses": { + "200": { + "body": { + "connectionString": "connection://string" + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Update.json b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Update.json new file mode 100644 index 0000000000..a845925ed0 --- /dev/null +++ b/typespec/Applications.Messaging/examples/2022-03-15-privatepreview/RabbitMQQueues_Update.json @@ -0,0 +1,59 @@ +{ + "operationId": "RabbitMqQueues_Update", + "title": "Update a RabbitMQQueue resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "rabbitMQQueueName": "rabbitmq0", + "api-version": "2022-03-15-privatepreview", + "rabbitMQQueueParameters": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq0", + "name": "rabbitmq0", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + }, + "201": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Messaging/rabbitMQQueues/rabbitmq1", + "name": "rabbitmq1", + "type": "Applications.Messaging/rabbitMQQueues", + "location": "global", + "properties": { + "provisioningState": "Accepted", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/testApplication", + "environment": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/environments/env0", + "resourceProvisioning": "manual", + "queue": "rabbitmq0", + "secrets": { + "connectionString": "connection://string" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/Applications.Messaging/main.tsp b/typespec/Applications.Messaging/main.tsp new file mode 100644 index 0000000000..1ce5c8f874 --- /dev/null +++ b/typespec/Applications.Messaging/main.tsp @@ -0,0 +1,41 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-resource-manager"; + +import "./rabbitMQQueues.tsp"; + +using TypeSpec.Versioning; +using Azure.ResourceManager; + +@armProviderNamespace +@service({ + title: "Applications.Messaging Resource Management APIs", +}) +@doc("REST APIs for Applications.Messaging") +@versioned(Versions) +namespace Applications.Messaging; + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Supported API versions for the Applications.Messaging resource provider.") +enum Versions { + @doc("2022-03-15-privatepreview") + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + v2022_03_15_privatepreview: "2022-03-15-privatepreview", +} diff --git a/typespec/Applications.Messaging/rabbitMQQueues.tsp b/typespec/Applications.Messaging/rabbitMQQueues.tsp new file mode 100644 index 0000000000..4f9e1c7de8 --- /dev/null +++ b/typespec/Applications.Messaging/rabbitMQQueues.tsp @@ -0,0 +1,133 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.ResourceManager; +using OpenAPI; + +namespace Applications.Messaging; + +#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Model types must use PascalCase" +@doc("RabbitMQQueue portable resource") +model RabbitMQQueueResource is TrackedResource { + @doc("The name of the RabbitMQQueue portable resource resource") + @key("rabbitMQQueueName") + @segment("rabbitMQQueues") + @path + name: ResourceNameString; +} + +#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Model types must use PascalCase" +@doc("The secret values for the given RabbitMQQueue resource") +model RabbitMQListSecretsResult is RabbitMQSecrets; + +#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Model types must use PascalCase" +@doc("The connection secrets properties to the RabbitMQ instance") +model RabbitMQSecrets { + @doc("The password used to connect to the RabbitMQ instance") + password?: string; + + @doc("The connection URI of the RabbitMQ instance. Generated automatically from host, port, SSL, username, password, and vhost. Can be overridden with a custom value") + uri?: string; +} + +#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Model types must use PascalCase" +@doc("RabbitMQQueue portable resource properties") +model RabbitMQQueueProperties { + ...EnvironmentScopedResource; + + @doc("The secrets to connect to the RabbitMQ instance") + secrets?: RabbitMQSecrets; + + @doc("The name of the queue") + queue?: string; + + @doc("The hostname of the RabbitMQ instance") + host?: string; + + @doc("The port of the RabbitMQ instance. Defaults to 5672") + port?: int32; + + @doc("The RabbitMQ virtual host (vHost) the client will connect to. Defaults to no vHost.") + vHost?: string; + + @doc("The username to use when connecting to the RabbitMQ instance") + username?: string; + + @doc("List of the resource IDs that support the rabbitMQ resource") + resources?: ResourceReference[]; + + @doc("Specifies whether to use SSL when connecting to the RabbitMQ instance") + tls?: boolean; + + ...RecipeBaseProperties; +} + +#suppress "@azure-tools/typespec-azure-core/casing-style" "The names of Model types must use PascalCase" +@armResourceOperations +interface RabbitMQQueues { + get is ArmResourceRead< + RabbitMQQueueResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + RabbitMQQueueResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + RabbitMQQueueResource, + RabbitMQQueueProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + RabbitMQQueueResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + RabbitMQQueueResource, + UCPBaseParameters, + "Scope", + "Scope" + >; + + @doc("Lists secrets values for the specified RabbitMQQueue resource") + @action("listSecrets") + listSecrets is ArmResourceActionSync< + RabbitMQQueueResource, + {}, + RabbitMQListSecretsResult, + UCPBaseParameters + >; +} diff --git a/typespec/Applications.Messaging/tspconfig.yaml b/typespec/Applications.Messaging/tspconfig.yaml new file mode 100644 index 0000000000..38f0dc630d --- /dev/null +++ b/typespec/Applications.Messaging/tspconfig.yaml @@ -0,0 +1,10 @@ +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + use-read-only-status-schema: true + azure-resource-provider-folder: "resource-manager" + examples-directory: "examples" + emitter-output-dir: "{project-root}/../../swagger/specification/applications" + arm-types-dir: "{project-root}/../../swagger/specification/common-types/resource-management" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" diff --git a/typespec/README.md b/typespec/README.md new file mode 100644 index 0000000000..2cef191e60 --- /dev/null +++ b/typespec/README.md @@ -0,0 +1,111 @@ +# TypeSpec for Radius + +TypeSpec is a language for describing cloud service APIs and generating other API description languages, client and service code, documentation, and other assets. TypeSpec provides highly extensible core language primitives that can describe API shapes common among REST, GraphQL, gRPC, and other protocols. + +## Directory structure + +### TypeSpec + +* **[Applications.Core](./Applications.Core/)**: This directory contains Applications.Core TypeSpec files to define its namespace and resource types. +* **[Test.Resource](./Test.Resource/)**: This directory contains the template typespec files to create new namespace and resource types. +* **[radius/v1](./radius/v1/)**: This directory contains the radius shared typespec v1 libraries used by each namespace. + +### OpenAPIv2 Spec file output + +Once you compile your typespec files, the default output OpenAPIv2 spec file will be emitted to [/swagger/specification/applications/resource-manager](../swagger/specification/swagger/specification/applications/resource-manager). + +## Prerequisite + +1. Install [NodeJS 16+](https://nodejs.org/en/download) +1. Install [TypeSpec compiler](https://microsoft.github.io/typespec/introduction/installation) + ```bash + npm install -g @typespec/compiler + ``` + +## Build TypeSpec to OpenAPI swagger. + +Radius uses [OpenAPIv2 specifications](../swagger/) for defining API and validating the API request. You can compile and emit swagger spec files by following steps. + +1. Install dependencies + ```bash + tsp install + ``` +1. Compile and emit the swagger files + ```bash + tsp compile ./Test.Resource + ``` + Please ensure that you resolve all warnings and errors from the compiler. +1. Review your emitted swagger file under [/swagger/specification/applications/resource-manager/Test.Resource](../swagger/specification/applications/resource-manager/Test.Resource). + + +## TypeSpec authoring guideline + +This section provides the tips and guidelines to define APIs with TypeSpec. + +### TypeSpec file formatting + +TypeSpec compiler has its own formatting TypeSpec files. Ensure that you run the following command once you edit spec files. + +```bash +tsp format **/*.tsp +``` + +### Use [Test.Resource](./Test.Resource/) template to create new namespace + +1. Copy the entire [Test.Resource](./Test.Resource/) directory to new directory with the new namespace name under [typespec](./). +1. Open [main.tsp](./Test.Resource/main.tsp) and update `Versions` enum to support new API version for your namespace. +1. Create new `ResourceTypeName.tsp` file to define new resource type based on [testasyncresources.tsp](./Test.Resource/testasyncresources.tsp) or [testsyncresources.tsp](./Test.Resource/testsyncresources.tsp). +1. Add `import "ResourceTypeName.tsp";` in `main.tsp` and remove the sample resource type tsp imports. +1. Run the formatter and compiler + ```bash + tsp format **/*.tsp + tsp compile ./YourNamespace + ``` + +### Support multiple API versions + +You can manage multiple API versions with the decorator of [TypeSpec.Versioning](https://microsoft.github.io/typespec/standard-library/versioning/reference) library. + +1. Describe the supported version in `enum Verisons` of `main.tsp`. For example, [Test.Resource/main.tsp](./Test.Resource/main.tsp) supports two API verisons, `2022-08-19-preview` and `2023-08-19`. +1. Use [the versioning decorators](https://microsoft.github.io/typespec/standard-library/versioning/reference#decorators) for model and property. [Test.Resource/typesyncresources.tsp](./Test.Resource/testsyncresources.tsp) includes the example to use `@added` decorator to add new resource type in `v2023-08-19` API version. + +### Link API operation to example files with `x-ms-examples` custom property + +With TypeSpec, we do not need to specify the properties for `x-ms-examples`. Instead, TypeSpec emitter library has the built-in feature to link resource operations to request/response example files automatically. To leverage this feature, JSON example files needs to be located under +`/typespec//examples//`. `operationId` property value in example file must match `_`. + +For example, [TestSyncResource](./Test.Resource/testsyncresources.tsp) defines the following operations: + +```ts +@added(Versions.v2023_08_19) +@armResourceOperations +interface TestSyncResources { + get is ArmResourceRead>; + + createOrUpdate is ArmResourceCreateOrReplaceSync< + TestSyncResource, + UCPBaseParameters + >; + ... +``` + +You can create [TestSyncResource_Get.json](./Test.Resource/examples/2023-08-19/TestSyncResource_Get.json) and [TestSyncResource_CreateOrUpdate.json](./Test.Resource/examples/2023-08-19/TestSyncResource_CreateOrUpdate.json) in `Test.Resource/examples/2023-08-19/` like the following sample. + +```json +{ + "operationId": "TestSyncResources_Get", // <-- This must match the name convention - "_". + "title": "Get a TestSyncResources resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testSyncResourceName": "resource0", + "api-version": "2023-08-19" + }, + // ... +``` + +## References + +* [Introduction to TypeSpec](https://microsoft.github.io/typespec/) +* [TypeSpec Azure](https://azure.github.io/typespec-azure/) +* [TypeSpec Samples](https://github.com/microsoft/typespec/tree/main/packages/samples) +* [TypeSpec Azure samples](https://github.com/Azure/typespec-azure/tree/main/packages/samples/specs/resource-manager) \ No newline at end of file diff --git a/typespec/Test.Resource/common.tsp b/typespec/Test.Resource/common.tsp new file mode 100644 index 0000000000..a8c58440dd --- /dev/null +++ b/typespec/Test.Resource/common.tsp @@ -0,0 +1,21 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/openapi"; + +using OpenAPI; + +// TODO: Add shared models here. diff --git a/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_CreateOrUpdate.json b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_CreateOrUpdate.json new file mode 100644 index 0000000000..4b6cf1b500 --- /dev/null +++ b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_CreateOrUpdate.json @@ -0,0 +1,30 @@ +{ + "operationId": "TestAsyncResources_CreateOrUpdate", + "title": "Create or Update TestAsyncResource resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testAsyncResourceName": "resource0", + "api-version": "2022-08-19-preview", + "TestAsyncResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Delete.json b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Delete.json new file mode 100644 index 0000000000..dc4fd265ef --- /dev/null +++ b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "TestAsyncResources_Delete", + "title": "Delete a TestAsyncResource resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testAsyncResourceName": "resource0", + "api-version": "2022-08-19-preview" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Get.json b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Get.json new file mode 100644 index 0000000000..8c4f351bc3 --- /dev/null +++ b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Get.json @@ -0,0 +1,22 @@ +{ + "operationId": "TestAsyncResources_Get", + "title": "Get a TestAsyncResource resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testAsyncResourceName": "resource0", + "api-version": "2022-08-19-preview" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_List.json b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_List.json new file mode 100644 index 0000000000..bb7f6f5eff --- /dev/null +++ b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_List.json @@ -0,0 +1,35 @@ +{ + "operationId": "TestAsyncResources_ListByScope", + "title": "List TestAsyncResource resources by resourcegroup", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource1", + "name": "resource1", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Test.Resource/testAsyncResources?api-version=2022-08-19-preview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_ListByScope.json b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_ListByScope.json new file mode 100644 index 0000000000..37e52d2155 --- /dev/null +++ b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_ListByScope.json @@ -0,0 +1,35 @@ +{ + "operationId": "TestAsyncResources_ListByScope", + "title": "List TestAsyncResource resources at root scope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource1", + "name": "resource1", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Test.Resource/testAsyncResources?api-version=2022-08-19-preview&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Update.json b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Update.json new file mode 100644 index 0000000000..e23e021d59 --- /dev/null +++ b/typespec/Test.Resource/examples/2022-08-19-preview/TestAsyncResource_Update.json @@ -0,0 +1,30 @@ +{ + "operationId": "TestAsyncResources_Update", + "title": "Update TestAsyncResource resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testSyncResourceName": "resource0", + "api-version": "2022-08-19-preview", + "TestSyncResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_CreateOrUpdate.json b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_CreateOrUpdate.json new file mode 100644 index 0000000000..ab9354729d --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_CreateOrUpdate.json @@ -0,0 +1,30 @@ +{ + "operationId": "TestAsyncResources_CreateOrUpdate", + "title": "Create or Update TestAsyncResource resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testAsyncResourceName": "resource0", + "api-version": "2023-08-19", + "TestAsyncResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Delete.json b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Delete.json new file mode 100644 index 0000000000..bf27a5e050 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "TestAsyncResources_Delete", + "title": "Delete a TestAsyncResource resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testAsyncResourceName": "resource0", + "api-version": "2023-08-19" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Get.json b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Get.json new file mode 100644 index 0000000000..be851ac706 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Get.json @@ -0,0 +1,22 @@ +{ + "operationId": "TestAsyncResources_Get", + "title": "Get a TestAsyncResource resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testAsyncResourceName": "resource0", + "api-version": "2023-08-19" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_List.json b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_List.json new file mode 100644 index 0000000000..a3b3f205ed --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_List.json @@ -0,0 +1,35 @@ +{ + "operationId": "TestAsyncResources_ListByScope", + "title": "List TestAsyncResource resources by resourcegroup", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource1", + "name": "resource1", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Test.Resource/testAsyncResources?api-version=2023-08-19&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_ListByScope.json b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_ListByScope.json new file mode 100644 index 0000000000..07fde44c99 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_ListByScope.json @@ -0,0 +1,35 @@ +{ + "operationId": "TestAsyncResources_ListByScope", + "title": "List TestAsyncResource resources at root scope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2022-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource1", + "name": "resource1", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Test.Resource/testAsyncResources?api-version=2023-08-19&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Update.json b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Update.json new file mode 100644 index 0000000000..2c1ff5c348 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestAsyncResource_Update.json @@ -0,0 +1,30 @@ +{ + "operationId": "TestAsyncResources_Update", + "title": "Update TestAsyncResource resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testSyncResourceName": "resource0", + "api-version": "2023-08-19", + "TestSyncResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testAsyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testAsyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_CreateOrUpdate.json b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_CreateOrUpdate.json new file mode 100644 index 0000000000..d449d53a12 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_CreateOrUpdate.json @@ -0,0 +1,30 @@ +{ + "operationId": "TestSyncResources_CreateOrUpdate", + "title": "Create or Update TestSyncResource resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testSyncResourceName": "resource0", + "api-version": "2023-08-19", + "TestSyncResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testSyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testSyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Delete.json b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Delete.json new file mode 100644 index 0000000000..4285aaa3f2 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "TestSyncResource_Delete", + "title": "Delete a TestSyncResource resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testSyncResourceName": "resource0", + "api-version": "2023-08-19" + }, + "responses": { + "200": {}, + "202": {}, + "204": {} + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Get.json b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Get.json new file mode 100644 index 0000000000..a3b3d18932 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Get.json @@ -0,0 +1,22 @@ +{ + "operationId": "TestSyncResources_Get", + "title": "Get a TestSyncResources resource", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testSyncResourceName": "resource0", + "api-version": "2023-08-19" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testSyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testSyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_List.json b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_List.json new file mode 100644 index 0000000000..2738f17a34 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_List.json @@ -0,0 +1,35 @@ +{ + "operationId": "TestSyncResources_ListByScope", + "title": "List TestSyncResource resources by resourcegroup", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "api-version": "2023-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testSyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testSyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testSyncResources/resource1", + "name": "resource1", + "type": "Test.Resource/testSyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Test.Resource/testSyncResources?api-version=2023-08-19&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_ListByScope.json b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_ListByScope.json new file mode 100644 index 0000000000..78a0e58803 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_ListByScope.json @@ -0,0 +1,35 @@ +{ + "operationId": "TestSyncResources_ListByScope", + "title": "List TestSyncResource resources at root scope", + "parameters": { + "rootScope": "/planes/radius/local", + "api-version": "2023-03-15-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testSyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testSyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + }, + { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testSyncResources/resource1", + "name": "resource1", + "type": "Test.Resource/testSyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0" + } + } + ], + "nextLink": "https://serviceRoot/planes/radius/local/providers/Test.Resource/testSyncResources?api-version=2023-08-19&$skiptoken=X'12345'" + } + } + } +} diff --git a/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Update.json b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Update.json new file mode 100644 index 0000000000..f710358466 --- /dev/null +++ b/typespec/Test.Resource/examples/2023-08-19/TestSyncResource_Update.json @@ -0,0 +1,30 @@ +{ + "operationId": "TestSyncResources_Update", + "title": "Update TestSyncResource resources", + "parameters": { + "rootScope": "/planes/radius/local/resourceGroups/testGroup", + "testSyncResourceName": "resource0", + "api-version": "2023-08-19", + "TestSyncResource": { + "location": "global", + "properties": { + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourceGroups/testGroup/providers/Test.Resource/testSyncResources/resource0", + "name": "resource0", + "type": "Test.Resource/testSyncResources", + "properties": { + "provisioningState": "Succeeded", + "application": "/planes/radius/local/resourceGroups/testGroup/providers/Applications.Core/applications/app0", + "property1": "test" + } + } + } + } +} diff --git a/typespec/Test.Resource/main.tsp b/typespec/Test.Resource/main.tsp new file mode 100644 index 0000000000..eee535caff --- /dev/null +++ b/typespec/Test.Resource/main.tsp @@ -0,0 +1,49 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-resource-manager"; + +// TODO: after creating a copy of this file, create individual .tsp files for each of your resources and +// use the 'import' keyword to import them here. +import "./testsyncresources.tsp"; +import "./testasyncresources.tsp"; + +using TypeSpec.Versioning; +using Azure.ResourceManager; + +@armProviderNamespace +@service({ + title: "Test.Resource Resource Management APIs", +}) +@doc("REST APIs for Test.Resource") +@versioned(Versions) +namespace Test.Resource; + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Supported API versions for the Test.Resource resource provider.") +enum Versions { + @doc("2022-08-19-preview") + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + v2022_08_19_preview: "2022-08-19-preview", + + @doc("2023-08-19") + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + v2023_08_19: "2023-08-19", +} diff --git a/typespec/Test.Resource/testasyncresources.tsp b/typespec/Test.Resource/testasyncresources.tsp new file mode 100644 index 0000000000..daa3bdd423 --- /dev/null +++ b/typespec/Test.Resource/testasyncresources.tsp @@ -0,0 +1,85 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Test.Resource; + +@doc("The TestAsyncResource which implements asynchornous API.") +model TestAsyncResource is TrackedResource { + @doc("The name of TestSyncResource") + @path + @key("testAsyncResourceName") + @segment("testAsyncResources") + name: ResourceNameString; +} + +@doc("TestAsyncResource properties") +model TestAsyncResourceProperties { + ...ApplicationScopedResource; + + @doc("The property1 of TestASyncResource") + property1: string; +} + +@armResourceOperations +interface TestAsyncResources { + get is ArmResourceRead< + TestAsyncResource, + UCPBaseParameters + >; + + createOrUpdate is ArmResourceCreateOrReplaceAsync< + TestAsyncResource, + UCPBaseParameters + >; + + update is ArmResourcePatchAsync< + TestAsyncResource, + TestAsyncResourceProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteAsync< + TestAsyncResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + TestAsyncResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Test.Resource/testsyncresources.tsp b/typespec/Test.Resource/testsyncresources.tsp new file mode 100644 index 0000000000..896a1801ee --- /dev/null +++ b/typespec/Test.Resource/testsyncresources.tsp @@ -0,0 +1,83 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Test.Resource; + +@doc("The TestSyncResource type.") +model TestSyncResource is TrackedResource { + @doc("The name of TestSyncResource") + @path + @key("testSyncResourceName") + @segment("testSyncResources") + name: ResourceNameString; +} + +@doc("TestSyncResource properties") +model TestSyncResourceProperties { + ...ApplicationScopedResource; + + @doc("The property1 of TestSyncResource") + property1: string; +} + +@added(Versions.v2023_08_19) +@armResourceOperations +interface TestSyncResources { + get is ArmResourceRead>; + + createOrUpdate is ArmResourceCreateOrReplaceSync< + TestSyncResource, + UCPBaseParameters + >; + + update is ArmResourcePatchSync< + TestSyncResource, + TestSyncResourceProperties, + UCPBaseParameters + >; + + delete is ArmResourceDeleteSync< + TestSyncResource, + UCPBaseParameters + >; + + listByScope is ArmResourceListByParent< + TestSyncResource, + UCPBaseParameters, + "Scope", + "Scope" + >; +} diff --git a/typespec/Test.Resource/tspconfig.yaml b/typespec/Test.Resource/tspconfig.yaml new file mode 100644 index 0000000000..36ae5ddecf --- /dev/null +++ b/typespec/Test.Resource/tspconfig.yaml @@ -0,0 +1,10 @@ +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + use-read-only-status-schema: true + azure-resource-provider-folder: "resource-manager" + examples-directory: "{project-root}/examples" + emitter-output-dir: "{project-root}/../../swagger/specification/applications" + arm-types-dir: "{project-root}/../../swagger/specification/common-types/resource-management" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" diff --git a/typespec/UCP/aws-credentials.tsp b/typespec/UCP/aws-credentials.tsp new file mode 100644 index 0000000000..6b4b86166b --- /dev/null +++ b/typespec/UCP/aws-credentials.tsp @@ -0,0 +1,133 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; +import "./ucp-operations.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; +using OpenAPI; + +namespace Ucp; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars" +model AwsCredentialResource is TrackedResource { + @key("credentialName") + @doc("The AWS credential name.") + @path + @segment("providers/System.AWS/credentials") + name: ResourceNameString; +} + +@doc("The parameter for AWS plane name") +model AwsPlaneNameParameter { + @doc("The name of AWS plane") + @path + @segment("planes/aws") + @extension("x-ms-skip-url-encoding", true) + @extension("x-ms-parameter-location", "method") + planeName: ResourceNameString; +} + +@doc("AWS credential kind") +enum AWSCredentialKind { + @doc("The AWS Access Key credential") + AccessKey, +} + +@discriminator("kind") +@doc("AWS Credential properties") +model AwsCredentialProperties { + @doc("The AWS credential kind") + kind: AWSCredentialKind; + + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; +} + +@doc("AWS credential storage properties") +model AwsAccessKeyCredentialProperties extends AwsCredentialProperties { + @doc("Access Key kind") + kind: AWSCredentialKind.AccessKey; + + @doc("Access key ID for AWS identity") + @secret + accessKeyId: string; + + @doc("Secret Access Key for AWS identity") + @secret + secretAccessKey: string; + + @doc("The storage properties") + storage: CredentialStorageProperties; +} + +alias AwsCredentialBaseParameter = CredentialBaseParameters< + TResource, + AwsPlaneNameParameter +>; + +@armResourceOperations +interface AwsCredentials { + @doc("List AWS credentials") + list is UcpResourceList< + AwsCredentialResource, + { + ...ApiVersionParameter; + ...AwsPlaneNameParameter; + } + >; + + @doc("Get an AWS credential") + get is UcpResourceRead< + AwsCredentialResource, + AwsCredentialBaseParameter + >; + + @doc("Create or update an AWS credential") + createOrUpdate is UcpResourceCreateOrUpdateSync< + AwsCredentialResource, + AwsCredentialBaseParameter + >; + + @doc("Update an AWS credential") + update is UcpCustomPatchSync< + AwsCredentialResource, + AwsCredentialBaseParameter + >; + + @doc("Delete an AWS credential") + delete is UcpResourceDeleteSync< + AwsCredentialResource, + AwsCredentialBaseParameter + >; +} diff --git a/typespec/UCP/azure-credentials.tsp b/typespec/UCP/azure-credentials.tsp new file mode 100644 index 0000000000..113456e352 --- /dev/null +++ b/typespec/UCP/azure-credentials.tsp @@ -0,0 +1,137 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; +import "./ucp-operations.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; +using OpenAPI; + +namespace Ucp; + +@doc("The parameter of Azure plane") +model AzurePlaneNameParameter { + @doc("The name of the plane") + @path + @extension("x-ms-skip-url-encoding", true) + @extension("x-ms-parameter-location", "method") + @segment("planes/azure") + planeName: ResourceNameString; +} + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars" +@doc("Represents Azure Credential Resource") +model AzureCredentialResource is TrackedResource { + @doc("The Azure credential name.") + @path + @key("credentialName") + @segment("providers/System.Azure/credentials") + name: ResourceNameString; +} + +@doc("Azure credential kinds supported.") +enum AzureCredentialKind { + @doc("The Service Principal Credential") + ServicePrincipal, +} + +@discriminator("kind") +@doc("The base properties of Azure Credential") +model AzureCredentialProperties { + @doc("The kind of Azure credential") + kind: AzureCredentialKind; + + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; +} + +@doc("The properties of Service Principal credential storage") +model AzureServicePrincipalProperties extends AzureCredentialProperties { + @doc("Service principal kind") + kind: AzureCredentialKind.ServicePrincipal; + + @doc("clientId for ServicePrincipal") + clientId: string; + + @doc("secret for ServicePrincipal") + @extension("x-ms-secret", true) + clientSecret: string; + + @doc("tenantId for ServicePrincipal") + tenantId: string; + + @doc("The storage properties") + storage: CredentialStorageProperties; +} + +alias AzureCredentialBaseParameter = CredentialBaseParameters< + TResource, + AzurePlaneNameParameter +>; + +@autoRoute +@armResourceOperations +interface AzureCredentials { + @doc("List Azure credentials") + list is UcpResourceList< + AzureCredentialResource, + { + ...ApiVersionParameter; + ...AzurePlaneNameParameter; + } + >; + + @doc("Get an Azure credential") + get is UcpResourceRead< + AzureCredentialResource, + AzureCredentialBaseParameter + >; + + @doc("Create or update an Azure credential") + createOrUpdate is UcpResourceCreateOrUpdateSync< + AzureCredentialResource, + AzureCredentialBaseParameter + >; + + @doc("Update an Azure credential") + update is UcpCustomPatchSync< + AzureCredentialResource, + AzureCredentialBaseParameter + >; + + @doc("Delete an Azure credential") + delete is UcpResourceDeleteSync< + AzureCredentialResource, + AzureCredentialBaseParameter + >; +} diff --git a/typespec/UCP/common.tsp b/typespec/UCP/common.tsp new file mode 100644 index 0000000000..5387ba08df --- /dev/null +++ b/typespec/UCP/common.tsp @@ -0,0 +1,66 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; +using OpenAPI; + +@doc("The UCP HTTP request base parameters.") +model CredentialBaseParameters { + ...ApiVersionParameter; + ...TPlaneName; + ...KeysOf; +} + +@doc("Credential store kinds supported.") +enum CredentialStorageKind { + @doc("Internal credential storage") + Internal, +} + +@doc("The base credential storage properties") +@discriminator("kind") +model CredentialStorageProperties { + @doc("The kind of credential storage") + kind: CredentialStorageKind; +} + +@doc("Internal credential storage properties") +model InternalCredentialStorageProperties extends CredentialStorageProperties { + @doc("Internal credential storage kind") + kind: CredentialStorageKind.Internal; + + @doc("The name of secret stored.") + @visibility("read") + secretName: string; +} diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_CreateOrUpdate.json b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_CreateOrUpdate.json new file mode 100644 index 0000000000..c7fef81833 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_CreateOrUpdate.json @@ -0,0 +1,53 @@ +{ + "operationId": "AwsCredentials_CreateOrUpdate", + "title": "Create or update a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "aws", + "credentialName": "default", + "Credential": { + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "accessKeyId": "enterAccessKeyIdHere", + "secretAccessKey": "enterSecretAccessKey", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + }, + "201": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Delete.json b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Delete.json new file mode 100644 index 0000000000..30907afdbe --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "AwsCredentials_Delete", + "title": "Delete a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "awscloud", + "credentialName": "default" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Get.json b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Get.json new file mode 100644 index 0000000000..1d6b3ee794 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Get.json @@ -0,0 +1,27 @@ +{ + "operationId": "AwsCredentials_Get", + "title": "Get a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "awscloud", + "credentialName": "default" + }, + "responses": { + "200": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_List.json b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_List.json new file mode 100644 index 0000000000..53baf9b1cb --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_List.json @@ -0,0 +1,30 @@ +{ + "operationId": "AwsCredentials_List", + "title": "List AWS credentials", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "awscloud" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Update.json b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Update.json new file mode 100644 index 0000000000..f9de8aaac1 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AWSCredential_Update.json @@ -0,0 +1,53 @@ +{ + "operationId": "AwsCredentials_Update", + "title": "Update a AWS credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "aws", + "planeName": "aws", + "credentialName": "default", + "Credential": { + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "accessKeyId": "enterAccessKeyIdHere", + "secretAccessKey": "enterSecretAccessKey", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + }, + "201": { + "body": { + "id": "/planes/AWS/aws/providers/System.AWS/credentials/default", + "name": "default", + "type": "System.AWS/credentials", + "location": "us-west-2", + "properties": { + "kind": "AccessKey", + "storage": { + "kind": "Internal", + "secretName": "aws-awscloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_CreateOrUpdate.json b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_CreateOrUpdate.json new file mode 100644 index 0000000000..f2aad4bdc4 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_CreateOrUpdate.json @@ -0,0 +1,57 @@ +{ + "operationId": "AzureCredentials_CreateOrUpdate", + "title": "Create or update a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default", + "Credential": { + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "clientId": "00000000-0000-0000-0000-000000000000", + "clientSecret": "secretString", + "tenantId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "201": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Delete.json b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Delete.json new file mode 100644 index 0000000000..6d034d1e3b --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "AzureCredentials_Delete", + "title": "Delete a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Get.json b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Get.json new file mode 100644 index 0000000000..90eede6d4a --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Get.json @@ -0,0 +1,29 @@ +{ + "operationId": "AzureCredentials_Get", + "title": "Get a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default" + }, + "responses": { + "200": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_List.json b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_List.json new file mode 100644 index 0000000000..4f6ab2d815 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_List.json @@ -0,0 +1,32 @@ +{ + "operationId": "AzureCredentials_List", + "title": "List Azure credentials", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Update.json b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Update.json new file mode 100644 index 0000000000..916dff73b8 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/AzureCredential_Update.json @@ -0,0 +1,57 @@ +{ + "operationId": "AzureCredentials_Update", + "title": "Update a Azure credential", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "azure", + "planeName": "azurecloud", + "credentialName": "default", + "Credential": { + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "clientId": "00000000-0000-0000-0000-000000000000", + "clientSecret": "secretString", + "tenantId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "responses": { + "200": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal" + } + } + } + }, + "201": { + "body": { + "id": "/planes/azure/azurecloud/providers/System.Azure/credentials/default", + "name": "default", + "type": "System.Azure/credentials", + "location": "west-us-2", + "properties": { + "kind": "ServicePrincipal", + "tenantId": "00000000-0000-0000-0000-000000000000", + "clientId": "00000000-0000-0000-0000-000000000000", + "storage": { + "kind": "Internal", + "secretName": "azure-azurecloud-default" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/Planes_CreateOrUpdate.json b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_CreateOrUpdate.json new file mode 100644 index 0000000000..12de0f2d68 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_CreateOrUpdate.json @@ -0,0 +1,34 @@ +{ + "operationId": "Planes_CreateOrUpdate", + "title": "Create or update a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "Plane": { + "location": "global", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/Planes_Delete.json b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_Delete.json new file mode 100644 index 0000000000..9467f217ba --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_Delete.json @@ -0,0 +1,13 @@ +{ + "operationId": "Planes_Delete", + "title": "Delete a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "radius", + "planeName": "local" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/Planes_GetPlaneLocal.json b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_GetPlaneLocal.json new file mode 100644 index 0000000000..ba3efe8c02 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_GetPlaneLocal.json @@ -0,0 +1,26 @@ +{ + "operationId": "Planes_Get", + "title": "Get a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "location": "global", + "properties": { + "resourceProviders": { + "Applications.Datastores": "http://applications-rp.radius-system:5444", + "Applications.Core": "http://applications-rp.radius-system:5443" + }, + "kind": "UCPNative" + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/Planes_List.json b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_List.json new file mode 100644 index 0000000000..2f22f7beb5 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_List.json @@ -0,0 +1,29 @@ +{ + "operationId": "Planes_ListPlanes", + "title": "List planes", + "parameters": { + "api-version": "2022-09-01-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "location": "global", + "properties": { + "resourceProviders": { + "Applications.Datastores": "http://applications-rp.radius-system:5444", + "Applications.Core": "http://applications-rp.radius-system:5443", + "Microsoft.Resources": "http://bicep-de.radius-system:6443" + }, + "kind": "UCPNative" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/Planes_ListPlanesByType.json b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_ListPlanesByType.json new file mode 100644 index 0000000000..1544d77af2 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_ListPlanesByType.json @@ -0,0 +1,29 @@ +{ + "operationId": "Planes_ListByType", + "title": "List planes by planeType", + "parameters": { + "planeType": "radius", + "api-version": "2022-09-01-privatepreview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "location": "global", + "properties": { + "resourceProviders": { + "Applications.Datastores": "http://applications-rp.radius-system:5444", + "Applications.Core": "http://applications-rp.radius-system:5443" + }, + "kind": "UCPNative" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/Planes_Update.json b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_Update.json new file mode 100644 index 0000000000..08b77b42ca --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/Planes_Update.json @@ -0,0 +1,34 @@ +{ + "operationId": "Planes_Update", + "title": "Update a plane", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "Plane": { + "location": "global", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local", + "name": "local", + "type": "System.Planes/radius", + "properties": { + "kind": "UCPNative", + "resourceProviders": { + "Applications.Core": "http://localhost:7443" + } + } + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_CreateOrUpdate.json b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_CreateOrUpdate.json new file mode 100644 index 0000000000..889ee27bb1 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_CreateOrUpdate.json @@ -0,0 +1,22 @@ +{ + "operationId": "ResourceGroups_CreateOrUpdate", + "title": "Create or update a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "radius", + "planeName": "local", + "resourceGroupName": "rg1", + "ResourceGroup": { + "location": "global" + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1" + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Delete.json b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Delete.json new file mode 100644 index 0000000000..df56306964 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Delete.json @@ -0,0 +1,14 @@ +{ + "operationId": "ResourceGroups_Delete", + "title": "Delete a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "resourceGroupName": "rg1", + "planeType": "radius", + "planeName": "local" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Get.json b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Get.json new file mode 100644 index 0000000000..c64ec98f63 --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Get.json @@ -0,0 +1,19 @@ +{ + "operationId": "ResourceGroups_Get", + "title": "Get a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "resourceGroupName": "rg1" + }, + "responses": { + "200": { + "body": { + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1", + "location": "global" + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_List.json b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_List.json new file mode 100644 index 0000000000..3e67b7150c --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_List.json @@ -0,0 +1,27 @@ +{ + "operationId": "ResourceGroups_List", + "title": "List resource groups", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1", + "location": "global" + }, + { + "id": "/planes/radius/local/resourcegroups/rg2", + "name": "rg2", + "location": "global" + } + ] + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Update.json b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Update.json new file mode 100644 index 0000000000..abcd61906a --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/ResourceGroups_Update.json @@ -0,0 +1,22 @@ +{ + "operationId": "ResourceGroups_Update", + "title": "Update a resource group", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeType": "radius", + "planeName": "local", + "resourceGroupName": "rg1", + "ResourceGroup": { + "location": "global" + } + }, + "responses": { + "200": { + "body": { + "location": "global", + "id": "/planes/radius/local/resourcegroups/rg1", + "name": "rg1" + } + } + } +} \ No newline at end of file diff --git a/typespec/UCP/examples/2022-09-01-privatepreview/Resources_List.json b/typespec/UCP/examples/2022-09-01-privatepreview/Resources_List.json new file mode 100644 index 0000000000..47836a988a --- /dev/null +++ b/typespec/UCP/examples/2022-09-01-privatepreview/Resources_List.json @@ -0,0 +1,30 @@ +{ + "operationId": "Resources_List", + "title": "List resources in a resource group.", + "parameters": { + "api-version": "2022-09-01-privatepreview", + "planeName": "local", + "planeType": "radius", + "resourceGroupName": "rg1" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/planes/radius/local/resourcegroups/rg1/providers/Applications.Core/containers/my-container", + "name": "my-container", + "location": "global", + "type": "Applications.Core/containers" + }, + { + "id": "/planes/radius/local/resourcegroups/rg1/providers/Applications.Core/applications/my-application", + "name": "my-application", + "location": "global", + "type": "Applications.Core/applications" + } + ] + } + } + } + } \ No newline at end of file diff --git a/typespec/UCP/main.tsp b/typespec/UCP/main.tsp new file mode 100644 index 0000000000..01f5c2162e --- /dev/null +++ b/typespec/UCP/main.tsp @@ -0,0 +1,44 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-resource-manager"; + +import "./common.tsp"; +import "./planes.tsp"; +import "./resourcegroups.tsp"; +import "./aws-credentials.tsp"; +import "./azure-credentials.tsp"; + +using TypeSpec.Versioning; +using Azure.ResourceManager; + +#suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" +@armProviderNamespace +@service({ + title: "Universal Control Plane Resource Management APIs", +}) +@doc("REST APIs for Universal Control Plane") +@versioned(Versions) +namespace Ucp; + +@doc("Supported API versions for Universal Control Plane resource provider.") +enum Versions { + @doc("2022-09-01-privatepreview") + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + v2022_09_01_privatepreview: "2022-09-01-privatepreview", +} diff --git a/typespec/UCP/planes.tsp b/typespec/UCP/planes.tsp new file mode 100644 index 0000000000..0c8bee781d --- /dev/null +++ b/typespec/UCP/planes.tsp @@ -0,0 +1,130 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; +using OpenAPI; + +namespace Ucp; + +@doc("The plane resource") +model PlaneResource is TrackedResource { + @key("planeType") + @doc("The plane type.") + @segment("planes") + @path + name: string; +} + +@doc("Plane kinds supported.") +enum PlaneKind { + @doc("UCP Native Plane") + UCPNative, + + @doc("Azure Plane") + Azure, + + @doc("AWS Plane") + AWS, +} + +@doc("The Plane Name parameter.") +model PlaneNameParameter { + @doc("The name of the plane") + @path + @extension("x-ms-skip-url-encoding", true) + @extension("x-ms-parameter-location", "method") + planeName: ResourceNameString; +} + +@doc("The UCP HTTP request base parameters.") +model PlaneBaseParameters< + TResource, + TPlaneName extends {} = PlaneNameParameter +> { + ...ApiVersionParameter; + ...KeysOf; + ...TPlaneName; +} + +@doc("The Plane properties.") +model PlaneResourceProperties { + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; + + @doc("The kind of plane") + kind: PlaneKind; + + @doc("URL to forward requests to for non UCP Native Plane") + url?: string; + + @doc("Resource Providers for UCP Native Plane") + resourceProviders?: Record; +} + +@armResourceOperations +interface Planes { + @doc("List all planes") + listPlanes is UcpResourceList; + + @doc("List planes by type") + @get + @autoRoute + @armResourceRead(PlaneResource) + @armResourceList(PlaneResource) + listByType( + ...PlaneBaseParameters, + ): ArmResponse> | ErrorResponse; + + @doc("Get a plane by name") + get is UcpResourceRead>; + + @doc("Create or update a plane") + createOrUpdate is UcpResourceCreateOrUpdateAsync< + PlaneResource, + PlaneBaseParameters + >; + + @doc("Update a plane") + update is UcpCustomPatchAsync< + PlaneResource, + PlaneBaseParameters + >; + + @doc("Delete a plane") + delete is UcpResourceDeleteAsync< + PlaneResource, + PlaneBaseParameters + >; +} diff --git a/typespec/UCP/resourcegroups.tsp b/typespec/UCP/resourcegroups.tsp new file mode 100644 index 0000000000..03edb5c601 --- /dev/null +++ b/typespec/UCP/resourcegroups.tsp @@ -0,0 +1,113 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/versioning"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +import "../radius/v1/ucprootscope.tsp"; +import "../radius/v1/resources.tsp"; +import "./common.tsp"; +import "./ucp-operations.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Autorest; +using Azure.Core; +using Azure.ResourceManager; +using OpenAPI; + +namespace Ucp; + +@doc("The resource group resource") +model ResourceGroupResource is TrackedResource { + @doc("The name of resource group") + @path + @key("resourceGroupName") + @segment("resourcegroups") + name: ResourceNameString; +} + +@doc("The resource group resource properties") +model ResourceGroupProperties { + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; +} + +@doc("Represents resource data.") +@parentResource(ResourceGroupResource) +model GenericResource extends ProxyResource { + @doc("The name of resource") + @path + @key("resourceName") + @segment("resources") + @visibility("read") + name: ResourceNameString; +} + +@doc("The resource properties") +model ResourceProperties {} + +@doc("The UCP HTTP request base parameters.") +model ResourceGroupBaseParameters { + ...PlaneBaseParameters; + ...KeysOf; +} + +@armResourceOperations +interface ResourceGroups { + @doc("List resource groups") + list is UcpResourceList< + ResourceGroupResource, + PlaneBaseParameters + >; + + @doc("Get a resource group") + get is UcpResourceRead< + ResourceGroupResource, + ResourceGroupBaseParameters + >; + + @doc("Create or update a resource group") + createOrUpdate is UcpResourceCreateOrUpdateSync< + ResourceGroupResource, + ResourceGroupBaseParameters + >; + + @doc("Update a resource group") + update is UcpCustomPatchSync< + ResourceGroupResource, + ResourceGroupBaseParameters + >; + + @doc("Delete a resource group") + delete is UcpResourceDeleteSync< + ResourceGroupResource, + ResourceGroupBaseParameters + >; +} + +@armResourceOperations +interface Resources { + @doc("List resources in a resource group") + list is UcpResourceList>; +} diff --git a/typespec/UCP/tspconfig.yaml b/typespec/UCP/tspconfig.yaml new file mode 100644 index 0000000000..7bd4805bb3 --- /dev/null +++ b/typespec/UCP/tspconfig.yaml @@ -0,0 +1,10 @@ +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + use-read-only-status-schema: true + azure-resource-provider-folder: "resource-manager" + examples-directory: "{project-root}/examples" + emitter-output-dir: "{project-root}/../../swagger/specification/ucp" + arm-types-dir: "{project-root}/../../swagger/specification/common-types/resource-management" + output-file: "{azure-resource-provider-folder}/UCP/{version-status}/{version}/openapi.json" diff --git a/typespec/UCP/ucp-operations.tsp b/typespec/UCP/ucp-operations.tsp new file mode 100644 index 0000000000..7cdb7f6165 --- /dev/null +++ b/typespec/UCP/ucp-operations.tsp @@ -0,0 +1,159 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/rest"; +import "@typespec/openapi"; +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; +using OpenAPI; + +// These operation helpers are created based on the following TypeSpec operations: +// https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-resource-manager/lib/operations.tsp + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@get +@autoRoute +@doc("List {name}", TResource) +@segmentOf(TResource) +@armResourceList(TResource) +op UcpResourceList( + ...TBaseParameters, + ...ParentKeysOf, +): ArmResponse> | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@autoRoute +@doc("Get a {name}", TResource) +@get +@armResourceRead(TResource) +op UcpResourceRead( + ...TBaseParameters, +): ArmResponse | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@autoRoute +@doc("Create a {name}", TResource) +@extension("x-ms-long-running-operation", true) +@extension( + "x-ms-long-running-operation-options", + { + `final-state-via`: "azure-async-operation", + } +) +@armResourceCreateOrUpdate(TResource) +@put +op UcpResourceCreateOrUpdateAsync< + TResource extends ArmResource, + TBaseParameters +>( + ...TBaseParameters, + + @doc("Resource create parameters.") + @body + resource: TResource, +): ArmResourceUpdatedResponse | ArmResourceCreatedResponse | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@autoRoute +@doc("Update a {name}", TResource) +@extension("x-ms-long-running-operation", true) +@extension( + "x-ms-long-running-operation-options", + { + `final-state-via`: "location", + } +) +@armResourceUpdate(TResource) +@patch +op UcpCustomPatchAsync< + TResource extends ArmResource, + TBaseParameters, + TPatchModel extends TypeSpec.Reflection.Model = TagsUpdateModel +>( + ...TBaseParameters, + + @doc("The resource properties to be updated.") + @body + properties: TPatchModel, +): ArmResponse | ArmAcceptedLroResponse<"Resource update request accepted."> | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@autoRoute +@doc("Delete a {name}", TResource) +@extension("x-ms-long-running-operation", true) +@extension( + "x-ms-long-running-operation-options", + { + `final-state-via`: "location", + } +) +@armResourceDelete(TResource) +@delete +op UcpResourceDeleteAsync( + ...TBaseParameters, +): + | ArmDeletedResponse + | ArmDeleteAcceptedLroResponse + | ArmDeletedNoContentResponse + | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@autoRoute +@doc("Create a {name}", TResource) +@armResourceCreateOrUpdate(TResource) +@put +op UcpResourceCreateOrUpdateSync< + TResource extends ArmResource, + TBaseParameters +>( + ...TBaseParameters, + + @doc("Resource create parameters.") + @body + resource: TResource, +): ArmResourceUpdatedResponse | ArmResourceCreatedSyncResponse | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@autoRoute +@doc("Update a {name}", TResource) +@armResourceUpdate(TResource) +@patch +op UcpCustomPatchSync< + TResource extends ArmResource, + TBaseParameters, + TPatchModel extends TypeSpec.Reflection.Model = TagsUpdateModel +>( + ...TBaseParameters, + + @doc("The resource properties to be updated.") + @body + properties: TPatchModel, +): ArmResponse | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation-outside-interface" +@autoRoute +@doc("Delete a {name}", TResource) +@armResourceDelete(TResource) +@delete +op UcpResourceDeleteSync( + ...TBaseParameters, +): ArmDeletedResponse | ArmDeletedNoContentResponse | ErrorResponse; diff --git a/typespec/package-lock.json b/typespec/package-lock.json new file mode 100644 index 0000000000..e3d5a76cd7 --- /dev/null +++ b/typespec/package-lock.json @@ -0,0 +1,1039 @@ +{ + "name": "radius", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "radius", + "version": "0.1.0", + "license": "Apache-2.0", + "dependencies": { + "@azure-tools/typespec-autorest": "latest", + "@azure-tools/typespec-azure-core": "latest", + "@azure-tools/typespec-azure-resource-manager": "latest", + "@azure-tools/typespec-providerhub": "latest", + "@typespec/compiler": "latest", + "@typespec/http": "latest", + "@typespec/openapi": "latest", + "@typespec/rest": "latest", + "@typespec/versioning": "latest" + } + }, + "node_modules/@azure-tools/typespec-autorest": { + "version": "0.33.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.33.0.tgz", + "integrity": "sha512-xA29JJt6Dnb8402xYJrR1dAwzEuhen/gcYeUk4KZrfn/3FsLpfiGQCwTAfcCd6iyLDRx7yQ34ysJmLt5ebcOdw==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@azure-tools/typespec-azure-core": "~0.33.0", + "@typespec/compiler": "~0.47.0", + "@typespec/http": "~0.47.0", + "@typespec/openapi": "~0.47.0", + "@typespec/rest": "~0.47.0", + "@typespec/versioning": "~0.47.0" + } + }, + "node_modules/@azure-tools/typespec-azure-core": { + "version": "0.33.1", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.33.1.tgz", + "integrity": "sha512-g2MbyofjGo5GrPu/L0D3dXRcYXJOIA+abLWS6CRwwGN0RT0W+tnV8SFvGWRbBFsU0gWEZapfJKBwpVVwau6pVQ==", + "dependencies": { + "@typespec/lint": "~0.47.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.47.0", + "@typespec/http": "~0.47.0", + "@typespec/rest": "~0.47.0" + } + }, + "node_modules/@azure-tools/typespec-azure-resource-manager": { + "version": "0.33.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.33.0.tgz", + "integrity": "sha512-8jkOae2Yf5fsYVh7ZgdC+a06Ghlfnk6DvLIQPouwOIftsmnUXScJdDIPodqxjdHuR5AWr053+OiKtVrJDWYgjw==", + "dependencies": { + "@typespec/lint": "~0.47.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@azure-tools/typespec-autorest": "~0.33.0", + "@azure-tools/typespec-azure-core": "~0.33.0", + "@typespec/compiler": "~0.47.0", + "@typespec/http": "~0.47.0", + "@typespec/openapi": "~0.47.0", + "@typespec/rest": "~0.47.0", + "@typespec/versioning": "~0.47.0" + } + }, + "node_modules/@azure-tools/typespec-providerhub": { + "version": "0.33.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-providerhub/-/typespec-providerhub-0.33.0.tgz", + "integrity": "sha512-18HRdQUwSrzcyDxP95REu4qIOL8SMjUhifZAJjGThwhkqczTxoeqPI3ek3ISFj9C7SsSvvlLAsL09kiy+GKYZA==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@azure-tools/typespec-autorest": "~0.33.0", + "@azure-tools/typespec-azure-core": "~0.33.0", + "@azure-tools/typespec-azure-resource-manager": "~0.33.0", + "@typespec/compiler": "~0.47.0", + "@typespec/http": "~0.47.0", + "@typespec/openapi": "~0.47.0", + "@typespec/rest": "~0.47.0", + "@typespec/versioning": "~0.47.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.10.tgz", + "integrity": "sha512-/KKIMG4UEL35WmI9OlvMhurwtytjvXoFcGNrOvyG9zIzA8YmPjVtIZUf7b05+TPO7G7/GEmLHDaoCgACHl9hhA==", + "dependencies": { + "@babel/highlight": "^7.22.10", + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", + "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.22.10", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.10.tgz", + "integrity": "sha512-78aUtVcT7MUscr0K5mIEnkwxPE0MaxkR5RxRwuHaQ+JuU5AmTPhY+do2mdzVTnIJJpyBglql2pehuBIWHug+WQ==", + "dependencies": { + "@babel/helper-validator-identifier": "^7.22.5", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@typespec/compiler": { + "version": "0.47.1", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-0.47.1.tgz", + "integrity": "sha512-EBTweucgrUiFLVbBLYJobgV1emoGzM50iPrOz/Fr3dwFFnISpZJ8wzapq+z0okrvx75+W5q12bms8DjsUWapTA==", + "dependencies": { + "@babel/code-frame": "~7.22.5", + "ajv": "~8.12.0", + "change-case": "~4.1.2", + "globby": "~13.1.1", + "js-yaml": "~4.1.0", + "mustache": "~4.2.0", + "picocolors": "~1.0.0", + "prettier": "~3.0.1", + "prompts": "~2.4.1", + "semver": "^7.3.8", + "vscode-languageserver": "~8.1.0", + "vscode-languageserver-textdocument": "~1.0.1", + "yargs": "~17.7.1" + }, + "bin": { + "tsp": "cmd/tsp.js", + "tsp-server": "cmd/tsp-server.js" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@typespec/http": { + "version": "0.47.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-0.47.0.tgz", + "integrity": "sha512-HrVu5mGV+p3KGPtcNFHB5gXm9pU4rYRG3hJWZdLcN8fy+OuwbhmOgjOGN4AB7HLllnISmcFn6LtlqGnr0LpyfA==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.47.0" + } + }, + "node_modules/@typespec/lint": { + "version": "0.47.0", + "resolved": "https://registry.npmjs.org/@typespec/lint/-/lint-0.47.0.tgz", + "integrity": "sha512-+CZ8OC8ABHU+HljjWvkVfLDZzyj2kc8VqEOHoXYdomt7PTo2GdVubyOXZMAYFiXWJr/k4YWHD2moPcvu+e2yTQ==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.47.0" + } + }, + "node_modules/@typespec/openapi": { + "version": "0.47.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-0.47.0.tgz", + "integrity": "sha512-p10NA5MQ1/z/yltTmK9g/RHgRQa+UPJg7ntcix8I9DIwX6u3yJReYwWBrKLeRNExd8ylNHNqjXTwiHJfptmR3w==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.47.0", + "@typespec/http": "~0.47.0", + "@typespec/rest": "~0.47.0" + } + }, + "node_modules/@typespec/rest": { + "version": "0.47.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.47.0.tgz", + "integrity": "sha512-sjxCY2dQ6Wc51W7NYDLgcZdeTI35vFJR0aK+tuYHMTwjhZJK20ezwb/c+RZQ8xyGIyX+vUj9yhTc7lBZGw4n1A==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.47.0" + } + }, + "node_modules/@typespec/versioning": { + "version": "0.47.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.47.0.tgz", + "integrity": "sha512-j3NUBm61k40ZI5aljgqfVFvduoR+q7ijLpwt+lzXw/DecOgNWZX7R/GGzwCmUVyfJUZpMA/8zhuxmx4fB36P7g==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@typespec/compiler": "~0.47.0" + } + }, + "node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "dependencies": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + } + }, + "node_modules/capital-case": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", + "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3", + "upper-case-first": "^2.0.2" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/change-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", + "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", + "dependencies": { + "camel-case": "^4.1.2", + "capital-case": "^1.0.4", + "constant-case": "^3.0.4", + "dot-case": "^3.0.4", + "header-case": "^2.0.4", + "no-case": "^3.0.4", + "param-case": "^3.0.4", + "pascal-case": "^3.1.2", + "path-case": "^3.0.4", + "sentence-case": "^3.0.4", + "snake-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" + }, + "node_modules/constant-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz", + "integrity": "sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ==", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3", + "upper-case": "^2.0.2" + } + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "node_modules/fast-glob": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globby": { + "version": "13.1.4", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.4.tgz", + "integrity": "sha512-iui/IiiW+QrJ1X1hKH5qwlMQyv34wJAYwH1vrf8b9kBA4sNiif3gKsMHa+BrdnOpEudWjpotfa7LrTzB1ERS/g==", + "dependencies": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.11", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/header-case": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz", + "integrity": "sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==", + "dependencies": { + "capital-case": "^1.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "engines": { + "node": ">=6" + } + }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "bin": { + "mustache": "bin/mustache" + } + }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, + "node_modules/param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/path-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz", + "integrity": "sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg==", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/prettier": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.2.tgz", + "integrity": "sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sentence-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz", + "integrity": "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg==", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3", + "upper-case-first": "^2.0.2" + } + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" + }, + "node_modules/slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/snake-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", + "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tslib": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz", + "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==" + }, + "node_modules/upper-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz", + "integrity": "sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg==", + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/upper-case-first": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", + "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/vscode-jsonrpc": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", + "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/vscode-languageserver": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0.tgz", + "integrity": "sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==", + "dependencies": { + "vscode-languageserver-protocol": "3.17.3" + }, + "bin": { + "installServerIntoExtension": "bin/installServerIntoExtension" + } + }, + "node_modules/vscode-languageserver-protocol": { + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", + "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", + "dependencies": { + "vscode-jsonrpc": "8.1.0", + "vscode-languageserver-types": "3.17.3" + } + }, + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.8.tgz", + "integrity": "sha512-1bonkGqQs5/fxGT5UchTgjGVnfysL0O8v1AYMBjqTbWQTFn721zaPGDYFkOKtfDgFiSgXM3KwaG3FMGfW4Ed9Q==" + }, + "node_modules/vscode-languageserver-types": { + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", + "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/wrap-ansi/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "engines": { + "node": ">=12" + } + } + } +} diff --git a/typespec/package.json b/typespec/package.json new file mode 100644 index 0000000000..44eb82d565 --- /dev/null +++ b/typespec/package.json @@ -0,0 +1,19 @@ +{ + "name": "radius", + "version": "0.1.0", + "type": "module", + "dependencies": { + "@typespec/compiler": "latest", + "@azure-tools/typespec-autorest": "latest", + "@azure-tools/typespec-azure-core": "latest", + "@azure-tools/typespec-azure-resource-manager": "latest", + "@azure-tools/typespec-providerhub": "latest", + "@typespec/http": "latest", + "@typespec/openapi": "latest", + "@typespec/rest": "latest", + "@typespec/versioning": "latest" + }, + "private": true, + "author": "Radius Authors", + "license": "Apache-2.0" +} \ No newline at end of file diff --git a/typespec/radius/v1/resources.tsp b/typespec/radius/v1/resources.tsp new file mode 100644 index 0000000000..0d9f1e9812 --- /dev/null +++ b/typespec/radius/v1/resources.tsp @@ -0,0 +1,176 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@azure-tools/typespec-autorest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@typespec/openapi"; + +using OpenAPI; +using Azure.Core; +using Azure.ResourceManager; + +@doc("The resource name") +@maxLength(63) +@pattern("^[A-Za-z]([-A-Za-z0-9]*[A-Za-z0-9])?$") +scalar ResourceNameString extends string; + +@doc("Base properties of a Environment-scoped resource") +model EnvironmentScopedResource { + @doc("Fully qualified resource ID for the environment that the portable resource is linked to") + environment: string; + + @doc("Fully qualified resource ID for the application that the portable resource is consumed by (if applicable)") + application?: string; + + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; + + @doc("Status of a resource.") + @visibility("read") + status?: ResourceStatus; +} + +@doc("Base properties of a Application-scoped resource") +model ApplicationScopedResource { + @doc("Fully qualified resource ID for the environment that the portable resource is linked to (if applicable)") + environment?: string; + + @doc("Fully qualified resource ID for the application that the portable resource is consumed by") + application: string; + + @doc("The status of the asynchronous operation.") + @visibility("read") + provisioningState?: ProvisioningState; + + @doc("Status of a resource.") + @visibility("read") + status?: ResourceStatus; +} + +@doc("IdentitySettings is the external identity setting.") +model IdentitySettings { + @doc("kind of identity setting") + kind: IdentitySettingKind; + + @doc("The URI for your compute platform's OIDC issuer") + oidcIssuer?: string; + + @doc("The resource ID of the provisioned identity") + resource?: string; +} + +@doc("IdentitySettingKind is the kind of supported external identity setting") +enum IdentitySettingKind { + @doc("undefined identity") + undefined: "undefined", + + @doc("azure ad workload identity") + `azure.com.workload`: "azure.com.workload", +} + +@discriminator("kind") +@doc("Represents backing compute resource") +model EnvironmentCompute { + @doc("The resource id of the compute resource for application environment.") + resourceId?: string; + + @doc("Configuration for supported external identity providers") + identity?: IdentitySettings; +} + +@doc("The Kubernetes compute configuration") +model KubernetesCompute extends EnvironmentCompute { + @doc("The Kubernetes compute kind") + kind: "kubernetes"; + + @doc("The namespace to use for the environment.") + `namespace`: string; +} + +@doc("Status of a resource.") +model ResourceStatus { + @doc("The compute resource associated with the resource.") + compute?: EnvironmentCompute; + + @doc("Properties of an output resource") + @extension("x-ms-identifiers", []) + outputResources?: OutputResource[]; +} + +@doc("Properties of an output resource.") +model OutputResource { + @doc("The logical identifier scoped to the owning Radius resource. This is only needed or used when a resource has a dependency relationship. LocalIDs do not have any particular format or meaning beyond being compared to determine dependency relationships.") + localId?: string; + + @doc("The UCP resource ID of the underlying resource.") + id?: string; + + @doc("Determines whether Radius manages the lifecycle of the underlying resource.") + radiusManaged?: boolean; +} + +@doc("Describes a reference to an existing resource") +model ResourceReference { + @doc("Resource id of an existing resource") + id: string; +} + +@doc("Provisioning state of the portable resource at the time the operation was called") +@lroStatus +enum ProvisioningState { + ...ResourceProvisioningState, + + @doc("The resource is being provisioned") + Provisioning, + + @doc("The resource is updating") + Updating, + + @doc("The resource is being deleted") + Deleting, + + @doc("The resource create request has been accepted") + Accepted, +} + +@doc("The base properties of Recipe") +model RecipeBaseProperties { + @doc("The recipe used to automatically deploy underlying infrastructure for the resource") + recipe?: Recipe; + + @doc("Specifies how the underlying service/resource is provisioned and managed.") + resourceProvisioning?: ResourceProvisioning; +} + +@doc("Specifies how the underlying service/resource is provisioned and managed. Available values are 'recipe', where Radius manages the lifecycle of the resource through a Recipe, and 'manual', where a user manages the resource and provides the values.") +enum ResourceProvisioning { + @doc("The resource lifecycle will be managed by Radius") + recipe, + + @doc("The resource lifecycle will be managed by the user") + manual, +} + +@doc("The recipe used to automatically deploy underlying infrastructure for a portable resource") +model Recipe { + @doc("The name of the recipe within the environment to use") + name: string; + + @doc("Key/value parameters to pass into the recipe at deployment") + parameters?: {}; +} diff --git a/typespec/radius/v1/ucprootscope.tsp b/typespec/radius/v1/ucprootscope.tsp new file mode 100644 index 0000000000..15efa22483 --- /dev/null +++ b/typespec/radius/v1/ucprootscope.tsp @@ -0,0 +1,41 @@ +/* +Copyright 2023 The Radius Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import "@typespec/openapi"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-providerhub"; + +using OpenAPI; +using TypeSpec.Http; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; + +@doc("The default rootScope parameter type.") +model RootScopeParameter { + @path + @minLength(1) + @extension("x-ms-skip-url-encoding", true) + @extension("x-ms-parameter-location", "client") + @doc("The scope in which the resource is present. UCP Scope is /planes/{planeType}/{planeName}/resourceGroup/{resourcegroupID} and Azure resource scope is /subscriptions/{subscriptionID}/resourceGroup/{resourcegroupID}") + rootScope: string; +} + +@doc("The UCP HTTP request base parameters.") +model UCPBaseParameters { + ...ApiVersionParameter; + ...RootScopeParameter; +}