From 210b8a6e97090751f52ff875ea79c707ae1748ae Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 22 Aug 2024 08:53:17 +0000 Subject: [PATCH] CodeGen from PR 3486 in test-repo-billy/azure-rest-api-specs Merge d89b28f77b3a51daf78eec3de0629005f3ed8329 into c221294c903b4bcbe7b1ee4bce901322a7056943 --- .../armcommunitytraining/CHANGELOG.md | 8 + .../armcommunitytraining/LICENSE.txt | 21 + .../armcommunitytraining/README.md | 92 ++ .../armcommunitytraining/autorest.md | 13 + .../armcommunitytraining/build.go | 7 + .../armcommunitytraining/ci.yml | 28 + .../armcommunitytraining/client_factory.go | 52 + .../communitytrainings_client.go | 462 ++++++ .../armcommunitytraining/constants.go | 121 ++ .../fake/communitytrainings_server.go | 353 +++++ .../armcommunitytraining/fake/internal.go | 64 + .../fake/operations_server.go | 96 ++ .../fake/server_factory.go | 82 ++ .../armcommunitytraining/fake/time_rfc3339.go | 110 ++ .../armcommunitytraining/go.mod | 11 + .../armcommunitytraining/go.sum | 12 + .../armcommunitytraining/models.go | 243 ++++ .../armcommunitytraining/models_serde.go | 560 ++++++++ .../armcommunitytraining/operations_client.go | 88 ++ .../armcommunitytraining/options.go | 52 + .../armcommunitytraining/responses.go | 50 + .../armcommunitytraining/time_rfc3339.go | 110 ++ .../armcomputeschedule/CHANGELOG.md | 8 + .../armcomputeschedule/LICENSE.txt | 21 + .../armcomputeschedule/README.md | 92 ++ .../armcomputeschedule/autorest.md | 13 + .../armcomputeschedule/build.go | 7 + .../computeschedule/armcomputeschedule/ci.yml | 28 + .../armcomputeschedule/client_factory.go | 52 + .../armcomputeschedule/constants.go | 152 ++ .../armcomputeschedule/fake/internal.go | 64 + .../fake/operations_server.go | 96 ++ .../fake/scheduledactions_server.go | 412 ++++++ .../armcomputeschedule/fake/server_factory.go | 82 ++ .../armcomputeschedule/fake/time_rfc3339.go | 110 ++ .../computeschedule/armcomputeschedule/go.mod | 11 + .../computeschedule/armcomputeschedule/go.sum | 12 + .../armcomputeschedule/models.go | 363 +++++ .../armcomputeschedule/models_serde.go | 1009 ++++++++++++++ .../armcomputeschedule/operations_client.go | 88 ++ .../armcomputeschedule/options.go | 68 + .../armcomputeschedule/responses.go | 69 + .../scheduledactions_client.go | 621 +++++++++ .../armcomputeschedule/time_rfc3339.go | 110 ++ .../armcontainerservicefleet/CHANGELOG.md | 4 + .../armcontainerservicefleet/autorest.md | 7 +- .../armcontainerservicefleet/constants.go | 2 +- .../fleetmembers_client_example_test.go | 219 --- .../fleets_client_example_test.go | 367 ----- ...eetupdatestrategies_client_example_test.go | 212 --- .../armcontainerservicefleet/go.mod | 2 +- .../armcontainerservicefleet/models.go | 2 +- .../operations_client_example_test.go | 56 - .../updateruns_client_example_test.go | 668 --------- .../armcontainerstorage/CHANGELOG.md | 8 + .../armcontainerstorage/LICENSE.txt | 21 + .../armcontainerstorage/README.md | 92 ++ .../armcontainerstorage/autorest.md | 13 + .../armcontainerstorage/build.go | 7 + .../armcontainerstorage/ci.yml | 28 + .../armcontainerstorage/client_factory.go | 68 + .../armcontainerstorage/constants.go | 255 ++++ .../armcontainerstorage/fake/internal.go | 64 + .../fake/operations_server.go | 96 ++ .../armcontainerstorage/fake/pools_server.go | 353 +++++ .../fake/server_factory.go | 90 ++ .../fake/snapshots_server.go | 272 ++++ .../armcontainerstorage/fake/time_rfc3339.go | 110 ++ .../fake/volumes_server.go | 332 +++++ .../armcontainerstorage/go.mod | 11 + .../armcontainerstorage/go.sum | 12 + .../armcontainerstorage/models.go | 439 ++++++ .../armcontainerstorage/models_serde.go | 1236 +++++++++++++++++ .../armcontainerstorage/operations_client.go | 88 ++ .../armcontainerstorage/options.go | 99 ++ .../armcontainerstorage/pools_client.go | 460 ++++++ .../armcontainerstorage/responses.go | 102 ++ .../armcontainerstorage/snapshots_client.go | 345 +++++ .../armcontainerstorage/time_rfc3339.go | 110 ++ .../armcontainerstorage/volumes_client.go | 429 ++++++ .../contoso/armcontoso/CHANGELOG.md | 8 + .../contoso/armcontoso/LICENSE.txt | 21 + .../contoso/armcontoso/README.md | 92 ++ sdk/resourcemanager/contoso/armcontoso/ci.yml | 28 + .../contoso/armcontoso/client_factory.go | 48 + .../contoso/armcontoso/constants.go | 104 ++ .../contoso/armcontoso/employees_client.go | 444 ++++++ .../employees_client_example_test.go | 302 ++++ .../armcontoso/fake/employees_server.go | 336 +++++ .../contoso/armcontoso/fake/internal.go | 60 + .../armcontoso/fake/operations_server.go | 92 ++ .../contoso/armcontoso/fake/server_factory.go | 79 ++ .../contoso/armcontoso/fake/time_rfc3339.go | 109 ++ sdk/resourcemanager/contoso/armcontoso/go.mod | 21 + sdk/resourcemanager/contoso/armcontoso/go.sum | 29 + .../contoso/armcontoso/models.go | 146 ++ .../contoso/armcontoso/models_serde.go | 398 ++++++ .../contoso/armcontoso/operations_client.go | 84 ++ .../operations_client_example_test.go | 56 + .../contoso/armcontoso/options.go | 45 + .../contoso/armcontoso/responses.go | 46 + .../contoso/armcontoso/time_rfc3339.go | 109 ++ .../contoso/armcontoso/tsp-location.yaml | 4 + .../armdeviceregistry/CHANGELOG.md | 4 + ...setendpointprofiles_client_example_test.go | 486 ------- .../assets_client_example_test.go | 1082 --------------- .../armdeviceregistry/autorest.md | 7 +- .../armdeviceregistry/constants.go | 2 +- .../deviceregistry/armdeviceregistry/go.mod | 12 +- .../deviceregistry/armdeviceregistry/go.sum | 17 - .../armdeviceregistry/models.go | 4 +- .../operations_client_example_test.go | 54 - .../operationstatus_client_example_test.go | 46 - .../armdevopsinfrastructure/CHANGELOG.md | 27 + .../armdevopsinfrastructure/autorest.md | 7 +- .../armdevopsinfrastructure/constants.go | 12 +- .../fake/subscriptionusages_server.go | 46 +- .../armdevopsinfrastructure/go.mod | 12 +- .../armdevopsinfrastructure/go.sum | 17 - .../imageversions_client_example_test.go | 54 - .../armdevopsinfrastructure/interfaces.go | 18 - .../armdevopsinfrastructure/models.go | 159 +-- .../armdevopsinfrastructure/models_serde.go | 323 +---- .../armdevopsinfrastructure/options.go | 4 +- .../polymorphic_helpers.go | 46 - .../pools_client_example_test.go | 260 ---- .../resourcedetails_client_example_test.go | 64 - .../armdevopsinfrastructure/responses.go | 8 +- .../sku_client_example_test.go | 297 ---- .../subscriptionusages_client.go | 44 +- .../subscriptionusages_client_example_test.go | 72 - .../edgezones/armedgezones/CHANGELOG.md | 4 + .../edgezones/armedgezones/constants.go | 2 +- .../extendedzones_client_example_test.go | 199 +++ .../edgezones/armedgezones/go.mod | 12 +- .../edgezones/armedgezones/go.sum | 17 + .../edgezones/armedgezones/models.go | 14 +- .../operations_client_example_test.go | 32 +- .../edgezones/armedgezones/tsp-location.yaml | 6 +- .../fabric/armfabric/CHANGELOG.md | 8 + .../fabric/armfabric/LICENSE.txt | 21 + .../fabric/armfabric/README.md | 92 ++ .../fabric/armfabric/autorest.md | 13 + sdk/resourcemanager/fabric/armfabric/build.go | 7 + .../fabric/armfabric/capacities_client.go | 795 +++++++++++ sdk/resourcemanager/fabric/armfabric/ci.yml | 28 + .../fabric/armfabric/client_factory.go | 52 + .../fabric/armfabric/constants.go | 176 +++ .../armfabric/fake/capacities_server.go | 586 ++++++++ .../fabric/armfabric/fake/internal.go | 64 + .../armfabric/fake/operations_server.go | 96 ++ .../fabric/armfabric/fake/server_factory.go | 80 ++ .../fabric/armfabric/fake/time_rfc3339.go | 110 ++ sdk/resourcemanager/fabric/armfabric/go.mod | 11 + sdk/resourcemanager/fabric/armfabric/go.sum | 12 + .../fabric/armfabric/models.go | 223 +++ .../fabric/armfabric/models_serde.go | 631 +++++++++ .../fabric/armfabric/operations_client.go | 88 ++ .../fabric/armfabric/options.go | 79 ++ .../fabric/armfabric/responses.go | 78 ++ .../fabric/armfabric/time_rfc3339.go | 110 ++ 161 files changed, 17721 insertions(+), 4572 deletions(-) create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/CHANGELOG.md create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/LICENSE.txt create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/README.md create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/autorest.md create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/build.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/ci.yml create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/client_factory.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/communitytrainings_client.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/constants.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/fake/communitytrainings_server.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/fake/internal.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/fake/operations_server.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/fake/server_factory.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/go.mod create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/go.sum create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/models.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/models_serde.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/operations_client.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/options.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/responses.go create mode 100644 sdk/resourcemanager/communitytraining/armcommunitytraining/time_rfc3339.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/CHANGELOG.md create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/LICENSE.txt create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/README.md create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/autorest.md create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/build.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/ci.yml create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/client_factory.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/constants.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/fake/internal.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/fake/operations_server.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/fake/scheduledactions_server.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/fake/server_factory.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/go.mod create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/go.sum create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/models.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/models_serde.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/operations_client.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/options.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/responses.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/scheduledactions_client.go create mode 100644 sdk/resourcemanager/computeschedule/armcomputeschedule/time_rfc3339.go delete mode 100644 sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetmembers_client_example_test.go delete mode 100644 sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleets_client_example_test.go delete mode 100644 sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetupdatestrategies_client_example_test.go delete mode 100644 sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/operations_client_example_test.go delete mode 100644 sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/updateruns_client_example_test.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/LICENSE.txt create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/README.md create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/autorest.md create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/build.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/ci.yml create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/fake/internal.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/fake/operations_server.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/fake/pools_server.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/fake/server_factory.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/fake/snapshots_server.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/fake/volumes_server.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/models.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/options.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/responses.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/snapshots_client.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go create mode 100644 sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/CHANGELOG.md create mode 100644 sdk/resourcemanager/contoso/armcontoso/LICENSE.txt create mode 100644 sdk/resourcemanager/contoso/armcontoso/README.md create mode 100644 sdk/resourcemanager/contoso/armcontoso/ci.yml create mode 100644 sdk/resourcemanager/contoso/armcontoso/client_factory.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/constants.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/employees_client.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/employees_client_example_test.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/fake/employees_server.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/fake/internal.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/fake/operations_server.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/fake/server_factory.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/go.mod create mode 100644 sdk/resourcemanager/contoso/armcontoso/go.sum create mode 100644 sdk/resourcemanager/contoso/armcontoso/models.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/models_serde.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/operations_client.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/operations_client_example_test.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/options.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/responses.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/time_rfc3339.go create mode 100644 sdk/resourcemanager/contoso/armcontoso/tsp-location.yaml delete mode 100644 sdk/resourcemanager/deviceregistry/armdeviceregistry/assetendpointprofiles_client_example_test.go delete mode 100644 sdk/resourcemanager/deviceregistry/armdeviceregistry/assets_client_example_test.go delete mode 100644 sdk/resourcemanager/deviceregistry/armdeviceregistry/operations_client_example_test.go delete mode 100644 sdk/resourcemanager/deviceregistry/armdeviceregistry/operationstatus_client_example_test.go delete mode 100644 sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/imageversions_client_example_test.go delete mode 100644 sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/pools_client_example_test.go delete mode 100644 sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/resourcedetails_client_example_test.go delete mode 100644 sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/sku_client_example_test.go delete mode 100644 sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client_example_test.go create mode 100644 sdk/resourcemanager/edgezones/armedgezones/extendedzones_client_example_test.go rename sdk/resourcemanager/{devopsinfrastructure/armdevopsinfrastructure => edgezones/armedgezones}/operations_client_example_test.go (52%) create mode 100644 sdk/resourcemanager/fabric/armfabric/CHANGELOG.md create mode 100644 sdk/resourcemanager/fabric/armfabric/LICENSE.txt create mode 100644 sdk/resourcemanager/fabric/armfabric/README.md create mode 100644 sdk/resourcemanager/fabric/armfabric/autorest.md create mode 100644 sdk/resourcemanager/fabric/armfabric/build.go create mode 100644 sdk/resourcemanager/fabric/armfabric/capacities_client.go create mode 100644 sdk/resourcemanager/fabric/armfabric/ci.yml create mode 100644 sdk/resourcemanager/fabric/armfabric/client_factory.go create mode 100644 sdk/resourcemanager/fabric/armfabric/constants.go create mode 100644 sdk/resourcemanager/fabric/armfabric/fake/capacities_server.go create mode 100644 sdk/resourcemanager/fabric/armfabric/fake/internal.go create mode 100644 sdk/resourcemanager/fabric/armfabric/fake/operations_server.go create mode 100644 sdk/resourcemanager/fabric/armfabric/fake/server_factory.go create mode 100644 sdk/resourcemanager/fabric/armfabric/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/fabric/armfabric/go.mod create mode 100644 sdk/resourcemanager/fabric/armfabric/go.sum create mode 100644 sdk/resourcemanager/fabric/armfabric/models.go create mode 100644 sdk/resourcemanager/fabric/armfabric/models_serde.go create mode 100644 sdk/resourcemanager/fabric/armfabric/operations_client.go create mode 100644 sdk/resourcemanager/fabric/armfabric/options.go create mode 100644 sdk/resourcemanager/fabric/armfabric/responses.go create mode 100644 sdk/resourcemanager/fabric/armfabric/time_rfc3339.go diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/CHANGELOG.md b/sdk/resourcemanager/communitytraining/armcommunitytraining/CHANGELOG.md new file mode 100644 index 000000000000..a61c464683c2 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0 (2024-08-22) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/LICENSE.txt b/sdk/resourcemanager/communitytraining/armcommunitytraining/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/README.md b/sdk/resourcemanager/communitytraining/armcommunitytraining/README.md new file mode 100644 index 000000000000..0aff324e0268 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/README.md @@ -0,0 +1,92 @@ +# Azure Communitytraining Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining) + +The `armcommunitytraining` module provides operations for working with Azure Communitytraining. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/communitytraining/armcommunitytraining) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Communitytraining module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Communitytraining. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Communitytraining module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armcommunitytraining.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armcommunitytraining.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewCommunityTrainingsClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Communitytraining` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/autorest.md b/sdk/resourcemanager/communitytraining/armcommunitytraining/autorest.md new file mode 100644 index 000000000000..cd046f2f1cf4 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/communitytraining/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/communitytraining/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 1.0.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/build.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/build.go new file mode 100644 index 000000000000..a99ab22506ee --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/communitytraining/armcommunitytraining + +package armcommunitytraining diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/ci.yml b/sdk/resourcemanager/communitytraining/armcommunitytraining/ci.yml new file mode 100644 index 000000000000..2df5d762f18a --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/communitytraining/armcommunitytraining/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/communitytraining/armcommunitytraining/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/communitytraining/armcommunitytraining' diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/client_factory.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/client_factory.go new file mode 100644 index 000000000000..ea806b575839 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/client_factory.go @@ -0,0 +1,52 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +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 { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewCommunityTrainingsClient creates a new instance of CommunityTrainingsClient. +func (c *ClientFactory) NewCommunityTrainingsClient() *CommunityTrainingsClient { + return &CommunityTrainingsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/communitytrainings_client.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/communitytrainings_client.go new file mode 100644 index 000000000000..e26451a153a7 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/communitytrainings_client.go @@ -0,0 +1,462 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +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" +) + +// CommunityTrainingsClient contains the methods for the CommunityTrainings group. +// Don't use this type directly, use NewCommunityTrainingsClient() instead. +type CommunityTrainingsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCommunityTrainingsClient creates a new instance of CommunityTrainingsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewCommunityTrainingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CommunityTrainingsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CommunityTrainingsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create a CommunityTraining +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityTrainingName - The name of the Community Training Resource +// - resource - Resource create parameters. +// - options - CommunityTrainingsClientBeginCreateOptions contains the optional parameters for the CommunityTrainingsClient.BeginCreate +// method. +func (client *CommunityTrainingsClient) BeginCreate(ctx context.Context, resourceGroupName string, communityTrainingName string, resource CommunityTraining, options *CommunityTrainingsClientBeginCreateOptions) (*runtime.Poller[CommunityTrainingsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, communityTrainingName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityTrainingsClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityTrainingsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create a CommunityTraining +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CommunityTrainingsClient) create(ctx context.Context, resourceGroupName string, communityTrainingName string, resource CommunityTraining, options *CommunityTrainingsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "CommunityTrainingsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, communityTrainingName, 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 +} + +// createCreateRequest creates the Create request. +func (client *CommunityTrainingsClient) createCreateRequest(ctx context.Context, resourceGroupName string, communityTrainingName string, resource CommunityTraining, options *CommunityTrainingsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Community/communityTrainings/{communityTrainingName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communityTrainingName == "" { + return nil, errors.New("parameter communityTrainingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityTrainingName}", url.PathEscape(communityTrainingName)) + 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", "2023-11-01") + 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 CommunityTraining +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityTrainingName - The name of the Community Training Resource +// - options - CommunityTrainingsClientBeginDeleteOptions contains the optional parameters for the CommunityTrainingsClient.BeginDelete +// method. +func (client *CommunityTrainingsClient) BeginDelete(ctx context.Context, resourceGroupName string, communityTrainingName string, options *CommunityTrainingsClientBeginDeleteOptions) (*runtime.Poller[CommunityTrainingsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, communityTrainingName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityTrainingsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityTrainingsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a CommunityTraining +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CommunityTrainingsClient) deleteOperation(ctx context.Context, resourceGroupName string, communityTrainingName string, options *CommunityTrainingsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "CommunityTrainingsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, communityTrainingName, 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 *CommunityTrainingsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communityTrainingName string, options *CommunityTrainingsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Community/communityTrainings/{communityTrainingName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communityTrainingName == "" { + return nil, errors.New("parameter communityTrainingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityTrainingName}", url.PathEscape(communityTrainingName)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a CommunityTraining +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityTrainingName - The name of the Community Training Resource +// - options - CommunityTrainingsClientGetOptions contains the optional parameters for the CommunityTrainingsClient.Get method. +func (client *CommunityTrainingsClient) Get(ctx context.Context, resourceGroupName string, communityTrainingName string, options *CommunityTrainingsClientGetOptions) (CommunityTrainingsClientGetResponse, error) { + var err error + const operationName = "CommunityTrainingsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, communityTrainingName, options) + if err != nil { + return CommunityTrainingsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CommunityTrainingsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CommunityTrainingsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *CommunityTrainingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, communityTrainingName string, options *CommunityTrainingsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Community/communityTrainings/{communityTrainingName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communityTrainingName == "" { + return nil, errors.New("parameter communityTrainingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityTrainingName}", url.PathEscape(communityTrainingName)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CommunityTrainingsClient) getHandleResponse(resp *http.Response) (CommunityTrainingsClientGetResponse, error) { + result := CommunityTrainingsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunityTraining); err != nil { + return CommunityTrainingsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List CommunityTraining resources by resource group +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - CommunityTrainingsClientListByResourceGroupOptions contains the optional parameters for the CommunityTrainingsClient.NewListByResourceGroupPager +// method. +func (client *CommunityTrainingsClient) NewListByResourceGroupPager(resourceGroupName string, options *CommunityTrainingsClientListByResourceGroupOptions) *runtime.Pager[CommunityTrainingsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunityTrainingsClientListByResourceGroupResponse]{ + More: func(page CommunityTrainingsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunityTrainingsClientListByResourceGroupResponse) (CommunityTrainingsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CommunityTrainingsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return CommunityTrainingsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CommunityTrainingsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CommunityTrainingsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Community/communityTrainings" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *CommunityTrainingsClient) listByResourceGroupHandleResponse(resp *http.Response) (CommunityTrainingsClientListByResourceGroupResponse, error) { + result := CommunityTrainingsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil { + return CommunityTrainingsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List CommunityTraining resources by subscription ID +// +// Generated from API version 2023-11-01 +// - options - CommunityTrainingsClientListBySubscriptionOptions contains the optional parameters for the CommunityTrainingsClient.NewListBySubscriptionPager +// method. +func (client *CommunityTrainingsClient) NewListBySubscriptionPager(options *CommunityTrainingsClientListBySubscriptionOptions) *runtime.Pager[CommunityTrainingsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunityTrainingsClientListBySubscriptionResponse]{ + More: func(page CommunityTrainingsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunityTrainingsClientListBySubscriptionResponse) (CommunityTrainingsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CommunityTrainingsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return CommunityTrainingsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CommunityTrainingsClient) listBySubscriptionCreateRequest(ctx context.Context, options *CommunityTrainingsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Community/communityTrainings" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *CommunityTrainingsClient) listBySubscriptionHandleResponse(resp *http.Response) (CommunityTrainingsClientListBySubscriptionResponse, error) { + result := CommunityTrainingsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil { + return CommunityTrainingsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a CommunityTraining +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityTrainingName - The name of the Community Training Resource +// - properties - The resource properties to be updated. +// - options - CommunityTrainingsClientBeginUpdateOptions contains the optional parameters for the CommunityTrainingsClient.BeginUpdate +// method. +func (client *CommunityTrainingsClient) BeginUpdate(ctx context.Context, resourceGroupName string, communityTrainingName string, properties Update, options *CommunityTrainingsClientBeginUpdateOptions) (*runtime.Poller[CommunityTrainingsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, communityTrainingName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityTrainingsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityTrainingsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a CommunityTraining +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CommunityTrainingsClient) update(ctx context.Context, resourceGroupName string, communityTrainingName string, properties Update, options *CommunityTrainingsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CommunityTrainingsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, communityTrainingName, 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 *CommunityTrainingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communityTrainingName string, properties Update, options *CommunityTrainingsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Community/communityTrainings/{communityTrainingName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if communityTrainingName == "" { + return nil, errors.New("parameter communityTrainingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityTrainingName}", url.PathEscape(communityTrainingName)) + 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", "2023-11-01") + 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/sdk/resourcemanager/communitytraining/armcommunitytraining/constants.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/constants.go new file mode 100644 index 000000000000..3c151ca14a0c --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/constants.go @@ -0,0 +1,121 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining" + moduleVersion = "v1.0.0" +) + +// 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 - The status of the current operation. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Change accepted for processing + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - Deletion in progress + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - Initial provisioning in progress + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Update in progress + 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, + } +} + +// SKUTier - This field is required to be implemented by the Resource Provider if the service has more than one tier, but +// is not required on a PUT. +type SKUTier string + +const ( + SKUTierBasic SKUTier = "Basic" + SKUTierFree SKUTier = "Free" + SKUTierPremium SKUTier = "Premium" + SKUTierStandard SKUTier = "Standard" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierBasic, + SKUTierFree, + SKUTierPremium, + SKUTierStandard, + } +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/communitytrainings_server.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/communitytrainings_server.go new file mode 100644 index 000000000000..ad16358d964c --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/communitytrainings_server.go @@ -0,0 +1,353 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining" + "net/http" + "net/url" + "regexp" +) + +// CommunityTrainingsServer is a fake server for instances of the armcommunitytraining.CommunityTrainingsClient type. +type CommunityTrainingsServer struct { + // BeginCreate is the fake for method CommunityTrainingsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, communityTrainingName string, resource armcommunitytraining.CommunityTraining, options *armcommunitytraining.CommunityTrainingsClientBeginCreateOptions) (resp azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method CommunityTrainingsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, communityTrainingName string, options *armcommunitytraining.CommunityTrainingsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CommunityTrainingsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, communityTrainingName string, options *armcommunitytraining.CommunityTrainingsClientGetOptions) (resp azfake.Responder[armcommunitytraining.CommunityTrainingsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method CommunityTrainingsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armcommunitytraining.CommunityTrainingsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armcommunitytraining.CommunityTrainingsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method CommunityTrainingsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armcommunitytraining.CommunityTrainingsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armcommunitytraining.CommunityTrainingsClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method CommunityTrainingsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, communityTrainingName string, properties armcommunitytraining.Update, options *armcommunitytraining.CommunityTrainingsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewCommunityTrainingsServerTransport creates a new instance of CommunityTrainingsServerTransport with the provided implementation. +// The returned CommunityTrainingsServerTransport instance is connected to an instance of armcommunitytraining.CommunityTrainingsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCommunityTrainingsServerTransport(srv *CommunityTrainingsServer) *CommunityTrainingsServerTransport { + return &CommunityTrainingsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armcommunitytraining.CommunityTrainingsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armcommunitytraining.CommunityTrainingsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientUpdateResponse]](), + } +} + +// CommunityTrainingsServerTransport connects instances of armcommunitytraining.CommunityTrainingsClient to instances of CommunityTrainingsServer. +// Don't use this type directly, use NewCommunityTrainingsServerTransport instead. +type CommunityTrainingsServerTransport struct { + srv *CommunityTrainingsServer + beginCreate *tracker[azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armcommunitytraining.CommunityTrainingsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armcommunitytraining.CommunityTrainingsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armcommunitytraining.CommunityTrainingsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for CommunityTrainingsServerTransport. +func (c *CommunityTrainingsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "CommunityTrainingsClient.BeginCreate": + resp, err = c.dispatchBeginCreate(req) + case "CommunityTrainingsClient.BeginDelete": + resp, err = c.dispatchBeginDelete(req) + case "CommunityTrainingsClient.Get": + resp, err = c.dispatchGet(req) + case "CommunityTrainingsClient.NewListByResourceGroupPager": + resp, err = c.dispatchNewListByResourceGroupPager(req) + case "CommunityTrainingsClient.NewListBySubscriptionPager": + resp, err = c.dispatchNewListBySubscriptionPager(req) + case "CommunityTrainingsClient.BeginUpdate": + resp, err = c.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CommunityTrainingsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := c.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Community/communityTrainings/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcommunitytraining.CommunityTraining](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityTrainingNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityTrainingName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreate(req.Context(), resourceGroupNameParam, communityTrainingNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + c.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + c.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + c.beginCreate.remove(req) + } + + return resp, nil +} + +func (c *CommunityTrainingsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := c.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Community/communityTrainings/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityTrainingNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityTrainingName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, communityTrainingNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + c.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + c.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + c.beginDelete.remove(req) + } + + return resp, nil +} + +func (c *CommunityTrainingsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Community/communityTrainings/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityTrainingNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityTrainingName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, communityTrainingNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CommunityTraining, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CommunityTrainingsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Community/communityTrainings` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armcommunitytraining.CommunityTrainingsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + c.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (c *CommunityTrainingsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := c.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Community/communityTrainings` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := c.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + c.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armcommunitytraining.CommunityTrainingsClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + c.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (c *CommunityTrainingsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := c.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Community/communityTrainings/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcommunitytraining.Update](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityTrainingNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityTrainingName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, communityTrainingNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + c.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + c.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/internal.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/internal.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/operations_server.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/operations_server.go new file mode 100644 index 000000000000..905fa95fcae0 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining" + "net/http" +) + +// OperationsServer is a fake server for instances of the armcommunitytraining.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armcommunitytraining.OperationsClientListOptions) (resp azfake.PagerResponder[armcommunitytraining.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armcommunitytraining.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcommunitytraining.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armcommunitytraining.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armcommunitytraining.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcommunitytraining.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/server_factory.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/server_factory.go new file mode 100644 index 000000000000..8f941a6dd272 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/server_factory.go @@ -0,0 +1,82 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armcommunitytraining.ClientFactory type. +type ServerFactory struct { + CommunityTrainingsServer CommunityTrainingsServer + OperationsServer OperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armcommunitytraining.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armcommunitytraining.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trCommunityTrainingsServer *CommunityTrainingsServerTransport + trOperationsServer *OperationsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "CommunityTrainingsClient": + initServer(s, &s.trCommunityTrainingsServer, func() *CommunityTrainingsServerTransport { + return NewCommunityTrainingsServerTransport(&s.srv.CommunityTrainingsServer) + }) + resp, err = s.trCommunityTrainingsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/time_rfc3339.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/time_rfc3339.go new file mode 100644 index 000000000000..81f308b0d343 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/fake/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/communitytraining/armcommunitytraining/go.mod b/sdk/resourcemanager/communitytraining/armcommunitytraining/go.mod new file mode 100644 index 000000000000..d108e2ded432 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/communitytraining/armcommunitytraining + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/go.sum b/sdk/resourcemanager/communitytraining/armcommunitytraining/go.sum new file mode 100644 index 000000000000..03ce617a1873 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/models.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/models.go new file mode 100644 index 000000000000..1179600177cc --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/models.go @@ -0,0 +1,243 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +import "time" + +// CommunityTraining - A CommunityProviderHub resource +type CommunityTraining struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *Properties + + // The SKU (Stock Keeping Unit) assigned to this resource. + SKU *SKU + + // Resource tags. + Tags map[string]*string + + // 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 + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// IdentityConfigurationProperties - Details of the Community CommunityTraining Identity Configuration +type IdentityConfigurationProperties struct { + // REQUIRED; The clientId of the application registered in the selected identity provider for the Community Training Resource + ClientID *string + + // REQUIRED; The client secret of the application registered in the selected identity provider for the Community Training + // Resource + ClientSecret *string + + // REQUIRED; The domain name of the selected identity provider for the Community Training Resource + DomainName *string + + // REQUIRED; The identity type of the Community Training Resource + IdentityType *string + + // REQUIRED; The tenantId of the selected identity provider for the Community Training Resource + TenantID *string + + // The name of the authentication policy registered in ADB2C for the Community Training Resource + B2CAuthenticationPolicy *string + + // The name of the password reset policy registered in ADB2C for the Community Training Resource + B2CPasswordResetPolicy *string + + // The custom login parameters for the Community Training Resource + CustomLoginParameters *string + + // To indicate whether the Community Training Resource has Teams enabled + TeamsEnabled *bool +} + +// IdentityConfigurationPropertiesUpdate - Details of the Community CommunityTraining Identity Configuration +type IdentityConfigurationPropertiesUpdate struct { + // The name of the authentication policy registered in ADB2C for the Community Training Resource + B2CAuthenticationPolicy *string + + // The name of the password reset policy registered in ADB2C for the Community Training Resource + B2CPasswordResetPolicy *string + + // The clientId of the application registered in the selected identity provider for the Community Training Resource + ClientID *string + + // The client secret of the application registered in the selected identity provider for the Community Training Resource + ClientSecret *string + + // The custom login parameters for the Community Training Resource + CustomLoginParameters *string + + // The domain name of the selected identity provider for the Community Training Resource + DomainName *string + + // The identity type of the Community Training Resource + IdentityType *string + + // To indicate whether the Community Training Resource has Teams enabled + TeamsEnabled *bool + + // The tenantId of the selected identity provider for the Community Training Resource + TenantID *string +} + +// ListResult - The response of a CommunityTraining list operation. +type ListResult struct { + // REQUIRED; The CommunityTraining items on this page + Value []*CommunityTraining + + // The link to the next page of items + NextLink *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 + + // 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 +} + +// Properties - Details of the Community CommunityTraining. +type Properties struct { + // REQUIRED; To indicate whether the Community Training instance has Disaster Recovery enabled + DisasterRecoveryEnabled *bool + + // REQUIRED; The identity configuration of the Community Training resource + IdentityConfiguration *IdentityConfigurationProperties + + // REQUIRED; The email address of the portal admin + PortalAdminEmailAddress *string + + // REQUIRED; The portal name (website name) of the Community Training instance + PortalName *string + + // REQUIRED; The email address of the portal owner. Will be used as the primary contact + PortalOwnerEmailAddress *string + + // REQUIRED; The organization name of the portal owner + PortalOwnerOrganizationName *string + + // REQUIRED; To indicate whether the Community Training instance has Zone Redundancy enabled + ZoneRedundancyEnabled *bool + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// SKU - The resource model definition representing SKU +type SKU struct { + // REQUIRED; The name of the SKU. Ex - P3. It is typically a letter+number code + Name *string + + // If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the + // resource this may be omitted. + Capacity *int32 + + // If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string + + // The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string + + // This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required + // on a PUT. + Tier *SKUTier +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// Update - The type used for update operations of the CommunityTraining. +type Update struct { + // The resource-specific properties for this resource. + Properties *UpdateProperties + + // The SKU (Stock Keeping Unit) assigned to this resource. + SKU *SKU + + // Resource tags. + Tags map[string]*string +} + +// UpdateProperties - The updatable properties of the CommunityTraining. +type UpdateProperties struct { + // The identity configuration of the Community Training resource + IdentityConfiguration *IdentityConfigurationPropertiesUpdate +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/models_serde.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/models_serde.go new file mode 100644 index 000000000000..9b159415d5f0 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/models_serde.go @@ -0,0 +1,560 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CommunityTraining. +func (c CommunityTraining) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityTraining. +func (c *CommunityTraining) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + 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 "sku": + err = unpopulate(val, "SKU", &c.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 IdentityConfigurationProperties. +func (i IdentityConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "b2cAuthenticationPolicy", i.B2CAuthenticationPolicy) + populate(objectMap, "b2cPasswordResetPolicy", i.B2CPasswordResetPolicy) + populate(objectMap, "clientId", i.ClientID) + populate(objectMap, "clientSecret", i.ClientSecret) + populate(objectMap, "customLoginParameters", i.CustomLoginParameters) + populate(objectMap, "domainName", i.DomainName) + populate(objectMap, "identityType", i.IdentityType) + populate(objectMap, "teamsEnabled", i.TeamsEnabled) + populate(objectMap, "tenantId", i.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentityConfigurationProperties. +func (i *IdentityConfigurationProperties) 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 "b2cAuthenticationPolicy": + err = unpopulate(val, "B2CAuthenticationPolicy", &i.B2CAuthenticationPolicy) + delete(rawMsg, key) + case "b2cPasswordResetPolicy": + err = unpopulate(val, "B2CPasswordResetPolicy", &i.B2CPasswordResetPolicy) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &i.ClientID) + delete(rawMsg, key) + case "clientSecret": + err = unpopulate(val, "ClientSecret", &i.ClientSecret) + delete(rawMsg, key) + case "customLoginParameters": + err = unpopulate(val, "CustomLoginParameters", &i.CustomLoginParameters) + delete(rawMsg, key) + case "domainName": + err = unpopulate(val, "DomainName", &i.DomainName) + delete(rawMsg, key) + case "identityType": + err = unpopulate(val, "IdentityType", &i.IdentityType) + delete(rawMsg, key) + case "teamsEnabled": + err = unpopulate(val, "TeamsEnabled", &i.TeamsEnabled) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + 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 IdentityConfigurationPropertiesUpdate. +func (i IdentityConfigurationPropertiesUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "b2cAuthenticationPolicy", i.B2CAuthenticationPolicy) + populate(objectMap, "b2cPasswordResetPolicy", i.B2CPasswordResetPolicy) + populate(objectMap, "clientId", i.ClientID) + populate(objectMap, "clientSecret", i.ClientSecret) + populate(objectMap, "customLoginParameters", i.CustomLoginParameters) + populate(objectMap, "domainName", i.DomainName) + populate(objectMap, "identityType", i.IdentityType) + populate(objectMap, "teamsEnabled", i.TeamsEnabled) + populate(objectMap, "tenantId", i.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentityConfigurationPropertiesUpdate. +func (i *IdentityConfigurationPropertiesUpdate) 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 "b2cAuthenticationPolicy": + err = unpopulate(val, "B2CAuthenticationPolicy", &i.B2CAuthenticationPolicy) + delete(rawMsg, key) + case "b2cPasswordResetPolicy": + err = unpopulate(val, "B2CPasswordResetPolicy", &i.B2CPasswordResetPolicy) + delete(rawMsg, key) + case "clientId": + err = unpopulate(val, "ClientID", &i.ClientID) + delete(rawMsg, key) + case "clientSecret": + err = unpopulate(val, "ClientSecret", &i.ClientSecret) + delete(rawMsg, key) + case "customLoginParameters": + err = unpopulate(val, "CustomLoginParameters", &i.CustomLoginParameters) + delete(rawMsg, key) + case "domainName": + err = unpopulate(val, "DomainName", &i.DomainName) + delete(rawMsg, key) + case "identityType": + err = unpopulate(val, "IdentityType", &i.IdentityType) + delete(rawMsg, key) + case "teamsEnabled": + err = unpopulate(val, "TeamsEnabled", &i.TeamsEnabled) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + 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 ListResult. +func (l ListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListResult. +func (l *ListResult) 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", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + 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 Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "disasterRecoveryEnabled", p.DisasterRecoveryEnabled) + populate(objectMap, "identityConfiguration", p.IdentityConfiguration) + populate(objectMap, "portalAdminEmailAddress", p.PortalAdminEmailAddress) + populate(objectMap, "portalName", p.PortalName) + populate(objectMap, "portalOwnerEmailAddress", p.PortalOwnerEmailAddress) + populate(objectMap, "portalOwnerOrganizationName", p.PortalOwnerOrganizationName) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "zoneRedundancyEnabled", p.ZoneRedundancyEnabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Properties. +func (p *Properties) 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 "disasterRecoveryEnabled": + err = unpopulate(val, "DisasterRecoveryEnabled", &p.DisasterRecoveryEnabled) + delete(rawMsg, key) + case "identityConfiguration": + err = unpopulate(val, "IdentityConfiguration", &p.IdentityConfiguration) + delete(rawMsg, key) + case "portalAdminEmailAddress": + err = unpopulate(val, "PortalAdminEmailAddress", &p.PortalAdminEmailAddress) + delete(rawMsg, key) + case "portalName": + err = unpopulate(val, "PortalName", &p.PortalName) + delete(rawMsg, key) + case "portalOwnerEmailAddress": + err = unpopulate(val, "PortalOwnerEmailAddress", &p.PortalOwnerEmailAddress) + delete(rawMsg, key) + case "portalOwnerOrganizationName": + err = unpopulate(val, "PortalOwnerOrganizationName", &p.PortalOwnerOrganizationName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "zoneRedundancyEnabled": + err = unpopulate(val, "ZoneRedundancyEnabled", &p.ZoneRedundancyEnabled) + 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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) + populate(objectMap, "name", s.Name) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) 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 "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 Update. +func (u Update) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", u.Properties) + populate(objectMap, "sku", u.SKU) + populate(objectMap, "tags", u.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Update. +func (u *Update) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &u.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &u.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &u.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UpdateProperties. +func (u UpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identityConfiguration", u.IdentityConfiguration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateProperties. +func (u *UpdateProperties) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identityConfiguration": + err = unpopulate(val, "IdentityConfiguration", &u.IdentityConfiguration) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + 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 any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/operations_client.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/operations_client.go new file mode 100644 index 000000000000..408be23444de --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + 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. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2023-11-01 +// - 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 { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Community/operations" + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/options.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/options.go new file mode 100644 index 000000000000..dc33dd376a96 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/options.go @@ -0,0 +1,52 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +// CommunityTrainingsClientBeginCreateOptions contains the optional parameters for the CommunityTrainingsClient.BeginCreate +// method. +type CommunityTrainingsClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CommunityTrainingsClientBeginDeleteOptions contains the optional parameters for the CommunityTrainingsClient.BeginDelete +// method. +type CommunityTrainingsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CommunityTrainingsClientBeginUpdateOptions contains the optional parameters for the CommunityTrainingsClient.BeginUpdate +// method. +type CommunityTrainingsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CommunityTrainingsClientGetOptions contains the optional parameters for the CommunityTrainingsClient.Get method. +type CommunityTrainingsClientGetOptions struct { + // placeholder for future optional parameters +} + +// CommunityTrainingsClientListByResourceGroupOptions contains the optional parameters for the CommunityTrainingsClient.NewListByResourceGroupPager +// method. +type CommunityTrainingsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CommunityTrainingsClientListBySubscriptionOptions contains the optional parameters for the CommunityTrainingsClient.NewListBySubscriptionPager +// method. +type CommunityTrainingsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/responses.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/responses.go new file mode 100644 index 000000000000..2c325c430d81 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/responses.go @@ -0,0 +1,50 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +// CommunityTrainingsClientCreateResponse contains the response from method CommunityTrainingsClient.BeginCreate. +type CommunityTrainingsClientCreateResponse struct { + // A CommunityProviderHub resource + CommunityTraining +} + +// CommunityTrainingsClientDeleteResponse contains the response from method CommunityTrainingsClient.BeginDelete. +type CommunityTrainingsClientDeleteResponse struct { + // placeholder for future response values +} + +// CommunityTrainingsClientGetResponse contains the response from method CommunityTrainingsClient.Get. +type CommunityTrainingsClientGetResponse struct { + // A CommunityProviderHub resource + CommunityTraining +} + +// CommunityTrainingsClientListByResourceGroupResponse contains the response from method CommunityTrainingsClient.NewListByResourceGroupPager. +type CommunityTrainingsClientListByResourceGroupResponse struct { + // The response of a CommunityTraining list operation. + ListResult +} + +// CommunityTrainingsClientListBySubscriptionResponse contains the response from method CommunityTrainingsClient.NewListBySubscriptionPager. +type CommunityTrainingsClientListBySubscriptionResponse struct { + // The response of a CommunityTraining list operation. + ListResult +} + +// CommunityTrainingsClientUpdateResponse contains the response from method CommunityTrainingsClient.BeginUpdate. +type CommunityTrainingsClientUpdateResponse struct { + // A CommunityProviderHub resource + CommunityTraining +} + +// 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 +} diff --git a/sdk/resourcemanager/communitytraining/armcommunitytraining/time_rfc3339.go b/sdk/resourcemanager/communitytraining/armcommunitytraining/time_rfc3339.go new file mode 100644 index 000000000000..abec8b90b451 --- /dev/null +++ b/sdk/resourcemanager/communitytraining/armcommunitytraining/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcommunitytraining + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/computeschedule/armcomputeschedule/CHANGELOG.md b/sdk/resourcemanager/computeschedule/armcomputeschedule/CHANGELOG.md new file mode 100644 index 000000000000..83b42956a6de --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2024-08-22) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/LICENSE.txt b/sdk/resourcemanager/computeschedule/armcomputeschedule/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/README.md b/sdk/resourcemanager/computeschedule/armcomputeschedule/README.md new file mode 100644 index 000000000000..a8285d513fe7 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/README.md @@ -0,0 +1,92 @@ +# Azure Computeschedule Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule) + +The `armcomputeschedule` module provides operations for working with Azure Computeschedule. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/computeschedule/armcomputeschedule) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Computeschedule module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Computeschedule. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Computeschedule module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armcomputeschedule.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armcomputeschedule.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewScheduledActionsClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Computeschedule` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/autorest.md b/sdk/resourcemanager/computeschedule/armcomputeschedule/autorest.md new file mode 100644 index 000000000000..f69a513d0bc3 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/computeschedule/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/computeschedule/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/build.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/build.go new file mode 100644 index 000000000000..62d8e2521509 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/computeschedule/armcomputeschedule + +package armcomputeschedule diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/ci.yml b/sdk/resourcemanager/computeschedule/armcomputeschedule/ci.yml new file mode 100644 index 000000000000..92844a7fc49f --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/computeschedule/armcomputeschedule/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/computeschedule/armcomputeschedule/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/computeschedule/armcomputeschedule' diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/client_factory.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/client_factory.go new file mode 100644 index 000000000000..f3b18164ab51 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/client_factory.go @@ -0,0 +1,52 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +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 { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewScheduledActionsClient creates a new instance of ScheduledActionsClient. +func (c *ClientFactory) NewScheduledActionsClient() *ScheduledActionsClient { + return &ScheduledActionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/constants.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/constants.go new file mode 100644 index 000000000000..1fb518798fba --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/constants.go @@ -0,0 +1,152 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule" + moduleVersion = "v0.1.0" +) + +// 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, + } +} + +// DeadlineType - The types of deadlines supported by ScheduledActions +type DeadlineType string + +const ( + // DeadlineTypeCompleteBy - Complete the operation by the given deadline. + DeadlineTypeCompleteBy DeadlineType = "CompleteBy" + // DeadlineTypeInitiateAt - Initiate the operation at the given deadline. + DeadlineTypeInitiateAt DeadlineType = "InitiateAt" + // DeadlineTypeUnknown - Default value of Unknown. + DeadlineTypeUnknown DeadlineType = "Unknown" +) + +// PossibleDeadlineTypeValues returns the possible values for the DeadlineType const type. +func PossibleDeadlineTypeValues() []DeadlineType { + return []DeadlineType{ + DeadlineTypeCompleteBy, + DeadlineTypeInitiateAt, + DeadlineTypeUnknown, + } +} + +// OperationState - Values that define the states of operations in Scheduled Actions +type OperationState string + +const ( + // OperationStateBlocked - Operations that are blocked + OperationStateBlocked OperationState = "Blocked" + // OperationStateCancelled - Operations that have been cancelled by the user + OperationStateCancelled OperationState = "Cancelled" + // OperationStateExecuting - Operations that are in the process of being executed + OperationStateExecuting OperationState = "Executing" + // OperationStateFailed - Operations that have failed + OperationStateFailed OperationState = "Failed" + // OperationStatePendingExecution - Operations that are waiting to be executed + OperationStatePendingExecution OperationState = "PendingExecution" + // OperationStatePendingScheduling - Operations that are pending scheduling + OperationStatePendingScheduling OperationState = "PendingScheduling" + // OperationStateScheduled - Operations that have been scheduled + OperationStateScheduled OperationState = "Scheduled" + // OperationStateSucceeded - Operations that suceeded + OperationStateSucceeded OperationState = "Succeeded" + // OperationStateUnknown - The default value for the operation state enum + OperationStateUnknown OperationState = "Unknown" +) + +// PossibleOperationStateValues returns the possible values for the OperationState const type. +func PossibleOperationStateValues() []OperationState { + return []OperationState{ + OperationStateBlocked, + OperationStateCancelled, + OperationStateExecuting, + OperationStateFailed, + OperationStatePendingExecution, + OperationStatePendingScheduling, + OperationStateScheduled, + OperationStateSucceeded, + OperationStateUnknown, + } +} + +// OptimizationPreference - The preferences customers can select to optimize their requests to ScheduledActions +type OptimizationPreference string + +const ( + // OptimizationPreferenceAvailability - Optimize while considering availability of resources + OptimizationPreferenceAvailability OptimizationPreference = "Availability" + // OptimizationPreferenceCost - Optimize while considering cost savings + OptimizationPreferenceCost OptimizationPreference = "Cost" + // OptimizationPreferenceCostAvailabilityBalanced - Optimize while considering a balance of cost and availability + OptimizationPreferenceCostAvailabilityBalanced OptimizationPreference = "CostAvailabilityBalanced" +) + +// PossibleOptimizationPreferenceValues returns the possible values for the OptimizationPreference const type. +func PossibleOptimizationPreferenceValues() []OptimizationPreference { + return []OptimizationPreference{ + OptimizationPreferenceAvailability, + OptimizationPreferenceCost, + OptimizationPreferenceCostAvailabilityBalanced, + } +} + +// 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, + } +} + +// ResourceOperationType - Type of operation performed on the resources +type ResourceOperationType string + +const ( + // ResourceOperationTypeDeallocate - Deallocate operations on the resources + ResourceOperationTypeDeallocate ResourceOperationType = "Deallocate" + // ResourceOperationTypeHibernate - Hibernate operations on the resources + ResourceOperationTypeHibernate ResourceOperationType = "Hibernate" + // ResourceOperationTypeStart - Start operations on the resources + ResourceOperationTypeStart ResourceOperationType = "Start" + // ResourceOperationTypeUnknown - The default value for this enum type + ResourceOperationTypeUnknown ResourceOperationType = "Unknown" +) + +// PossibleResourceOperationTypeValues returns the possible values for the ResourceOperationType const type. +func PossibleResourceOperationTypeValues() []ResourceOperationType { + return []ResourceOperationType{ + ResourceOperationTypeDeallocate, + ResourceOperationTypeHibernate, + ResourceOperationTypeStart, + ResourceOperationTypeUnknown, + } +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/internal.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/internal.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/operations_server.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/operations_server.go new file mode 100644 index 000000000000..0e47f1aeeaef --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule" + "net/http" +) + +// OperationsServer is a fake server for instances of the armcomputeschedule.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armcomputeschedule.OperationsClientListOptions) (resp azfake.PagerResponder[armcomputeschedule.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armcomputeschedule.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcomputeschedule.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armcomputeschedule.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armcomputeschedule.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcomputeschedule.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/scheduledactions_server.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/scheduledactions_server.go new file mode 100644 index 000000000000..bed1392f6310 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/scheduledactions_server.go @@ -0,0 +1,412 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule" + "net/http" + "net/url" + "regexp" +) + +// ScheduledActionsServer is a fake server for instances of the armcomputeschedule.ScheduledActionsClient type. +type ScheduledActionsServer struct { + // VirtualMachinesCancelOperations is the fake for method ScheduledActionsClient.VirtualMachinesCancelOperations + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesCancelOperations func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.CancelOperationsRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesCancelOperationsOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesCancelOperationsResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesExecuteDeallocate is the fake for method ScheduledActionsClient.VirtualMachinesExecuteDeallocate + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesExecuteDeallocate func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.ExecuteDeallocateRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesExecuteHibernate is the fake for method ScheduledActionsClient.VirtualMachinesExecuteHibernate + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesExecuteHibernate func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.ExecuteHibernateRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesExecuteHibernateOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesExecuteHibernateResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesExecuteStart is the fake for method ScheduledActionsClient.VirtualMachinesExecuteStart + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesExecuteStart func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.ExecuteStartRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesExecuteStartOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesExecuteStartResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesGetOperationErrors is the fake for method ScheduledActionsClient.VirtualMachinesGetOperationErrors + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesGetOperationErrors func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.GetOperationErrorsRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesGetOperationStatus is the fake for method ScheduledActionsClient.VirtualMachinesGetOperationStatus + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesGetOperationStatus func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.GetOperationStatusRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesGetOperationStatusOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesGetOperationStatusResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesSubmitDeallocate is the fake for method ScheduledActionsClient.VirtualMachinesSubmitDeallocate + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesSubmitDeallocate func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.SubmitDeallocateRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesSubmitHibernate is the fake for method ScheduledActionsClient.VirtualMachinesSubmitHibernate + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesSubmitHibernate func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.SubmitHibernateRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesSubmitHibernateOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesSubmitHibernateResponse], errResp azfake.ErrorResponder) + + // VirtualMachinesSubmitStart is the fake for method ScheduledActionsClient.VirtualMachinesSubmitStart + // HTTP status codes to indicate success: http.StatusOK + VirtualMachinesSubmitStart func(ctx context.Context, locationparameter string, requestBody armcomputeschedule.SubmitStartRequest, options *armcomputeschedule.ScheduledActionsClientVirtualMachinesSubmitStartOptions) (resp azfake.Responder[armcomputeschedule.ScheduledActionsClientVirtualMachinesSubmitStartResponse], errResp azfake.ErrorResponder) +} + +// NewScheduledActionsServerTransport creates a new instance of ScheduledActionsServerTransport with the provided implementation. +// The returned ScheduledActionsServerTransport instance is connected to an instance of armcomputeschedule.ScheduledActionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewScheduledActionsServerTransport(srv *ScheduledActionsServer) *ScheduledActionsServerTransport { + return &ScheduledActionsServerTransport{srv: srv} +} + +// ScheduledActionsServerTransport connects instances of armcomputeschedule.ScheduledActionsClient to instances of ScheduledActionsServer. +// Don't use this type directly, use NewScheduledActionsServerTransport instead. +type ScheduledActionsServerTransport struct { + srv *ScheduledActionsServer +} + +// Do implements the policy.Transporter interface for ScheduledActionsServerTransport. +func (s *ScheduledActionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ScheduledActionsClient.VirtualMachinesCancelOperations": + resp, err = s.dispatchVirtualMachinesCancelOperations(req) + case "ScheduledActionsClient.VirtualMachinesExecuteDeallocate": + resp, err = s.dispatchVirtualMachinesExecuteDeallocate(req) + case "ScheduledActionsClient.VirtualMachinesExecuteHibernate": + resp, err = s.dispatchVirtualMachinesExecuteHibernate(req) + case "ScheduledActionsClient.VirtualMachinesExecuteStart": + resp, err = s.dispatchVirtualMachinesExecuteStart(req) + case "ScheduledActionsClient.VirtualMachinesGetOperationErrors": + resp, err = s.dispatchVirtualMachinesGetOperationErrors(req) + case "ScheduledActionsClient.VirtualMachinesGetOperationStatus": + resp, err = s.dispatchVirtualMachinesGetOperationStatus(req) + case "ScheduledActionsClient.VirtualMachinesSubmitDeallocate": + resp, err = s.dispatchVirtualMachinesSubmitDeallocate(req) + case "ScheduledActionsClient.VirtualMachinesSubmitHibernate": + resp, err = s.dispatchVirtualMachinesSubmitHibernate(req) + case "ScheduledActionsClient.VirtualMachinesSubmitStart": + resp, err = s.dispatchVirtualMachinesSubmitStart(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesCancelOperations(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesCancelOperations == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesCancelOperations not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesCancelOperations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.CancelOperationsRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesCancelOperations(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CancelOperationsResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesExecuteDeallocate(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesExecuteDeallocate == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesExecuteDeallocate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesExecuteDeallocate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.ExecuteDeallocateRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesExecuteDeallocate(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeallocateResourceOperationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesExecuteHibernate(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesExecuteHibernate == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesExecuteHibernate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesExecuteHibernate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.ExecuteHibernateRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesExecuteHibernate(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).HibernateResourceOperationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesExecuteStart(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesExecuteStart == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesExecuteStart not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesExecuteStart` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.ExecuteStartRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesExecuteStart(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).StartResourceOperationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesGetOperationErrors(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesGetOperationErrors == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesGetOperationErrors not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesGetOperationErrors` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.GetOperationErrorsRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesGetOperationErrors(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GetOperationErrorsResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesGetOperationStatus(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesGetOperationStatus == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesGetOperationStatus not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesGetOperationStatus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.GetOperationStatusRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesGetOperationStatus(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).GetOperationStatusResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesSubmitDeallocate(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesSubmitDeallocate == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesSubmitDeallocate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesSubmitDeallocate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.SubmitDeallocateRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesSubmitDeallocate(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeallocateResourceOperationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesSubmitHibernate(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesSubmitHibernate == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesSubmitHibernate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesSubmitHibernate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.SubmitHibernateRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesSubmitHibernate(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).HibernateResourceOperationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScheduledActionsServerTransport) dispatchVirtualMachinesSubmitStart(req *http.Request) (*http.Response, error) { + if s.srv.VirtualMachinesSubmitStart == nil { + return nil, &nonRetriableError{errors.New("fake for method VirtualMachinesSubmitStart not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ComputeSchedule/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachinesSubmitStart` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcomputeschedule.SubmitStartRequest](req) + if err != nil { + return nil, err + } + locationparameterParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationparameter")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VirtualMachinesSubmitStart(req.Context(), locationparameterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).StartResourceOperationResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/server_factory.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/server_factory.go new file mode 100644 index 000000000000..98595b101731 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/server_factory.go @@ -0,0 +1,82 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armcomputeschedule.ClientFactory type. +type ServerFactory struct { + OperationsServer OperationsServer + ScheduledActionsServer ScheduledActionsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armcomputeschedule.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armcomputeschedule.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trOperationsServer *OperationsServerTransport + trScheduledActionsServer *ScheduledActionsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "ScheduledActionsClient": + initServer(s, &s.trScheduledActionsServer, func() *ScheduledActionsServerTransport { + return NewScheduledActionsServerTransport(&s.srv.ScheduledActionsServer) + }) + resp, err = s.trScheduledActionsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/time_rfc3339.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/time_rfc3339.go new file mode 100644 index 000000000000..81f308b0d343 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/fake/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/computeschedule/armcomputeschedule/go.mod b/sdk/resourcemanager/computeschedule/armcomputeschedule/go.mod new file mode 100644 index 000000000000..cf5a3e0b2eec --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/computeschedule/armcomputeschedule + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/go.sum b/sdk/resourcemanager/computeschedule/armcomputeschedule/go.sum new file mode 100644 index 000000000000..03ce617a1873 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/models.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/models.go new file mode 100644 index 000000000000..ffe9dcefc02a --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/models.go @@ -0,0 +1,363 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +import "time" + +// CancelOperationsRequest - This is the request to cancel running operations in scheduled actions using the operation ids +type CancelOperationsRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The list of operation ids to cancel operations on + OperationIDs []*string +} + +// CancelOperationsResponse - This is the response from a cancel operations request +type CancelOperationsResponse struct { + // REQUIRED; An array of resource operations that were successfully cancelled + Results []*ResourceOperation +} + +// DeallocateResourceOperationResponse - The response from a deallocate request +type DeallocateResourceOperationResponse struct { + // REQUIRED; The description of the operation response + Description *string + + // REQUIRED; The location of the deallocate request eg westus + Location *string + + // REQUIRED; The type of resources used in the deallocate request eg virtual machines + Type *string + + // The results from the deallocate request if no errors exist + Results []*ResourceOperation +} + +// ExecuteDeallocateRequest - The ExecuteDeallocateRequest request for executeDeallocate operations +type ExecuteDeallocateRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The execution parameters for the request + ExecutionParameters *ExecutionParameters + + // REQUIRED; The resources for the request + Resources *Resources +} + +// ExecuteHibernateRequest - The ExecuteHibernateRequest request for executeHibernate operations +type ExecuteHibernateRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The execution parameters for the request + ExecutionParameters *ExecutionParameters + + // REQUIRED; The resources for the request + Resources *Resources +} + +// ExecuteStartRequest - The ExecuteStartRequest request for executeStart operations +type ExecuteStartRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The execution parameters for the request + ExecutionParameters *ExecutionParameters + + // REQUIRED; The resources for the request + Resources *Resources +} + +// ExecutionParameters - Extra details needed to run the user's request +type ExecutionParameters struct { + // Details that could optimize the user's request + OptimizationPreference *OptimizationPreference + + // Retry policy the user can pass + RetryPolicy *RetryPolicy +} + +// GetOperationErrorsRequest - This is the request to get errors per vm operations +type GetOperationErrorsRequest struct { + // REQUIRED; The list of operation ids to query errors of + OperationIDs []*string +} + +// GetOperationErrorsResponse - This is the response from a get operations errors request +type GetOperationErrorsResponse struct { + // REQUIRED; An array of operationids and their corresponding errors if any + Results []*OperationErrorsResult +} + +// GetOperationStatusRequest - This is the request to get operation status using operationids +type GetOperationStatusRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The list of operation ids to get the status of + OperationIDs []*string +} + +// GetOperationStatusResponse - This is the response from a get operations status request +type GetOperationStatusResponse struct { + // REQUIRED; An array of resource operations based on their operation ids + Results []*ResourceOperation +} + +// HibernateResourceOperationResponse - The response from a Hibernate request +type HibernateResourceOperationResponse struct { + // REQUIRED; The description of the operation response + Description *string + + // REQUIRED; The location of the Hibernate request eg westus + Location *string + + // REQUIRED; The type of resources used in the Hibernate request eg virtual machines + Type *string + + // The results from the Hibernate request if no errors exist + Results []*ResourceOperation +} + +// 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 +} + +// OperationErrorDetails - This defines a list of operation errors associated with a unique operationId +type OperationErrorDetails struct { + // REQUIRED; CRP operationid of the operation for deeper analysis + CrpOperationID *string + + // REQUIRED; The error code of the operation + ErrorCode *string + + // REQUIRED; The error details of the operation + ErrorDetails *time.Time + + // REQUIRED; The timestamp of the error occurence + TimeStamp *time.Time +} + +// OperationErrorsResult - This is the first level of operation errors from the request when clients get errors per vm operation +type OperationErrorsResult struct { + // The activation time of a vm operation + ActivationTime *time.Time + + // The completion time of the operation if the operation was completed + CompletedAt *time.Time + + // The creation time of the error result + CreationTime *time.Time + + // A list of errors associated with the operationid + OperationErrors []*OperationErrorDetails + + // The operationId identifying a vm operation + OperationID *string + + // Request level error code + RequestErrorCode *string + + // Request level error details + RequestErrorDetails *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 +} + +// ResourceOperation - High level response from an operation on a resource +type ResourceOperation struct { + // Resource level error code if it exists + ErrorCode *string + + // Resource level error details if they exist + ErrorDetails *string + + // Details of the operation performed on a resource + Operation *ResourceOperationDetails + + // Unique identifier for the resource involved in the operation, eg ArmId + ResourceID *string +} + +// ResourceOperationDetails - The details of a response from an operation on a resource +type ResourceOperationDetails struct { + // REQUIRED; Deadline for the operation + Deadline *time.Time + + // REQUIRED; Type of deadline of the operation + DeadlineType *DeadlineType + + // REQUIRED; Type of operation performed on the resources + OpType *ResourceOperationType + + // REQUIRED; Operation identifier for the unique operation + OperationID *string + + // REQUIRED; Unique identifier for the resource involved in the operation, eg ArmId + ResourceID *string + + // REQUIRED; Current state of the operation + State *OperationState + + // REQUIRED; Subscription id attached to the request + SubscriptionID *string + + // Time the operation was complete if errors are null + CompletedAt *time.Time + + // Operation level errors if they exist + ResourceOperationError *ResourceOperationError + + // Retry policy the user can pass + RetryPolicy *RetryPolicy + + // Timezone for the operation + TimeZone *string +} + +// ResourceOperationError - These describe errors that occur at the resource level +type ResourceOperationError struct { + // REQUIRED; Code for the error eg 404, 500 + ErrorCode *string + + // REQUIRED; Detailed message about the error + ErrorDetails *string +} + +// Resources - The resources needed for the user request +type Resources struct { + // REQUIRED; The resource ids used for the request + IDs []*string +} + +// RetryPolicy - The retry policy for the user request +type RetryPolicy struct { + // Retry count for user request + RetryCount *int32 + + // Retry window in minutes for user request + RetryWindowInMinutes *int32 +} + +// Schedule - The schedule details for the user request +type Schedule struct { + // REQUIRED; The deadline for the operation + DeadLine *time.Time + + // REQUIRED; The deadlinetype of the operation, this can either be InitiateAt or CompleteBy + DeadlineType *DeadlineType + + // REQUIRED; The timezone for the operation + TimeZone *string +} + +// StartResourceOperationResponse - The response from a start request +type StartResourceOperationResponse struct { + // REQUIRED; The description of the operation response + Description *string + + // REQUIRED; The location of the start request eg westus + Location *string + + // REQUIRED; The type of resources used in the start request eg virtual machines + Type *string + + // The results from the start request if no errors exist + Results []*ResourceOperation +} + +// SubmitDeallocateRequest - The deallocate request for resources +type SubmitDeallocateRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The execution parameters for the request + ExecutionParameters *ExecutionParameters + + // REQUIRED; The resources for the request + Resources *Resources + + // REQUIRED; The schedule for the request + Schedule *Schedule +} + +// SubmitHibernateRequest - This is the request for hibernate +type SubmitHibernateRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The execution parameters for the request + ExecutionParameters *ExecutionParameters + + // REQUIRED; The resources for the request + Resources *Resources + + // REQUIRED; The schedule for the request + Schedule *Schedule +} + +// SubmitStartRequest - This is the request for start +type SubmitStartRequest struct { + // REQUIRED; Correlationid item + Correlationid *string + + // REQUIRED; The execution parameters for the request + ExecutionParameters *ExecutionParameters + + // REQUIRED; The resources for the request + Resources *Resources + + // REQUIRED; The schedule for the request + Schedule *Schedule +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/models_serde.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/models_serde.go new file mode 100644 index 000000000000..c55c4955f270 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/models_serde.go @@ -0,0 +1,1009 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CancelOperationsRequest. +func (c CancelOperationsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", c.Correlationid) + populate(objectMap, "operationIds", c.OperationIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CancelOperationsRequest. +func (c *CancelOperationsRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &c.Correlationid) + delete(rawMsg, key) + case "operationIds": + err = unpopulate(val, "OperationIDs", &c.OperationIDs) + 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 CancelOperationsResponse. +func (c CancelOperationsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "results", c.Results) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CancelOperationsResponse. +func (c *CancelOperationsResponse) 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 "results": + err = unpopulate(val, "Results", &c.Results) + 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 DeallocateResourceOperationResponse. +func (d DeallocateResourceOperationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", d.Description) + populate(objectMap, "location", d.Location) + populate(objectMap, "results", d.Results) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeallocateResourceOperationResponse. +func (d *DeallocateResourceOperationResponse) 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 "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "results": + err = unpopulate(val, "Results", &d.Results) + 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 ExecuteDeallocateRequest. +func (e ExecuteDeallocateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", e.Correlationid) + populate(objectMap, "executionParameters", e.ExecutionParameters) + populate(objectMap, "resources", e.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExecuteDeallocateRequest. +func (e *ExecuteDeallocateRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &e.Correlationid) + delete(rawMsg, key) + case "executionParameters": + err = unpopulate(val, "ExecutionParameters", &e.ExecutionParameters) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &e.Resources) + 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 ExecuteHibernateRequest. +func (e ExecuteHibernateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", e.Correlationid) + populate(objectMap, "executionParameters", e.ExecutionParameters) + populate(objectMap, "resources", e.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExecuteHibernateRequest. +func (e *ExecuteHibernateRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &e.Correlationid) + delete(rawMsg, key) + case "executionParameters": + err = unpopulate(val, "ExecutionParameters", &e.ExecutionParameters) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &e.Resources) + 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 ExecuteStartRequest. +func (e ExecuteStartRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", e.Correlationid) + populate(objectMap, "executionParameters", e.ExecutionParameters) + populate(objectMap, "resources", e.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExecuteStartRequest. +func (e *ExecuteStartRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &e.Correlationid) + delete(rawMsg, key) + case "executionParameters": + err = unpopulate(val, "ExecutionParameters", &e.ExecutionParameters) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &e.Resources) + 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 ExecutionParameters. +func (e ExecutionParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "optimizationPreference", e.OptimizationPreference) + populate(objectMap, "retryPolicy", e.RetryPolicy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExecutionParameters. +func (e *ExecutionParameters) 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 "optimizationPreference": + err = unpopulate(val, "OptimizationPreference", &e.OptimizationPreference) + delete(rawMsg, key) + case "retryPolicy": + err = unpopulate(val, "RetryPolicy", &e.RetryPolicy) + 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 GetOperationErrorsRequest. +func (g GetOperationErrorsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operationIds", g.OperationIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetOperationErrorsRequest. +func (g *GetOperationErrorsRequest) 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 "operationIds": + err = unpopulate(val, "OperationIDs", &g.OperationIDs) + 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 GetOperationErrorsResponse. +func (g GetOperationErrorsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "results", g.Results) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetOperationErrorsResponse. +func (g *GetOperationErrorsResponse) 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 "results": + err = unpopulate(val, "Results", &g.Results) + 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 GetOperationStatusRequest. +func (g GetOperationStatusRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", g.Correlationid) + populate(objectMap, "operationIds", g.OperationIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetOperationStatusRequest. +func (g *GetOperationStatusRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &g.Correlationid) + delete(rawMsg, key) + case "operationIds": + err = unpopulate(val, "OperationIDs", &g.OperationIDs) + 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 GetOperationStatusResponse. +func (g GetOperationStatusResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "results", g.Results) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetOperationStatusResponse. +func (g *GetOperationStatusResponse) 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 "results": + err = unpopulate(val, "Results", &g.Results) + 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 HibernateResourceOperationResponse. +func (h HibernateResourceOperationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", h.Description) + populate(objectMap, "location", h.Location) + populate(objectMap, "results", h.Results) + populate(objectMap, "type", h.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HibernateResourceOperationResponse. +func (h *HibernateResourceOperationResponse) 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 "description": + err = unpopulate(val, "Description", &h.Description) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &h.Location) + delete(rawMsg, key) + case "results": + err = unpopulate(val, "Results", &h.Results) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &h.Type) + 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 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 OperationErrorDetails. +func (o OperationErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "crpOperationId", o.CrpOperationID) + populate(objectMap, "errorCode", o.ErrorCode) + populateDateTimeRFC3339(objectMap, "errorDetails", o.ErrorDetails) + populateDateTimeRFC3339(objectMap, "timeStamp", o.TimeStamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationErrorDetails. +func (o *OperationErrorDetails) 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 "crpOperationId": + err = unpopulate(val, "CrpOperationID", &o.CrpOperationID) + delete(rawMsg, key) + case "errorCode": + err = unpopulate(val, "ErrorCode", &o.ErrorCode) + delete(rawMsg, key) + case "errorDetails": + err = unpopulateDateTimeRFC3339(val, "ErrorDetails", &o.ErrorDetails) + delete(rawMsg, key) + case "timeStamp": + err = unpopulateDateTimeRFC3339(val, "TimeStamp", &o.TimeStamp) + 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 OperationErrorsResult. +func (o OperationErrorsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "activationTime", o.ActivationTime) + populateDateTimeRFC3339(objectMap, "completedAt", o.CompletedAt) + populateDateTimeRFC3339(objectMap, "creationTime", o.CreationTime) + populate(objectMap, "operationErrors", o.OperationErrors) + populate(objectMap, "operationId", o.OperationID) + populate(objectMap, "requestErrorCode", o.RequestErrorCode) + populate(objectMap, "requestErrorDetails", o.RequestErrorDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationErrorsResult. +func (o *OperationErrorsResult) 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 "activationTime": + err = unpopulateDateTimeRFC3339(val, "ActivationTime", &o.ActivationTime) + delete(rawMsg, key) + case "completedAt": + err = unpopulateDateTimeRFC3339(val, "CompletedAt", &o.CompletedAt) + delete(rawMsg, key) + case "creationTime": + err = unpopulateDateTimeRFC3339(val, "CreationTime", &o.CreationTime) + delete(rawMsg, key) + case "operationErrors": + err = unpopulate(val, "OperationErrors", &o.OperationErrors) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &o.OperationID) + delete(rawMsg, key) + case "requestErrorCode": + err = unpopulate(val, "RequestErrorCode", &o.RequestErrorCode) + delete(rawMsg, key) + case "requestErrorDetails": + err = unpopulate(val, "RequestErrorDetails", &o.RequestErrorDetails) + 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 ResourceOperation. +func (r ResourceOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "errorCode", r.ErrorCode) + populate(objectMap, "errorDetails", r.ErrorDetails) + populate(objectMap, "operation", r.Operation) + populate(objectMap, "resourceId", r.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceOperation. +func (r *ResourceOperation) 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 "errorCode": + err = unpopulate(val, "ErrorCode", &r.ErrorCode) + delete(rawMsg, key) + case "errorDetails": + err = unpopulate(val, "ErrorDetails", &r.ErrorDetails) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &r.Operation) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &r.ResourceID) + 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 ResourceOperationDetails. +func (r ResourceOperationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "completedAt", r.CompletedAt) + populateDateTimeRFC3339(objectMap, "deadline", r.Deadline) + populate(objectMap, "deadlineType", r.DeadlineType) + populate(objectMap, "opType", r.OpType) + populate(objectMap, "operationId", r.OperationID) + populate(objectMap, "resourceId", r.ResourceID) + populate(objectMap, "resourceOperationError", r.ResourceOperationError) + populate(objectMap, "retryPolicy", r.RetryPolicy) + populate(objectMap, "state", r.State) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "timeZone", r.TimeZone) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceOperationDetails. +func (r *ResourceOperationDetails) 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 "completedAt": + err = unpopulateDateTimeRFC3339(val, "CompletedAt", &r.CompletedAt) + delete(rawMsg, key) + case "deadline": + err = unpopulateDateTimeRFC3339(val, "Deadline", &r.Deadline) + delete(rawMsg, key) + case "deadlineType": + err = unpopulate(val, "DeadlineType", &r.DeadlineType) + delete(rawMsg, key) + case "opType": + err = unpopulate(val, "OpType", &r.OpType) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &r.OperationID) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &r.ResourceID) + delete(rawMsg, key) + case "resourceOperationError": + err = unpopulate(val, "ResourceOperationError", &r.ResourceOperationError) + delete(rawMsg, key) + case "retryPolicy": + err = unpopulate(val, "RetryPolicy", &r.RetryPolicy) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &r.State) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &r.SubscriptionID) + delete(rawMsg, key) + case "timeZone": + err = unpopulate(val, "TimeZone", &r.TimeZone) + 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 ResourceOperationError. +func (r ResourceOperationError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "errorCode", r.ErrorCode) + populate(objectMap, "errorDetails", r.ErrorDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceOperationError. +func (r *ResourceOperationError) 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 "errorCode": + err = unpopulate(val, "ErrorCode", &r.ErrorCode) + delete(rawMsg, key) + case "errorDetails": + err = unpopulate(val, "ErrorDetails", &r.ErrorDetails) + 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 Resources. +func (r Resources) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ids", r.IDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resources. +func (r *Resources) 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 "ids": + err = unpopulate(val, "IDs", &r.IDs) + 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 RetryPolicy. +func (r RetryPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "retryCount", r.RetryCount) + populate(objectMap, "retryWindowInMinutes", r.RetryWindowInMinutes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RetryPolicy. +func (r *RetryPolicy) 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 "retryCount": + err = unpopulate(val, "RetryCount", &r.RetryCount) + delete(rawMsg, key) + case "retryWindowInMinutes": + err = unpopulate(val, "RetryWindowInMinutes", &r.RetryWindowInMinutes) + 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 Schedule. +func (s Schedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "deadLine", s.DeadLine) + populate(objectMap, "deadlineType", s.DeadlineType) + populate(objectMap, "timeZone", s.TimeZone) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Schedule. +func (s *Schedule) 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 "deadLine": + err = unpopulateDateTimeRFC3339(val, "DeadLine", &s.DeadLine) + delete(rawMsg, key) + case "deadlineType": + err = unpopulate(val, "DeadlineType", &s.DeadlineType) + delete(rawMsg, key) + case "timeZone": + err = unpopulate(val, "TimeZone", &s.TimeZone) + 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 StartResourceOperationResponse. +func (s StartResourceOperationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", s.Description) + populate(objectMap, "location", s.Location) + populate(objectMap, "results", s.Results) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StartResourceOperationResponse. +func (s *StartResourceOperationResponse) 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 "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "results": + err = unpopulate(val, "Results", &s.Results) + 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 SubmitDeallocateRequest. +func (s SubmitDeallocateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", s.Correlationid) + populate(objectMap, "executionParameters", s.ExecutionParameters) + populate(objectMap, "resources", s.Resources) + populate(objectMap, "schedule", s.Schedule) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubmitDeallocateRequest. +func (s *SubmitDeallocateRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &s.Correlationid) + delete(rawMsg, key) + case "executionParameters": + err = unpopulate(val, "ExecutionParameters", &s.ExecutionParameters) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &s.Resources) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, "Schedule", &s.Schedule) + 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 SubmitHibernateRequest. +func (s SubmitHibernateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", s.Correlationid) + populate(objectMap, "executionParameters", s.ExecutionParameters) + populate(objectMap, "resources", s.Resources) + populate(objectMap, "schedule", s.Schedule) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubmitHibernateRequest. +func (s *SubmitHibernateRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &s.Correlationid) + delete(rawMsg, key) + case "executionParameters": + err = unpopulate(val, "ExecutionParameters", &s.ExecutionParameters) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &s.Resources) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, "Schedule", &s.Schedule) + 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 SubmitStartRequest. +func (s SubmitStartRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationid", s.Correlationid) + populate(objectMap, "executionParameters", s.ExecutionParameters) + populate(objectMap, "resources", s.Resources) + populate(objectMap, "schedule", s.Schedule) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubmitStartRequest. +func (s *SubmitStartRequest) 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 "correlationid": + err = unpopulate(val, "Correlationid", &s.Correlationid) + delete(rawMsg, key) + case "executionParameters": + err = unpopulate(val, "ExecutionParameters", &s.ExecutionParameters) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &s.Resources) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, "Schedule", &s.Schedule) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + 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 any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/operations_client.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/operations_client.go new file mode 100644 index 000000000000..eb20a5fc8271 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + 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. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2024-08-15-preview +// - 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 { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ComputeSchedule/operations" + 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", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/options.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/options.go new file mode 100644 index 000000000000..74458d76ce84 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/options.go @@ -0,0 +1,68 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesCancelOperationsOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesCancelOperations +// method. +type ScheduledActionsClientVirtualMachinesCancelOperationsOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteDeallocate +// method. +type ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesExecuteHibernateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteHibernate +// method. +type ScheduledActionsClientVirtualMachinesExecuteHibernateOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesExecuteStartOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteStart +// method. +type ScheduledActionsClientVirtualMachinesExecuteStartOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesGetOperationErrors +// method. +type ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesGetOperationStatusOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesGetOperationStatus +// method. +type ScheduledActionsClientVirtualMachinesGetOperationStatusOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitDeallocate +// method. +type ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesSubmitHibernateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitHibernate +// method. +type ScheduledActionsClientVirtualMachinesSubmitHibernateOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientVirtualMachinesSubmitStartOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitStart +// method. +type ScheduledActionsClientVirtualMachinesSubmitStartOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/responses.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/responses.go new file mode 100644 index 000000000000..4f24350bc7d9 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/responses.go @@ -0,0 +1,69 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +// 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 +} + +// ScheduledActionsClientVirtualMachinesCancelOperationsResponse contains the response from method ScheduledActionsClient.VirtualMachinesCancelOperations. +type ScheduledActionsClientVirtualMachinesCancelOperationsResponse struct { + // This is the response from a cancel operations request + CancelOperationsResponse +} + +// ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse contains the response from method ScheduledActionsClient.VirtualMachinesExecuteDeallocate. +type ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse struct { + // The response from a deallocate request + DeallocateResourceOperationResponse +} + +// ScheduledActionsClientVirtualMachinesExecuteHibernateResponse contains the response from method ScheduledActionsClient.VirtualMachinesExecuteHibernate. +type ScheduledActionsClientVirtualMachinesExecuteHibernateResponse struct { + // The response from a Hibernate request + HibernateResourceOperationResponse +} + +// ScheduledActionsClientVirtualMachinesExecuteStartResponse contains the response from method ScheduledActionsClient.VirtualMachinesExecuteStart. +type ScheduledActionsClientVirtualMachinesExecuteStartResponse struct { + // The response from a start request + StartResourceOperationResponse +} + +// ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse contains the response from method ScheduledActionsClient.VirtualMachinesGetOperationErrors. +type ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse struct { + // This is the response from a get operations errors request + GetOperationErrorsResponse +} + +// ScheduledActionsClientVirtualMachinesGetOperationStatusResponse contains the response from method ScheduledActionsClient.VirtualMachinesGetOperationStatus. +type ScheduledActionsClientVirtualMachinesGetOperationStatusResponse struct { + // This is the response from a get operations status request + GetOperationStatusResponse +} + +// ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse contains the response from method ScheduledActionsClient.VirtualMachinesSubmitDeallocate. +type ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse struct { + // The response from a deallocate request + DeallocateResourceOperationResponse +} + +// ScheduledActionsClientVirtualMachinesSubmitHibernateResponse contains the response from method ScheduledActionsClient.VirtualMachinesSubmitHibernate. +type ScheduledActionsClientVirtualMachinesSubmitHibernateResponse struct { + // The response from a Hibernate request + HibernateResourceOperationResponse +} + +// ScheduledActionsClientVirtualMachinesSubmitStartResponse contains the response from method ScheduledActionsClient.VirtualMachinesSubmitStart. +type ScheduledActionsClientVirtualMachinesSubmitStartResponse struct { + // The response from a start request + StartResourceOperationResponse +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/scheduledactions_client.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/scheduledactions_client.go new file mode 100644 index 000000000000..8e18116fac53 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/scheduledactions_client.go @@ -0,0 +1,621 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +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" +) + +// ScheduledActionsClient contains the methods for the ScheduledActions group. +// Don't use this type directly, use NewScheduledActionsClient() instead. +type ScheduledActionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewScheduledActionsClient creates a new instance of ScheduledActionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewScheduledActionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ScheduledActionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ScheduledActionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// VirtualMachinesCancelOperations - virtualMachinesCancelOperations: cancelOperations for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesCancelOperationsOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesCancelOperations +// method. +func (client *ScheduledActionsClient) VirtualMachinesCancelOperations(ctx context.Context, locationparameter string, requestBody CancelOperationsRequest, options *ScheduledActionsClientVirtualMachinesCancelOperationsOptions) (ScheduledActionsClientVirtualMachinesCancelOperationsResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesCancelOperations" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesCancelOperationsCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, err + } + resp, err := client.virtualMachinesCancelOperationsHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesCancelOperationsCreateRequest creates the VirtualMachinesCancelOperations request. +func (client *ScheduledActionsClient) virtualMachinesCancelOperationsCreateRequest(ctx context.Context, locationparameter string, requestBody CancelOperationsRequest, options *ScheduledActionsClientVirtualMachinesCancelOperationsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesCancelOperations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesCancelOperationsHandleResponse handles the VirtualMachinesCancelOperations response. +func (client *ScheduledActionsClient) virtualMachinesCancelOperationsHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesCancelOperationsResponse, error) { + result := ScheduledActionsClientVirtualMachinesCancelOperationsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CancelOperationsResponse); err != nil { + return ScheduledActionsClientVirtualMachinesCancelOperationsResponse{}, err + } + return result, nil +} + +// VirtualMachinesExecuteDeallocate - virtualMachinesExecuteDeallocate: executeDeallocate for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteDeallocate +// method. +func (client *ScheduledActionsClient) VirtualMachinesExecuteDeallocate(ctx context.Context, locationparameter string, requestBody ExecuteDeallocateRequest, options *ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions) (ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesExecuteDeallocate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesExecuteDeallocateCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, err + } + resp, err := client.virtualMachinesExecuteDeallocateHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesExecuteDeallocateCreateRequest creates the VirtualMachinesExecuteDeallocate request. +func (client *ScheduledActionsClient) virtualMachinesExecuteDeallocateCreateRequest(ctx context.Context, locationparameter string, requestBody ExecuteDeallocateRequest, options *ScheduledActionsClientVirtualMachinesExecuteDeallocateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteDeallocate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesExecuteDeallocateHandleResponse handles the VirtualMachinesExecuteDeallocate response. +func (client *ScheduledActionsClient) virtualMachinesExecuteDeallocateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse, error) { + result := ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeallocateResourceOperationResponse); err != nil { + return ScheduledActionsClientVirtualMachinesExecuteDeallocateResponse{}, err + } + return result, nil +} + +// VirtualMachinesExecuteHibernate - virtualMachinesExecuteHibernate: executeHibernate for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesExecuteHibernateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteHibernate +// method. +func (client *ScheduledActionsClient) VirtualMachinesExecuteHibernate(ctx context.Context, locationparameter string, requestBody ExecuteHibernateRequest, options *ScheduledActionsClientVirtualMachinesExecuteHibernateOptions) (ScheduledActionsClientVirtualMachinesExecuteHibernateResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesExecuteHibernate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesExecuteHibernateCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, err + } + resp, err := client.virtualMachinesExecuteHibernateHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesExecuteHibernateCreateRequest creates the VirtualMachinesExecuteHibernate request. +func (client *ScheduledActionsClient) virtualMachinesExecuteHibernateCreateRequest(ctx context.Context, locationparameter string, requestBody ExecuteHibernateRequest, options *ScheduledActionsClientVirtualMachinesExecuteHibernateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteHibernate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesExecuteHibernateHandleResponse handles the VirtualMachinesExecuteHibernate response. +func (client *ScheduledActionsClient) virtualMachinesExecuteHibernateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesExecuteHibernateResponse, error) { + result := ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HibernateResourceOperationResponse); err != nil { + return ScheduledActionsClientVirtualMachinesExecuteHibernateResponse{}, err + } + return result, nil +} + +// VirtualMachinesExecuteStart - virtualMachinesExecuteStart: executeStart for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesExecuteStartOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesExecuteStart +// method. +func (client *ScheduledActionsClient) VirtualMachinesExecuteStart(ctx context.Context, locationparameter string, requestBody ExecuteStartRequest, options *ScheduledActionsClientVirtualMachinesExecuteStartOptions) (ScheduledActionsClientVirtualMachinesExecuteStartResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesExecuteStart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesExecuteStartCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesExecuteStartResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesExecuteStartResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesExecuteStartResponse{}, err + } + resp, err := client.virtualMachinesExecuteStartHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesExecuteStartCreateRequest creates the VirtualMachinesExecuteStart request. +func (client *ScheduledActionsClient) virtualMachinesExecuteStartCreateRequest(ctx context.Context, locationparameter string, requestBody ExecuteStartRequest, options *ScheduledActionsClientVirtualMachinesExecuteStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteStart" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesExecuteStartHandleResponse handles the VirtualMachinesExecuteStart response. +func (client *ScheduledActionsClient) virtualMachinesExecuteStartHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesExecuteStartResponse, error) { + result := ScheduledActionsClientVirtualMachinesExecuteStartResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StartResourceOperationResponse); err != nil { + return ScheduledActionsClientVirtualMachinesExecuteStartResponse{}, err + } + return result, nil +} + +// VirtualMachinesGetOperationErrors - virtualMachinesGetOperationErrors: getOperationErrors associated with an operation +// on a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesGetOperationErrors +// method. +func (client *ScheduledActionsClient) VirtualMachinesGetOperationErrors(ctx context.Context, locationparameter string, requestBody GetOperationErrorsRequest, options *ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions) (ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesGetOperationErrors" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesGetOperationErrorsCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, err + } + resp, err := client.virtualMachinesGetOperationErrorsHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesGetOperationErrorsCreateRequest creates the VirtualMachinesGetOperationErrors request. +func (client *ScheduledActionsClient) virtualMachinesGetOperationErrorsCreateRequest(ctx context.Context, locationparameter string, requestBody GetOperationErrorsRequest, options *ScheduledActionsClientVirtualMachinesGetOperationErrorsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationErrors" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesGetOperationErrorsHandleResponse handles the VirtualMachinesGetOperationErrors response. +func (client *ScheduledActionsClient) virtualMachinesGetOperationErrorsHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse, error) { + result := ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GetOperationErrorsResponse); err != nil { + return ScheduledActionsClientVirtualMachinesGetOperationErrorsResponse{}, err + } + return result, nil +} + +// VirtualMachinesGetOperationStatus - virtualMachinesGetOperationStatus: getOperationStatus for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesGetOperationStatusOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesGetOperationStatus +// method. +func (client *ScheduledActionsClient) VirtualMachinesGetOperationStatus(ctx context.Context, locationparameter string, requestBody GetOperationStatusRequest, options *ScheduledActionsClientVirtualMachinesGetOperationStatusOptions) (ScheduledActionsClientVirtualMachinesGetOperationStatusResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesGetOperationStatus" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesGetOperationStatusCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{}, err + } + resp, err := client.virtualMachinesGetOperationStatusHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesGetOperationStatusCreateRequest creates the VirtualMachinesGetOperationStatus request. +func (client *ScheduledActionsClient) virtualMachinesGetOperationStatusCreateRequest(ctx context.Context, locationparameter string, requestBody GetOperationStatusRequest, options *ScheduledActionsClientVirtualMachinesGetOperationStatusOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationStatus" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesGetOperationStatusHandleResponse handles the VirtualMachinesGetOperationStatus response. +func (client *ScheduledActionsClient) virtualMachinesGetOperationStatusHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesGetOperationStatusResponse, error) { + result := ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GetOperationStatusResponse); err != nil { + return ScheduledActionsClientVirtualMachinesGetOperationStatusResponse{}, err + } + return result, nil +} + +// VirtualMachinesSubmitDeallocate - virtualMachinesSubmitDeallocate: submitDeallocate for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitDeallocate +// method. +func (client *ScheduledActionsClient) VirtualMachinesSubmitDeallocate(ctx context.Context, locationparameter string, requestBody SubmitDeallocateRequest, options *ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions) (ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesSubmitDeallocate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesSubmitDeallocateCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err + } + resp, err := client.virtualMachinesSubmitDeallocateHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesSubmitDeallocateCreateRequest creates the VirtualMachinesSubmitDeallocate request. +func (client *ScheduledActionsClient) virtualMachinesSubmitDeallocateCreateRequest(ctx context.Context, locationparameter string, requestBody SubmitDeallocateRequest, options *ScheduledActionsClientVirtualMachinesSubmitDeallocateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitDeallocate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesSubmitDeallocateHandleResponse handles the VirtualMachinesSubmitDeallocate response. +func (client *ScheduledActionsClient) virtualMachinesSubmitDeallocateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse, error) { + result := ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeallocateResourceOperationResponse); err != nil { + return ScheduledActionsClientVirtualMachinesSubmitDeallocateResponse{}, err + } + return result, nil +} + +// VirtualMachinesSubmitHibernate - virtualMachinesSubmitHibernate: submitHibernate for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesSubmitHibernateOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitHibernate +// method. +func (client *ScheduledActionsClient) VirtualMachinesSubmitHibernate(ctx context.Context, locationparameter string, requestBody SubmitHibernateRequest, options *ScheduledActionsClientVirtualMachinesSubmitHibernateOptions) (ScheduledActionsClientVirtualMachinesSubmitHibernateResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesSubmitHibernate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesSubmitHibernateCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err + } + resp, err := client.virtualMachinesSubmitHibernateHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesSubmitHibernateCreateRequest creates the VirtualMachinesSubmitHibernate request. +func (client *ScheduledActionsClient) virtualMachinesSubmitHibernateCreateRequest(ctx context.Context, locationparameter string, requestBody SubmitHibernateRequest, options *ScheduledActionsClientVirtualMachinesSubmitHibernateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitHibernate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesSubmitHibernateHandleResponse handles the VirtualMachinesSubmitHibernate response. +func (client *ScheduledActionsClient) virtualMachinesSubmitHibernateHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesSubmitHibernateResponse, error) { + result := ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HibernateResourceOperationResponse); err != nil { + return ScheduledActionsClientVirtualMachinesSubmitHibernateResponse{}, err + } + return result, nil +} + +// VirtualMachinesSubmitStart - virtualMachinesSubmitStart: submitStart for a virtual machine +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-15-preview +// - locationparameter - The location name. +// - requestBody - The request body +// - options - ScheduledActionsClientVirtualMachinesSubmitStartOptions contains the optional parameters for the ScheduledActionsClient.VirtualMachinesSubmitStart +// method. +func (client *ScheduledActionsClient) VirtualMachinesSubmitStart(ctx context.Context, locationparameter string, requestBody SubmitStartRequest, options *ScheduledActionsClientVirtualMachinesSubmitStartOptions) (ScheduledActionsClientVirtualMachinesSubmitStartResponse, error) { + var err error + const operationName = "ScheduledActionsClient.VirtualMachinesSubmitStart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.virtualMachinesSubmitStartCreateRequest(ctx, locationparameter, requestBody, options) + if err != nil { + return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err + } + resp, err := client.virtualMachinesSubmitStartHandleResponse(httpResp) + return resp, err +} + +// virtualMachinesSubmitStartCreateRequest creates the VirtualMachinesSubmitStart request. +func (client *ScheduledActionsClient) virtualMachinesSubmitStartCreateRequest(ctx context.Context, locationparameter string, requestBody SubmitStartRequest, options *ScheduledActionsClientVirtualMachinesSubmitStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitStart" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locationparameter == "" { + return nil, errors.New("parameter locationparameter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationparameter}", url.PathEscape(locationparameter)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-15-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, requestBody); err != nil { + return nil, err + } + return req, nil +} + +// virtualMachinesSubmitStartHandleResponse handles the VirtualMachinesSubmitStart response. +func (client *ScheduledActionsClient) virtualMachinesSubmitStartHandleResponse(resp *http.Response) (ScheduledActionsClientVirtualMachinesSubmitStartResponse, error) { + result := ScheduledActionsClientVirtualMachinesSubmitStartResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StartResourceOperationResponse); err != nil { + return ScheduledActionsClientVirtualMachinesSubmitStartResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/computeschedule/armcomputeschedule/time_rfc3339.go b/sdk/resourcemanager/computeschedule/armcomputeschedule/time_rfc3339.go new file mode 100644 index 000000000000..c69bdcbe0925 --- /dev/null +++ b/sdk/resourcemanager/computeschedule/armcomputeschedule/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcomputeschedule + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/CHANGELOG.md b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/CHANGELOG.md index 168cbc4d21a9..7f5689632af1 100644 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/CHANGELOG.md +++ b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2024-08-22) +### Other Changes + + ## 1.2.0 (2024-05-24) ### Features Added diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/autorest.md b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/autorest.md index 8cdb3b25b312..40f161a871c0 100644 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/autorest.md +++ b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 -tag: package-2024-04 +module-version: 1.2.1 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/constants.go b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/constants.go index 5d447b55d731..92d0a524e59f 100644 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/constants.go +++ b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/constants.go @@ -10,7 +10,7 @@ package armcontainerservicefleet const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetmembers_client_example_test.go b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetmembers_client_example_test.go deleted file mode 100644 index 90f3191a97fe..000000000000 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetmembers_client_example_test.go +++ /dev/null @@ -1,219 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armcontainerservicefleet_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/FleetMembers_ListByFleet.json -func ExampleFleetMembersClient_NewListByFleetPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFleetMembersClient().NewListByFleetPager("rg1", "fleet1", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.FleetMemberListResult = armcontainerservicefleet.FleetMemberListResult{ - // Value: []*armcontainerservicefleet.FleetMember{ - // { - // Name: to.Ptr("member-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/members"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1/members/member-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("kd30rkdfo49="), - // Properties: &armcontainerservicefleet.FleetMemberProperties{ - // ClusterResourceID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster-1"), - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetMemberProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/FleetMembers_Get.json -func ExampleFleetMembersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFleetMembersClient().Get(ctx, "rg1", "fleet1", "member-1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FleetMember = armcontainerservicefleet.FleetMember{ - // Name: to.Ptr("member-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/members"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1/members/member-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("kd30rkdfo49="), - // Properties: &armcontainerservicefleet.FleetMemberProperties{ - // ClusterResourceID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster-1"), - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetMemberProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/FleetMembers_Create.json -func ExampleFleetMembersClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetMembersClient().BeginCreate(ctx, "rg1", "fleet1", "member-1", armcontainerservicefleet.FleetMember{ - Properties: &armcontainerservicefleet.FleetMemberProperties{ - ClusterResourceID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster-1"), - }, - }, &armcontainerservicefleet.FleetMembersClientBeginCreateOptions{IfMatch: nil, - IfNoneMatch: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FleetMember = armcontainerservicefleet.FleetMember{ - // Name: to.Ptr("member-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/members"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1/members/member-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("23ujdflewrj3="), - // Properties: &armcontainerservicefleet.FleetMemberProperties{ - // ClusterResourceID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster-1"), - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetMemberProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/FleetMembers_Update.json -func ExampleFleetMembersClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetMembersClient().BeginUpdate(ctx, "rg1", "fleet1", "member-1", armcontainerservicefleet.FleetMemberUpdate{ - Properties: &armcontainerservicefleet.FleetMemberUpdateProperties{ - Group: to.Ptr("staging"), - }, - }, &armcontainerservicefleet.FleetMembersClientBeginUpdateOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FleetMember = armcontainerservicefleet.FleetMember{ - // Name: to.Ptr("member-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/members"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1/members/member-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("23ujdflewrj3="), - // Properties: &armcontainerservicefleet.FleetMemberProperties{ - // ClusterResourceID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster-1"), - // Group: to.Ptr("staging"), - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetMemberProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/FleetMembers_Delete.json -func ExampleFleetMembersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetMembersClient().BeginDelete(ctx, "rg1", "fleet1", "member-1", &armcontainerservicefleet.FleetMembersClientBeginDeleteOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleets_client_example_test.go b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleets_client_example_test.go deleted file mode 100644 index 8f62cc00bde2..000000000000 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleets_client_example_test.go +++ /dev/null @@ -1,367 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armcontainerservicefleet_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Fleets_ListBySub.json -func ExampleFleetsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFleetsClient().NewListBySubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.FleetListResult = armcontainerservicefleet.FleetListResult{ - // Value: []*armcontainerservicefleet.Fleet{ - // { - // Name: to.Ptr("fleet-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "archv2": to.Ptr(""), - // "tier": to.Ptr("production"), - // }, - // ETag: to.Ptr("23ujdflewrj3="), - // Properties: &armcontainerservicefleet.FleetProperties{ - // HubProfile: &armcontainerservicefleet.FleetHubProfile{ - // AgentProfile: &armcontainerservicefleet.AgentProfile{ - // VMSize: to.Ptr("Standard_DS1"), - // }, - // DNSPrefix: to.Ptr("dnsprefix1"), - // Fqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // KubernetesVersion: to.Ptr("1.22.4"), - // PortalFqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Fleets_ListByResourceGroup.json -func ExampleFleetsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFleetsClient().NewListByResourceGroupPager("rg1", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.FleetListResult = armcontainerservicefleet.FleetListResult{ - // Value: []*armcontainerservicefleet.Fleet{ - // { - // Name: to.Ptr("fleet1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "archv2": to.Ptr(""), - // "tier": to.Ptr("production"), - // }, - // ETag: to.Ptr("23ujdflewrj3="), - // Properties: &armcontainerservicefleet.FleetProperties{ - // HubProfile: &armcontainerservicefleet.FleetHubProfile{ - // AgentProfile: &armcontainerservicefleet.AgentProfile{ - // VMSize: to.Ptr("Standard_DS1"), - // }, - // DNSPrefix: to.Ptr("dnsprefix1"), - // Fqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // KubernetesVersion: to.Ptr("1.22.4"), - // PortalFqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Fleets_Get.json -func ExampleFleetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFleetsClient().Get(ctx, "rg1", "fleet1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Fleet = armcontainerservicefleet.Fleet{ - // Name: to.Ptr("fleet-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "archv2": to.Ptr(""), - // "tier": to.Ptr("production"), - // }, - // ETag: to.Ptr("23ujdflewrj3="), - // Properties: &armcontainerservicefleet.FleetProperties{ - // HubProfile: &armcontainerservicefleet.FleetHubProfile{ - // AgentProfile: &armcontainerservicefleet.AgentProfile{ - // VMSize: to.Ptr("Standard_DS1"), - // }, - // DNSPrefix: to.Ptr("dnsprefix1"), - // Fqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // KubernetesVersion: to.Ptr("1.22.4"), - // PortalFqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Fleets_CreateOrUpdate.json -func ExampleFleetsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetsClient().BeginCreateOrUpdate(ctx, "rg1", "fleet1", armcontainerservicefleet.Fleet{ - Location: to.Ptr("East US"), - Tags: map[string]*string{ - "archv2": to.Ptr(""), - "tier": to.Ptr("production"), - }, - Properties: &armcontainerservicefleet.FleetProperties{ - HubProfile: &armcontainerservicefleet.FleetHubProfile{ - AgentProfile: &armcontainerservicefleet.AgentProfile{ - VMSize: to.Ptr("Standard_DS1"), - }, - DNSPrefix: to.Ptr("dnsprefix1"), - }, - }, - }, &armcontainerservicefleet.FleetsClientBeginCreateOrUpdateOptions{IfMatch: nil, - IfNoneMatch: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Fleet = armcontainerservicefleet.Fleet{ - // Name: to.Ptr("fleet-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "archv2": to.Ptr(""), - // "tier": to.Ptr("production"), - // }, - // ETag: to.Ptr("23ujdflewrj3="), - // Properties: &armcontainerservicefleet.FleetProperties{ - // HubProfile: &armcontainerservicefleet.FleetHubProfile{ - // AgentProfile: &armcontainerservicefleet.AgentProfile{ - // VMSize: to.Ptr("Standard_DS1"), - // }, - // DNSPrefix: to.Ptr("dnsprefix1"), - // Fqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // KubernetesVersion: to.Ptr("1.22.4"), - // PortalFqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Fleets_PatchTags.json -func ExampleFleetsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetsClient().BeginUpdate(ctx, "rg1", "fleet1", armcontainerservicefleet.FleetPatch{ - Tags: map[string]*string{ - "env": to.Ptr("prod"), - "tier": to.Ptr("secure"), - }, - }, &armcontainerservicefleet.FleetsClientBeginUpdateOptions{IfMatch: to.Ptr("dfjkwelr7384")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Fleet = armcontainerservicefleet.Fleet{ - // Name: to.Ptr("fleet-1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets"), - // ID: to.Ptr("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/fleets/fleet-1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // CreatedBy: to.Ptr("someUser"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-03-23T05:40:40.657Z"); return t}()), - // LastModifiedBy: to.Ptr("someOtherUser"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // Location: to.Ptr("East US"), - // Tags: map[string]*string{ - // "env": to.Ptr("prod"), - // "tier": to.Ptr("secure"), - // }, - // ETag: to.Ptr("23ujdflewrj3="), - // Properties: &armcontainerservicefleet.FleetProperties{ - // HubProfile: &armcontainerservicefleet.FleetHubProfile{ - // AgentProfile: &armcontainerservicefleet.AgentProfile{ - // VMSize: to.Ptr("Standard_DS1"), - // }, - // DNSPrefix: to.Ptr("dnsprefix1"), - // Fqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // KubernetesVersion: to.Ptr("1.22.4"), - // PortalFqdn: to.Ptr("dnsprefix1-abcd1234.flt.eastus.azmk8s.io"), - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Fleets_Delete.json -func ExampleFleetsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetsClient().BeginDelete(ctx, "rg1", "fleet1", &armcontainerservicefleet.FleetsClientBeginDeleteOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Fleets_ListCredentialsResult.json -func ExampleFleetsClient_ListCredentials() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFleetsClient().ListCredentials(ctx, "rg1", "fleet", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FleetCredentialResults = armcontainerservicefleet.FleetCredentialResults{ - // Kubeconfigs: []*armcontainerservicefleet.FleetCredentialResult{ - // { - // Name: to.Ptr("credentialName1"), - // Value: []byte("Y3JlZGVudGlhbFZhbHVlMQ=="), - // }}, - // } -} diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetupdatestrategies_client_example_test.go b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetupdatestrategies_client_example_test.go deleted file mode 100644 index e9b0baabd4dc..000000000000 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/fleetupdatestrategies_client_example_test.go +++ /dev/null @@ -1,212 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armcontainerservicefleet_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateStrategies_ListByFleet.json -func ExampleFleetUpdateStrategiesClient_NewListByFleetPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFleetUpdateStrategiesClient().NewListByFleetPager("rg1", "fleet1", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.FleetUpdateStrategyListResult = armcontainerservicefleet.FleetUpdateStrategyListResult{ - // Value: []*armcontainerservicefleet.FleetUpdateStrategy{ - // { - // Name: to.Ptr("strategy1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateStrategies"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.FleetUpdateStrategyProperties{ - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetUpdateStrategyProvisioningStateSucceeded), - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateStrategies_Get.json -func ExampleFleetUpdateStrategiesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFleetUpdateStrategiesClient().Get(ctx, "rg1", "fleet1", "strategy1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FleetUpdateStrategy = armcontainerservicefleet.FleetUpdateStrategy{ - // Name: to.Ptr("strategy1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateStrategies"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.FleetUpdateStrategyProperties{ - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetUpdateStrategyProvisioningStateSucceeded), - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateStrategies_CreateOrUpdate.json -func ExampleFleetUpdateStrategiesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetUpdateStrategiesClient().BeginCreateOrUpdate(ctx, "rg1", "fleet1", "strartegy1", armcontainerservicefleet.FleetUpdateStrategy{ - Properties: &armcontainerservicefleet.FleetUpdateStrategyProperties{ - Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - Stages: []*armcontainerservicefleet.UpdateStage{ - { - Name: to.Ptr("stage1"), - AfterStageWaitInSeconds: to.Ptr[int32](3600), - Groups: []*armcontainerservicefleet.UpdateGroup{ - { - Name: to.Ptr("group-a"), - }}, - }}, - }, - }, - }, &armcontainerservicefleet.FleetUpdateStrategiesClientBeginCreateOrUpdateOptions{IfMatch: nil, - IfNoneMatch: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FleetUpdateStrategy = armcontainerservicefleet.FleetUpdateStrategy{ - // Name: to.Ptr("strategy1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateStrategies"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.FleetUpdateStrategyProperties{ - // ProvisioningState: to.Ptr(armcontainerservicefleet.FleetUpdateStrategyProvisioningStateSucceeded), - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateStrategies_Delete.json -func ExampleFleetUpdateStrategiesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFleetUpdateStrategiesClient().BeginDelete(ctx, "rg1", "fleet1", "strategy1", &armcontainerservicefleet.FleetUpdateStrategiesClientBeginDeleteOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/go.mod b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/go.mod index 4fbee231ef93..a99d214e306e 100644 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/go.mod +++ b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/go.mod @@ -4,7 +4,6 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 @@ -12,6 +11,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/models.go b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/models.go index 2f5b42cf9063..aad23057ca37 100644 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/models.go +++ b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/models.go @@ -179,7 +179,7 @@ type FleetMemberProperties struct { // FleetMemberUpdate - The type used for update operations of the FleetMember. type FleetMemberUpdate struct { - // The updatable properties of the FleetMember. + // The resource-specific properties for this resource. Properties *FleetMemberUpdateProperties } diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/operations_client_example_test.go b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/operations_client_example_test.go deleted file mode 100644 index 904cfa948935..000000000000 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/operations_client_example_test.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armcontainerservicefleet_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armcontainerservicefleet.OperationListResult{ - // Value: []*armcontainerservicefleet.Operation{ - // { - // Name: to.Ptr("Microsoft.ContainerService/locations/operations/read"), - // Display: &armcontainerservicefleet.OperationDisplay{ - // Description: to.Ptr("Gets the status of an asynchronous operation"), - // Operation: to.Ptr("Get Operation"), - // Provider: to.Ptr("Microsoft Container Service"), - // Resource: to.Ptr("Operation"), - // }, - // Origin: to.Ptr(armcontainerservicefleet.OriginUserSystem), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/updateruns_client_example_test.go b/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/updateruns_client_example_test.go deleted file mode 100644 index a8a0a93fe0e5..000000000000 --- a/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet/updateruns_client_example_test.go +++ /dev/null @@ -1,668 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armcontainerservicefleet_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservicefleet/armcontainerservicefleet" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateRuns_ListByFleet.json -func ExampleUpdateRunsClient_NewListByFleetPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUpdateRunsClient().NewListByFleetPager("rg1", "fleet1", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UpdateRunListResult = armcontainerservicefleet.UpdateRunListResult{ - // Value: []*armcontainerservicefleet.UpdateRun{ - // { - // Name: to.Ptr("run1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateRuns"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateRuns/run1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.UpdateRunProperties{ - // ManagedClusterUpdate: &armcontainerservicefleet.ManagedClusterUpdate{ - // NodeImageSelection: &armcontainerservicefleet.NodeImageSelection{ - // Type: to.Ptr(armcontainerservicefleet.NodeImageSelectionTypeLatest), - // }, - // Upgrade: &armcontainerservicefleet.ManagedClusterUpgradeSpec{ - // Type: to.Ptr(armcontainerservicefleet.ManagedClusterUpgradeTypeFull), - // KubernetesVersion: to.Ptr("1.26.1"), - // }, - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.UpdateRunProvisioningStateSucceeded), - // Status: &armcontainerservicefleet.UpdateRunStatus{ - // Stages: []*armcontainerservicefleet.UpdateStageStatus{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitStatus: &armcontainerservicefleet.WaitStatus{ - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // WaitDurationInSeconds: to.Ptr[int32](3600), - // }, - // Groups: []*armcontainerservicefleet.UpdateGroupStatus{ - // { - // Name: to.Ptr("group-a"), - // Members: []*armcontainerservicefleet.MemberUpdateStatus{ - // { - // Name: to.Ptr("member-one"), - // ClusterResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myClusters/providers/Microsoft.ContainerService/managedClusters/myCluster"), - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }, - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateRuns_Get.json -func ExampleUpdateRunsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewUpdateRunsClient().Get(ctx, "rg1", "fleet1", "run1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UpdateRun = armcontainerservicefleet.UpdateRun{ - // Name: to.Ptr("run1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateRuns"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateRuns/run1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.UpdateRunProperties{ - // ManagedClusterUpdate: &armcontainerservicefleet.ManagedClusterUpdate{ - // NodeImageSelection: &armcontainerservicefleet.NodeImageSelection{ - // Type: to.Ptr(armcontainerservicefleet.NodeImageSelectionTypeLatest), - // }, - // Upgrade: &armcontainerservicefleet.ManagedClusterUpgradeSpec{ - // Type: to.Ptr(armcontainerservicefleet.ManagedClusterUpgradeTypeFull), - // KubernetesVersion: to.Ptr("1.26.1"), - // }, - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.UpdateRunProvisioningStateSucceeded), - // Status: &armcontainerservicefleet.UpdateRunStatus{ - // Stages: []*armcontainerservicefleet.UpdateStageStatus{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitStatus: &armcontainerservicefleet.WaitStatus{ - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // WaitDurationInSeconds: to.Ptr[int32](3600), - // }, - // Groups: []*armcontainerservicefleet.UpdateGroupStatus{ - // { - // Name: to.Ptr("group-a"), - // Members: []*armcontainerservicefleet.MemberUpdateStatus{ - // { - // Name: to.Ptr("member-one"), - // ClusterResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myClusters/providers/Microsoft.ContainerService/managedClusters/myCluster"), - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }, - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateRuns_CreateOrUpdate.json -func ExampleUpdateRunsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewUpdateRunsClient().BeginCreateOrUpdate(ctx, "rg1", "fleet1", "run1", armcontainerservicefleet.UpdateRun{ - Properties: &armcontainerservicefleet.UpdateRunProperties{ - ManagedClusterUpdate: &armcontainerservicefleet.ManagedClusterUpdate{ - NodeImageSelection: &armcontainerservicefleet.NodeImageSelection{ - Type: to.Ptr(armcontainerservicefleet.NodeImageSelectionTypeLatest), - }, - Upgrade: &armcontainerservicefleet.ManagedClusterUpgradeSpec{ - Type: to.Ptr(armcontainerservicefleet.ManagedClusterUpgradeTypeFull), - KubernetesVersion: to.Ptr("1.26.1"), - }, - }, - Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - Stages: []*armcontainerservicefleet.UpdateStage{ - { - Name: to.Ptr("stage1"), - AfterStageWaitInSeconds: to.Ptr[int32](3600), - Groups: []*armcontainerservicefleet.UpdateGroup{ - { - Name: to.Ptr("group-a"), - }}, - }}, - }, - UpdateStrategyID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), - }, - }, &armcontainerservicefleet.UpdateRunsClientBeginCreateOrUpdateOptions{IfMatch: nil, - IfNoneMatch: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UpdateRun = armcontainerservicefleet.UpdateRun{ - // Name: to.Ptr("run1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateRuns"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateRuns/run1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.UpdateRunProperties{ - // ManagedClusterUpdate: &armcontainerservicefleet.ManagedClusterUpdate{ - // NodeImageSelection: &armcontainerservicefleet.NodeImageSelection{ - // Type: to.Ptr(armcontainerservicefleet.NodeImageSelectionTypeLatest), - // }, - // Upgrade: &armcontainerservicefleet.ManagedClusterUpgradeSpec{ - // Type: to.Ptr(armcontainerservicefleet.ManagedClusterUpgradeTypeFull), - // KubernetesVersion: to.Ptr("1.26.1"), - // }, - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.UpdateRunProvisioningStateSucceeded), - // Status: &armcontainerservicefleet.UpdateRunStatus{ - // Stages: []*armcontainerservicefleet.UpdateStageStatus{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitStatus: &armcontainerservicefleet.WaitStatus{ - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // WaitDurationInSeconds: to.Ptr[int32](3600), - // }, - // Groups: []*armcontainerservicefleet.UpdateGroupStatus{ - // { - // Name: to.Ptr("group-a"), - // Members: []*armcontainerservicefleet.MemberUpdateStatus{ - // { - // Name: to.Ptr("member-one"), - // ClusterResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myClusters/providers/Microsoft.ContainerService/managedClusters/myCluster"), - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // }, - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // UpdateStrategyID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateRuns_Delete.json -func ExampleUpdateRunsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewUpdateRunsClient().BeginDelete(ctx, "rg1", "fleet1", "run1", &armcontainerservicefleet.UpdateRunsClientBeginDeleteOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateRuns_Skip.json -func ExampleUpdateRunsClient_BeginSkip() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewUpdateRunsClient().BeginSkip(ctx, "rg1", "fleet1", "run1", armcontainerservicefleet.SkipProperties{ - Targets: []*armcontainerservicefleet.SkipTarget{ - { - Name: to.Ptr("member-one"), - Type: to.Ptr(armcontainerservicefleet.TargetTypeMember), - }, - { - Name: to.Ptr("stage1"), - Type: to.Ptr(armcontainerservicefleet.TargetTypeAfterStageWait), - }}, - }, &armcontainerservicefleet.UpdateRunsClientBeginSkipOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UpdateRun = armcontainerservicefleet.UpdateRun{ - // Name: to.Ptr("run1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateRuns"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateRuns/run1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:09:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.UpdateRunProperties{ - // ManagedClusterUpdate: &armcontainerservicefleet.ManagedClusterUpdate{ - // NodeImageSelection: &armcontainerservicefleet.NodeImageSelection{ - // Type: to.Ptr(armcontainerservicefleet.NodeImageSelectionTypeLatest), - // }, - // Upgrade: &armcontainerservicefleet.ManagedClusterUpgradeSpec{ - // Type: to.Ptr(armcontainerservicefleet.ManagedClusterUpgradeTypeFull), - // KubernetesVersion: to.Ptr("1.26.1"), - // }, - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.UpdateRunProvisioningStateSucceeded), - // Status: &armcontainerservicefleet.UpdateRunStatus{ - // Stages: []*armcontainerservicefleet.UpdateStageStatus{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitStatus: &armcontainerservicefleet.WaitStatus{ - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateSkipped), - // }, - // WaitDurationInSeconds: to.Ptr[int32](3600), - // }, - // Groups: []*armcontainerservicefleet.UpdateGroupStatus{ - // { - // Name: to.Ptr("group-a"), - // Members: []*armcontainerservicefleet.MemberUpdateStatus{ - // { - // Name: to.Ptr("member-one"), - // ClusterResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myClusters/providers/Microsoft.ContainerService/managedClusters/myCluster-1"), - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateSkipped), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateSkipped), - // }, - // }, - // { - // Name: to.Ptr("group-b"), - // Members: []*armcontainerservicefleet.MemberUpdateStatus{ - // { - // Name: to.Ptr("member-two"), - // ClusterResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myClusters/providers/Microsoft.ContainerService/managedClusters/myCluster-2"), - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }, - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }, - // { - // Name: to.Ptr("group-b"), - // }}, - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateRuns_Start.json -func ExampleUpdateRunsClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewUpdateRunsClient().BeginStart(ctx, "rg1", "fleet1", "run1", &armcontainerservicefleet.UpdateRunsClientBeginStartOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UpdateRun = armcontainerservicefleet.UpdateRun{ - // Name: to.Ptr("run1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateRuns"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateRuns/run1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:09:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.UpdateRunProperties{ - // ManagedClusterUpdate: &armcontainerservicefleet.ManagedClusterUpdate{ - // NodeImageSelection: &armcontainerservicefleet.NodeImageSelection{ - // Type: to.Ptr(armcontainerservicefleet.NodeImageSelectionTypeLatest), - // }, - // Upgrade: &armcontainerservicefleet.ManagedClusterUpgradeSpec{ - // Type: to.Ptr(armcontainerservicefleet.ManagedClusterUpgradeTypeFull), - // KubernetesVersion: to.Ptr("1.26.1"), - // }, - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.UpdateRunProvisioningStateSucceeded), - // Status: &armcontainerservicefleet.UpdateRunStatus{ - // Stages: []*armcontainerservicefleet.UpdateStageStatus{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitStatus: &armcontainerservicefleet.WaitStatus{ - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // WaitDurationInSeconds: to.Ptr[int32](3600), - // }, - // Groups: []*armcontainerservicefleet.UpdateGroupStatus{ - // { - // Name: to.Ptr("group-a"), - // Members: []*armcontainerservicefleet.MemberUpdateStatus{ - // { - // Name: to.Ptr("member-one"), - // ClusterResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myClusters/providers/Microsoft.ContainerService/managedClusters/myCluster"), - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateRunning), - // }, - // }, - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/stable/2024-04-01/examples/UpdateRuns_Stop.json -func ExampleUpdateRunsClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerservicefleet.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewUpdateRunsClient().BeginStop(ctx, "rg1", "fleet1", "run1", &armcontainerservicefleet.UpdateRunsClientBeginStopOptions{IfMatch: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UpdateRun = armcontainerservicefleet.UpdateRun{ - // Name: to.Ptr("run1"), - // Type: to.Ptr("Microsoft.ContainerService/fleets/updateRuns"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateRuns/run1"), - // SystemData: &armcontainerservicefleet.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:09:08.395Z"); return t}()), - // CreatedBy: to.Ptr("@contoso.com"), - // CreatedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // LastModifiedBy: to.Ptr("@contoso.com"), - // LastModifiedByType: to.Ptr(armcontainerservicefleet.CreatedByTypeUser), - // }, - // ETag: to.Ptr("\"EtagValue\""), - // Properties: &armcontainerservicefleet.UpdateRunProperties{ - // ManagedClusterUpdate: &armcontainerservicefleet.ManagedClusterUpdate{ - // NodeImageSelection: &armcontainerservicefleet.NodeImageSelection{ - // Type: to.Ptr(armcontainerservicefleet.NodeImageSelectionTypeLatest), - // }, - // Upgrade: &armcontainerservicefleet.ManagedClusterUpgradeSpec{ - // Type: to.Ptr(armcontainerservicefleet.ManagedClusterUpgradeTypeFull), - // KubernetesVersion: to.Ptr("1.26.1"), - // }, - // }, - // ProvisioningState: to.Ptr(armcontainerservicefleet.UpdateRunProvisioningStateSucceeded), - // Status: &armcontainerservicefleet.UpdateRunStatus{ - // Stages: []*armcontainerservicefleet.UpdateStageStatus{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitStatus: &armcontainerservicefleet.WaitStatus{ - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateNotStarted), - // }, - // WaitDurationInSeconds: to.Ptr[int32](3600), - // }, - // Groups: []*armcontainerservicefleet.UpdateGroupStatus{ - // { - // Name: to.Ptr("group-a"), - // Members: []*armcontainerservicefleet.MemberUpdateStatus{ - // { - // Name: to.Ptr("member-one"), - // ClusterResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myClusters/providers/Microsoft.ContainerService/managedClusters/myCluster"), - // Status: &armcontainerservicefleet.UpdateStatus{ - // State: to.Ptr(armcontainerservicefleet.UpdateStateStopping), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateStopping), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateStopping), - // }, - // }}, - // Status: &armcontainerservicefleet.UpdateStatus{ - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T01:10:08.395Z"); return t}()), - // State: to.Ptr(armcontainerservicefleet.UpdateStateStopping), - // }, - // }, - // Strategy: &armcontainerservicefleet.UpdateRunStrategy{ - // Stages: []*armcontainerservicefleet.UpdateStage{ - // { - // Name: to.Ptr("stage1"), - // AfterStageWaitInSeconds: to.Ptr[int32](3600), - // Groups: []*armcontainerservicefleet.UpdateGroup{ - // { - // Name: to.Ptr("group-a"), - // }}, - // }}, - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md b/sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md new file mode 100644 index 000000000000..bba329e4504e --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2024-08-22) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/LICENSE.txt b/sdk/resourcemanager/containerstorage/armcontainerstorage/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/README.md b/sdk/resourcemanager/containerstorage/armcontainerstorage/README.md new file mode 100644 index 000000000000..ff32d56e776b --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/README.md @@ -0,0 +1,92 @@ +# Azure Containerstorage Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage) + +The `armcontainerstorage` module provides operations for working with Azure Containerstorage. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/containerstorage/armcontainerstorage) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Containerstorage module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Containerstorage. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Containerstorage module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armcontainerstorage.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armcontainerstorage.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewPoolsClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Containerstorage` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/autorest.md b/sdk/resourcemanager/containerstorage/armcontainerstorage/autorest.md new file mode 100644 index 000000000000..fcb6c5904b9f --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/containerstorage/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/containerstorage/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/build.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/build.go new file mode 100644 index 000000000000..910d3d406430 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/containerstorage/armcontainerstorage + +package armcontainerstorage diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/ci.yml b/sdk/resourcemanager/containerstorage/armcontainerstorage/ci.yml new file mode 100644 index 000000000000..8c36707591c1 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/containerstorage/armcontainerstorage/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/containerstorage/armcontainerstorage/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/containerstorage/armcontainerstorage' diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go new file mode 100644 index 000000000000..5faf18cad3b5 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/client_factory.go @@ -0,0 +1,68 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +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 { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewPoolsClient creates a new instance of PoolsClient. +func (c *ClientFactory) NewPoolsClient() *PoolsClient { + return &PoolsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewSnapshotsClient creates a new instance of SnapshotsClient. +func (c *ClientFactory) NewSnapshotsClient() *SnapshotsClient { + return &SnapshotsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewVolumesClient creates a new instance of VolumesClient. +func (c *ClientFactory) NewVolumesClient() *VolumesClient { + return &VolumesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go new file mode 100644 index 000000000000..b819279ee00f --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/constants.go @@ -0,0 +1,255 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage" + moduleVersion = "v0.1.0" +) + +// 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, + } +} + +// AssignmentStatusState - Status of the assignment resource +type AssignmentStatusState string + +const ( + // AssignmentStatusStateAssigned - The assignment to the pool was successful. + AssignmentStatusStateAssigned AssignmentStatusState = "Assigned" + // AssignmentStatusStateAssigning - The assignment of the pool to the resource is in progress + AssignmentStatusStateAssigning AssignmentStatusState = "Assigning" + // AssignmentStatusStateFailed - The operation of assigning or unassigning the pool failed. + AssignmentStatusStateFailed AssignmentStatusState = "Failed" + // AssignmentStatusStateUnassigning - The pool is being unassigned. + AssignmentStatusStateUnassigning AssignmentStatusState = "Unassigning" +) + +// PossibleAssignmentStatusStateValues returns the possible values for the AssignmentStatusState const type. +func PossibleAssignmentStatusStateValues() []AssignmentStatusState { + return []AssignmentStatusState{ + AssignmentStatusStateAssigned, + AssignmentStatusStateAssigning, + AssignmentStatusStateFailed, + AssignmentStatusStateUnassigning, + } +} + +// AzureDiskSKUName - SKU of the underlying managed disk +type AzureDiskSKUName string + +const ( + // AzureDiskSKUNamePremiumLRS - Premium_LRS SKU + AzureDiskSKUNamePremiumLRS AzureDiskSKUName = "Premium_LRS" + // AzureDiskSKUNamePremiumV2LRS - PremiumV2_LRS SKU + AzureDiskSKUNamePremiumV2LRS AzureDiskSKUName = "PremiumV2_LRS" + // AzureDiskSKUNamePremiumZRS - Premium_ZRS SKU + AzureDiskSKUNamePremiumZRS AzureDiskSKUName = "Premium_ZRS" + // AzureDiskSKUNameStandardLRS - Standard_LRS SKU + AzureDiskSKUNameStandardLRS AzureDiskSKUName = "Standard_LRS" + // AzureDiskSKUNameStandardSSDLRS - StandardSSD_LRS SKU + AzureDiskSKUNameStandardSSDLRS AzureDiskSKUName = "StandardSSD_LRS" + // AzureDiskSKUNameStandardSSDZRS - StandardSSD_ZRS SKU + AzureDiskSKUNameStandardSSDZRS AzureDiskSKUName = "StandardSSD_ZRS" + // AzureDiskSKUNameUltraSSDLRS - UltraSSD_LRS SKU + AzureDiskSKUNameUltraSSDLRS AzureDiskSKUName = "UltraSSD_LRS" +) + +// PossibleAzureDiskSKUNameValues returns the possible values for the AzureDiskSKUName const type. +func PossibleAzureDiskSKUNameValues() []AzureDiskSKUName { + return []AzureDiskSKUName{ + AzureDiskSKUNamePremiumLRS, + AzureDiskSKUNamePremiumV2LRS, + AzureDiskSKUNamePremiumZRS, + AzureDiskSKUNameStandardLRS, + AzureDiskSKUNameStandardSSDLRS, + AzureDiskSKUNameStandardSSDZRS, + AzureDiskSKUNameUltraSSDLRS, + } +} + +// 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, + } +} + +// ElasticSanSKUName - ElasticSAN SKUs +type ElasticSanSKUName string + +const ( + // ElasticSanSKUNamePremiumLRS - Premium_LRS SKU + ElasticSanSKUNamePremiumLRS ElasticSanSKUName = "Premium_LRS" + // ElasticSanSKUNamePremiumZRS - Premium_ZRS SKU + ElasticSanSKUNamePremiumZRS ElasticSanSKUName = "Premium_ZRS" +) + +// PossibleElasticSanSKUNameValues returns the possible values for the ElasticSanSKUName const type. +func PossibleElasticSanSKUNameValues() []ElasticSanSKUName { + return []ElasticSanSKUName{ + ElasticSanSKUNamePremiumLRS, + ElasticSanSKUNamePremiumZRS, + } +} + +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned, UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + +// 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 resource. +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" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ReclaimPolicy - Reclaim policy +type ReclaimPolicy string + +const ( + // ReclaimPolicyDelete - Delete resource + ReclaimPolicyDelete ReclaimPolicy = "Delete" + // ReclaimPolicyRetain - Retain resource + ReclaimPolicyRetain ReclaimPolicy = "Retain" +) + +// PossibleReclaimPolicyValues returns the possible values for the ReclaimPolicy const type. +func PossibleReclaimPolicyValues() []ReclaimPolicy { + return []ReclaimPolicy{ + ReclaimPolicyDelete, + ReclaimPolicyRetain, + } +} + +// ResourceOperationStatusState - State of the resource. +type ResourceOperationStatusState string + +const ( + // ResourceOperationStatusStateAvailable - The resource is available. + ResourceOperationStatusStateAvailable ResourceOperationStatusState = "Available" + // ResourceOperationStatusStatePending - The resource is pending. + ResourceOperationStatusStatePending ResourceOperationStatusState = "Pending" + // ResourceOperationStatusStateUnavailable - The resource is unavailable. + ResourceOperationStatusStateUnavailable ResourceOperationStatusState = "Unavailable" +) + +// PossibleResourceOperationStatusStateValues returns the possible values for the ResourceOperationStatusState const type. +func PossibleResourceOperationStatusStateValues() []ResourceOperationStatusState { + return []ResourceOperationStatusState{ + ResourceOperationStatusStateAvailable, + ResourceOperationStatusStatePending, + ResourceOperationStatusStateUnavailable, + } +} + +// Zone - Availability Zones +type Zone string + +const ( + // ZoneZone1 - First availability zone. + ZoneZone1 Zone = "1" + // ZoneZone2 - Second availability zone. + ZoneZone2 Zone = "2" + // ZoneZone3 - Third availability zone. + ZoneZone3 Zone = "3" +) + +// PossibleZoneValues returns the possible values for the Zone const type. +func PossibleZoneValues() []Zone { + return []Zone{ + ZoneZone1, + ZoneZone2, + ZoneZone3, + } +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/internal.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/internal.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/operations_server.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/operations_server.go new file mode 100644 index 000000000000..90e252df207c --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage" + "net/http" +) + +// OperationsServer is a fake server for instances of the armcontainerstorage.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armcontainerstorage.OperationsClientListOptions) (resp azfake.PagerResponder[armcontainerstorage.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armcontainerstorage.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcontainerstorage.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armcontainerstorage.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armcontainerstorage.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcontainerstorage.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/pools_server.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/pools_server.go new file mode 100644 index 000000000000..8ea332c44aa6 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/pools_server.go @@ -0,0 +1,353 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage" + "net/http" + "net/url" + "regexp" +) + +// PoolsServer is a fake server for instances of the armcontainerstorage.PoolsClient type. +type PoolsServer struct { + // BeginCreateOrUpdate is the fake for method PoolsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, poolName string, resource armcontainerstorage.Pool, options *armcontainerstorage.PoolsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armcontainerstorage.PoolsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method PoolsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, poolName string, options *armcontainerstorage.PoolsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerstorage.PoolsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PoolsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, poolName string, options *armcontainerstorage.PoolsClientGetOptions) (resp azfake.Responder[armcontainerstorage.PoolsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method PoolsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armcontainerstorage.PoolsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armcontainerstorage.PoolsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method PoolsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armcontainerstorage.PoolsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armcontainerstorage.PoolsClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method PoolsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, poolName string, properties armcontainerstorage.PoolUpdate, options *armcontainerstorage.PoolsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerstorage.PoolsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewPoolsServerTransport creates a new instance of PoolsServerTransport with the provided implementation. +// The returned PoolsServerTransport instance is connected to an instance of armcontainerstorage.PoolsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPoolsServerTransport(srv *PoolsServer) *PoolsServerTransport { + return &PoolsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armcontainerstorage.PoolsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armcontainerstorage.PoolsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armcontainerstorage.PoolsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armcontainerstorage.PoolsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armcontainerstorage.PoolsClientUpdateResponse]](), + } +} + +// PoolsServerTransport connects instances of armcontainerstorage.PoolsClient to instances of PoolsServer. +// Don't use this type directly, use NewPoolsServerTransport instead. +type PoolsServerTransport struct { + srv *PoolsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armcontainerstorage.PoolsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armcontainerstorage.PoolsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armcontainerstorage.PoolsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armcontainerstorage.PoolsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armcontainerstorage.PoolsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for PoolsServerTransport. +func (p *PoolsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "PoolsClient.BeginCreateOrUpdate": + resp, err = p.dispatchBeginCreateOrUpdate(req) + case "PoolsClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) + case "PoolsClient.Get": + resp, err = p.dispatchGet(req) + case "PoolsClient.NewListByResourceGroupPager": + resp, err = p.dispatchNewListByResourceGroupPager(req) + case "PoolsClient.NewListBySubscriptionPager": + resp, err = p.dispatchNewListBySubscriptionPager(req) + case "PoolsClient.BeginUpdate": + resp, err = p.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PoolsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := p.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerstorage.Pool](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, poolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + p.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + p.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + p.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (p *PoolsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, poolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + p.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + p.beginDelete.remove(req) + } + + return resp, nil +} + +func (p *PoolsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, poolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Pool, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PoolsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := p.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + p.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armcontainerstorage.PoolsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + p.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (p *PoolsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := p.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := p.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + p.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armcontainerstorage.PoolsClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + p.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (p *PoolsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := p.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerstorage.PoolUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginUpdate(req.Context(), resourceGroupNameParam, poolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + p.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + p.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/server_factory.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/server_factory.go new file mode 100644 index 000000000000..c6b03ace148b --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/server_factory.go @@ -0,0 +1,90 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armcontainerstorage.ClientFactory type. +type ServerFactory struct { + OperationsServer OperationsServer + PoolsServer PoolsServer + SnapshotsServer SnapshotsServer + VolumesServer VolumesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armcontainerstorage.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armcontainerstorage.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trOperationsServer *OperationsServerTransport + trPoolsServer *PoolsServerTransport + trSnapshotsServer *SnapshotsServerTransport + trVolumesServer *VolumesServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "PoolsClient": + initServer(s, &s.trPoolsServer, func() *PoolsServerTransport { return NewPoolsServerTransport(&s.srv.PoolsServer) }) + resp, err = s.trPoolsServer.Do(req) + case "SnapshotsClient": + initServer(s, &s.trSnapshotsServer, func() *SnapshotsServerTransport { return NewSnapshotsServerTransport(&s.srv.SnapshotsServer) }) + resp, err = s.trSnapshotsServer.Do(req) + case "VolumesClient": + initServer(s, &s.trVolumesServer, func() *VolumesServerTransport { return NewVolumesServerTransport(&s.srv.VolumesServer) }) + resp, err = s.trVolumesServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/snapshots_server.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/snapshots_server.go new file mode 100644 index 000000000000..c5c8e95e7f6c --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/snapshots_server.go @@ -0,0 +1,272 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage" + "net/http" + "net/url" + "regexp" +) + +// SnapshotsServer is a fake server for instances of the armcontainerstorage.SnapshotsClient type. +type SnapshotsServer struct { + // BeginCreateOrUpdate is the fake for method SnapshotsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, resource armcontainerstorage.Snapshot, options *armcontainerstorage.SnapshotsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armcontainerstorage.SnapshotsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method SnapshotsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, options *armcontainerstorage.SnapshotsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerstorage.SnapshotsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SnapshotsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, options *armcontainerstorage.SnapshotsClientGetOptions) (resp azfake.Responder[armcontainerstorage.SnapshotsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByPoolPager is the fake for method SnapshotsClient.NewListByPoolPager + // HTTP status codes to indicate success: http.StatusOK + NewListByPoolPager func(resourceGroupName string, poolName string, options *armcontainerstorage.SnapshotsClientListByPoolOptions) (resp azfake.PagerResponder[armcontainerstorage.SnapshotsClientListByPoolResponse]) +} + +// NewSnapshotsServerTransport creates a new instance of SnapshotsServerTransport with the provided implementation. +// The returned SnapshotsServerTransport instance is connected to an instance of armcontainerstorage.SnapshotsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSnapshotsServerTransport(srv *SnapshotsServer) *SnapshotsServerTransport { + return &SnapshotsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armcontainerstorage.SnapshotsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armcontainerstorage.SnapshotsClientDeleteResponse]](), + newListByPoolPager: newTracker[azfake.PagerResponder[armcontainerstorage.SnapshotsClientListByPoolResponse]](), + } +} + +// SnapshotsServerTransport connects instances of armcontainerstorage.SnapshotsClient to instances of SnapshotsServer. +// Don't use this type directly, use NewSnapshotsServerTransport instead. +type SnapshotsServerTransport struct { + srv *SnapshotsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armcontainerstorage.SnapshotsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armcontainerstorage.SnapshotsClientDeleteResponse]] + newListByPoolPager *tracker[azfake.PagerResponder[armcontainerstorage.SnapshotsClientListByPoolResponse]] +} + +// Do implements the policy.Transporter interface for SnapshotsServerTransport. +func (s *SnapshotsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SnapshotsClient.BeginCreateOrUpdate": + resp, err = s.dispatchBeginCreateOrUpdate(req) + case "SnapshotsClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "SnapshotsClient.Get": + resp, err = s.dispatchGet(req) + case "SnapshotsClient.NewListByPoolPager": + resp, err = s.dispatchNewListByPoolPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SnapshotsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerstorage.Snapshot](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + snapshotNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("snapshotName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, poolNameParam, snapshotNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + s.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + s.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (s *SnapshotsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + snapshotNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("snapshotName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, poolNameParam, snapshotNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *SnapshotsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + snapshotNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("snapshotName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, poolNameParam, snapshotNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Snapshot, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SnapshotsServerTransport) dispatchNewListByPoolPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByPoolPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByPoolPager not implemented")} + } + newListByPoolPager := s.newListByPoolPager.get(req) + if newListByPoolPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/snapshots` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListByPoolPager(resourceGroupNameParam, poolNameParam, nil) + newListByPoolPager = &resp + s.newListByPoolPager.add(req, newListByPoolPager) + server.PagerResponderInjectNextLinks(newListByPoolPager, req, func(page *armcontainerstorage.SnapshotsClientListByPoolResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByPoolPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByPoolPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByPoolPager) { + s.newListByPoolPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/time_rfc3339.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/time_rfc3339.go new file mode 100644 index 000000000000..81f308b0d343 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/volumes_server.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/volumes_server.go new file mode 100644 index 000000000000..53d1ea8a6730 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/fake/volumes_server.go @@ -0,0 +1,332 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage" + "net/http" + "net/url" + "regexp" +) + +// VolumesServer is a fake server for instances of the armcontainerstorage.VolumesClient type. +type VolumesServer struct { + // BeginCreateOrUpdate is the fake for method VolumesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, poolName string, volumeName string, resource armcontainerstorage.Volume, options *armcontainerstorage.VolumesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armcontainerstorage.VolumesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method VolumesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *armcontainerstorage.VolumesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerstorage.VolumesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method VolumesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *armcontainerstorage.VolumesClientGetOptions) (resp azfake.Responder[armcontainerstorage.VolumesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByPoolPager is the fake for method VolumesClient.NewListByPoolPager + // HTTP status codes to indicate success: http.StatusOK + NewListByPoolPager func(resourceGroupName string, poolName string, options *armcontainerstorage.VolumesClientListByPoolOptions) (resp azfake.PagerResponder[armcontainerstorage.VolumesClientListByPoolResponse]) + + // BeginUpdate is the fake for method VolumesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, poolName string, volumeName string, properties armcontainerstorage.VolumeUpdate, options *armcontainerstorage.VolumesClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerstorage.VolumesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewVolumesServerTransport creates a new instance of VolumesServerTransport with the provided implementation. +// The returned VolumesServerTransport instance is connected to an instance of armcontainerstorage.VolumesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVolumesServerTransport(srv *VolumesServer) *VolumesServerTransport { + return &VolumesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armcontainerstorage.VolumesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armcontainerstorage.VolumesClientDeleteResponse]](), + newListByPoolPager: newTracker[azfake.PagerResponder[armcontainerstorage.VolumesClientListByPoolResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armcontainerstorage.VolumesClientUpdateResponse]](), + } +} + +// VolumesServerTransport connects instances of armcontainerstorage.VolumesClient to instances of VolumesServer. +// Don't use this type directly, use NewVolumesServerTransport instead. +type VolumesServerTransport struct { + srv *VolumesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armcontainerstorage.VolumesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armcontainerstorage.VolumesClientDeleteResponse]] + newListByPoolPager *tracker[azfake.PagerResponder[armcontainerstorage.VolumesClientListByPoolResponse]] + beginUpdate *tracker[azfake.PollerResponder[armcontainerstorage.VolumesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for VolumesServerTransport. +func (v *VolumesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "VolumesClient.BeginCreateOrUpdate": + resp, err = v.dispatchBeginCreateOrUpdate(req) + case "VolumesClient.BeginDelete": + resp, err = v.dispatchBeginDelete(req) + case "VolumesClient.Get": + resp, err = v.dispatchGet(req) + case "VolumesClient.NewListByPoolPager": + resp, err = v.dispatchNewListByPoolPager(req) + case "VolumesClient.BeginUpdate": + resp, err = v.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VolumesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if v.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := v.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerstorage.Volume](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + volumeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, poolNameParam, volumeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + v.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + v.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + v.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (v *VolumesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if v.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := v.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + volumeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginDelete(req.Context(), resourceGroupNameParam, poolNameParam, volumeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + v.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + v.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + v.beginDelete.remove(req) + } + + return resp, nil +} + +func (v *VolumesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if v.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + volumeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Get(req.Context(), resourceGroupNameParam, poolNameParam, volumeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Volume, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VolumesServerTransport) dispatchNewListByPoolPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListByPoolPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByPoolPager not implemented")} + } + newListByPoolPager := v.newListByPoolPager.get(req) + if newListByPoolPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + resp := v.srv.NewListByPoolPager(resourceGroupNameParam, poolNameParam, nil) + newListByPoolPager = &resp + v.newListByPoolPager.add(req, newListByPoolPager) + server.PagerResponderInjectNextLinks(newListByPoolPager, req, func(page *armcontainerstorage.VolumesClientListByPoolResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByPoolPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + v.newListByPoolPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByPoolPager) { + v.newListByPoolPager.remove(req) + } + return resp, nil +} + +func (v *VolumesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if v.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := v.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerStorage/pools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/volumes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerstorage.VolumeUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + poolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("poolName")]) + if err != nil { + return nil, err + } + volumeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("volumeName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginUpdate(req.Context(), resourceGroupNameParam, poolNameParam, volumeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + v.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + v.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod new file mode 100644 index 000000000000..8843d6fcb660 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerstorage/armcontainerstorage + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum new file mode 100644 index 000000000000..03ce617a1873 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/models.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/models.go new file mode 100644 index 000000000000..af2d9390769e --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/models.go @@ -0,0 +1,439 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +import "time" + +// Assignment Properties +type Assignment struct { + // REQUIRED; Resource id for the assigned resource + ID *string + + // READ-ONLY; Indicates if the assignment is in a usable state + Status *AssignmentStatus +} + +// AssignmentStatus - Status of the assignment resource +type AssignmentStatus struct { + // REQUIRED; State of the assignment resource + State *AssignmentStatusState + + // Reason for the status + Message *string +} + +// AzureDisk - Azure Disk Pool Properties +type AzureDisk struct { + // Only required if individual disk selection is desired. Path to disk, e.g. :/dev/sda or WWN. Supports specifying multiple + // disks (same syntax as tags). + Disks []*Disk + + // Encryption specifies the encryption configuration for the Azure Disk pool + Encryption *Encryption + + // Sku name + SKUName *AzureDiskSKUName + + // READ-ONLY; Managed resource group for the pool. + ResourceGroup *string +} + +// AzureDiskUpdate - Azure Disk Pool Properties +type AzureDiskUpdate struct { + // Only required if individual disk selection is desired. Path to disk, e.g. :/dev/sda or WWN. Supports specifying multiple + // disks (same syntax as tags). + Disks []*Disk +} + +// Disk - Model for disk for that pool is using +type Disk struct { + // REQUIRED; ID is the disk identifier visible to the OS. It is typically the WWN or disk ID in formats such as eui.e8238fa6bf530001001b448b45263379 + // or 0x5002cf6cbc5dd460 + ID *string + + // REQUIRED; Reference is the location of the disk in an external system. + Reference *string +} + +// ElasticSan - Elastic San Pool Properties +type ElasticSan struct { + // Encryption specifies the encryption configuration for the Azure Disk pool + Encryption *Encryption + + // Sku name + SKUName *ElasticSanSKUName + + // READ-ONLY; Managed resource group for the pool. + ResourceGroup *string +} + +// ElasticSanVolumeProperties - Properties of the ElasticSAN iSCSI target +type ElasticSanVolumeProperties struct { + // REQUIRED; iSCSI Target IQN (iSCSI Qualified Name); example: "iqn.2005-03.org.iscsi:server" + TargetIqn *string + + // REQUIRED; iSCSI Target Portal Host Name + TargetPortalHostname *string + + // REQUIRED; iSCSI Target Portal Port + TargetPortalPort *int32 +} + +// Encryption key properties for the pool. +type Encryption struct { + // REQUIRED; The name of the key vault key. + KeyName *string + + // REQUIRED; The URI of the key vault. + KeyVaultURI *string + + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity +} + +// EphemeralDisk - Ephemeral Disk Pool Properties +type EphemeralDisk struct { + // Only required if individual disk selection is desired. Path to disk, e.g. :/dev/sda or WWN. Supports specifying multiple + // disks (same syntax as tags). + Disks []*Disk + + // The number of data copies. Default 3. + Replicas *int64 +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *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 + + // 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 +} + +// Pool resource +type Pool struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *PoolProperties + + // Resource tags. + Tags map[string]*string + + // 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 + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// PoolListResult - The response of a Pool list operation. +type PoolListResult struct { + // REQUIRED; The Pool items on this page + Value []*Pool + + // The link to the next page of items + NextLink *string +} + +// PoolProperties - Pool Properties +type PoolProperties struct { + // REQUIRED; Type of the Pool: ephemeralDisk, azureDisk, or elasticsan. + PoolType *PoolType + + // List of resources that should have access to the pool. Typically ARM references to AKS clusters or ACI Container Groups. + // For local and standard this must be a single reference. For ElasticSAN there + // can be many. + Assignments []*Assignment + + // ReclaimPolicy defines what happens to the backend storage when StoragePool is deleted + ReclaimPolicy *ReclaimPolicy + + // Resources represent the resources the pool should have. + Resources *Resources + + // List of availability zones that resources can be created in. + Zones []*Zone + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The operational status of the resource + Status *ResourceOperationalStatus +} + +// PoolType - Type of the Pool: ephemeralDisk, azureDisk, or elasticsan +type PoolType struct { + // Disk Pool Properties + AzureDisk *AzureDisk + + // Elastic San Pool Properties + ElasticSan *ElasticSan + + // Ephemeral Pool Properties + EphemeralDisk *EphemeralDisk +} + +// PoolTypeUpdate - Type of the Pool: ephemeralDisk, azureDisk, or elasticsan +type PoolTypeUpdate struct { + // Disk Pool Properties + AzureDisk *AzureDiskUpdate + + // Elastic San Pool Properties + ElasticSan any + + // Ephemeral Pool Properties + EphemeralDisk *EphemeralDisk +} + +// PoolUpdate - The type used for update operations of the Pool. +type PoolUpdate struct { + // The resource-specific properties for this resource. + Properties *PoolUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// PoolUpdateProperties - The updatable properties of the Pool. +type PoolUpdateProperties struct { + // List of resources that should have access to the pool. Typically ARM references to AKS clusters or ACI Container Groups. + // For local and standard this must be a single reference. For ElasticSAN there + // can be many. + Assignments []*Assignment + + // Type of the Pool: ephemeralDisk, azureDisk, or elasticsan. + PoolType *PoolTypeUpdate + + // Resources represent the resources the pool should have. + Resources *Resources +} + +// Requests for capacity for the pool. +type Requests struct { + // Requested capacity of the pool in GiB. + Storage *int64 +} + +// ResourceOperationalStatus - Status of the resource +type ResourceOperationalStatus struct { + // REQUIRED; state of the resource + State *ResourceOperationStatusState + + // Reason for state. + Message *string +} + +// Resources - Resource Requests for the pool. +type Resources struct { + // Requests for capacity for the pool. + Requests *Requests +} + +// Snapshot - Concrete proxy resource types can be created by aliasing this type using a specific property type. +type Snapshot struct { + // The resource-specific properties for this resource. + Properties *SnapshotProperties + + // 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 + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// SnapshotListResult - The response of a Snapshot list operation. +type SnapshotListResult struct { + // REQUIRED; The Snapshot items on this page + Value []*Snapshot + + // The link to the next page of items + NextLink *string +} + +// SnapshotProperties - Volume Snapshot Properties +type SnapshotProperties struct { + // REQUIRED; Reference to the source volume + Source *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The status of the resource. + Status *ResourceOperationalStatus +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string +} + +// Volume - Concrete proxy resource types can be created by aliasing this type using a specific property type. +type Volume struct { + // The resource-specific properties for this resource. + Properties *VolumeProperties + + // 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 + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// VolumeListResult - The response of a Volume list operation. +type VolumeListResult struct { + // REQUIRED; The Volume items on this page + Value []*Volume + + // The link to the next page of items + NextLink *string +} + +// VolumeProperties - Volume Properties +type VolumeProperties struct { + // REQUIRED; Requested capacity in GiB + CapacityGiB *int64 + + // REQUIRED; String KV pairs indicating labels + Labels map[string]*string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The status of the resource. + Status *ResourceOperationalStatus + + // READ-ONLY; Properties of the volume + VolumeType *VolumeType +} + +// VolumeType - Properties of the volume +type VolumeType struct { + // READ-ONLY; Properties of the ElasticSAN iSCSI target + ElasticSan *ElasticSanVolumeProperties +} + +// VolumeUpdate - The type used for update operations of the Volume. +type VolumeUpdate struct { + // The resource-specific properties for this resource. + Properties *VolumeUpdateProperties +} + +// VolumeUpdateProperties - The updatable properties of the Volume. +type VolumeUpdateProperties struct { + // Requested capacity in GiB + CapacityGiB *int64 + + // String KV pairs indicating labels + Labels map[string]*string +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go new file mode 100644 index 000000000000..9ce82604017d --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/models_serde.go @@ -0,0 +1,1236 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Assignment. +func (a Assignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "status", a.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Assignment. +func (a *Assignment) 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 "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + 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 AssignmentStatus. +func (a AssignmentStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", a.Message) + populate(objectMap, "state", a.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentStatus. +func (a *AssignmentStatus) 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 "message": + err = unpopulate(val, "Message", &a.Message) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &a.State) + 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 AzureDisk. +func (a AzureDisk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "disks", a.Disks) + populate(objectMap, "encryption", a.Encryption) + populate(objectMap, "resourceGroup", a.ResourceGroup) + populate(objectMap, "skuName", a.SKUName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureDisk. +func (a *AzureDisk) 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 "disks": + err = unpopulate(val, "Disks", &a.Disks) + delete(rawMsg, key) + case "encryption": + err = unpopulate(val, "Encryption", &a.Encryption) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &a.ResourceGroup) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &a.SKUName) + 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 AzureDiskUpdate. +func (a AzureDiskUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "disks", a.Disks) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureDiskUpdate. +func (a *AzureDiskUpdate) 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 "disks": + err = unpopulate(val, "Disks", &a.Disks) + 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 Disk. +func (d Disk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "reference", d.Reference) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Disk. +func (d *Disk) 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 "reference": + err = unpopulate(val, "Reference", &d.Reference) + 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 ElasticSan. +func (e ElasticSan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "encryption", e.Encryption) + populate(objectMap, "resourceGroup", e.ResourceGroup) + populate(objectMap, "skuName", e.SKUName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ElasticSan. +func (e *ElasticSan) 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 "encryption": + err = unpopulate(val, "Encryption", &e.Encryption) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &e.ResourceGroup) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &e.SKUName) + 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 ElasticSanVolumeProperties. +func (e ElasticSanVolumeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "targetIqn", e.TargetIqn) + populate(objectMap, "targetPortalHostname", e.TargetPortalHostname) + populate(objectMap, "targetPortalPort", e.TargetPortalPort) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ElasticSanVolumeProperties. +func (e *ElasticSanVolumeProperties) 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 "targetIqn": + err = unpopulate(val, "TargetIqn", &e.TargetIqn) + delete(rawMsg, key) + case "targetPortalHostname": + err = unpopulate(val, "TargetPortalHostname", &e.TargetPortalHostname) + delete(rawMsg, key) + case "targetPortalPort": + err = unpopulate(val, "TargetPortalPort", &e.TargetPortalPort) + 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 Encryption. +func (e Encryption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "keyName", e.KeyName) + populate(objectMap, "keyVaultUri", e.KeyVaultURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Encryption. +func (e *Encryption) 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 "keyName": + err = unpopulate(val, "KeyName", &e.KeyName) + delete(rawMsg, key) + case "keyVaultUri": + err = unpopulate(val, "KeyVaultURI", &e.KeyVaultURI) + 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 EphemeralDisk. +func (e EphemeralDisk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "disks", e.Disks) + populate(objectMap, "replicas", e.Replicas) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EphemeralDisk. +func (e *EphemeralDisk) 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 "disks": + err = unpopulate(val, "Disks", &e.Disks) + delete(rawMsg, key) + case "replicas": + err = unpopulate(val, "Replicas", &e.Replicas) + 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 ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) 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 "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + 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]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 Pool. +func (p Pool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Pool. +func (p *Pool) 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 "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolListResult. +func (p PoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolListResult. +func (p *PoolListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 PoolProperties. +func (p PoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignments", p.Assignments) + populate(objectMap, "poolType", p.PoolType) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "reclaimPolicy", p.ReclaimPolicy) + populate(objectMap, "resources", p.Resources) + populate(objectMap, "status", p.Status) + populate(objectMap, "zones", p.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolProperties. +func (p *PoolProperties) 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 "assignments": + err = unpopulate(val, "Assignments", &p.Assignments) + delete(rawMsg, key) + case "poolType": + err = unpopulate(val, "PoolType", &p.PoolType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "reclaimPolicy": + err = unpopulate(val, "ReclaimPolicy", &p.ReclaimPolicy) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &p.Resources) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "zones": + err = unpopulate(val, "Zones", &p.Zones) + 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 PoolType. +func (p PoolType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureDisk", p.AzureDisk) + populate(objectMap, "elasticSan", p.ElasticSan) + populate(objectMap, "ephemeralDisk", p.EphemeralDisk) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolType. +func (p *PoolType) 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 "azureDisk": + err = unpopulate(val, "AzureDisk", &p.AzureDisk) + delete(rawMsg, key) + case "elasticSan": + err = unpopulate(val, "ElasticSan", &p.ElasticSan) + delete(rawMsg, key) + case "ephemeralDisk": + err = unpopulate(val, "EphemeralDisk", &p.EphemeralDisk) + 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 PoolTypeUpdate. +func (p PoolTypeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureDisk", p.AzureDisk) + populateAny(objectMap, "elasticSan", p.ElasticSan) + populate(objectMap, "ephemeralDisk", p.EphemeralDisk) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolTypeUpdate. +func (p *PoolTypeUpdate) 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 "azureDisk": + err = unpopulate(val, "AzureDisk", &p.AzureDisk) + delete(rawMsg, key) + case "elasticSan": + err = unpopulate(val, "ElasticSan", &p.ElasticSan) + delete(rawMsg, key) + case "ephemeralDisk": + err = unpopulate(val, "EphemeralDisk", &p.EphemeralDisk) + 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 PoolUpdate. +func (p PoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolUpdate. +func (p *PoolUpdate) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, 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 PoolUpdateProperties. +func (p PoolUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignments", p.Assignments) + populate(objectMap, "poolType", p.PoolType) + populate(objectMap, "resources", p.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolUpdateProperties. +func (p *PoolUpdateProperties) 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 "assignments": + err = unpopulate(val, "Assignments", &p.Assignments) + delete(rawMsg, key) + case "poolType": + err = unpopulate(val, "PoolType", &p.PoolType) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &p.Resources) + 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 Requests. +func (r Requests) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storage", r.Storage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Requests. +func (r *Requests) 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 "storage": + err = unpopulate(val, "Storage", &r.Storage) + 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 ResourceOperationalStatus. +func (r ResourceOperationalStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", r.Message) + populate(objectMap, "state", r.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceOperationalStatus. +func (r *ResourceOperationalStatus) 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 "message": + err = unpopulate(val, "Message", &r.Message) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &r.State) + 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 Resources. +func (r Resources) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "requests", r.Requests) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resources. +func (r *Resources) 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 "requests": + err = unpopulate(val, "Requests", &r.Requests) + 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 Snapshot. +func (s Snapshot) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Snapshot. +func (s *Snapshot) 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 "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 "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 SnapshotListResult. +func (s SnapshotListResult) 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 SnapshotListResult. +func (s *SnapshotListResult) 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 SnapshotProperties. +func (s SnapshotProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "source", s.Source) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SnapshotProperties. +func (s *SnapshotProperties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &s.Source) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + 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]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Volume. +func (v Volume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Volume. +func (v *Volume) 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 "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + 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 VolumeListResult. +func (v VolumeListResult) 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 VolumeListResult. +func (v *VolumeListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + 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 VolumeProperties. +func (v VolumeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacityGiB", v.CapacityGiB) + populate(objectMap, "labels", v.Labels) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "status", v.Status) + populate(objectMap, "volumeType", v.VolumeType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeProperties. +func (v *VolumeProperties) 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 "capacityGiB": + err = unpopulate(val, "CapacityGiB", &v.CapacityGiB) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &v.Labels) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &v.Status) + delete(rawMsg, key) + case "volumeType": + err = unpopulate(val, "VolumeType", &v.VolumeType) + 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 VolumeType. +func (v VolumeType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "elasticSan", v.ElasticSan) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeType. +func (v *VolumeType) 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 "elasticSan": + err = unpopulate(val, "ElasticSan", &v.ElasticSan) + 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 VolumeUpdate. +func (v VolumeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeUpdate. +func (v *VolumeUpdate) 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VolumeUpdateProperties. +func (v VolumeUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacityGiB", v.CapacityGiB) + populate(objectMap, "labels", v.Labels) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VolumeUpdateProperties. +func (v *VolumeUpdateProperties) 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 "capacityGiB": + err = unpopulate(val, "CapacityGiB", &v.CapacityGiB) + delete(rawMsg, key) + case "labels": + err = unpopulate(val, "Labels", &v.Labels) + 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 + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go new file mode 100644 index 000000000000..5fccdf456bfd --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + 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. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2023-07-01-preview +// - 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 { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ContainerStorage/operations" + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/options.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/options.go new file mode 100644 index 000000000000..41772ee412e8 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/options.go @@ -0,0 +1,99 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PoolsClientBeginCreateOrUpdateOptions contains the optional parameters for the PoolsClient.BeginCreateOrUpdate method. +type PoolsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientBeginDeleteOptions contains the optional parameters for the PoolsClient.BeginDelete method. +type PoolsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientBeginUpdateOptions contains the optional parameters for the PoolsClient.BeginUpdate method. +type PoolsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientGetOptions contains the optional parameters for the PoolsClient.Get method. +type PoolsClientGetOptions struct { + // placeholder for future optional parameters +} + +// PoolsClientListByResourceGroupOptions contains the optional parameters for the PoolsClient.NewListByResourceGroupPager +// method. +type PoolsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PoolsClientListBySubscriptionOptions contains the optional parameters for the PoolsClient.NewListBySubscriptionPager method. +type PoolsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// SnapshotsClientBeginCreateOrUpdateOptions contains the optional parameters for the SnapshotsClient.BeginCreateOrUpdate +// method. +type SnapshotsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SnapshotsClientBeginDeleteOptions contains the optional parameters for the SnapshotsClient.BeginDelete method. +type SnapshotsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SnapshotsClientGetOptions contains the optional parameters for the SnapshotsClient.Get method. +type SnapshotsClientGetOptions struct { + // placeholder for future optional parameters +} + +// SnapshotsClientListByPoolOptions contains the optional parameters for the SnapshotsClient.NewListByPoolPager method. +type SnapshotsClientListByPoolOptions 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 +} + +// VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +type VolumesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// 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. +type VolumesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VolumesClientListByPoolOptions contains the optional parameters for the VolumesClient.NewListByPoolPager method. +type VolumesClientListByPoolOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go new file mode 100644 index 000000000000..5413461476ae --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/pools_client.go @@ -0,0 +1,460 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +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" +) + +// PoolsClient contains the methods for the Pools group. +// Don't use this type directly, use NewPoolsClient() instead. +type PoolsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPoolsClient creates a new instance of PoolsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PoolsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PoolsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - resource - Resource create parameters. +// - options - PoolsClientBeginCreateOrUpdateOptions contains the optional parameters for the PoolsClient.BeginCreateOrUpdate +// method. +func (client *PoolsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, poolName string, resource Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*runtime.Poller[PoolsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, poolName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoolsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PoolsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *PoolsClient) createOrUpdate(ctx context.Context, resourceGroupName string, poolName string, resource Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "PoolsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, poolName, 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 *PoolsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, resource Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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", "2023-07-01-preview") + 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 Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - PoolsClientBeginDeleteOptions contains the optional parameters for the PoolsClient.BeginDelete method. +func (client *PoolsClient) BeginDelete(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientBeginDeleteOptions) (*runtime.Poller[PoolsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, poolName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoolsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PoolsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *PoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "PoolsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, poolName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - PoolsClientGetOptions contains the optional parameters for the PoolsClient.Get method. +func (client *PoolsClient) Get(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientGetOptions) (PoolsClientGetResponse, error) { + var err error + const operationName = "PoolsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, poolName, options) + if err != nil { + return PoolsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PoolsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PoolsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PoolsClient) getCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *PoolsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PoolsClient) getHandleResponse(resp *http.Response) (PoolsClientGetResponse, error) { + result := PoolsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Pool); err != nil { + return PoolsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List Pool resources by resource group +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - PoolsClientListByResourceGroupOptions contains the optional parameters for the PoolsClient.NewListByResourceGroupPager +// method. +func (client *PoolsClient) NewListByResourceGroupPager(resourceGroupName string, options *PoolsClientListByResourceGroupOptions) *runtime.Pager[PoolsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[PoolsClientListByResourceGroupResponse]{ + More: func(page PoolsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PoolsClientListByResourceGroupResponse) (PoolsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PoolsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return PoolsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PoolsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *PoolsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *PoolsClient) listByResourceGroupHandleResponse(resp *http.Response) (PoolsClientListByResourceGroupResponse, error) { + result := PoolsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PoolListResult); err != nil { + return PoolsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List Pool resources by subscription ID +// +// Generated from API version 2023-07-01-preview +// - options - PoolsClientListBySubscriptionOptions contains the optional parameters for the PoolsClient.NewListBySubscriptionPager +// method. +func (client *PoolsClient) NewListBySubscriptionPager(options *PoolsClientListBySubscriptionOptions) *runtime.Pager[PoolsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[PoolsClientListBySubscriptionResponse]{ + More: func(page PoolsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PoolsClientListBySubscriptionResponse) (PoolsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PoolsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return PoolsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PoolsClient) listBySubscriptionCreateRequest(ctx context.Context, options *PoolsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerStorage/pools" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PoolsClient) listBySubscriptionHandleResponse(resp *http.Response) (PoolsClientListBySubscriptionResponse, error) { + result := PoolsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PoolListResult); err != nil { + return PoolsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - properties - The resource properties to be updated. +// - options - PoolsClientBeginUpdateOptions contains the optional parameters for the PoolsClient.BeginUpdate method. +func (client *PoolsClient) BeginUpdate(ctx context.Context, resourceGroupName string, poolName string, properties PoolUpdate, options *PoolsClientBeginUpdateOptions) (*runtime.Poller[PoolsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, poolName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PoolsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PoolsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a Pool +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *PoolsClient) update(ctx context.Context, resourceGroupName string, poolName string, properties PoolUpdate, options *PoolsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "PoolsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, poolName, 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 *PoolsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, properties PoolUpdate, options *PoolsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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", "2023-07-01-preview") + 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/sdk/resourcemanager/containerstorage/armcontainerstorage/responses.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/responses.go new file mode 100644 index 000000000000..bd88414d5bac --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/responses.go @@ -0,0 +1,102 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +// 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 +} + +// PoolsClientCreateOrUpdateResponse contains the response from method PoolsClient.BeginCreateOrUpdate. +type PoolsClientCreateOrUpdateResponse struct { + // Pool resource + Pool +} + +// PoolsClientDeleteResponse contains the response from method PoolsClient.BeginDelete. +type PoolsClientDeleteResponse struct { + // placeholder for future response values +} + +// PoolsClientGetResponse contains the response from method PoolsClient.Get. +type PoolsClientGetResponse struct { + // Pool resource + Pool +} + +// PoolsClientListByResourceGroupResponse contains the response from method PoolsClient.NewListByResourceGroupPager. +type PoolsClientListByResourceGroupResponse struct { + // The response of a Pool list operation. + PoolListResult +} + +// PoolsClientListBySubscriptionResponse contains the response from method PoolsClient.NewListBySubscriptionPager. +type PoolsClientListBySubscriptionResponse struct { + // The response of a Pool list operation. + PoolListResult +} + +// PoolsClientUpdateResponse contains the response from method PoolsClient.BeginUpdate. +type PoolsClientUpdateResponse struct { + // Pool resource + Pool +} + +// SnapshotsClientCreateOrUpdateResponse contains the response from method SnapshotsClient.BeginCreateOrUpdate. +type SnapshotsClientCreateOrUpdateResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Snapshot +} + +// SnapshotsClientDeleteResponse contains the response from method SnapshotsClient.BeginDelete. +type SnapshotsClientDeleteResponse struct { + // placeholder for future response values +} + +// SnapshotsClientGetResponse contains the response from method SnapshotsClient.Get. +type SnapshotsClientGetResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Snapshot +} + +// SnapshotsClientListByPoolResponse contains the response from method SnapshotsClient.NewListByPoolPager. +type SnapshotsClientListByPoolResponse struct { + // The response of a Snapshot list operation. + SnapshotListResult +} + +// VolumesClientCreateOrUpdateResponse contains the response from method VolumesClient.BeginCreateOrUpdate. +type VolumesClientCreateOrUpdateResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Volume +} + +// 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 { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Volume +} + +// VolumesClientListByPoolResponse contains the response from method VolumesClient.NewListByPoolPager. +type VolumesClientListByPoolResponse struct { + // The response of a Volume list operation. + VolumeListResult +} + +// VolumesClientUpdateResponse contains the response from method VolumesClient.BeginUpdate. +type VolumesClientUpdateResponse struct { + // Concrete proxy resource types can be created by aliasing this type using a specific property type. + Volume +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/snapshots_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/snapshots_client.go new file mode 100644 index 000000000000..06ff0b32b00a --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/snapshots_client.go @@ -0,0 +1,345 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +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" +) + +// SnapshotsClient contains the methods for the Snapshots group. +// Don't use this type directly, use NewSnapshotsClient() instead. +type SnapshotsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewSnapshotsClient creates a new instance of SnapshotsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSnapshotsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SnapshotsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SnapshotsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Snapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - snapshotName - Volume Snapshot Resource +// - resource - Resource create parameters. +// - options - SnapshotsClientBeginCreateOrUpdateOptions contains the optional parameters for the SnapshotsClient.BeginCreateOrUpdate +// method. +func (client *SnapshotsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, resource Snapshot, options *SnapshotsClientBeginCreateOrUpdateOptions) (*runtime.Poller[SnapshotsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, poolName, snapshotName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SnapshotsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SnapshotsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a Snapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *SnapshotsClient) createOrUpdate(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, resource Snapshot, options *SnapshotsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "SnapshotsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, poolName, snapshotName, 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 *SnapshotsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, resource Snapshot, options *SnapshotsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/snapshots/{snapshotName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if snapshotName == "" { + return nil, errors.New("parameter snapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{snapshotName}", url.PathEscape(snapshotName)) + 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", "2023-07-01-preview") + 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 Snapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - snapshotName - Volume Snapshot Resource +// - options - SnapshotsClientBeginDeleteOptions contains the optional parameters for the SnapshotsClient.BeginDelete method. +func (client *SnapshotsClient) BeginDelete(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, options *SnapshotsClientBeginDeleteOptions) (*runtime.Poller[SnapshotsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, poolName, snapshotName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SnapshotsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SnapshotsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a Snapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *SnapshotsClient) deleteOperation(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, options *SnapshotsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "SnapshotsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, poolName, snapshotName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SnapshotsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, options *SnapshotsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/snapshots/{snapshotName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if snapshotName == "" { + return nil, errors.New("parameter snapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{snapshotName}", url.PathEscape(snapshotName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Snapshot +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - snapshotName - Volume Snapshot Resource +// - options - SnapshotsClientGetOptions contains the optional parameters for the SnapshotsClient.Get method. +func (client *SnapshotsClient) Get(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, options *SnapshotsClientGetOptions) (SnapshotsClientGetResponse, error) { + var err error + const operationName = "SnapshotsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, poolName, snapshotName, options) + if err != nil { + return SnapshotsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SnapshotsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SnapshotsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SnapshotsClient) getCreateRequest(ctx context.Context, resourceGroupName string, poolName string, snapshotName string, options *SnapshotsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/snapshots/{snapshotName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if snapshotName == "" { + return nil, errors.New("parameter snapshotName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{snapshotName}", url.PathEscape(snapshotName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SnapshotsClient) getHandleResponse(resp *http.Response) (SnapshotsClientGetResponse, error) { + result := SnapshotsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Snapshot); err != nil { + return SnapshotsClientGetResponse{}, err + } + return result, nil +} + +// NewListByPoolPager - List Snapshot resources by Pool +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - SnapshotsClientListByPoolOptions contains the optional parameters for the SnapshotsClient.NewListByPoolPager +// method. +func (client *SnapshotsClient) NewListByPoolPager(resourceGroupName string, poolName string, options *SnapshotsClientListByPoolOptions) *runtime.Pager[SnapshotsClientListByPoolResponse] { + return runtime.NewPager(runtime.PagingHandler[SnapshotsClientListByPoolResponse]{ + More: func(page SnapshotsClientListByPoolResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SnapshotsClientListByPoolResponse) (SnapshotsClientListByPoolResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SnapshotsClient.NewListByPoolPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByPoolCreateRequest(ctx, resourceGroupName, poolName, options) + }, nil) + if err != nil { + return SnapshotsClientListByPoolResponse{}, err + } + return client.listByPoolHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByPoolCreateRequest creates the ListByPool request. +func (client *SnapshotsClient) listByPoolCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *SnapshotsClientListByPoolOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/snapshots" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByPoolHandleResponse handles the ListByPool response. +func (client *SnapshotsClient) listByPoolHandleResponse(resp *http.Response) (SnapshotsClientListByPoolResponse, error) { + result := SnapshotsClientListByPoolResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SnapshotListResult); err != nil { + return SnapshotsClientListByPoolResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go new file mode 100644 index 000000000000..716bff1f04e6 --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go b/sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go new file mode 100644 index 000000000000..0f3733824a3e --- /dev/null +++ b/sdk/resourcemanager/containerstorage/armcontainerstorage/volumes_client.go @@ -0,0 +1,429 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armcontainerstorage + +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" +) + +// VolumesClient contains the methods for the Volumes group. +// Don't use this type directly, use NewVolumesClient() instead. +type VolumesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewVolumesClient creates a new instance of VolumesClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewVolumesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VolumesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VolumesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - resource - Resource create parameters. +// - options - VolumesClientBeginCreateOrUpdateOptions contains the optional parameters for the VolumesClient.BeginCreateOrUpdate +// method. +func (client *VolumesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeName string, resource Volume, options *VolumesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VolumesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, poolName, volumeName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VolumesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *VolumesClient) createOrUpdate(ctx context.Context, resourceGroupName string, poolName string, volumeName string, resource Volume, options *VolumesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "VolumesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, poolName, volumeName, 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 *VolumesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, resource Volume, options *VolumesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + 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", "2023-07-01-preview") + 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 Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - options - VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +func (client *VolumesClient) BeginDelete(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*runtime.Poller[VolumesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, poolName, volumeName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VolumesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *VolumesClient) deleteOperation(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "VolumesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, poolName, volumeName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VolumesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - options - VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. +func (client *VolumesClient) Get(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientGetOptions) (VolumesClientGetResponse, error) { + var err error + const operationName = "VolumesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, poolName, volumeName, options) + if err != nil { + return VolumesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VolumesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VolumesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VolumesClient) getCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, options *VolumesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VolumesClient) getHandleResponse(resp *http.Response) (VolumesClientGetResponse, error) { + result := VolumesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Volume); err != nil { + return VolumesClientGetResponse{}, err + } + return result, nil +} + +// NewListByPoolPager - List Volume resources by Pool +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - options - VolumesClientListByPoolOptions contains the optional parameters for the VolumesClient.NewListByPoolPager method. +func (client *VolumesClient) NewListByPoolPager(resourceGroupName string, poolName string, options *VolumesClientListByPoolOptions) *runtime.Pager[VolumesClientListByPoolResponse] { + return runtime.NewPager(runtime.PagingHandler[VolumesClientListByPoolResponse]{ + More: func(page VolumesClientListByPoolResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VolumesClientListByPoolResponse) (VolumesClientListByPoolResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VolumesClient.NewListByPoolPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByPoolCreateRequest(ctx, resourceGroupName, poolName, options) + }, nil) + if err != nil { + return VolumesClientListByPoolResponse{}, err + } + return client.listByPoolHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByPoolCreateRequest creates the ListByPool request. +func (client *VolumesClient) listByPoolCreateRequest(ctx context.Context, resourceGroupName string, poolName string, options *VolumesClientListByPoolOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + 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", "2023-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByPoolHandleResponse handles the ListByPool response. +func (client *VolumesClient) listByPoolHandleResponse(resp *http.Response) (VolumesClientListByPoolResponse, error) { + result := VolumesClientListByPoolResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VolumeListResult); err != nil { + return VolumesClientListByPoolResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - poolName - Pool Object +// - volumeName - Volume Resource +// - 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, resourceGroupName string, poolName string, volumeName string, properties VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*runtime.Poller[VolumesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, poolName, volumeName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VolumesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a Volume +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-01-preview +func (client *VolumesClient) update(ctx context.Context, resourceGroupName string, poolName string, volumeName string, properties VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "VolumesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, poolName, volumeName, 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 *VolumesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, poolName string, volumeName string, properties VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerStorage/pools/{poolName}/volumes/{volumeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if volumeName == "" { + return nil, errors.New("parameter volumeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) + 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", "2023-07-01-preview") + 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/sdk/resourcemanager/contoso/armcontoso/CHANGELOG.md b/sdk/resourcemanager/contoso/armcontoso/CHANGELOG.md new file mode 100644 index 000000000000..b221d0b6a1c4 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2024-08-22) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/contoso/armcontoso/LICENSE.txt b/sdk/resourcemanager/contoso/armcontoso/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/contoso/armcontoso/README.md b/sdk/resourcemanager/contoso/armcontoso/README.md new file mode 100644 index 000000000000..aef1020792c7 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/README.md @@ -0,0 +1,92 @@ +# Azure Contoso Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso) + +The `armcontoso` module provides operations for working with Azure Contoso. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/contoso/armcontoso) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Contoso module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Contoso. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Contoso module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armcontoso.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armcontoso.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewEmployeesClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Contoso` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/contoso/armcontoso/ci.yml b/sdk/resourcemanager/contoso/armcontoso/ci.yml new file mode 100644 index 000000000000..a068465b72a2 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/contoso/armcontoso/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/contoso/armcontoso/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/contoso/armcontoso' diff --git a/sdk/resourcemanager/contoso/armcontoso/client_factory.go b/sdk/resourcemanager/contoso/armcontoso/client_factory.go new file mode 100644 index 000000000000..0a0944ec82c6 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/client_factory.go @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +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 { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewEmployeesClient creates a new instance of EmployeesClient. +func (c *ClientFactory) NewEmployeesClient() *EmployeesClient { + return &EmployeesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/contoso/armcontoso/constants.go b/sdk/resourcemanager/contoso/armcontoso/constants.go new file mode 100644 index 000000000000..35ca72f6b867 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/constants.go @@ -0,0 +1,104 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso" + moduleVersion = "v0.1.0" +) + +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + // ActionTypeInternal - Actions are for internal-only APIs. + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CreatedByType - The kind of entity that created the resource. +type CreatedByType string + +const ( + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser - The entity was created by a user. + 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 - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - The resource provisioning state. +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" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} diff --git a/sdk/resourcemanager/contoso/armcontoso/employees_client.go b/sdk/resourcemanager/contoso/armcontoso/employees_client.go new file mode 100644 index 000000000000..df4a365b75fd --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/employees_client.go @@ -0,0 +1,444 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +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" +) + +// EmployeesClient contains the methods for the Employees group. +// Don't use this type directly, use NewEmployeesClient() instead. +type EmployeesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEmployeesClient creates a new instance of EmployeesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewEmployeesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EmployeesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EmployeesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a Employee +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-10-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - employeeName - The name of the Employee +// - resource - Resource create parameters. +// - options - EmployeesClientBeginCreateOrUpdateOptions contains the optional parameters for the EmployeesClient.BeginCreateOrUpdate +// method. +func (client *EmployeesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, employeeName string, resource Employee, options *EmployeesClientBeginCreateOrUpdateOptions) (*runtime.Poller[EmployeesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, employeeName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EmployeesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EmployeesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a Employee +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-10-01-preview +func (client *EmployeesClient) createOrUpdate(ctx context.Context, resourceGroupName string, employeeName string, resource Employee, options *EmployeesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "EmployeesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, employeeName, 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 *EmployeesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, employeeName string, resource Employee, _ *EmployeesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if employeeName == "" { + return nil, errors.New("parameter employeeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{employeeName}", url.PathEscape(employeeName)) + 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", "2021-10-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a Employee +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-10-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - employeeName - The name of the Employee +// - options - EmployeesClientBeginDeleteOptions contains the optional parameters for the EmployeesClient.BeginDelete method. +func (client *EmployeesClient) BeginDelete(ctx context.Context, resourceGroupName string, employeeName string, options *EmployeesClientBeginDeleteOptions) (*runtime.Poller[EmployeesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, employeeName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EmployeesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EmployeesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a Employee +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-10-01-preview +func (client *EmployeesClient) deleteOperation(ctx context.Context, resourceGroupName string, employeeName string, options *EmployeesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "EmployeesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, employeeName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EmployeesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, employeeName string, _ *EmployeesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if employeeName == "" { + return nil, errors.New("parameter employeeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{employeeName}", url.PathEscape(employeeName)) + 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", "2021-10-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Employee +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-10-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - employeeName - The name of the Employee +// - options - EmployeesClientGetOptions contains the optional parameters for the EmployeesClient.Get method. +func (client *EmployeesClient) Get(ctx context.Context, resourceGroupName string, employeeName string, options *EmployeesClientGetOptions) (EmployeesClientGetResponse, error) { + var err error + const operationName = "EmployeesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, employeeName, options) + if err != nil { + return EmployeesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EmployeesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EmployeesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EmployeesClient) getCreateRequest(ctx context.Context, resourceGroupName string, employeeName string, _ *EmployeesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if employeeName == "" { + return nil, errors.New("parameter employeeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{employeeName}", url.PathEscape(employeeName)) + 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", "2021-10-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EmployeesClient) getHandleResponse(resp *http.Response) (EmployeesClientGetResponse, error) { + result := EmployeesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Employee); err != nil { + return EmployeesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List Employee resources by resource group +// +// Generated from API version 2021-10-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - EmployeesClientListByResourceGroupOptions contains the optional parameters for the EmployeesClient.NewListByResourceGroupPager +// method. +func (client *EmployeesClient) NewListByResourceGroupPager(resourceGroupName string, options *EmployeesClientListByResourceGroupOptions) *runtime.Pager[EmployeesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[EmployeesClientListByResourceGroupResponse]{ + More: func(page EmployeesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EmployeesClientListByResourceGroupResponse) (EmployeesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EmployeesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return EmployeesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *EmployeesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *EmployeesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2021-10-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *EmployeesClient) listByResourceGroupHandleResponse(resp *http.Response) (EmployeesClientListByResourceGroupResponse, error) { + result := EmployeesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EmployeeListResult); err != nil { + return EmployeesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List Employee resources by subscription ID +// +// Generated from API version 2021-10-01-preview +// - options - EmployeesClientListBySubscriptionOptions contains the optional parameters for the EmployeesClient.NewListBySubscriptionPager +// method. +func (client *EmployeesClient) NewListBySubscriptionPager(options *EmployeesClientListBySubscriptionOptions) *runtime.Pager[EmployeesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[EmployeesClientListBySubscriptionResponse]{ + More: func(page EmployeesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EmployeesClientListBySubscriptionResponse) (EmployeesClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EmployeesClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return EmployeesClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *EmployeesClient) listBySubscriptionCreateRequest(ctx context.Context, _ *EmployeesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/employees" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2021-10-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *EmployeesClient) listBySubscriptionHandleResponse(resp *http.Response) (EmployeesClientListBySubscriptionResponse, error) { + result := EmployeesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EmployeeListResult); err != nil { + return EmployeesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Update a Employee +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-10-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - employeeName - The name of the Employee +// - properties - The resource properties to be updated. +// - options - EmployeesClientUpdateOptions contains the optional parameters for the EmployeesClient.Update method. +func (client *EmployeesClient) Update(ctx context.Context, resourceGroupName string, employeeName string, properties EmployeeUpdate, options *EmployeesClientUpdateOptions) (EmployeesClientUpdateResponse, error) { + var err error + const operationName = "EmployeesClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, employeeName, properties, options) + if err != nil { + return EmployeesClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EmployeesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EmployeesClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *EmployeesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, employeeName string, properties EmployeeUpdate, _ *EmployeesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/employees/{employeeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if employeeName == "" { + return nil, errors.New("parameter employeeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{employeeName}", url.PathEscape(employeeName)) + 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", "2021-10-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *EmployeesClient) updateHandleResponse(resp *http.Response) (EmployeesClientUpdateResponse, error) { + result := EmployeesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Employee); err != nil { + return EmployeesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/contoso/armcontoso/employees_client_example_test.go b/sdk/resourcemanager/contoso/armcontoso/employees_client_example_test.go new file mode 100644 index 000000000000..d51ca0c55dc7 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/employees_client_example_test.go @@ -0,0 +1,302 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso" + "log" +) + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso/TempTypeSpecFiles/Contoso.Management/examples/2021-10-01-preview/Employees_CreateOrUpdate.json +func ExampleEmployeesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontoso.NewClientFactory("11809CA1-E126-4017-945E-AA795CD5C5A9", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEmployeesClient().BeginCreateOrUpdate(ctx, "rgopenapi", "9KF-f-8b", armcontoso.Employee{ + Properties: &armcontoso.EmployeeProperties{ + Age: to.Ptr[int32](30), + City: to.Ptr("gydhnntudughbmxlkyzrskcdkotrxn"), + Profile: []byte("ms"), + }, + Tags: map[string]*string{ + "key2913": to.Ptr("urperxmkkhhkp"), + }, + Location: to.Ptr("itajgxyqozseoygnl"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontoso.EmployeesClientCreateOrUpdateResponse{ + // Employee: &armcontoso.Employee{ + // Properties: &armcontoso.EmployeeProperties{ + // Age: to.Ptr[int32](30), + // City: to.Ptr("gydhnntudughbmxlkyzrskcdkotrxn"), + // Profile: []byte("ms"), + // ProvisioningState: to.Ptr(armcontoso.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "key2913": to.Ptr("urperxmkkhhkp"), + // }, + // Location: to.Ptr("itajgxyqozseoygnl"), + // ID: to.Ptr("/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/le-8MU--J3W6q8D386p3-iT3"), + // Name: to.Ptr("xepyxhpb"), + // Type: to.Ptr("svvamxrdnnv"), + // SystemData: &armcontoso.SystemData{ + // CreatedBy: to.Ptr("iewyxsnriqktsvp"), + // CreatedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // LastModifiedBy: to.Ptr("xrchbnnuzierzpxw"), + // LastModifiedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso/TempTypeSpecFiles/Contoso.Management/examples/2021-10-01-preview/Employees_Delete.json +func ExampleEmployeesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontoso.NewClientFactory("11809CA1-E126-4017-945E-AA795CD5C5A9", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEmployeesClient().BeginDelete(ctx, "rgopenapi", "5vX--BxSu3ux48rI4O9OQ569", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso/TempTypeSpecFiles/Contoso.Management/examples/2021-10-01-preview/Employees_Get.json +func ExampleEmployeesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontoso.NewClientFactory("11809CA1-E126-4017-945E-AA795CD5C5A9", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEmployeesClient().Get(ctx, "rgopenapi", "le-8MU--J3W6q8D386p3-iT3", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontoso.EmployeesClientGetResponse{ + // Employee: &armcontoso.Employee{ + // Properties: &armcontoso.EmployeeProperties{ + // Age: to.Ptr[int32](30), + // City: to.Ptr("gydhnntudughbmxlkyzrskcdkotrxn"), + // Profile: []byte("ms"), + // ProvisioningState: to.Ptr(armcontoso.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "key2913": to.Ptr("urperxmkkhhkp"), + // }, + // Location: to.Ptr("itajgxyqozseoygnl"), + // ID: to.Ptr("/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/le-8MU--J3W6q8D386p3-iT3"), + // Name: to.Ptr("xepyxhpb"), + // Type: to.Ptr("svvamxrdnnv"), + // SystemData: &armcontoso.SystemData{ + // CreatedBy: to.Ptr("iewyxsnriqktsvp"), + // CreatedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // LastModifiedBy: to.Ptr("xrchbnnuzierzpxw"), + // LastModifiedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso/TempTypeSpecFiles/Contoso.Management/examples/2021-10-01-preview/Employees_ListByResourceGroup.json +func ExampleEmployeesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontoso.NewClientFactory("11809CA1-E126-4017-945E-AA795CD5C5A9", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEmployeesClient().NewListByResourceGroupPager("rgopenapi", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcontoso.EmployeesClientListByResourceGroupResponse{ + // EmployeeListResult: armcontoso.EmployeeListResult{ + // Value: []*armcontoso.Employee{ + // { + // Properties: &armcontoso.EmployeeProperties{ + // Age: to.Ptr[int32](30), + // City: to.Ptr("gydhnntudughbmxlkyzrskcdkotrxn"), + // Profile: []byte("ms"), + // ProvisioningState: to.Ptr(armcontoso.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "key2913": to.Ptr("urperxmkkhhkp"), + // }, + // Location: to.Ptr("itajgxyqozseoygnl"), + // ID: to.Ptr("/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/test"), + // Name: to.Ptr("xepyxhpb"), + // Type: to.Ptr("svvamxrdnnv"), + // SystemData: &armcontoso.SystemData{ + // CreatedBy: to.Ptr("iewyxsnriqktsvp"), + // CreatedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // LastModifiedBy: to.Ptr("xrchbnnuzierzpxw"), + // LastModifiedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso/TempTypeSpecFiles/Contoso.Management/examples/2021-10-01-preview/Employees_ListBySubscription.json +func ExampleEmployeesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontoso.NewClientFactory("11809CA1-E126-4017-945E-AA795CD5C5A9", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEmployeesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcontoso.EmployeesClientListBySubscriptionResponse{ + // EmployeeListResult: armcontoso.EmployeeListResult{ + // Value: []*armcontoso.Employee{ + // { + // Properties: &armcontoso.EmployeeProperties{ + // Age: to.Ptr[int32](30), + // City: to.Ptr("gydhnntudughbmxlkyzrskcdkotrxn"), + // Profile: []byte("ms"), + // ProvisioningState: to.Ptr(armcontoso.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "key2913": to.Ptr("urperxmkkhhkp"), + // }, + // Location: to.Ptr("itajgxyqozseoygnl"), + // ID: to.Ptr("/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/rgopenapi/providers/Microsoft.Contoso/employees/test"), + // Name: to.Ptr("xepyxhpb"), + // Type: to.Ptr("svvamxrdnnv"), + // SystemData: &armcontoso.SystemData{ + // CreatedBy: to.Ptr("iewyxsnriqktsvp"), + // CreatedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // LastModifiedBy: to.Ptr("xrchbnnuzierzpxw"), + // LastModifiedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso/TempTypeSpecFiles/Contoso.Management/examples/2021-10-01-preview/Employees_Update.json +func ExampleEmployeesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontoso.NewClientFactory("11809CA1-E126-4017-945E-AA795CD5C5A9", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEmployeesClient().Update(ctx, "rgopenapi", "-XhyNJ--", armcontoso.EmployeeUpdate{ + Tags: map[string]*string{ + "key7952": to.Ptr("no"), + }, + Properties: &armcontoso.EmployeeUpdateProperties{ + Age: to.Ptr[int32](24), + City: to.Ptr("uyfg"), + Profile: []byte("oapgijcswfkruiuuzbwco"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontoso.EmployeesClientUpdateResponse{ + // Employee: &armcontoso.Employee{ + // Properties: &armcontoso.EmployeeProperties{ + // Age: to.Ptr[int32](30), + // City: to.Ptr("gydhnntudughbmxlkyzrskcdkotrxn"), + // Profile: []byte("ms"), + // ProvisioningState: to.Ptr(armcontoso.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "key2913": to.Ptr("urperxmkkhhkp"), + // }, + // Location: to.Ptr("itajgxyqozseoygnl"), + // ID: to.Ptr("/subscriptions/11809CA1-E126-4017-945E-AA795CD5C5A9/resourceGroups/contoso/providers/Microsoft.Contoso/employees/test"), + // Name: to.Ptr("xepyxhpb"), + // Type: to.Ptr("svvamxrdnnv"), + // SystemData: &armcontoso.SystemData{ + // CreatedBy: to.Ptr("iewyxsnriqktsvp"), + // CreatedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // LastModifiedBy: to.Ptr("xrchbnnuzierzpxw"), + // LastModifiedByType: to.Ptr(armcontoso.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-05-19T00:28:48.610Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/contoso/armcontoso/fake/employees_server.go b/sdk/resourcemanager/contoso/armcontoso/fake/employees_server.go new file mode 100644 index 000000000000..332c373af4ab --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/fake/employees_server.go @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso" + "net/http" + "net/url" + "regexp" +) + +// EmployeesServer is a fake server for instances of the armcontoso.EmployeesClient type. +type EmployeesServer struct { + // BeginCreateOrUpdate is the fake for method EmployeesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, employeeName string, resource armcontoso.Employee, options *armcontoso.EmployeesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armcontoso.EmployeesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method EmployeesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, employeeName string, options *armcontoso.EmployeesClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontoso.EmployeesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EmployeesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, employeeName string, options *armcontoso.EmployeesClientGetOptions) (resp azfake.Responder[armcontoso.EmployeesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method EmployeesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armcontoso.EmployeesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armcontoso.EmployeesClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method EmployeesClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armcontoso.EmployeesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armcontoso.EmployeesClientListBySubscriptionResponse]) + + // Update is the fake for method EmployeesClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, employeeName string, properties armcontoso.EmployeeUpdate, options *armcontoso.EmployeesClientUpdateOptions) (resp azfake.Responder[armcontoso.EmployeesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewEmployeesServerTransport creates a new instance of EmployeesServerTransport with the provided implementation. +// The returned EmployeesServerTransport instance is connected to an instance of armcontoso.EmployeesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEmployeesServerTransport(srv *EmployeesServer) *EmployeesServerTransport { + return &EmployeesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armcontoso.EmployeesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armcontoso.EmployeesClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armcontoso.EmployeesClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armcontoso.EmployeesClientListBySubscriptionResponse]](), + } +} + +// EmployeesServerTransport connects instances of armcontoso.EmployeesClient to instances of EmployeesServer. +// Don't use this type directly, use NewEmployeesServerTransport instead. +type EmployeesServerTransport struct { + srv *EmployeesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armcontoso.EmployeesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armcontoso.EmployeesClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armcontoso.EmployeesClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armcontoso.EmployeesClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for EmployeesServerTransport. +func (e *EmployeesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return e.dispatchToMethodFake(req, method) +} + +func (e *EmployeesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + var resp *http.Response + var err error + + switch method { + case "EmployeesClient.BeginCreateOrUpdate": + resp, err = e.dispatchBeginCreateOrUpdate(req) + case "EmployeesClient.BeginDelete": + resp, err = e.dispatchBeginDelete(req) + case "EmployeesClient.Get": + resp, err = e.dispatchGet(req) + case "EmployeesClient.NewListByResourceGroupPager": + resp, err = e.dispatchNewListByResourceGroupPager(req) + case "EmployeesClient.NewListBySubscriptionPager": + resp, err = e.dispatchNewListBySubscriptionPager(req) + case "EmployeesClient.Update": + resp, err = e.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + return resp, err +} + +func (e *EmployeesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if e.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := e.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Contoso/employees/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontoso.Employee](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + employeeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("employeeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, employeeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + e.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + e.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + e.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (e *EmployeesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if e.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := e.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Contoso/employees/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + employeeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("employeeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameParam, employeeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + e.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + e.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + e.beginDelete.remove(req) + } + + return resp, nil +} + +func (e *EmployeesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Contoso/employees/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + employeeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("employeeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, employeeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Employee, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EmployeesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := e.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Contoso/employees` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + e.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armcontoso.EmployeesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + e.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (e *EmployeesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := e.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Contoso/employees` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := e.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + e.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armcontoso.EmployeesClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + e.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (e *EmployeesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if e.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Contoso/employees/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontoso.EmployeeUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + employeeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("employeeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Update(req.Context(), resourceGroupNameParam, employeeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Employee, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/contoso/armcontoso/fake/internal.go b/sdk/resourcemanager/contoso/armcontoso/fake/internal.go new file mode 100644 index 000000000000..56a8f624f5f3 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/fake/internal.go @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/contoso/armcontoso/fake/operations_server.go b/sdk/resourcemanager/contoso/armcontoso/fake/operations_server.go new file mode 100644 index 000000000000..5cd31d949c8d --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/fake/operations_server.go @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso" + "net/http" +) + +// OperationsServer is a fake server for instances of the armcontoso.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armcontoso.OperationsClientListOptions) (resp azfake.PagerResponder[armcontoso.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armcontoso.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcontoso.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armcontoso.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armcontoso.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + return resp, err +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcontoso.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/contoso/armcontoso/fake/server_factory.go b/sdk/resourcemanager/contoso/armcontoso/fake/server_factory.go new file mode 100644 index 000000000000..9ddfd8463c5a --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/fake/server_factory.go @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armcontoso.ClientFactory type. +type ServerFactory struct { + // EmployeesServer contains the fakes for client EmployeesClient + EmployeesServer EmployeesServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armcontoso.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armcontoso.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trEmployeesServer *EmployeesServerTransport + trOperationsServer *OperationsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "EmployeesClient": + initServer(s, &s.trEmployeesServer, func() *EmployeesServerTransport { return NewEmployeesServerTransport(&s.srv.EmployeesServer) }) + resp, err = s.trEmployeesServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/contoso/armcontoso/fake/time_rfc3339.go b/sdk/resourcemanager/contoso/armcontoso/fake/time_rfc3339.go new file mode 100644 index 000000000000..87ee11e83b32 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/fake/time_rfc3339.go @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/contoso/armcontoso/go.mod b/sdk/resourcemanager/contoso/armcontoso/go.mod new file mode 100644 index 000000000000..043fb45f0611 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect + golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect +) diff --git a/sdk/resourcemanager/contoso/armcontoso/go.sum b/sdk/resourcemanager/contoso/armcontoso/go.sum new file mode 100644 index 000000000000..09d275cb9a37 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/go.sum @@ -0,0 +1,29 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/contoso/armcontoso/models.go b/sdk/resourcemanager/contoso/armcontoso/models.go new file mode 100644 index 000000000000..1378e3ca5b78 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/models.go @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +import "time" + +// Employee resource +type Employee struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *EmployeeProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; The name of the Employee + 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 +} + +// EmployeeListResult - The response of a Employee list operation. +type EmployeeListResult struct { + // REQUIRED; The Employee items on this page + Value []*Employee + + // The link to the next page of items + NextLink *string +} + +// EmployeeProperties - Employee properties +type EmployeeProperties struct { + // Age of employee + Age *int32 + + // City of employee + City *string + + // Profile of employee + Profile []byte + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// EmployeeUpdate - The type used for update operations of the Employee. +type EmployeeUpdate struct { + // The resource-specific properties for this resource. + Properties *EmployeeUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// EmployeeUpdateProperties - The updatable properties of the Employee. +type EmployeeUpdateProperties struct { + // Age of employee + Age *int32 + + // City of employee + City *string + + // Profile of employee + Profile []byte +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + // Resource Manager/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 and 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 { + // REQUIRED; The Operation items on this page + Value []*Operation + + // The link to the next page of items + NextLink *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} diff --git a/sdk/resourcemanager/contoso/armcontoso/models_serde.go b/sdk/resourcemanager/contoso/armcontoso/models_serde.go new file mode 100644 index 000000000000..a5948b12a9ef --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/models_serde.go @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Employee. +func (e Employee) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 Employee. +func (e *Employee) 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 EmployeeListResult. +func (e EmployeeListResult) 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 EmployeeListResult. +func (e *EmployeeListResult) 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 EmployeeProperties. +func (e EmployeeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "age", e.Age) + populate(objectMap, "city", e.City) + populateByteArray(objectMap, "profile", e.Profile, func() any { + return runtime.EncodeByteArray(e.Profile, runtime.Base64URLFormat) + }) + populate(objectMap, "provisioningState", e.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmployeeProperties. +func (e *EmployeeProperties) 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 "age": + err = unpopulate(val, "Age", &e.Age) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &e.City) + delete(rawMsg, key) + case "profile": + if val != nil && string(val) != "null" { + err = runtime.DecodeByteArray(string(val), &e.Profile, runtime.Base64URLFormat) + } + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + 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 EmployeeUpdate. +func (e EmployeeUpdate) 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 EmployeeUpdate. +func (e *EmployeeUpdate) 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 EmployeeUpdateProperties. +func (e EmployeeUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "age", e.Age) + populate(objectMap, "city", e.City) + populateByteArray(objectMap, "profile", e.Profile, func() any { + return runtime.EncodeByteArray(e.Profile, runtime.Base64URLFormat) + }) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmployeeUpdateProperties. +func (e *EmployeeUpdateProperties) 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 "age": + err = unpopulate(val, "Age", &e.Age) + delete(rawMsg, key) + case "city": + err = unpopulate(val, "City", &e.City) + delete(rawMsg, key) + case "profile": + if val != nil && string(val) != "null" { + err = runtime.DecodeByteArray(string(val), &e.Profile, runtime.Base64URLFormat) + } + 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 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 SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateByteArray[T any](m map[string]any, k string, b []T, convert func() any) { + if azcore.IsNullValue(b) { + m[k] = nil + } else if len(b) == 0 { + return + } else { + m[k] = convert() + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/contoso/armcontoso/operations_client.go b/sdk/resourcemanager/contoso/armcontoso/operations_client.go new file mode 100644 index 000000000000..2a060162ef11 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/operations_client.go @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + 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. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2021-10-01-preview +// - 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 { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Contoso/operations" + 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", "2021-10-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/contoso/armcontoso/operations_client_example_test.go b/sdk/resourcemanager/contoso/armcontoso/operations_client_example_test.go new file mode 100644 index 000000000000..cd5db6a2e104 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/operations_client_example_test.go @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso" + "log" +) + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/contoso/armcontoso/TempTypeSpecFiles/Contoso.Management/examples/2021-10-01-preview/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontoso.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcontoso.OperationsClientListResponse{ + // OperationListResult: armcontoso.OperationListResult{ + // Value: []*armcontoso.Operation{ + // { + // Name: to.Ptr("ymeow"), + // IsDataAction: to.Ptr(true), + // Display: &armcontoso.OperationDisplay{ + // Provider: to.Ptr("qxyznq"), + // Resource: to.Ptr("bqfwkox"), + // Operation: to.Ptr("td"), + // Description: to.Ptr("yvgkhsuwartgxb"), + // }, + // Origin: to.Ptr(armcontoso.OriginUser), + // ActionType: to.Ptr(armcontoso.ActionTypeInternal), + // }, + // }, + // NextLink: to.Ptr("https://sample.com/nextLink"), + // }, + // } + } +} diff --git a/sdk/resourcemanager/contoso/armcontoso/options.go b/sdk/resourcemanager/contoso/armcontoso/options.go new file mode 100644 index 000000000000..11fee1c76771 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/options.go @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +// EmployeesClientBeginCreateOrUpdateOptions contains the optional parameters for the EmployeesClient.BeginCreateOrUpdate +// method. +type EmployeesClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EmployeesClientBeginDeleteOptions contains the optional parameters for the EmployeesClient.BeginDelete method. +type EmployeesClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EmployeesClientGetOptions contains the optional parameters for the EmployeesClient.Get method. +type EmployeesClientGetOptions struct { + // placeholder for future optional parameters +} + +// EmployeesClientListByResourceGroupOptions contains the optional parameters for the EmployeesClient.NewListByResourceGroupPager +// method. +type EmployeesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// EmployeesClientListBySubscriptionOptions contains the optional parameters for the EmployeesClient.NewListBySubscriptionPager +// method. +type EmployeesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// EmployeesClientUpdateOptions contains the optional parameters for the EmployeesClient.Update method. +type EmployeesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/contoso/armcontoso/responses.go b/sdk/resourcemanager/contoso/armcontoso/responses.go new file mode 100644 index 000000000000..9b28221cf0cb --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/responses.go @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +// EmployeesClientCreateOrUpdateResponse contains the response from method EmployeesClient.BeginCreateOrUpdate. +type EmployeesClientCreateOrUpdateResponse struct { + // Employee resource + Employee +} + +// EmployeesClientDeleteResponse contains the response from method EmployeesClient.BeginDelete. +type EmployeesClientDeleteResponse struct { + // placeholder for future response values +} + +// EmployeesClientGetResponse contains the response from method EmployeesClient.Get. +type EmployeesClientGetResponse struct { + // Employee resource + Employee +} + +// EmployeesClientListByResourceGroupResponse contains the response from method EmployeesClient.NewListByResourceGroupPager. +type EmployeesClientListByResourceGroupResponse struct { + // The response of a Employee list operation. + EmployeeListResult +} + +// EmployeesClientListBySubscriptionResponse contains the response from method EmployeesClient.NewListBySubscriptionPager. +type EmployeesClientListBySubscriptionResponse struct { + // The response of a Employee list operation. + EmployeeListResult +} + +// EmployeesClientUpdateResponse contains the response from method EmployeesClient.Update. +type EmployeesClientUpdateResponse struct { + // Employee resource + Employee +} + +// 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 +} diff --git a/sdk/resourcemanager/contoso/armcontoso/time_rfc3339.go b/sdk/resourcemanager/contoso/armcontoso/time_rfc3339.go new file mode 100644 index 000000000000..fd129d84c771 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/time_rfc3339.go @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontoso + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/contoso/armcontoso/tsp-location.yaml b/sdk/resourcemanager/contoso/armcontoso/tsp-location.yaml new file mode 100644 index 000000000000..7460c3033134 --- /dev/null +++ b/sdk/resourcemanager/contoso/armcontoso/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/contosowidgetmanager/Contoso.Management +commit: 37d436549a6380c74ed7b2a1f5114e97282e0042 +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: \ No newline at end of file diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/CHANGELOG.md b/sdk/resourcemanager/deviceregistry/armdeviceregistry/CHANGELOG.md index f66976289d9e..4f69fd9cfeda 100644 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/CHANGELOG.md +++ b/sdk/resourcemanager/deviceregistry/armdeviceregistry/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 0.1.1 (2024-08-22) +### Other Changes + + ## 0.1.0 (2024-04-26) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armdeviceregistry` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/assetendpointprofiles_client_example_test.go b/sdk/resourcemanager/deviceregistry/armdeviceregistry/assetendpointprofiles_client_example_test.go deleted file mode 100644 index 7db98ffb753b..000000000000 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/assetendpointprofiles_client_example_test.go +++ /dev/null @@ -1,486 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdeviceregistry_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armdeviceregistry" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json -func ExampleAssetEndpointProfilesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssetEndpointProfilesClient().NewListBySubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssetEndpointProfileListResult = armdeviceregistry.AssetEndpointProfileListResult{ - // Value: []*armdeviceregistry.AssetEndpointProfile{ - // { - // Name: to.Ptr("my-assetendpointprofile"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress"), - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeAnonymous), - // }, - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // }, - // }, - // { - // Name: to.Ptr("my-assetendpointprofile1"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile1"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-2"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress1"), - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeCertificate), - // X509Credentials: &armdeviceregistry.X509Credentials{ - // CertificateReference: to.Ptr("certificatRef"), - // }, - // }, - // UUID: to.Ptr("7824a74f-21e1-4458-ae06-604d3a241d2c"), - // }, - // }, - // { - // Name: to.Ptr("my-assetendpointprofile2"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile2"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-2"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress2"), - // TransportAuthentication: &armdeviceregistry.TransportAuthentication{ - // OwnCertificates: []*armdeviceregistry.OwnCertificate{ - // { - // CertPasswordReference: to.Ptr("passwordRef"), - // CertSecretReference: to.Ptr("secretRef"), - // CertThumbprint: to.Ptr("myThumbprint"), - // }}, - // }, - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeUsernamePassword), - // UsernamePasswordCredentials: &armdeviceregistry.UsernamePasswordCredentials{ - // PasswordReference: to.Ptr("passwordRef"), - // UsernameReference: to.Ptr("usernameRef"), - // }, - // }, - // UUID: to.Ptr("1824a74f-21e1-4458-ae07-604d3a241d2e"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json -func ExampleAssetEndpointProfilesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssetEndpointProfilesClient().NewListByResourceGroupPager("myResourceGroup", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssetEndpointProfileListResult = armdeviceregistry.AssetEndpointProfileListResult{ - // Value: []*armdeviceregistry.AssetEndpointProfile{ - // { - // Name: to.Ptr("my-assetendpointprofile"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress"), - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeAnonymous), - // }, - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // }, - // }, - // { - // Name: to.Ptr("my-assetendpointprofile1"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile1"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-2"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress1"), - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeCertificate), - // X509Credentials: &armdeviceregistry.X509Credentials{ - // CertificateReference: to.Ptr("certificatRef"), - // }, - // }, - // UUID: to.Ptr("7824a74f-21e1-4458-ae06-604d3a241d2c"), - // }, - // }, - // { - // Name: to.Ptr("my-assetendpointprofile2"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile2"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-2"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress2"), - // TransportAuthentication: &armdeviceregistry.TransportAuthentication{ - // OwnCertificates: []*armdeviceregistry.OwnCertificate{ - // { - // CertPasswordReference: to.Ptr("passwordRef"), - // CertSecretReference: to.Ptr("secretRef"), - // CertThumbprint: to.Ptr("myThumbprint"), - // }}, - // }, - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeUsernamePassword), - // UsernamePasswordCredentials: &armdeviceregistry.UsernamePasswordCredentials{ - // PasswordReference: to.Ptr("passwordRef"), - // UsernameReference: to.Ptr("usernameRef"), - // }, - // }, - // UUID: to.Ptr("1824a74f-21e1-4458-ae07-604d3a241d2e"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json -func ExampleAssetEndpointProfilesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssetEndpointProfilesClient().Get(ctx, "myResourceGroup", "my-assetendpointprofile", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssetEndpointProfile = armdeviceregistry.AssetEndpointProfile{ - // Name: to.Ptr("my-assetendpointprofile"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress"), - // TransportAuthentication: &armdeviceregistry.TransportAuthentication{ - // OwnCertificates: []*armdeviceregistry.OwnCertificate{ - // { - // CertPasswordReference: to.Ptr("passwordRef"), - // CertSecretReference: to.Ptr("secretRef"), - // CertThumbprint: to.Ptr("myThumbprint"), - // }}, - // }, - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeUsernamePassword), - // UsernamePasswordCredentials: &armdeviceregistry.UsernamePasswordCredentials{ - // PasswordReference: to.Ptr("passwordRef"), - // UsernameReference: to.Ptr("usernameRef"), - // }, - // }, - // UUID: to.Ptr("1824a74f-21e1-4458-ae07-604d3a241d2e"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json -func ExampleAssetEndpointProfilesClient_BeginCreateOrReplace() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetEndpointProfilesClient().BeginCreateOrReplace(ctx, "myResourceGroup", "my-assetendpointprofile", armdeviceregistry.AssetEndpointProfile{ - Location: to.Ptr("West Europe"), - Tags: map[string]*string{ - "site": to.Ptr("building-1"), - }, - ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - Type: to.Ptr("CustomLocation"), - }, - Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - TargetAddress: to.Ptr("https://www.example.com/myTargetAddress"), - UserAuthentication: &armdeviceregistry.UserAuthentication{ - Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeAnonymous), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssetEndpointProfile = armdeviceregistry.AssetEndpointProfile{ - // Name: to.Ptr("my-assetendpointprofile"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress"), - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeAnonymous), - // }, - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json -func ExampleAssetEndpointProfilesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetEndpointProfilesClient().BeginUpdate(ctx, "myResourceGroup", "my-assetendpointprofile", armdeviceregistry.AssetEndpointProfileUpdate{ - Properties: &armdeviceregistry.AssetEndpointProfileUpdateProperties{ - TargetAddress: to.Ptr("https://www.example.com/myTargetAddress"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AssetEndpointProfile = armdeviceregistry.AssetEndpointProfile{ - // Name: to.Ptr("my-assetendpointprofile"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assetEndpointProfiles"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/my-assetendpointprofile"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetEndpointProfileProperties{ - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // TargetAddress: to.Ptr("https://www.example.com/myTargetAddress"), - // UserAuthentication: &armdeviceregistry.UserAuthentication{ - // Mode: to.Ptr(armdeviceregistry.UserAuthenticationModeAnonymous), - // }, - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json -func ExampleAssetEndpointProfilesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetEndpointProfilesClient().BeginDelete(ctx, "myResourceGroup", "my-assetendpointprofile", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/assets_client_example_test.go b/sdk/resourcemanager/deviceregistry/armdeviceregistry/assets_client_example_test.go deleted file mode 100644 index ee34e7c59908..000000000000 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/assets_client_example_test.go +++ /dev/null @@ -1,1082 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdeviceregistry_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armdeviceregistry" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json -func ExampleAssetsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssetsClient().NewListBySubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssetListResult = armdeviceregistry.AssetListResult{ - // Value: []*armdeviceregistry.Asset{ - // { - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // }, - // { - // Name: to.Ptr("my-asset1"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset1"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-2"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset 1"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile1"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt10"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt20"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName 1"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt30"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt40"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("9AVD7KLPU03377981"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("12-984302-792341-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("7824a74f-21e1-4458-ae06-604d3a241d2c"), - // Version: to.Ptr[int32](73766), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json -func ExampleAssetsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssetsClient().NewListByResourceGroupPager("myResourceGroup", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AssetListResult = armdeviceregistry.AssetListResult{ - // Value: []*armdeviceregistry.Asset{ - // { - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // }, - // { - // Name: to.Ptr("my-asset1"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset1"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-2"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset 1"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile1"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt10"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt20"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName 1"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt30"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt40"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("9AVD7KLPU03377981"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("12-984302-792341-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("7824a74f-21e1-4458-ae06-604d3a241d2c"), - // Version: to.Ptr[int32](73766), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json -func ExampleAssetsClient_Get_getAnAsset() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssetsClient().Get(ctx, "myResourceGroup", "my-asset", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Asset = armdeviceregistry.Asset{ - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json -func ExampleAssetsClient_Get_getAnAssetWithSyncStatus() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssetsClient().Get(ctx, "myResourceGroup", "my-asset", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Asset = armdeviceregistry.Asset{ - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // Status: &armdeviceregistry.AssetStatus{ - // Errors: []*armdeviceregistry.AssetStatusError{ - // { - // Code: to.Ptr[int32](500), - // Message: to.Ptr("Internal Server Error"), - // }}, - // Version: to.Ptr[int32](1), - // }, - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json -func ExampleAssetsClient_BeginCreateOrReplace_createAnAssetWithExternalAssetId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetsClient().BeginCreateOrReplace(ctx, "myResourceGroup", "my-asset", armdeviceregistry.Asset{ - Location: to.Ptr("West Europe"), - Tags: map[string]*string{ - "site": to.Ptr("building-1"), - }, - ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - Type: to.Ptr("CustomLocation"), - }, - Properties: &armdeviceregistry.AssetProperties{ - Description: to.Ptr("This is a sample Asset"), - AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - AssetType: to.Ptr("MyAssetType"), - DataPoints: []*armdeviceregistry.DataPoint{ - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - }, - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - }}, - DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - DisplayName: to.Ptr("AssetDisplayName"), - DocumentationURI: to.Ptr("https://www.example.com/manual"), - Enabled: to.Ptr(true), - Events: []*armdeviceregistry.Event{ - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - }, - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - }}, - ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - HardwareRevision: to.Ptr("1.0"), - Manufacturer: to.Ptr("Contoso"), - ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - Model: to.Ptr("ContosoModel"), - ProductCode: to.Ptr("SA34VDG"), - SerialNumber: to.Ptr("64-103816-519918-8"), - SoftwareRevision: to.Ptr("2.0"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Asset = armdeviceregistry.Asset{ - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_DisplayName.json -func ExampleAssetsClient_BeginCreateOrReplace_createAnAssetWithoutDisplayName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetsClient().BeginCreateOrReplace(ctx, "myResourceGroup", "my-asset", armdeviceregistry.Asset{ - Location: to.Ptr("West Europe"), - Tags: map[string]*string{ - "site": to.Ptr("building-1"), - }, - ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - Type: to.Ptr("CustomLocation"), - }, - Properties: &armdeviceregistry.AssetProperties{ - Description: to.Ptr("This is a sample Asset"), - AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - AssetType: to.Ptr("MyAssetType"), - DataPoints: []*armdeviceregistry.DataPoint{ - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - }, - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - }}, - DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - DocumentationURI: to.Ptr("https://www.example.com/manual"), - Enabled: to.Ptr(true), - Events: []*armdeviceregistry.Event{ - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - }, - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - }}, - ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - HardwareRevision: to.Ptr("1.0"), - Manufacturer: to.Ptr("Contoso"), - ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - Model: to.Ptr("ContosoModel"), - ProductCode: to.Ptr("SA34VDG"), - SerialNumber: to.Ptr("64-103816-519918-8"), - SoftwareRevision: to.Ptr("2.0"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Asset = armdeviceregistry.Asset{ - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("myAsset"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_ExternalAssetId.json -func ExampleAssetsClient_BeginCreateOrReplace_createAnAssetWithoutExternalAssetId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetsClient().BeginCreateOrReplace(ctx, "myResourceGroup", "my-asset", armdeviceregistry.Asset{ - Location: to.Ptr("West Europe"), - Tags: map[string]*string{ - "site": to.Ptr("building-1"), - }, - ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - Type: to.Ptr("CustomLocation"), - }, - Properties: &armdeviceregistry.AssetProperties{ - Description: to.Ptr("This is a sample Asset"), - AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - AssetType: to.Ptr("MyAssetType"), - DataPoints: []*armdeviceregistry.DataPoint{ - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - }, - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - }}, - DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - DisplayName: to.Ptr("AssetDisplayName"), - DocumentationURI: to.Ptr("https://www.example.com/manual"), - Enabled: to.Ptr(true), - Events: []*armdeviceregistry.Event{ - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - }, - { - CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - }}, - HardwareRevision: to.Ptr("1.0"), - Manufacturer: to.Ptr("Contoso"), - ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - Model: to.Ptr("ContosoModel"), - ProductCode: to.Ptr("SA34VDG"), - SerialNumber: to.Ptr("64-103816-519918-8"), - SoftwareRevision: to.Ptr("2.0"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Asset = armdeviceregistry.Asset{ - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("AssetDisplayName"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json -func ExampleAssetsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetsClient().BeginUpdate(ctx, "myResourceGroup", "my-asset", armdeviceregistry.AssetUpdate{ - Properties: &armdeviceregistry.AssetUpdateProperties{ - DisplayName: to.Ptr("NewAssetDisplayName"), - Enabled: to.Ptr(false), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Asset = armdeviceregistry.Asset{ - // Name: to.Ptr("my-asset"), - // Type: to.Ptr("Microsoft.DeviceRegistry/assets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DeviceRegistry/assets/my-asset"), - // SystemData: &armdeviceregistry.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T00:36:43.251Z"); return t}()), - // CreatedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // CreatedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-16T01:37:16.092Z"); return t}()), - // LastModifiedBy: to.Ptr("2ta23112-4596-44ff-b773-19405922bfc1"), - // LastModifiedByType: to.Ptr(armdeviceregistry.CreatedByTypeApplication), - // }, - // Location: to.Ptr("West Europe"), - // Tags: map[string]*string{ - // "site": to.Ptr("building-1"), - // }, - // ExtendedLocation: &armdeviceregistry.ExtendedLocation{ - // Name: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1"), - // Type: to.Ptr("CustomLocation"), - // }, - // Properties: &armdeviceregistry.AssetProperties{ - // Description: to.Ptr("This is a sample Asset"), - // AssetEndpointProfileURI: to.Ptr("https://www.example.com/myAssetEndpointProfile"), - // AssetType: to.Ptr("MyAssetType"), - // DataPoints: []*armdeviceregistry.DataPoint{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeCounter), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // DataPointConfiguration: to.Ptr("{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}"), - // DataSource: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2"), - // ObservabilityMode: to.Ptr(armdeviceregistry.DataPointsObservabilityModeNone), - // }}, - // DefaultDataPointsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DefaultEventsConfiguration: to.Ptr("{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}"), - // DisplayName: to.Ptr("NewAssetDisplayName"), - // DocumentationURI: to.Ptr("https://www.example.com/manual"), - // Enabled: to.Ptr(true), - // Events: []*armdeviceregistry.Event{ - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__temperature;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeNone), - // }, - // { - // CapabilityID: to.Ptr("dtmi:com:example:Thermostat:__pressure;1"), - // EventConfiguration: to.Ptr("{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}"), - // EventNotifier: to.Ptr("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4"), - // ObservabilityMode: to.Ptr(armdeviceregistry.EventsObservabilityModeLog), - // }}, - // ExternalAssetID: to.Ptr("8ZBA6LRHU0A458969"), - // HardwareRevision: to.Ptr("1.0"), - // Manufacturer: to.Ptr("Contoso"), - // ManufacturerURI: to.Ptr("https://www.contoso.com/manufacturerUri"), - // Model: to.Ptr("ContosoModel"), - // ProductCode: to.Ptr("SA34VDG"), - // ProvisioningState: to.Ptr(armdeviceregistry.ProvisioningStateSucceeded), - // SerialNumber: to.Ptr("64-103816-519918-8"), - // SoftwareRevision: to.Ptr("2.0"), - // UUID: to.Ptr("0796f7c1-f2c8-44d7-9f5b-9a6f9522a85d"), - // Version: to.Ptr[int32](73766), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json -func ExampleAssetsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewAssetsClient().BeginDelete(ctx, "myResourceGroup", "my-asset", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/autorest.md b/sdk/resourcemanager/deviceregistry/armdeviceregistry/autorest.md index fdcc3a7d6863..baadfefb5e8d 100644 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/autorest.md +++ b/sdk/resourcemanager/deviceregistry/armdeviceregistry/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/deviceregistry/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/deviceregistry/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 -tag: package-preview-2023-11 +module-version: 0.1.1 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/constants.go b/sdk/resourcemanager/deviceregistry/armdeviceregistry/constants.go index f5a5edb7d532..655841e52d9c 100644 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/constants.go +++ b/sdk/resourcemanager/deviceregistry/armdeviceregistry/constants.go @@ -10,7 +10,7 @@ package armdeviceregistry const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armdeviceregistry" - moduleVersion = "v0.1.0" + moduleVersion = "v0.1.1" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.mod b/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.mod index 8e44d0d358eb..2f3f270f0bca 100644 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.mod +++ b/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armd go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.sum b/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.sum +++ b/sdk/resourcemanager/deviceregistry/armdeviceregistry/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/models.go b/sdk/resourcemanager/deviceregistry/armdeviceregistry/models.go index dec2bc3186c7..594df2afaa68 100644 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/models.go +++ b/sdk/resourcemanager/deviceregistry/armdeviceregistry/models.go @@ -98,7 +98,7 @@ type AssetEndpointProfileProperties struct { // AssetEndpointProfileUpdate - The type used for update operations of the AssetEndpointProfile. type AssetEndpointProfileUpdate struct { - // The updatable properties of the AssetEndpointProfile. + // The resource-specific properties for this resource. Properties *AssetEndpointProfileUpdateProperties // Resource tags. @@ -233,7 +233,7 @@ type AssetStatusError struct { // AssetUpdate - The type used for update operations of the Asset. type AssetUpdate struct { - // The updatable properties of the Asset. + // The resource-specific properties for this resource. Properties *AssetUpdateProperties // Resource tags. diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/operations_client_example_test.go b/sdk/resourcemanager/deviceregistry/armdeviceregistry/operations_client_example_test.go deleted file mode 100644 index e044d2e1c17b..000000000000 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/operations_client_example_test.go +++ /dev/null @@ -1,54 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdeviceregistry_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armdeviceregistry" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Operations.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armdeviceregistry.OperationListResult{ - // Value: []*armdeviceregistry.Operation{ - // { - // Name: to.Ptr("Microsoft.DeviceRegistry/assets/write"), - // Display: &armdeviceregistry.OperationDisplay{ - // Operation: to.Ptr("write"), - // Provider: to.Ptr("Microsoft Azure Device Registry"), - // Resource: to.Ptr("Asset"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/deviceregistry/armdeviceregistry/operationstatus_client_example_test.go b/sdk/resourcemanager/deviceregistry/armdeviceregistry/operationstatus_client_example_test.go deleted file mode 100644 index baccd5220666..000000000000 --- a/sdk/resourcemanager/deviceregistry/armdeviceregistry/operationstatus_client_example_test.go +++ /dev/null @@ -1,46 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdeviceregistry_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/deviceregistry/armdeviceregistry" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c77bbf822be2deaac1b690270c6cd03a52df0e37/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_OperationStatus.json -func ExampleOperationStatusClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeviceregistry.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOperationStatusClient().Get(ctx, "testLocation", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationStatusResult = armdeviceregistry.OperationStatusResult{ - // Name: to.Ptr("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-21T13:28:03.898Z"); return t}()), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.DeviceRegistry/locations/testLocation/operationStatuses/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), - // PercentComplete: to.Ptr[float32](100), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-21T13:27:03.898Z"); return t}()), - // Status: to.Ptr("Succeeded"), - // } -} diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/CHANGELOG.md b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/CHANGELOG.md index 96e36af4f892..7248d677a1aa 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/CHANGELOG.md +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/CHANGELOG.md @@ -1,5 +1,32 @@ # Release History +## 0.2.0 (2024-08-22) +### Breaking Changes + +- Type of `PoolUpdateProperties.AgentProfile` has been changed from `AgentProfileUpdateClassification` to `AgentProfileClassification` +- Type of `Quota.Name` has been changed from `*string` to `*QuotaName` +- Function `*AgentProfileUpdate.GetAgentProfileUpdate` has been removed +- Function `*AutomaticResourcePredictionsProfileUpdate.GetResourcePredictionsProfileUpdate` has been removed +- Function `*ManualResourcePredictionsProfileUpdate.GetResourcePredictionsProfileUpdate` has been removed +- Function `*ResourcePredictionsProfileUpdate.GetResourcePredictionsProfileUpdate` has been removed +- Function `*StatefulUpdate.GetAgentProfileUpdate` has been removed +- Function `*StatelessAgentProfileUpdate.GetAgentProfileUpdate` has been removed +- Function `*SubscriptionUsagesClient.NewListByLocationPager` has been removed +- Struct `AutomaticResourcePredictionsProfileUpdate` has been removed +- Struct `ManualResourcePredictionsProfileUpdate` has been removed +- Struct `QuotaListResult` has been removed +- Struct `QuotaProperties` has been removed +- Struct `StatefulUpdate` has been removed +- Struct `StatelessAgentProfileUpdate` has been removed +- Field `Properties`, `SystemData`, `Type` of struct `Quota` has been removed + +### Features Added + +- New function `*SubscriptionUsagesClient.NewUsagesPager(string, *SubscriptionUsagesClientUsagesOptions) *runtime.Pager[SubscriptionUsagesClientUsagesResponse]` +- New struct `PagedQuota` +- New field `CurrentValue`, `Limit`, `Unit` in struct `Quota` + + ## 0.1.0 (2024-05-24) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/autorest.md b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/autorest.md index 2ea4855f1b0b..8d594db1213e 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/autorest.md +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/devopsinfrastructure/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/devopsinfrastructure/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 -tag: package-preview-2024-04 +module-version: 0.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/constants.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/constants.go index cbed5af7fe2f..f72c86d86781 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/constants.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/constants.go @@ -10,7 +10,7 @@ package armdevopsinfrastructure const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure" - moduleVersion = "v0.1.0" + moduleVersion = "v0.2.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -245,11 +245,14 @@ func PossibleResourcePredictionsProfileTypeValues() []ResourcePredictionsProfile } } +// ResourceSKURestrictionsReasonCode - Describes the reason for SKU restriction. type ResourceSKURestrictionsReasonCode string const ( + // ResourceSKURestrictionsReasonCodeNotAvailableForSubscription - The restriction is not available for this subscription. ResourceSKURestrictionsReasonCodeNotAvailableForSubscription ResourceSKURestrictionsReasonCode = "NotAvailableForSubscription" - ResourceSKURestrictionsReasonCodeQuotaID ResourceSKURestrictionsReasonCode = "QuotaId" + // ResourceSKURestrictionsReasonCodeQuotaID - The restriction is due to exceeding a quota limitation. + ResourceSKURestrictionsReasonCodeQuotaID ResourceSKURestrictionsReasonCode = "QuotaId" ) // PossibleResourceSKURestrictionsReasonCodeValues returns the possible values for the ResourceSKURestrictionsReasonCode const type. @@ -260,11 +263,14 @@ func PossibleResourceSKURestrictionsReasonCodeValues() []ResourceSKURestrictions } } +// ResourceSKURestrictionsType - Describes the kind of SKU restrictions that can exist type ResourceSKURestrictionsType string const ( + // ResourceSKURestrictionsTypeLocation - SKU restricted by location. ResourceSKURestrictionsTypeLocation ResourceSKURestrictionsType = "Location" - ResourceSKURestrictionsTypeZone ResourceSKURestrictionsType = "Zone" + // ResourceSKURestrictionsTypeZone - SKU restricted by availability zone. + ResourceSKURestrictionsTypeZone ResourceSKURestrictionsType = "Zone" ) // PossibleResourceSKURestrictionsTypeValues returns the possible values for the ResourceSKURestrictionsType const type. diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/fake/subscriptionusages_server.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/fake/subscriptionusages_server.go index 814de64be755..9b4253943743 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/fake/subscriptionusages_server.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/fake/subscriptionusages_server.go @@ -23,9 +23,9 @@ import ( // SubscriptionUsagesServer is a fake server for instances of the armdevopsinfrastructure.SubscriptionUsagesClient type. type SubscriptionUsagesServer struct { - // NewListByLocationPager is the fake for method SubscriptionUsagesClient.NewListByLocationPager + // NewUsagesPager is the fake for method SubscriptionUsagesClient.NewUsagesPager // HTTP status codes to indicate success: http.StatusOK - NewListByLocationPager func(locationName string, options *armdevopsinfrastructure.SubscriptionUsagesClientListByLocationOptions) (resp azfake.PagerResponder[armdevopsinfrastructure.SubscriptionUsagesClientListByLocationResponse]) + NewUsagesPager func(location string, options *armdevopsinfrastructure.SubscriptionUsagesClientUsagesOptions) (resp azfake.PagerResponder[armdevopsinfrastructure.SubscriptionUsagesClientUsagesResponse]) } // NewSubscriptionUsagesServerTransport creates a new instance of SubscriptionUsagesServerTransport with the provided implementation. @@ -33,16 +33,16 @@ type SubscriptionUsagesServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewSubscriptionUsagesServerTransport(srv *SubscriptionUsagesServer) *SubscriptionUsagesServerTransport { return &SubscriptionUsagesServerTransport{ - srv: srv, - newListByLocationPager: newTracker[azfake.PagerResponder[armdevopsinfrastructure.SubscriptionUsagesClientListByLocationResponse]](), + srv: srv, + newUsagesPager: newTracker[azfake.PagerResponder[armdevopsinfrastructure.SubscriptionUsagesClientUsagesResponse]](), } } // SubscriptionUsagesServerTransport connects instances of armdevopsinfrastructure.SubscriptionUsagesClient to instances of SubscriptionUsagesServer. // Don't use this type directly, use NewSubscriptionUsagesServerTransport instead. type SubscriptionUsagesServerTransport struct { - srv *SubscriptionUsagesServer - newListByLocationPager *tracker[azfake.PagerResponder[armdevopsinfrastructure.SubscriptionUsagesClientListByLocationResponse]] + srv *SubscriptionUsagesServer + newUsagesPager *tracker[azfake.PagerResponder[armdevopsinfrastructure.SubscriptionUsagesClientUsagesResponse]] } // Do implements the policy.Transporter interface for SubscriptionUsagesServerTransport. @@ -57,8 +57,8 @@ func (s *SubscriptionUsagesServerTransport) Do(req *http.Request) (*http.Respons var err error switch method { - case "SubscriptionUsagesClient.NewListByLocationPager": - resp, err = s.dispatchNewListByLocationPager(req) + case "SubscriptionUsagesClient.NewUsagesPager": + resp, err = s.dispatchNewUsagesPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -70,39 +70,39 @@ func (s *SubscriptionUsagesServerTransport) Do(req *http.Request) (*http.Respons return resp, nil } -func (s *SubscriptionUsagesServerTransport) dispatchNewListByLocationPager(req *http.Request) (*http.Response, error) { - if s.srv.NewListByLocationPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByLocationPager not implemented")} +func (s *SubscriptionUsagesServerTransport) dispatchNewUsagesPager(req *http.Request) (*http.Response, error) { + if s.srv.NewUsagesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewUsagesPager not implemented")} } - newListByLocationPager := s.newListByLocationPager.get(req) - if newListByLocationPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevOpsInfrastructure/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/usages` + newUsagesPager := s.newUsagesPager.get(req) + if newUsagesPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DevOpsInfrastructure/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/usages` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - locationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("locationName")]) + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) if err != nil { return nil, err } - resp := s.srv.NewListByLocationPager(locationNameParam, nil) - newListByLocationPager = &resp - s.newListByLocationPager.add(req, newListByLocationPager) - server.PagerResponderInjectNextLinks(newListByLocationPager, req, func(page *armdevopsinfrastructure.SubscriptionUsagesClientListByLocationResponse, createLink func() string) { + resp := s.srv.NewUsagesPager(locationParam, nil) + newUsagesPager = &resp + s.newUsagesPager.add(req, newUsagesPager) + server.PagerResponderInjectNextLinks(newUsagesPager, req, func(page *armdevopsinfrastructure.SubscriptionUsagesClientUsagesResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListByLocationPager, req) + resp, err := server.PagerResponderNext(newUsagesPager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - s.newListByLocationPager.remove(req) + s.newUsagesPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListByLocationPager) { - s.newListByLocationPager.remove(req) + if !server.PagerResponderMore(newUsagesPager) { + s.newUsagesPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.mod b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.mod index 12db711df587..ff7f3e32c722 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.mod +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructur go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.sum b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.sum +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/imageversions_client_example_test.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/imageversions_client_example_test.go deleted file mode 100644 index 9949dcb23719..000000000000 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/imageversions_client_example_test.go +++ /dev/null @@ -1,54 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdevopsinfrastructure_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/ImageVersions_ListByImage.json -func ExampleImageVersionsClient_NewListByImagePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewImageVersionsClient().NewListByImagePager("my-resource-group", "windows-2022", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ImageVersionListResult = armdevopsinfrastructure.ImageVersionListResult{ - // Value: []*armdevopsinfrastructure.ImageVersion{ - // { - // Name: to.Ptr("2024.0417.0"), - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/images/windows-2022/versions/2024.0417.0"), - // }, - // { - // Name: to.Ptr("2024.0417.1"), - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/images/windows-2022/versions/2024.0417.1"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/interfaces.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/interfaces.go index 85e5dd582fa8..b8df99bb1347 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/interfaces.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/interfaces.go @@ -17,15 +17,6 @@ type AgentProfileClassification interface { GetAgentProfile() *AgentProfile } -// AgentProfileUpdateClassification provides polymorphic access to related types. -// Call the interface's GetAgentProfileUpdate() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AgentProfileUpdate, *StatefulUpdate, *StatelessAgentProfileUpdate -type AgentProfileUpdateClassification interface { - // GetAgentProfileUpdate returns the AgentProfileUpdate content of the underlying type. - GetAgentProfileUpdate() *AgentProfileUpdate -} - // FabricProfileClassification provides polymorphic access to related types. // Call the interface's GetFabricProfile() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: @@ -52,12 +43,3 @@ type ResourcePredictionsProfileClassification interface { // GetResourcePredictionsProfile returns the ResourcePredictionsProfile content of the underlying type. GetResourcePredictionsProfile() *ResourcePredictionsProfile } - -// ResourcePredictionsProfileUpdateClassification provides polymorphic access to related types. -// Call the interface's GetResourcePredictionsProfileUpdate() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AutomaticResourcePredictionsProfileUpdate, *ManualResourcePredictionsProfileUpdate, *ResourcePredictionsProfileUpdate -type ResourcePredictionsProfileUpdateClassification interface { - // GetResourcePredictionsProfileUpdate returns the ResourcePredictionsProfileUpdate content of the underlying type. - GetResourcePredictionsProfileUpdate() *ResourcePredictionsProfileUpdate -} diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models.go index 90f682a878c5..4a82cb1ab798 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models.go @@ -25,21 +25,6 @@ type AgentProfile struct { // GetAgentProfile implements the AgentProfileClassification interface for type AgentProfile. func (a *AgentProfile) GetAgentProfile() *AgentProfile { return a } -// AgentProfileUpdate - The agent profile of the machines in the pool. -type AgentProfileUpdate struct { - // REQUIRED; Discriminator property for AgentProfile. - Kind *string - - // Defines pool buffer/stand-by agents. - ResourcePredictions any - - // Defines how the pool buffer/stand-by agents is provided. - ResourcePredictionsProfile ResourcePredictionsProfileUpdateClassification -} - -// GetAgentProfileUpdate implements the AgentProfileUpdateClassification interface for type AgentProfileUpdate. -func (a *AgentProfileUpdate) GetAgentProfileUpdate() *AgentProfileUpdate { return a } - // AutomaticResourcePredictionsProfile - The stand-by agent scheme is determined based on historical demand. type AutomaticResourcePredictionsProfile struct { // REQUIRED; Determines how the stand-by scheme should be provided. @@ -56,22 +41,6 @@ func (a *AutomaticResourcePredictionsProfile) GetResourcePredictionsProfile() *R } } -// AutomaticResourcePredictionsProfileUpdate - The stand-by agent scheme is determined based on historical demand. -type AutomaticResourcePredictionsProfileUpdate struct { - // REQUIRED; Determines how the stand-by scheme should be provided. - Kind *ResourcePredictionsProfileType - - // Determines the balance between cost and performance. - PredictionPreference *PredictionPreference -} - -// GetResourcePredictionsProfileUpdate implements the ResourcePredictionsProfileUpdateClassification interface for type AutomaticResourcePredictionsProfileUpdate. -func (a *AutomaticResourcePredictionsProfileUpdate) GetResourcePredictionsProfileUpdate() *ResourcePredictionsProfileUpdate { - return &ResourcePredictionsProfileUpdate{ - Kind: a.Kind, - } -} - // AzureDevOpsOrganizationProfile - Azure DevOps organization profile type AzureDevOpsOrganizationProfile struct { // REQUIRED; Discriminator property for OrganizationProfile. @@ -226,19 +195,6 @@ func (m *ManualResourcePredictionsProfile) GetResourcePredictionsProfile() *Reso } } -// ManualResourcePredictionsProfileUpdate - Customer provides the stand-by agent scheme. -type ManualResourcePredictionsProfileUpdate struct { - // REQUIRED; Determines how the stand-by scheme should be provided. - Kind *ResourcePredictionsProfileType -} - -// GetResourcePredictionsProfileUpdate implements the ResourcePredictionsProfileUpdateClassification interface for type ManualResourcePredictionsProfileUpdate. -func (m *ManualResourcePredictionsProfileUpdate) GetResourcePredictionsProfileUpdate() *ResourcePredictionsProfileUpdate { - return &ResourcePredictionsProfileUpdate{ - Kind: m.Kind, - } -} - // NetworkProfile - The network profile of the machines in the pool. type NetworkProfile struct { // REQUIRED; The subnet id on which to put all machines created in the pool. @@ -324,6 +280,15 @@ type OsProfile struct { SecretsManagementSettings *SecretsManagementSettings } +// PagedQuota - Paged collection of Quota items +type PagedQuota struct { + // REQUIRED; The Quota items on this page + Value []*Quota + + // The link to the next page of items + NextLink *string +} + // Pool - Concrete tracked resource types can be created by aliasing this type using a specific property type. type Pool struct { // REQUIRED; The geo-location where the resource lives @@ -401,7 +366,7 @@ type PoolUpdate struct { // The managed service identities assigned to this resource. Identity *ManagedServiceIdentity - // The updatable properties of the Pool. + // The resource-specific properties for this resource. Properties *PoolUpdateProperties // Resource tags. @@ -411,7 +376,7 @@ type PoolUpdate struct { // PoolUpdateProperties - The updatable properties of the Pool. type PoolUpdateProperties struct { // Defines how the machine will be handled once it executed a job. - AgentProfile AgentProfileUpdateClassification + AgentProfile AgentProfileClassification // The resource id of the DevCenter Project the pool belongs to. DevCenterProjectResourceID *string @@ -431,29 +396,20 @@ type PoolUpdateProperties struct { // Quota - Describes Resource Quota type Quota struct { - // The resource-specific properties for this resource. - Properties *QuotaProperties + // REQUIRED; The current usage of the resource. + CurrentValue *int64 - // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + // REQUIRED; Fully qualified ARM resource id ID *string - // 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 -} + // REQUIRED; The maximum permitted usage of the resource. + Limit *int64 -// QuotaListResult - The response of a Quota list operation. -type QuotaListResult struct { - // REQUIRED; The Quota items on this page - Value []*Quota + // REQUIRED; The unit of usage measurement. + Unit *string - // The link to the next page of items - NextLink *string + // READ-ONLY; The name of the quota. + Name *QuotaName } // QuotaName - The Quota Names @@ -465,21 +421,6 @@ type QuotaName struct { Value *string } -// QuotaProperties - Describes Resource Quota properties -type QuotaProperties struct { - // REQUIRED; The current usage of the resource. - CurrentValue *int64 - - // REQUIRED; The maximum permitted usage of the resource. - Limit *int64 - - // REQUIRED; The details of the quota. - Name *QuotaName - - // REQUIRED; The unit of usage measurement. - Unit *string -} - // ResourceDetailsObject - A ResourceDetailsObject type ResourceDetailsObject struct { // The resource-specific properties for this resource. @@ -530,17 +471,6 @@ func (r *ResourcePredictionsProfile) GetResourcePredictionsProfile() *ResourcePr return r } -// ResourcePredictionsProfileUpdate - Determines how the stand-by scheme should be provided. -type ResourcePredictionsProfileUpdate struct { - // REQUIRED; Determines how the stand-by scheme should be provided. - Kind *ResourcePredictionsProfileType -} - -// GetResourcePredictionsProfileUpdate implements the ResourcePredictionsProfileUpdateClassification interface for type ResourcePredictionsProfileUpdate. -func (r *ResourcePredictionsProfileUpdate) GetResourcePredictionsProfileUpdate() *ResourcePredictionsProfileUpdate { - return r -} - // ResourceSKU - A ResourceSku type ResourceSKU struct { // The resource-specific properties for this resource. @@ -690,34 +620,6 @@ func (s *Stateful) GetAgentProfile() *AgentProfile { } } -// StatefulUpdate - Stateful profile meaning that the machines will be returned to the pool after running a job. -type StatefulUpdate struct { - // REQUIRED; Discriminator property for AgentProfile. - Kind *string - - // How long should the machine be kept around after it ran a workload when there are no stand-by agents. The maximum is one - // week. - GracePeriodTimeSpan *string - - // How long should stateful machines be kept around. The maximum is one week. - MaxAgentLifetime *string - - // Defines pool buffer/stand-by agents. - ResourcePredictions any - - // Defines how the pool buffer/stand-by agents is provided. - ResourcePredictionsProfile ResourcePredictionsProfileUpdateClassification -} - -// GetAgentProfileUpdate implements the AgentProfileUpdateClassification interface for type StatefulUpdate. -func (s *StatefulUpdate) GetAgentProfileUpdate() *AgentProfileUpdate { - return &AgentProfileUpdate{ - Kind: s.Kind, - ResourcePredictions: s.ResourcePredictions, - ResourcePredictionsProfile: s.ResourcePredictionsProfile, - } -} - // StatelessAgentProfile - Stateless profile meaning that the machines will be cleaned up after running a job. type StatelessAgentProfile struct { // REQUIRED; Discriminator property for AgentProfile. @@ -739,27 +641,6 @@ func (s *StatelessAgentProfile) GetAgentProfile() *AgentProfile { } } -// StatelessAgentProfileUpdate - Stateless profile meaning that the machines will be cleaned up after running a job. -type StatelessAgentProfileUpdate struct { - // REQUIRED; Discriminator property for AgentProfile. - Kind *string - - // Defines pool buffer/stand-by agents. - ResourcePredictions any - - // Defines how the pool buffer/stand-by agents is provided. - ResourcePredictionsProfile ResourcePredictionsProfileUpdateClassification -} - -// GetAgentProfileUpdate implements the AgentProfileUpdateClassification interface for type StatelessAgentProfileUpdate. -func (s *StatelessAgentProfileUpdate) GetAgentProfileUpdate() *AgentProfileUpdate { - return &AgentProfileUpdate{ - Kind: s.Kind, - ResourcePredictions: s.ResourcePredictions, - ResourcePredictionsProfile: s.ResourcePredictionsProfile, - } -} - // StorageProfile - The storage profile of the VMSS. type StorageProfile struct { // A list of empty data disks to attach. diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models_serde.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models_serde.go index 30ddb194628f..f7299128de07 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models_serde.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/models_serde.go @@ -50,41 +50,6 @@ func (a *AgentProfile) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AgentProfileUpdate. -func (a AgentProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - objectMap["kind"] = a.Kind - populateAny(objectMap, "resourcePredictions", a.ResourcePredictions) - populate(objectMap, "resourcePredictionsProfile", a.ResourcePredictionsProfile) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AgentProfileUpdate. -func (a *AgentProfileUpdate) 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 "resourcePredictions": - err = unpopulate(val, "ResourcePredictions", &a.ResourcePredictions) - delete(rawMsg, key) - case "resourcePredictionsProfile": - a.ResourcePredictionsProfile, err = unmarshalResourcePredictionsProfileUpdateClassification(val) - 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 AutomaticResourcePredictionsProfile. func (a AutomaticResourcePredictionsProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -116,37 +81,6 @@ func (a *AutomaticResourcePredictionsProfile) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type AutomaticResourcePredictionsProfileUpdate. -func (a AutomaticResourcePredictionsProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - objectMap["kind"] = ResourcePredictionsProfileTypeAutomatic - populate(objectMap, "predictionPreference", a.PredictionPreference) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AutomaticResourcePredictionsProfileUpdate. -func (a *AutomaticResourcePredictionsProfileUpdate) 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 "predictionPreference": - err = unpopulate(val, "PredictionPreference", &a.PredictionPreference) - 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 AzureDevOpsOrganizationProfile. func (a AzureDevOpsOrganizationProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -539,33 +473,6 @@ func (m *ManualResourcePredictionsProfile) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ManualResourcePredictionsProfileUpdate. -func (m ManualResourcePredictionsProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - objectMap["kind"] = ResourcePredictionsProfileTypeManual - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ManualResourcePredictionsProfileUpdate. -func (m *ManualResourcePredictionsProfileUpdate) 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 "kind": - err = unpopulate(val, "Kind", &m.Kind) - 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 NetworkProfile. func (n NetworkProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -799,6 +706,37 @@ func (o *OsProfile) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PagedQuota. +func (p PagedQuota) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PagedQuota. +func (p *PagedQuota) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 Pool. func (p Pool) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1028,7 +966,7 @@ func (p *PoolUpdateProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "agentProfile": - p.AgentProfile, err = unmarshalAgentProfileUpdateClassification(val) + p.AgentProfile, err = unmarshalAgentProfileClassification(val) delete(rawMsg, key) case "devCenterProjectResourceId": err = unpopulate(val, "DevCenterProjectResourceID", &p.DevCenterProjectResourceID) @@ -1056,11 +994,11 @@ func (p *PoolUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Quota. func (q Quota) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "currentValue", q.CurrentValue) populate(objectMap, "id", q.ID) + populate(objectMap, "limit", q.Limit) populate(objectMap, "name", q.Name) - populate(objectMap, "properties", q.Properties) - populate(objectMap, "systemData", q.SystemData) - populate(objectMap, "type", q.Type) + populate(objectMap, "unit", q.Unit) return json.Marshal(objectMap) } @@ -1073,51 +1011,20 @@ func (q *Quota) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "currentValue": + err = unpopulate(val, "CurrentValue", &q.CurrentValue) + delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &q.ID) delete(rawMsg, key) + case "limit": + err = unpopulate(val, "Limit", &q.Limit) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &q.Name) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &q.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &q.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &q.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", q, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type QuotaListResult. -func (q QuotaListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", q.NextLink) - populate(objectMap, "value", q.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaListResult. -func (q *QuotaListResult) 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", q, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &q.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &q.Value) + case "unit": + err = unpopulate(val, "Unit", &q.Unit) delete(rawMsg, key) } if err != nil { @@ -1158,45 +1065,6 @@ func (q *QuotaName) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type QuotaProperties. -func (q QuotaProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "currentValue", q.CurrentValue) - populate(objectMap, "limit", q.Limit) - populate(objectMap, "name", q.Name) - populate(objectMap, "unit", q.Unit) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaProperties. -func (q *QuotaProperties) 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", q, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "currentValue": - err = unpopulate(val, "CurrentValue", &q.CurrentValue) - delete(rawMsg, key) - case "limit": - err = unpopulate(val, "Limit", &q.Limit) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &q.Name) - delete(rawMsg, key) - case "unit": - err = unpopulate(val, "Unit", &q.Unit) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", q, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ResourceDetailsObject. func (r ResourceDetailsObject) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1333,33 +1201,6 @@ func (r *ResourcePredictionsProfile) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourcePredictionsProfileUpdate. -func (r ResourcePredictionsProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - objectMap["kind"] = r.Kind - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourcePredictionsProfileUpdate. -func (r *ResourcePredictionsProfileUpdate) 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 "kind": - err = unpopulate(val, "Kind", &r.Kind) - 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 ResourceSKU. func (r ResourceSKU) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1734,49 +1575,6 @@ func (s *Stateful) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type StatefulUpdate. -func (s StatefulUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "gracePeriodTimeSpan", s.GracePeriodTimeSpan) - objectMap["kind"] = "Stateful" - populate(objectMap, "maxAgentLifetime", s.MaxAgentLifetime) - populateAny(objectMap, "resourcePredictions", s.ResourcePredictions) - populate(objectMap, "resourcePredictionsProfile", s.ResourcePredictionsProfile) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type StatefulUpdate. -func (s *StatefulUpdate) 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 "gracePeriodTimeSpan": - err = unpopulate(val, "GracePeriodTimeSpan", &s.GracePeriodTimeSpan) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &s.Kind) - delete(rawMsg, key) - case "maxAgentLifetime": - err = unpopulate(val, "MaxAgentLifetime", &s.MaxAgentLifetime) - delete(rawMsg, key) - case "resourcePredictions": - err = unpopulate(val, "ResourcePredictions", &s.ResourcePredictions) - delete(rawMsg, key) - case "resourcePredictionsProfile": - s.ResourcePredictionsProfile, err = unmarshalResourcePredictionsProfileUpdateClassification(val) - 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 StatelessAgentProfile. func (s StatelessAgentProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1812,41 +1610,6 @@ func (s *StatelessAgentProfile) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type StatelessAgentProfileUpdate. -func (s StatelessAgentProfileUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - objectMap["kind"] = "Stateless" - populateAny(objectMap, "resourcePredictions", s.ResourcePredictions) - populate(objectMap, "resourcePredictionsProfile", s.ResourcePredictionsProfile) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type StatelessAgentProfileUpdate. -func (s *StatelessAgentProfileUpdate) 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 "kind": - err = unpopulate(val, "Kind", &s.Kind) - delete(rawMsg, key) - case "resourcePredictions": - err = unpopulate(val, "ResourcePredictions", &s.ResourcePredictions) - delete(rawMsg, key) - case "resourcePredictionsProfile": - s.ResourcePredictionsProfile, err = unmarshalResourcePredictionsProfileUpdateClassification(val) - 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 StorageProfile. func (s StorageProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/options.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/options.go index f44bb303f492..4229efc22a16 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/options.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/options.go @@ -64,8 +64,8 @@ type SKUClientListByLocationOptions struct { // placeholder for future optional parameters } -// SubscriptionUsagesClientListByLocationOptions contains the optional parameters for the SubscriptionUsagesClient.NewListByLocationPager +// SubscriptionUsagesClientUsagesOptions contains the optional parameters for the SubscriptionUsagesClient.NewUsagesPager // method. -type SubscriptionUsagesClientListByLocationOptions struct { +type SubscriptionUsagesClientUsagesOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/polymorphic_helpers.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/polymorphic_helpers.go index edcaa65c747c..9f0cc41ea0aa 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/polymorphic_helpers.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/polymorphic_helpers.go @@ -33,29 +33,6 @@ func unmarshalAgentProfileClassification(rawMsg json.RawMessage) (AgentProfileCl return b, nil } -func unmarshalAgentProfileUpdateClassification(rawMsg json.RawMessage) (AgentProfileUpdateClassification, error) { - if rawMsg == nil || string(rawMsg) == "null" { - return nil, nil - } - var m map[string]any - if err := json.Unmarshal(rawMsg, &m); err != nil { - return nil, err - } - var b AgentProfileUpdateClassification - switch m["kind"] { - case "Stateful": - b = &StatefulUpdate{} - case "Stateless": - b = &StatelessAgentProfileUpdate{} - default: - b = &AgentProfileUpdate{} - } - if err := json.Unmarshal(rawMsg, b); err != nil { - return nil, err - } - return b, nil -} - func unmarshalFabricProfileClassification(rawMsg json.RawMessage) (FabricProfileClassification, error) { if rawMsg == nil || string(rawMsg) == "null" { return nil, nil @@ -122,26 +99,3 @@ func unmarshalResourcePredictionsProfileClassification(rawMsg json.RawMessage) ( } return b, nil } - -func unmarshalResourcePredictionsProfileUpdateClassification(rawMsg json.RawMessage) (ResourcePredictionsProfileUpdateClassification, error) { - if rawMsg == nil || string(rawMsg) == "null" { - return nil, nil - } - var m map[string]any - if err := json.Unmarshal(rawMsg, &m); err != nil { - return nil, err - } - var b ResourcePredictionsProfileUpdateClassification - switch m["kind"] { - case string(ResourcePredictionsProfileTypeAutomatic): - b = &AutomaticResourcePredictionsProfileUpdate{} - case string(ResourcePredictionsProfileTypeManual): - b = &ManualResourcePredictionsProfileUpdate{} - default: - b = &ResourcePredictionsProfileUpdate{} - } - if err := json.Unmarshal(rawMsg, b); err != nil { - return nil, err - } - return b, nil -} diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/pools_client_example_test.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/pools_client_example_test.go deleted file mode 100644 index 3f84839167f5..000000000000 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/pools_client_example_test.go +++ /dev/null @@ -1,260 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdevopsinfrastructure_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/ListPoolsBySubscription.json -func ExamplePoolsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPoolsClient().NewListBySubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PoolListResult = armdevopsinfrastructure.PoolListResult{ - // Value: []*armdevopsinfrastructure.Pool{ - // { - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/aoiresourceGroupName/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), - // Location: to.Ptr("eastus"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/ListPoolsBySubscriptionAndResourceGroup.json -func ExamplePoolsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPoolsClient().NewListByResourceGroupPager("rg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PoolListResult = armdevopsinfrastructure.PoolListResult{ - // Value: []*armdevopsinfrastructure.Pool{ - // { - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/rg/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), - // Location: to.Ptr("eastus"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/GetPool.json -func ExamplePoolsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPoolsClient().Get(ctx, "rg", "pool", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Pool = armdevopsinfrastructure.Pool{ - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/rg/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), - // Location: to.Ptr("eastus"), - // Properties: &armdevopsinfrastructure.PoolProperties{ - // AgentProfile: &armdevopsinfrastructure.StatelessAgentProfile{ - // Kind: to.Ptr("Stateless"), - // }, - // DevCenterProjectResourceID: to.Ptr("/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES"), - // FabricProfile: &armdevopsinfrastructure.VmssFabricProfile{ - // Kind: to.Ptr("Vmss"), - // Images: []*armdevopsinfrastructure.PoolImage{ - // { - // ResourceID: to.Ptr("/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest"), - // }}, - // SKU: &armdevopsinfrastructure.DevOpsAzureSKU{ - // Name: to.Ptr("Standard_D4ads_v5"), - // }, - // }, - // MaximumConcurrency: to.Ptr[int32](10), - // OrganizationProfile: &armdevopsinfrastructure.AzureDevOpsOrganizationProfile{ - // Kind: to.Ptr("AzureDevOps"), - // Organizations: []*armdevopsinfrastructure.Organization{ - // { - // URL: to.Ptr("https://mseng.visualstudio.com"), - // }}, - // }, - // ProvisioningState: to.Ptr(armdevopsinfrastructure.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/CreateOrUpdatePool.json -func ExamplePoolsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPoolsClient().BeginCreateOrUpdate(ctx, "rg", "pool", armdevopsinfrastructure.Pool{ - Location: to.Ptr("eastus"), - Properties: &armdevopsinfrastructure.PoolProperties{ - AgentProfile: &armdevopsinfrastructure.StatelessAgentProfile{ - Kind: to.Ptr("Stateless"), - }, - DevCenterProjectResourceID: to.Ptr("/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES"), - FabricProfile: &armdevopsinfrastructure.VmssFabricProfile{ - Kind: to.Ptr("Vmss"), - Images: []*armdevopsinfrastructure.PoolImage{ - { - ResourceID: to.Ptr("/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest"), - }}, - SKU: &armdevopsinfrastructure.DevOpsAzureSKU{ - Name: to.Ptr("Standard_D4ads_v5"), - }, - }, - MaximumConcurrency: to.Ptr[int32](10), - OrganizationProfile: &armdevopsinfrastructure.AzureDevOpsOrganizationProfile{ - Kind: to.Ptr("AzureDevOps"), - Organizations: []*armdevopsinfrastructure.Organization{ - { - URL: to.Ptr("https://mseng.visualstudio.com"), - }}, - }, - ProvisioningState: to.Ptr(armdevopsinfrastructure.ProvisioningStateSucceeded), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Pool = armdevopsinfrastructure.Pool{ - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/rg/providers/Microsoft.DevOpsInfrastructure/Pools/pool"), - // Location: to.Ptr("eastus"), - // Properties: &armdevopsinfrastructure.PoolProperties{ - // AgentProfile: &armdevopsinfrastructure.StatelessAgentProfile{ - // Kind: to.Ptr("Stateless"), - // }, - // DevCenterProjectResourceID: to.Ptr("/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES"), - // FabricProfile: &armdevopsinfrastructure.VmssFabricProfile{ - // Kind: to.Ptr("Vmss"), - // Images: []*armdevopsinfrastructure.PoolImage{ - // { - // ResourceID: to.Ptr("/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest"), - // }}, - // SKU: &armdevopsinfrastructure.DevOpsAzureSKU{ - // Name: to.Ptr("Standard_D4ads_v5"), - // }, - // }, - // MaximumConcurrency: to.Ptr[int32](10), - // OrganizationProfile: &armdevopsinfrastructure.AzureDevOpsOrganizationProfile{ - // Kind: to.Ptr("AzureDevOps"), - // Organizations: []*armdevopsinfrastructure.Organization{ - // { - // URL: to.Ptr("https://mseng.visualstudio.com"), - // }}, - // }, - // ProvisioningState: to.Ptr(armdevopsinfrastructure.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/UpdatePool.json -func ExamplePoolsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPoolsClient().BeginUpdate(ctx, "rg", "pool", armdevopsinfrastructure.PoolUpdate{}, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Pool = armdevopsinfrastructure.Pool{ - // Location: to.Ptr("eastus"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/DeletePool.json -func ExamplePoolsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPoolsClient().BeginDelete(ctx, "rg", "pool", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/resourcedetails_client_example_test.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/resourcedetails_client_example_test.go deleted file mode 100644 index 2c320ed1d805..000000000000 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/resourcedetails_client_example_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdevopsinfrastructure_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/ResourceDetails_ListByPool.json -func ExampleResourceDetailsClient_NewListByPoolPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceDetailsClient().NewListByPoolPager("my-resource-group", "my-dev-ops-pool", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourceDetailsObjectListResult = armdevopsinfrastructure.ResourceDetailsObjectListResult{ - // Value: []*armdevopsinfrastructure.ResourceDetailsObject{ - // { - // Name: to.Ptr("dd8cc705c000000"), - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/my-devops-pool/resources/my-dev-ops-pool:04dcde21-626e-5a7e-8659-ce12f9284b29:dd8cc705c_0"), - // Properties: &armdevopsinfrastructure.ResourceDetailsObjectProperties{ - // Image: to.Ptr("my-image"), - // ImageVersion: to.Ptr("4.0.0"), - // Status: to.Ptr(armdevopsinfrastructure.ResourceStatusReady), - // }, - // }, - // { - // Name: to.Ptr("dd8cc705c000001"), - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/resourceGroups/my-resource-group/providers/Microsoft.DevOpsInfrastructure/pools/my-devops-pool/resources/my-dev-ops-pool:04dcde21-626e-5a7e-8659-ce12f9284b29:dd8cc705c_1"), - // Properties: &armdevopsinfrastructure.ResourceDetailsObjectProperties{ - // Image: to.Ptr("my-image"), - // ImageVersion: to.Ptr("4.0.0"), - // Status: to.Ptr(armdevopsinfrastructure.ResourceStatusAllocated), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/responses.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/responses.go index a536b94a7c60..6acca5cf2e33 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/responses.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/responses.go @@ -67,8 +67,8 @@ type SKUClientListByLocationResponse struct { ResourceSKUListResult } -// SubscriptionUsagesClientListByLocationResponse contains the response from method SubscriptionUsagesClient.NewListByLocationPager. -type SubscriptionUsagesClientListByLocationResponse struct { - // The response of a Quota list operation. - QuotaListResult +// SubscriptionUsagesClientUsagesResponse contains the response from method SubscriptionUsagesClient.NewUsagesPager. +type SubscriptionUsagesClientUsagesResponse struct { + // Paged collection of Quota items + PagedQuota } diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/sku_client_example_test.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/sku_client_example_test.go deleted file mode 100644 index 3ccfd416f8b2..000000000000 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/sku_client_example_test.go +++ /dev/null @@ -1,297 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdevopsinfrastructure_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/Sku_ListByLocation.json -func ExampleSKUClient_NewListByLocationPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSKUClient().NewListByLocationPager("eastus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourceSKUListResult = armdevopsinfrastructure.ResourceSKUListResult{ - // Value: []*armdevopsinfrastructure.ResourceSKU{ - // { - // Name: to.Ptr("Basic_A0"), - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/providers/Microsoft.DevOpsInfrastructure/locations/eastus/skus/Basic_A0"), - // Properties: &armdevopsinfrastructure.ResourceSKUProperties{ - // Capabilities: []*armdevopsinfrastructure.ResourceSKUCapabilities{ - // { - // Name: to.Ptr("MaxResourceVolumeMB"), - // Value: to.Ptr("20480"), - // }, - // { - // Name: to.Ptr("OSVhdSizeMB"), - // Value: to.Ptr("1047552"), - // }, - // { - // Name: to.Ptr("vCPUs"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("MemoryPreservingMaintenanceSupported"), - // Value: to.Ptr("True"), - // }, - // { - // Name: to.Ptr("HyperVGenerations"), - // Value: to.Ptr("V1"), - // }, - // { - // Name: to.Ptr("MemoryGB"), - // Value: to.Ptr("0.75"), - // }, - // { - // Name: to.Ptr("MaxDataDiskCount"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("CpuArchitectureType"), - // Value: to.Ptr("x64"), - // }, - // { - // Name: to.Ptr("LowPriorityCapable"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("PremiumIO"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("VMDeploymentTypes"), - // Value: to.Ptr("IaaS"), - // }, - // { - // Name: to.Ptr("vCPUsAvailable"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("ACUs"), - // Value: to.Ptr("50"), - // }, - // { - // Name: to.Ptr("vCPUsPerCore"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("EphemeralOSDiskSupported"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("EncryptionAtHostSupported"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("CapacityReservationSupported"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("AcceleratedNetworkingEnabled"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("RdmaEnabled"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("MaxNetworkInterfaces"), - // Value: to.Ptr("2"), - // }}, - // Family: to.Ptr("basicAFamily"), - // LocationInfo: []*armdevopsinfrastructure.ResourceSKULocationInfo{ - // { - // Location: to.Ptr("eastus"), - // ZoneDetails: []*armdevopsinfrastructure.ResourceSKUZoneDetails{ - // }, - // Zones: []*string{ - // }, - // }}, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("virtualMachines"), - // Restrictions: []*armdevopsinfrastructure.ResourceSKURestrictions{ - // { - // Type: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsTypeLocation), - // ReasonCode: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsReasonCodeNotAvailableForSubscription), - // RestrictionInfo: &armdevopsinfrastructure.ResourceSKURestrictionInfo{ - // Locations: []*string{ - // to.Ptr("eastus")}, - // }, - // Values: []*string{ - // to.Ptr("eastus")}, - // }, - // { - // Type: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsTypeZone), - // ReasonCode: to.Ptr(armdevopsinfrastructure.ResourceSKURestrictionsReasonCodeNotAvailableForSubscription), - // RestrictionInfo: &armdevopsinfrastructure.ResourceSKURestrictionInfo{ - // Locations: []*string{ - // to.Ptr("eastus")}, - // Zones: []*string{ - // to.Ptr("1"), - // to.Ptr("2"), - // to.Ptr("3")}, - // }, - // Values: []*string{ - // to.Ptr("eastus")}, - // }}, - // Size: to.Ptr("A0"), - // Tier: to.Ptr("Basic"), - // }, - // }, - // { - // Name: to.Ptr("Standard_A2_v2"), - // ID: to.Ptr("/subscriptions/a2e95d27-c161-4b61-bda4-11512c14c2c2/providers/Microsoft.DevOpsInfrastructure/locations/eastus/skus/Standard_A2_v2"), - // Properties: &armdevopsinfrastructure.ResourceSKUProperties{ - // Capabilities: []*armdevopsinfrastructure.ResourceSKUCapabilities{ - // { - // Name: to.Ptr("MaxResourceVolumeMB"), - // Value: to.Ptr("20480"), - // }, - // { - // Name: to.Ptr("OSVhdSizeMB"), - // Value: to.Ptr("1047552"), - // }, - // { - // Name: to.Ptr("vCPUs"), - // Value: to.Ptr("2"), - // }, - // { - // Name: to.Ptr("MemoryPreservingMaintenanceSupported"), - // Value: to.Ptr("True"), - // }, - // { - // Name: to.Ptr("HyperVGenerations"), - // Value: to.Ptr("V1"), - // }, - // { - // Name: to.Ptr("MemoryGB"), - // Value: to.Ptr("4"), - // }, - // { - // Name: to.Ptr("MaxDataDiskCount"), - // Value: to.Ptr("4"), - // }, - // { - // Name: to.Ptr("CpuArchitectureType"), - // Value: to.Ptr("x64"), - // }, - // { - // Name: to.Ptr("LowPriorityCapable"), - // Value: to.Ptr("True"), - // }, - // { - // Name: to.Ptr("PremiumIO"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("VMDeploymentTypes"), - // Value: to.Ptr("PaaS,IaaS"), - // }, - // { - // Name: to.Ptr("vCPUsAvailable"), - // Value: to.Ptr("2"), - // }, - // { - // Name: to.Ptr("ACUs"), - // Value: to.Ptr("100"), - // }, - // { - // Name: to.Ptr("vCPUsPerCore"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("CombinedTempDiskAndCachedIOPS"), - // Value: to.Ptr("2000"), - // }, - // { - // Name: to.Ptr("CombinedTempDiskAndCachedReadBytesPerSecond"), - // Value: to.Ptr("41943040"), - // }, - // { - // Name: to.Ptr("CombinedTempDiskAndCachedWriteBytesPerSecond"), - // Value: to.Ptr("20971520"), - // }, - // { - // Name: to.Ptr("UncachedDiskIOPS"), - // Value: to.Ptr("3200"), - // }, - // { - // Name: to.Ptr("UncachedDiskBytesPerSecond"), - // Value: to.Ptr("48000000"), - // }, - // { - // Name: to.Ptr("EphemeralOSDiskSupported"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("EncryptionAtHostSupported"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("CapacityReservationSupported"), - // Value: to.Ptr("True"), - // }, - // { - // Name: to.Ptr("AcceleratedNetworkingEnabled"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("RdmaEnabled"), - // Value: to.Ptr("False"), - // }, - // { - // Name: to.Ptr("MaxNetworkInterfaces"), - // Value: to.Ptr("2"), - // }}, - // Family: to.Ptr("standardAv2Family"), - // LocationInfo: []*armdevopsinfrastructure.ResourceSKULocationInfo{ - // { - // Location: to.Ptr("eastus"), - // ZoneDetails: []*armdevopsinfrastructure.ResourceSKUZoneDetails{ - // }, - // Zones: []*string{ - // to.Ptr("1"), - // to.Ptr("2"), - // to.Ptr("3")}, - // }}, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("virtualMachines"), - // Restrictions: []*armdevopsinfrastructure.ResourceSKURestrictions{ - // }, - // Size: to.Ptr("A2_v2"), - // Tier: to.Ptr("Standard"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client.go index 52c4e21bf58b..803d220a0080 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client.go +++ b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client.go @@ -43,46 +43,46 @@ func NewSubscriptionUsagesClient(subscriptionID string, credential azcore.TokenC return client, nil } -// NewListByLocationPager - List Quota resources by subscription ID +// NewUsagesPager - List Quota resources by subscription ID // // Generated from API version 2024-04-04-preview -// - locationName - Name of the location. -// - options - SubscriptionUsagesClientListByLocationOptions contains the optional parameters for the SubscriptionUsagesClient.NewListByLocationPager +// - location - The name of the Azure region. +// - options - SubscriptionUsagesClientUsagesOptions contains the optional parameters for the SubscriptionUsagesClient.NewUsagesPager // method. -func (client *SubscriptionUsagesClient) NewListByLocationPager(locationName string, options *SubscriptionUsagesClientListByLocationOptions) *runtime.Pager[SubscriptionUsagesClientListByLocationResponse] { - return runtime.NewPager(runtime.PagingHandler[SubscriptionUsagesClientListByLocationResponse]{ - More: func(page SubscriptionUsagesClientListByLocationResponse) bool { +func (client *SubscriptionUsagesClient) NewUsagesPager(location string, options *SubscriptionUsagesClientUsagesOptions) *runtime.Pager[SubscriptionUsagesClientUsagesResponse] { + return runtime.NewPager(runtime.PagingHandler[SubscriptionUsagesClientUsagesResponse]{ + More: func(page SubscriptionUsagesClientUsagesResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *SubscriptionUsagesClientListByLocationResponse) (SubscriptionUsagesClientListByLocationResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubscriptionUsagesClient.NewListByLocationPager") + Fetcher: func(ctx context.Context, page *SubscriptionUsagesClientUsagesResponse) (SubscriptionUsagesClientUsagesResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubscriptionUsagesClient.NewUsagesPager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByLocationCreateRequest(ctx, locationName, options) + return client.usagesCreateRequest(ctx, location, options) }, nil) if err != nil { - return SubscriptionUsagesClientListByLocationResponse{}, err + return SubscriptionUsagesClientUsagesResponse{}, err } - return client.listByLocationHandleResponse(resp) + return client.usagesHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listByLocationCreateRequest creates the ListByLocation request. -func (client *SubscriptionUsagesClient) listByLocationCreateRequest(ctx context.Context, locationName string, options *SubscriptionUsagesClientListByLocationOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevOpsInfrastructure/locations/{locationName}/usages" +// usagesCreateRequest creates the Usages request. +func (client *SubscriptionUsagesClient) usagesCreateRequest(ctx context.Context, location string, options *SubscriptionUsagesClientUsagesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevOpsInfrastructure/locations/{location}/usages" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if locationName == "" { - return nil, errors.New("parameter locationName cannot be empty") + if location == "" { + return nil, errors.New("parameter location cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err @@ -94,11 +94,11 @@ func (client *SubscriptionUsagesClient) listByLocationCreateRequest(ctx context. return req, nil } -// listByLocationHandleResponse handles the ListByLocation response. -func (client *SubscriptionUsagesClient) listByLocationHandleResponse(resp *http.Response) (SubscriptionUsagesClientListByLocationResponse, error) { - result := SubscriptionUsagesClientListByLocationResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.QuotaListResult); err != nil { - return SubscriptionUsagesClientListByLocationResponse{}, err +// usagesHandleResponse handles the Usages response. +func (client *SubscriptionUsagesClient) usagesHandleResponse(resp *http.Response) (SubscriptionUsagesClientUsagesResponse, error) { + result := SubscriptionUsagesClientUsagesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedQuota); err != nil { + return SubscriptionUsagesClientUsagesResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client_example_test.go b/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client_example_test.go deleted file mode 100644 index 46b092141c1a..000000000000 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/subscriptionusages_client_example_test.go +++ /dev/null @@ -1,72 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project 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 armdevopsinfrastructure_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/SubscriptionUsages_ListByLocation.json -func ExampleSubscriptionUsagesClient_NewListByLocationPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSubscriptionUsagesClient().NewListByLocationPager("eastus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.QuotaListResult = armdevopsinfrastructure.QuotaListResult{ - // Value: []*armdevopsinfrastructure.Quota{ - // { - // Name: to.Ptr("standardDADSv5Family"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus/providers/Microsoft.DevOpsInfrastructure/Usages/standardDADSv5Family"), - // Properties: &armdevopsinfrastructure.QuotaProperties{ - // Name: &armdevopsinfrastructure.QuotaName{ - // LocalizedValue: to.Ptr("Standard DADSv5 Family vCPUs (PME VMSS)"), - // Value: to.Ptr("standardDADSv5Family"), - // }, - // CurrentValue: to.Ptr[int64](0), - // Limit: to.Ptr[int64](212), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Name: to.Ptr("standardDPLDSv5Family"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus/providers/Microsoft.DevOpsInfrastructure/Usages/standardDPLDSv5Family"), - // Properties: &armdevopsinfrastructure.QuotaProperties{ - // Name: &armdevopsinfrastructure.QuotaName{ - // LocalizedValue: to.Ptr("Standard DPLDSv5 Family vCPUs (PME VMSS)"), - // Value: to.Ptr("standardDPLDSv5Family"), - // }, - // CurrentValue: to.Ptr[int64](0), - // Limit: to.Ptr[int64](100), - // Unit: to.Ptr("Count"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/edgezones/armedgezones/CHANGELOG.md b/sdk/resourcemanager/edgezones/armedgezones/CHANGELOG.md index ca1869b2b5e7..0313cb506d70 100644 --- a/sdk/resourcemanager/edgezones/armedgezones/CHANGELOG.md +++ b/sdk/resourcemanager/edgezones/armedgezones/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 0.1.1 (2024-08-22) +### Other Changes + + ## 0.1.0 (2024-07-08) ### Other Changes diff --git a/sdk/resourcemanager/edgezones/armedgezones/constants.go b/sdk/resourcemanager/edgezones/armedgezones/constants.go index 63895bc68229..252cf1ee0675 100644 --- a/sdk/resourcemanager/edgezones/armedgezones/constants.go +++ b/sdk/resourcemanager/edgezones/armedgezones/constants.go @@ -6,7 +6,7 @@ package armedgezones const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones" - moduleVersion = "v0.1.0" + moduleVersion = "v0.1.1" ) // ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/edgezones/armedgezones/extendedzones_client_example_test.go b/sdk/resourcemanager/edgezones/armedgezones/extendedzones_client_example_test.go new file mode 100644 index 000000000000..e390c3e58347 --- /dev/null +++ b/sdk/resourcemanager/edgezones/armedgezones/extendedzones_client_example_test.go @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armedgezones_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones" + "log" +) + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones/TempTypeSpecFiles/EdgeZones.Management/examples/2024-04-01-preview/ExtendedZones_Get.json +func ExampleExtendedZonesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgezones.NewClientFactory("a1ffc958-d2c7-493e-9f1e-125a0477f536", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExtendedZonesClient().Get(ctx, "losangeles", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armedgezones.ExtendedZonesClientGetResponse{ + // ExtendedZone: &armedgezones.ExtendedZone{ + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/providers/Microsoft.EdgeZones/extendedZones/losangeles"), + // Name: to.Ptr("losangeles"), + // Type: to.Ptr("Microsoft.EdgeZones/extendedZones"), + // Properties: &armedgezones.ExtendedZoneProperties{ + // ProvisioningState: to.Ptr(armedgezones.ProvisioningStateSucceeded), + // RegistrationState: to.Ptr(armedgezones.RegistrationStateNotRegistered), + // DisplayName: to.Ptr("Los Angeles"), + // RegionalDisplayName: to.Ptr("(US) Los Angeles"), + // RegionType: to.Ptr("Physical"), + // RegionCategory: to.Ptr("Other"), + // Geography: to.Ptr("usa"), + // GeographyGroup: to.Ptr("US"), + // Longitude: to.Ptr("-118.23537"), + // Latitude: to.Ptr("34.058414"), + // HomeLocation: to.Ptr("westus"), + // }, + // }, + // } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones/TempTypeSpecFiles/EdgeZones.Management/examples/2024-04-01-preview/ExtendedZones_ListBySubscription.json +func ExampleExtendedZonesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgezones.NewClientFactory("a1ffc958-d2c7-493e-9f1e-125a0477f536", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewExtendedZonesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armedgezones.ExtendedZonesClientListBySubscriptionResponse{ + // ExtendedZoneListResult: armedgezones.ExtendedZoneListResult{ + // Value: []*armedgezones.ExtendedZone{ + // { + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/providers/Microsoft.EdgeZones/extendedZones/redmond"), + // Name: to.Ptr("redmond"), + // Type: to.Ptr("Microsoft.EdgeZones/extendedZones"), + // Properties: &armedgezones.ExtendedZoneProperties{ + // ProvisioningState: to.Ptr(armedgezones.ProvisioningStateSucceeded), + // RegistrationState: to.Ptr(armedgezones.RegistrationStateNotRegistered), + // DisplayName: to.Ptr("Redmond"), + // RegionalDisplayName: to.Ptr("(US) Redmond"), + // RegionType: to.Ptr("Physical"), + // RegionCategory: to.Ptr("Other"), + // Geography: to.Ptr("usa"), + // GeographyGroup: to.Ptr("US"), + // Longitude: to.Ptr("-122.03197"), + // Latitude: to.Ptr("47.69106"), + // HomeLocation: to.Ptr("westus"), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/providers/Microsoft.EdgeZones/extendedZones/losangeles"), + // Name: to.Ptr("losangeles"), + // Type: to.Ptr("Microsoft.EdgeZones/extendedZones"), + // Properties: &armedgezones.ExtendedZoneProperties{ + // ProvisioningState: to.Ptr(armedgezones.ProvisioningStateSucceeded), + // RegistrationState: to.Ptr(armedgezones.RegistrationStateNotRegistered), + // DisplayName: to.Ptr("Los Angeles"), + // RegionalDisplayName: to.Ptr("(US) Los Angeles"), + // RegionType: to.Ptr("Physical"), + // RegionCategory: to.Ptr("Other"), + // Geography: to.Ptr("usa"), + // GeographyGroup: to.Ptr("US"), + // Longitude: to.Ptr("-118.23537"), + // Latitude: to.Ptr("34.058414"), + // HomeLocation: to.Ptr("westus"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones/TempTypeSpecFiles/EdgeZones.Management/examples/2024-04-01-preview/ExtendedZones_Register.json +func ExampleExtendedZonesClient_Register() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgezones.NewClientFactory("a1ffc958-d2c7-493e-9f1e-125a0477f536", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExtendedZonesClient().Register(ctx, "losangeles", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armedgezones.ExtendedZonesClientRegisterResponse{ + // ExtendedZone: &armedgezones.ExtendedZone{ + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/providers/Microsoft.EdgeZones/extendedZones/losangeles"), + // Name: to.Ptr("losangeles"), + // Type: to.Ptr("Microsoft.EdgeZones/extendedZones"), + // Properties: &armedgezones.ExtendedZoneProperties{ + // ProvisioningState: to.Ptr(armedgezones.ProvisioningStateSucceeded), + // RegistrationState: to.Ptr(armedgezones.RegistrationStatePendingRegister), + // DisplayName: to.Ptr("Los Angeles"), + // RegionalDisplayName: to.Ptr("(US) Los Angeles"), + // RegionType: to.Ptr("Physical"), + // RegionCategory: to.Ptr("Other"), + // Geography: to.Ptr("usa"), + // GeographyGroup: to.Ptr("US"), + // Longitude: to.Ptr("-118.23537"), + // Latitude: to.Ptr("34.058414"), + // HomeLocation: to.Ptr("westus"), + // }, + // }, + // } +} + +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones/TempTypeSpecFiles/EdgeZones.Management/examples/2024-04-01-preview/ExtendedZones_Unregister.json +func ExampleExtendedZonesClient_Unregister() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgezones.NewClientFactory("a1ffc958-d2c7-493e-9f1e-125a0477f536", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExtendedZonesClient().Unregister(ctx, "losangeles", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armedgezones.ExtendedZonesClientUnregisterResponse{ + // ExtendedZone: &armedgezones.ExtendedZone{ + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/providers/Microsoft.EdgeZones/extendedZones/losangeles"), + // Name: to.Ptr("losangeles"), + // Type: to.Ptr("Microsoft.EdgeZones/extendedZones"), + // Properties: &armedgezones.ExtendedZoneProperties{ + // ProvisioningState: to.Ptr(armedgezones.ProvisioningStateSucceeded), + // RegistrationState: to.Ptr(armedgezones.RegistrationStatePendingUnregister), + // DisplayName: to.Ptr("Los Angeles"), + // RegionalDisplayName: to.Ptr("(US) Los Angeles"), + // RegionType: to.Ptr("Physical"), + // RegionCategory: to.Ptr("Other"), + // Geography: to.Ptr("usa"), + // GeographyGroup: to.Ptr("US"), + // Longitude: to.Ptr("-118.23537"), + // Latitude: to.Ptr("34.058414"), + // HomeLocation: to.Ptr("westus"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/edgezones/armedgezones/go.mod b/sdk/resourcemanager/edgezones/armedgezones/go.mod index c84ad365f8a1..e7af0b95ddb6 100644 --- a/sdk/resourcemanager/edgezones/armedgezones/go.mod +++ b/sdk/resourcemanager/edgezones/armedgezones/go.mod @@ -2,10 +2,20 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezo go 1.18 -require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/edgezones/armedgezones/go.sum b/sdk/resourcemanager/edgezones/armedgezones/go.sum index 917448a001b7..09d275cb9a37 100644 --- a/sdk/resourcemanager/edgezones/armedgezones/go.sum +++ b/sdk/resourcemanager/edgezones/armedgezones/go.sum @@ -1,12 +1,29 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/edgezones/armedgezones/models.go b/sdk/resourcemanager/edgezones/armedgezones/models.go index 8545bdd4066e..90dfe1bb9687 100644 --- a/sdk/resourcemanager/edgezones/armedgezones/models.go +++ b/sdk/resourcemanager/edgezones/armedgezones/models.go @@ -74,7 +74,7 @@ type Operation struct { // Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. ActionType *ActionType - // Localized display information for this particular operation. + // READ-ONLY; Localized display information for this particular operation. Display *OperationDisplay // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure @@ -92,17 +92,19 @@ type Operation struct { // OperationDisplay - Localized display information for and operation. type OperationDisplay struct { - // The short, localized friendly description of the operation; suitable for tool tips and detailed views. + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. Description *string - // The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", - // "Restart Virtual Machine". + // 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 - // The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". Provider *string - // The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". Resource *string } diff --git a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/operations_client_example_test.go b/sdk/resourcemanager/edgezones/armedgezones/operations_client_example_test.go similarity index 52% rename from sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/operations_client_example_test.go rename to sdk/resourcemanager/edgezones/armedgezones/operations_client_example_test.go index 6cae58002b52..3976245c7509 100644 --- a/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure/operations_client_example_test.go +++ b/sdk/resourcemanager/edgezones/armedgezones/operations_client_example_test.go @@ -1,30 +1,24 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. -package armdevopsinfrastructure_test +package armedgezones_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devopsinfrastructure/armdevopsinfrastructure" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/devopsinfrastructure/resource-manager/Microsoft.DevOpsInfrastructure/preview/2024-04-04-preview/examples/ListOperations.json +// Generated from example definition: /mnt/vss/_work/1/s/azure-sdk-for-go/src/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgezones/armedgezones/TempTypeSpecFiles/EdgeZones.Management/examples/2024-04-01-preview/Operations_List.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armdevopsinfrastructure.NewClientFactory("", cred, nil) + clientFactory, err := armedgezones.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -39,7 +33,19 @@ func ExampleOperationsClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armdevopsinfrastructure.OperationListResult{ + // page = armedgezones.OperationsClientListResponse{ + // OperationListResult: armedgezones.OperationListResult{ + // Value: []*armedgezones.Operation{ + // { + // Name: to.Ptr("Microsoft.EdgeZones/extendedZones/read"), + // Display: &armedgezones.OperationDisplay{ + // Provider: to.Ptr("Microsoft.EdgeZones"), + // Resource: to.Ptr("extendedZones"), + // Operation: to.Ptr("read"), + // }, + // }, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/edgezones/armedgezones/tsp-location.yaml b/sdk/resourcemanager/edgezones/armedgezones/tsp-location.yaml index 5f0bfa9f57a2..7c973b2d3941 100644 --- a/sdk/resourcemanager/edgezones/armedgezones/tsp-location.yaml +++ b/sdk/resourcemanager/edgezones/armedgezones/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/edgezones/EdgeZones.Management -commit: ab064e0047ec560a700d6b501097d99471ad817b -repo: https://github.com/Azure/azure-rest-api-specs -additionalDirectories: +commit: 37d436549a6380c74ed7b2a1f5114e97282e0042 +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: \ No newline at end of file diff --git a/sdk/resourcemanager/fabric/armfabric/CHANGELOG.md b/sdk/resourcemanager/fabric/armfabric/CHANGELOG.md new file mode 100644 index 000000000000..dbc0012b2adc --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0 (2024-08-22) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/fabric/armfabric/LICENSE.txt b/sdk/resourcemanager/fabric/armfabric/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/fabric/armfabric/README.md b/sdk/resourcemanager/fabric/armfabric/README.md new file mode 100644 index 000000000000..53dab0b0b2db --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/README.md @@ -0,0 +1,92 @@ +# Azure Fabric Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric) + +The `armfabric` module provides operations for working with Azure Fabric. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/fabric/armfabric) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Fabric module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Fabric. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Fabric module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armfabric.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armfabric.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewCapacitiesClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Fabric` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/fabric/armfabric/autorest.md b/sdk/resourcemanager/fabric/armfabric/autorest.md new file mode 100644 index 000000000000..ddc94ad091df --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/fabric/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/fabric/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 1.0.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/fabric/armfabric/build.go b/sdk/resourcemanager/fabric/armfabric/build.go new file mode 100644 index 000000000000..8ae88f1f8781 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/fabric/armfabric + +package armfabric diff --git a/sdk/resourcemanager/fabric/armfabric/capacities_client.go b/sdk/resourcemanager/fabric/armfabric/capacities_client.go new file mode 100644 index 000000000000..2269bbad580e --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/capacities_client.go @@ -0,0 +1,795 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +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" +) + +// CapacitiesClient contains the methods for the FabricCapacities group. +// Don't use this type directly, use NewCapacitiesClient() instead. +type CapacitiesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCapacitiesClient creates a new instance of CapacitiesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewCapacitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CapacitiesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CapacitiesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckNameAvailability - Implements local CheckNameAvailability operations +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - location - The name of the Azure region. +// - body - The CheckAvailability request +// - options - CapacitiesClientCheckNameAvailabilityOptions contains the optional parameters for the CapacitiesClient.CheckNameAvailability +// method. +func (client *CapacitiesClient) CheckNameAvailability(ctx context.Context, location string, body CheckNameAvailabilityRequest, options *CapacitiesClientCheckNameAvailabilityOptions) (CapacitiesClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "CapacitiesClient.CheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkNameAvailabilityCreateRequest(ctx, location, body, options) + if err != nil { + return CapacitiesClientCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CapacitiesClientCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CapacitiesClientCheckNameAvailabilityResponse{}, err + } + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *CapacitiesClient) checkNameAvailabilityCreateRequest(ctx context.Context, location string, body CheckNameAvailabilityRequest, options *CapacitiesClientCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Fabric/locations/{location}/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + 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 +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *CapacitiesClient) checkNameAvailabilityHandleResponse(resp *http.Response) (CapacitiesClientCheckNameAvailabilityResponse, error) { + result := CapacitiesClientCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return CapacitiesClientCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdate - Create a FabricCapacity +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - capacityName - The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. +// - resource - Resource create parameters. +// - options - CapacitiesClientBeginCreateOrUpdateOptions contains the optional parameters for the CapacitiesClient.BeginCreateOrUpdate +// method. +func (client *CapacitiesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, capacityName string, resource Capacity, options *CapacitiesClientBeginCreateOrUpdateOptions) (*runtime.Poller[CapacitiesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, capacityName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CapacitiesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CapacitiesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a FabricCapacity +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CapacitiesClient) createOrUpdate(ctx context.Context, resourceGroupName string, capacityName string, resource Capacity, options *CapacitiesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CapacitiesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, capacityName, 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 *CapacitiesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, capacityName string, resource Capacity, options *CapacitiesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if capacityName == "" { + return nil, errors.New("parameter capacityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capacityName}", url.PathEscape(capacityName)) + 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", "2023-11-01") + 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 FabricCapacity +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - capacityName - The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. +// - options - CapacitiesClientBeginDeleteOptions contains the optional parameters for the CapacitiesClient.BeginDelete method. +func (client *CapacitiesClient) BeginDelete(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginDeleteOptions) (*runtime.Poller[CapacitiesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, capacityName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CapacitiesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CapacitiesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a FabricCapacity +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CapacitiesClient) deleteOperation(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "CapacitiesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, capacityName, 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.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CapacitiesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if capacityName == "" { + return nil, errors.New("parameter capacityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capacityName}", url.PathEscape(capacityName)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a FabricCapacity +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - capacityName - The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. +// - options - CapacitiesClientGetOptions contains the optional parameters for the CapacitiesClient.Get method. +func (client *CapacitiesClient) Get(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientGetOptions) (CapacitiesClientGetResponse, error) { + var err error + const operationName = "CapacitiesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, capacityName, options) + if err != nil { + return CapacitiesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CapacitiesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CapacitiesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *CapacitiesClient) getCreateRequest(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if capacityName == "" { + return nil, errors.New("parameter capacityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capacityName}", url.PathEscape(capacityName)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CapacitiesClient) getHandleResponse(resp *http.Response) (CapacitiesClientGetResponse, error) { + result := CapacitiesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Capacity); err != nil { + return CapacitiesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List FabricCapacity resources by resource group +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - CapacitiesClientListByResourceGroupOptions contains the optional parameters for the CapacitiesClient.NewListByResourceGroupPager +// method. +func (client *CapacitiesClient) NewListByResourceGroupPager(resourceGroupName string, options *CapacitiesClientListByResourceGroupOptions) *runtime.Pager[CapacitiesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[CapacitiesClientListByResourceGroupResponse]{ + More: func(page CapacitiesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CapacitiesClientListByResourceGroupResponse) (CapacitiesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CapacitiesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return CapacitiesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CapacitiesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CapacitiesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *CapacitiesClient) listByResourceGroupHandleResponse(resp *http.Response) (CapacitiesClientListByResourceGroupResponse, error) { + result := CapacitiesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CapacityListResult); err != nil { + return CapacitiesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List FabricCapacity resources by subscription ID +// +// Generated from API version 2023-11-01 +// - options - CapacitiesClientListBySubscriptionOptions contains the optional parameters for the CapacitiesClient.NewListBySubscriptionPager +// method. +func (client *CapacitiesClient) NewListBySubscriptionPager(options *CapacitiesClientListBySubscriptionOptions) *runtime.Pager[CapacitiesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[CapacitiesClientListBySubscriptionResponse]{ + More: func(page CapacitiesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CapacitiesClientListBySubscriptionResponse) (CapacitiesClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CapacitiesClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return CapacitiesClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CapacitiesClient) listBySubscriptionCreateRequest(ctx context.Context, options *CapacitiesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Fabric/capacities" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *CapacitiesClient) listBySubscriptionHandleResponse(resp *http.Response) (CapacitiesClientListBySubscriptionResponse, error) { + result := CapacitiesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CapacityListResult); err != nil { + return CapacitiesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// NewListSKUsPager - List eligible SKUs for Microsoft Fabric resource provider +// +// Generated from API version 2023-11-01 +// - options - CapacitiesClientListSKUsOptions contains the optional parameters for the CapacitiesClient.NewListSKUsPager method. +func (client *CapacitiesClient) NewListSKUsPager(options *CapacitiesClientListSKUsOptions) *runtime.Pager[CapacitiesClientListSKUsResponse] { + return runtime.NewPager(runtime.PagingHandler[CapacitiesClientListSKUsResponse]{ + More: func(page CapacitiesClientListSKUsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CapacitiesClientListSKUsResponse) (CapacitiesClientListSKUsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CapacitiesClient.NewListSKUsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listSKUsCreateRequest(ctx, options) + }, nil) + if err != nil { + return CapacitiesClientListSKUsResponse{}, err + } + return client.listSKUsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listSKUsCreateRequest creates the ListSKUs request. +func (client *CapacitiesClient) listSKUsCreateRequest(ctx context.Context, options *CapacitiesClientListSKUsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Fabric/skus" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listSKUsHandleResponse handles the ListSKUs response. +func (client *CapacitiesClient) listSKUsHandleResponse(resp *http.Response) (CapacitiesClientListSKUsResponse, error) { + result := CapacitiesClientListSKUsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RpSKUEnumerationForNewResourceResult); err != nil { + return CapacitiesClientListSKUsResponse{}, err + } + return result, nil +} + +// NewListSKUsForCapacityPager - List eligible SKUs for a Microsoft Fabric resource +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - capacityName - The name of the capacity. +// - options - CapacitiesClientListSKUsForCapacityOptions contains the optional parameters for the CapacitiesClient.NewListSKUsForCapacityPager +// method. +func (client *CapacitiesClient) NewListSKUsForCapacityPager(resourceGroupName string, capacityName string, options *CapacitiesClientListSKUsForCapacityOptions) *runtime.Pager[CapacitiesClientListSKUsForCapacityResponse] { + return runtime.NewPager(runtime.PagingHandler[CapacitiesClientListSKUsForCapacityResponse]{ + More: func(page CapacitiesClientListSKUsForCapacityResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CapacitiesClientListSKUsForCapacityResponse) (CapacitiesClientListSKUsForCapacityResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CapacitiesClient.NewListSKUsForCapacityPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listSKUsForCapacityCreateRequest(ctx, resourceGroupName, capacityName, options) + }, nil) + if err != nil { + return CapacitiesClientListSKUsForCapacityResponse{}, err + } + return client.listSKUsForCapacityHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listSKUsForCapacityCreateRequest creates the ListSKUsForCapacity request. +func (client *CapacitiesClient) listSKUsForCapacityCreateRequest(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientListSKUsForCapacityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/skus" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if capacityName == "" { + return nil, errors.New("parameter capacityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capacityName}", url.PathEscape(capacityName)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listSKUsForCapacityHandleResponse handles the ListSKUsForCapacity response. +func (client *CapacitiesClient) listSKUsForCapacityHandleResponse(resp *http.Response) (CapacitiesClientListSKUsForCapacityResponse, error) { + result := CapacitiesClientListSKUsForCapacityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RpSKUEnumerationForExistingResourceResult); err != nil { + return CapacitiesClientListSKUsForCapacityResponse{}, err + } + return result, nil +} + +// BeginResume - Resume operation of the specified Fabric capacity instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - capacityName - The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. +// - options - CapacitiesClientBeginResumeOptions contains the optional parameters for the CapacitiesClient.BeginResume method. +func (client *CapacitiesClient) BeginResume(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginResumeOptions) (*runtime.Poller[CapacitiesClientResumeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.resume(ctx, resourceGroupName, capacityName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CapacitiesClientResumeResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CapacitiesClientResumeResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Resume - Resume operation of the specified Fabric capacity instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CapacitiesClient) resume(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginResumeOptions) (*http.Response, error) { + var err error + const operationName = "CapacitiesClient.BeginResume" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.resumeCreateRequest(ctx, resourceGroupName, capacityName, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// resumeCreateRequest creates the Resume request. +func (client *CapacitiesClient) resumeCreateRequest(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginResumeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/resume" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if capacityName == "" { + return nil, errors.New("parameter capacityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capacityName}", url.PathEscape(capacityName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginSuspend - Suspend operation of the specified Fabric capacity instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - capacityName - The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. +// - options - CapacitiesClientBeginSuspendOptions contains the optional parameters for the CapacitiesClient.BeginSuspend method. +func (client *CapacitiesClient) BeginSuspend(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginSuspendOptions) (*runtime.Poller[CapacitiesClientSuspendResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.suspend(ctx, resourceGroupName, capacityName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CapacitiesClientSuspendResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CapacitiesClientSuspendResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Suspend - Suspend operation of the specified Fabric capacity instance. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CapacitiesClient) suspend(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginSuspendOptions) (*http.Response, error) { + var err error + const operationName = "CapacitiesClient.BeginSuspend" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.suspendCreateRequest(ctx, resourceGroupName, capacityName, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// suspendCreateRequest creates the Suspend request. +func (client *CapacitiesClient) suspendCreateRequest(ctx context.Context, resourceGroupName string, capacityName string, options *CapacitiesClientBeginSuspendOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}/suspend" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if capacityName == "" { + return nil, errors.New("parameter capacityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capacityName}", url.PathEscape(capacityName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginUpdate - Update a FabricCapacity +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - capacityName - The name of the Microsoft Fabric capacity. It must be a minimum of 3 characters, and a maximum of 63. +// - properties - The resource properties to be updated. +// - options - CapacitiesClientBeginUpdateOptions contains the optional parameters for the CapacitiesClient.BeginUpdate method. +func (client *CapacitiesClient) BeginUpdate(ctx context.Context, resourceGroupName string, capacityName string, properties CapacityUpdate, options *CapacitiesClientBeginUpdateOptions) (*runtime.Poller[CapacitiesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, capacityName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CapacitiesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CapacitiesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a FabricCapacity +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *CapacitiesClient) update(ctx context.Context, resourceGroupName string, capacityName string, properties CapacityUpdate, options *CapacitiesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CapacitiesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, capacityName, 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 *CapacitiesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, capacityName string, properties CapacityUpdate, options *CapacitiesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric/capacities/{capacityName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if capacityName == "" { + return nil, errors.New("parameter capacityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{capacityName}", url.PathEscape(capacityName)) + 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", "2023-11-01") + 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/sdk/resourcemanager/fabric/armfabric/ci.yml b/sdk/resourcemanager/fabric/armfabric/ci.yml new file mode 100644 index 000000000000..39fa6b58c77d --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/fabric/armfabric/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/fabric/armfabric/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/fabric/armfabric' diff --git a/sdk/resourcemanager/fabric/armfabric/client_factory.go b/sdk/resourcemanager/fabric/armfabric/client_factory.go new file mode 100644 index 000000000000..a9b08b8935f9 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/client_factory.go @@ -0,0 +1,52 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +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 { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewCapacitiesClient creates a new instance of CapacitiesClient. +func (c *ClientFactory) NewCapacitiesClient() *CapacitiesClient { + return &CapacitiesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/fabric/armfabric/constants.go b/sdk/resourcemanager/fabric/armfabric/constants.go new file mode 100644 index 000000000000..e7aa72b35c83 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/constants.go @@ -0,0 +1,176 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric" + moduleVersion = "v1.0.0" +) + +// 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, + } +} + +// CheckNameAvailabilityReason - The reason why the given name is not available. +type CheckNameAvailabilityReason string + +const ( + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +// PossibleCheckNameAvailabilityReasonValues returns the possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{ + CheckNameAvailabilityReasonAlreadyExists, + CheckNameAvailabilityReasonInvalid, + } +} + +// 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 - The provisioning state of the Fabric capacity resource. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - Resource is deleting + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - Resource is provisioning + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Resource is updating + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ResourceState - The state of the Fabric capacity resource. +type ResourceState string + +const ( + // ResourceStateActive - Resource is active + ResourceStateActive ResourceState = "Active" + // ResourceStateDeleting - Resource is deleting + ResourceStateDeleting ResourceState = "Deleting" + // ResourceStateFailed - Resource is failed + ResourceStateFailed ResourceState = "Failed" + // ResourceStatePaused - Resource is paused + ResourceStatePaused ResourceState = "Paused" + // ResourceStatePausing - Resource is pausing + ResourceStatePausing ResourceState = "Pausing" + // ResourceStatePreparing - Resource is preparing + ResourceStatePreparing ResourceState = "Preparing" + // ResourceStateProvisioning - Resource is provisioning + ResourceStateProvisioning ResourceState = "Provisioning" + // ResourceStateResuming - Resource is resuming + ResourceStateResuming ResourceState = "Resuming" + // ResourceStateScaling - Resource is scaling + ResourceStateScaling ResourceState = "Scaling" + // ResourceStateSuspended - Resource is suspended + ResourceStateSuspended ResourceState = "Suspended" + // ResourceStateSuspending - Resource is suspending + ResourceStateSuspending ResourceState = "Suspending" + // ResourceStateUpdating - Resource is updating + ResourceStateUpdating ResourceState = "Updating" +) + +// PossibleResourceStateValues returns the possible values for the ResourceState const type. +func PossibleResourceStateValues() []ResourceState { + return []ResourceState{ + ResourceStateActive, + ResourceStateDeleting, + ResourceStateFailed, + ResourceStatePaused, + ResourceStatePausing, + ResourceStatePreparing, + ResourceStateProvisioning, + ResourceStateResuming, + ResourceStateScaling, + ResourceStateSuspended, + ResourceStateSuspending, + ResourceStateUpdating, + } +} + +// RpSKUTier - The name of the Azure pricing tier to which the SKU applies. +type RpSKUTier string + +const ( + // RpSKUTierFabric - Fabric tier + RpSKUTierFabric RpSKUTier = "Fabric" +) + +// PossibleRpSKUTierValues returns the possible values for the RpSKUTier const type. +func PossibleRpSKUTierValues() []RpSKUTier { + return []RpSKUTier{ + RpSKUTierFabric, + } +} diff --git a/sdk/resourcemanager/fabric/armfabric/fake/capacities_server.go b/sdk/resourcemanager/fabric/armfabric/fake/capacities_server.go new file mode 100644 index 000000000000..5c33f777aa6c --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/fake/capacities_server.go @@ -0,0 +1,586 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric" + "net/http" + "net/url" + "regexp" +) + +// CapacitiesServer is a fake server for instances of the armfabric.CapacitiesClient type. +type CapacitiesServer struct { + // CheckNameAvailability is the fake for method CapacitiesClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, location string, body armfabric.CheckNameAvailabilityRequest, options *armfabric.CapacitiesClientCheckNameAvailabilityOptions) (resp azfake.Responder[armfabric.CapacitiesClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method CapacitiesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, capacityName string, resource armfabric.Capacity, options *armfabric.CapacitiesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armfabric.CapacitiesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method CapacitiesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, capacityName string, options *armfabric.CapacitiesClientBeginDeleteOptions) (resp azfake.PollerResponder[armfabric.CapacitiesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CapacitiesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, capacityName string, options *armfabric.CapacitiesClientGetOptions) (resp azfake.Responder[armfabric.CapacitiesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method CapacitiesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armfabric.CapacitiesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armfabric.CapacitiesClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method CapacitiesClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armfabric.CapacitiesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armfabric.CapacitiesClientListBySubscriptionResponse]) + + // NewListSKUsPager is the fake for method CapacitiesClient.NewListSKUsPager + // HTTP status codes to indicate success: http.StatusOK + NewListSKUsPager func(options *armfabric.CapacitiesClientListSKUsOptions) (resp azfake.PagerResponder[armfabric.CapacitiesClientListSKUsResponse]) + + // NewListSKUsForCapacityPager is the fake for method CapacitiesClient.NewListSKUsForCapacityPager + // HTTP status codes to indicate success: http.StatusOK + NewListSKUsForCapacityPager func(resourceGroupName string, capacityName string, options *armfabric.CapacitiesClientListSKUsForCapacityOptions) (resp azfake.PagerResponder[armfabric.CapacitiesClientListSKUsForCapacityResponse]) + + // BeginResume is the fake for method CapacitiesClient.BeginResume + // HTTP status codes to indicate success: http.StatusAccepted + BeginResume func(ctx context.Context, resourceGroupName string, capacityName string, options *armfabric.CapacitiesClientBeginResumeOptions) (resp azfake.PollerResponder[armfabric.CapacitiesClientResumeResponse], errResp azfake.ErrorResponder) + + // BeginSuspend is the fake for method CapacitiesClient.BeginSuspend + // HTTP status codes to indicate success: http.StatusAccepted + BeginSuspend func(ctx context.Context, resourceGroupName string, capacityName string, options *armfabric.CapacitiesClientBeginSuspendOptions) (resp azfake.PollerResponder[armfabric.CapacitiesClientSuspendResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method CapacitiesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, capacityName string, properties armfabric.CapacityUpdate, options *armfabric.CapacitiesClientBeginUpdateOptions) (resp azfake.PollerResponder[armfabric.CapacitiesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewCapacitiesServerTransport creates a new instance of CapacitiesServerTransport with the provided implementation. +// The returned CapacitiesServerTransport instance is connected to an instance of armfabric.CapacitiesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCapacitiesServerTransport(srv *CapacitiesServer) *CapacitiesServerTransport { + return &CapacitiesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armfabric.CapacitiesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armfabric.CapacitiesClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armfabric.CapacitiesClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armfabric.CapacitiesClientListBySubscriptionResponse]](), + newListSKUsPager: newTracker[azfake.PagerResponder[armfabric.CapacitiesClientListSKUsResponse]](), + newListSKUsForCapacityPager: newTracker[azfake.PagerResponder[armfabric.CapacitiesClientListSKUsForCapacityResponse]](), + beginResume: newTracker[azfake.PollerResponder[armfabric.CapacitiesClientResumeResponse]](), + beginSuspend: newTracker[azfake.PollerResponder[armfabric.CapacitiesClientSuspendResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armfabric.CapacitiesClientUpdateResponse]](), + } +} + +// CapacitiesServerTransport connects instances of armfabric.CapacitiesClient to instances of CapacitiesServer. +// Don't use this type directly, use NewCapacitiesServerTransport instead. +type CapacitiesServerTransport struct { + srv *CapacitiesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armfabric.CapacitiesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armfabric.CapacitiesClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armfabric.CapacitiesClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armfabric.CapacitiesClientListBySubscriptionResponse]] + newListSKUsPager *tracker[azfake.PagerResponder[armfabric.CapacitiesClientListSKUsResponse]] + newListSKUsForCapacityPager *tracker[azfake.PagerResponder[armfabric.CapacitiesClientListSKUsForCapacityResponse]] + beginResume *tracker[azfake.PollerResponder[armfabric.CapacitiesClientResumeResponse]] + beginSuspend *tracker[azfake.PollerResponder[armfabric.CapacitiesClientSuspendResponse]] + beginUpdate *tracker[azfake.PollerResponder[armfabric.CapacitiesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for CapacitiesServerTransport. +func (c *CapacitiesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "CapacitiesClient.CheckNameAvailability": + resp, err = c.dispatchCheckNameAvailability(req) + case "CapacitiesClient.BeginCreateOrUpdate": + resp, err = c.dispatchBeginCreateOrUpdate(req) + case "CapacitiesClient.BeginDelete": + resp, err = c.dispatchBeginDelete(req) + case "CapacitiesClient.Get": + resp, err = c.dispatchGet(req) + case "CapacitiesClient.NewListByResourceGroupPager": + resp, err = c.dispatchNewListByResourceGroupPager(req) + case "CapacitiesClient.NewListBySubscriptionPager": + resp, err = c.dispatchNewListBySubscriptionPager(req) + case "CapacitiesClient.NewListSKUsPager": + resp, err = c.dispatchNewListSKUsPager(req) + case "CapacitiesClient.NewListSKUsForCapacityPager": + resp, err = c.dispatchNewListSKUsForCapacityPager(req) + case "CapacitiesClient.BeginResume": + resp, err = c.dispatchBeginResume(req) + case "CapacitiesClient.BeginSuspend": + resp, err = c.dispatchBeginSuspend(req) + case "CapacitiesClient.BeginUpdate": + resp, err = c.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if c.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfabric.CheckNameAvailabilityRequest](req) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CheckNameAvailability(req.Context(), locationParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := c.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfabric.Capacity](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + capacityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("capacityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, capacityNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + c.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + c.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + c.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := c.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + capacityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("capacityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, capacityNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + c.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + c.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + c.beginDelete.remove(req) + } + + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + capacityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("capacityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, capacityNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Capacity, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armfabric.CapacitiesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + c.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := c.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := c.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + c.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armfabric.CapacitiesClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + c.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchNewListSKUsPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListSKUsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListSKUsPager not implemented")} + } + newListSKUsPager := c.newListSKUsPager.get(req) + if newListSKUsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/skus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := c.srv.NewListSKUsPager(nil) + newListSKUsPager = &resp + c.newListSKUsPager.add(req, newListSKUsPager) + server.PagerResponderInjectNextLinks(newListSKUsPager, req, func(page *armfabric.CapacitiesClientListSKUsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListSKUsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListSKUsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListSKUsPager) { + c.newListSKUsPager.remove(req) + } + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchNewListSKUsForCapacityPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListSKUsForCapacityPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListSKUsForCapacityPager not implemented")} + } + newListSKUsForCapacityPager := c.newListSKUsForCapacityPager.get(req) + if newListSKUsForCapacityPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/skus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + capacityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("capacityName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListSKUsForCapacityPager(resourceGroupNameParam, capacityNameParam, nil) + newListSKUsForCapacityPager = &resp + c.newListSKUsForCapacityPager.add(req, newListSKUsForCapacityPager) + server.PagerResponderInjectNextLinks(newListSKUsForCapacityPager, req, func(page *armfabric.CapacitiesClientListSKUsForCapacityResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListSKUsForCapacityPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListSKUsForCapacityPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListSKUsForCapacityPager) { + c.newListSKUsForCapacityPager.remove(req) + } + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchBeginResume(req *http.Request) (*http.Response, error) { + if c.srv.BeginResume == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResume not implemented")} + } + beginResume := c.beginResume.get(req) + if beginResume == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resume` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + capacityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("capacityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginResume(req.Context(), resourceGroupNameParam, capacityNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResume = &respr + c.beginResume.add(req, beginResume) + } + + resp, err := server.PollerResponderNext(beginResume, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + c.beginResume.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResume) { + c.beginResume.remove(req) + } + + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchBeginSuspend(req *http.Request) (*http.Response, error) { + if c.srv.BeginSuspend == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSuspend not implemented")} + } + beginSuspend := c.beginSuspend.get(req) + if beginSuspend == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/suspend` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + capacityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("capacityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginSuspend(req.Context(), resourceGroupNameParam, capacityNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSuspend = &respr + c.beginSuspend.add(req, beginSuspend) + } + + resp, err := server.PollerResponderNext(beginSuspend, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + c.beginSuspend.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSuspend) { + c.beginSuspend.remove(req) + } + + return resp, nil +} + +func (c *CapacitiesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := c.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Fabric/capacities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armfabric.CapacityUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + capacityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("capacityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, capacityNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + c.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + c.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/fabric/armfabric/fake/internal.go b/sdk/resourcemanager/fabric/armfabric/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/fake/internal.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/fabric/armfabric/fake/operations_server.go b/sdk/resourcemanager/fabric/armfabric/fake/operations_server.go new file mode 100644 index 000000000000..cfd4a853bdbf --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric" + "net/http" +) + +// OperationsServer is a fake server for instances of the armfabric.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armfabric.OperationsClientListOptions) (resp azfake.PagerResponder[armfabric.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armfabric.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armfabric.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armfabric.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armfabric.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armfabric.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/fabric/armfabric/fake/server_factory.go b/sdk/resourcemanager/fabric/armfabric/fake/server_factory.go new file mode 100644 index 000000000000..2257cedf6538 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/fake/server_factory.go @@ -0,0 +1,80 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armfabric.ClientFactory type. +type ServerFactory struct { + CapacitiesServer CapacitiesServer + OperationsServer OperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armfabric.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armfabric.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trCapacitiesServer *CapacitiesServerTransport + trOperationsServer *OperationsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "CapacitiesClient": + initServer(s, &s.trCapacitiesServer, func() *CapacitiesServerTransport { return NewCapacitiesServerTransport(&s.srv.CapacitiesServer) }) + resp, err = s.trCapacitiesServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/fabric/armfabric/fake/time_rfc3339.go b/sdk/resourcemanager/fabric/armfabric/fake/time_rfc3339.go new file mode 100644 index 000000000000..81f308b0d343 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/fake/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + 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/sdk/resourcemanager/fabric/armfabric/go.mod b/sdk/resourcemanager/fabric/armfabric/go.mod new file mode 100644 index 000000000000..66392ca328f2 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fabric/armfabric + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/sdk/resourcemanager/fabric/armfabric/go.sum b/sdk/resourcemanager/fabric/armfabric/go.sum new file mode 100644 index 000000000000..03ce617a1873 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/fabric/armfabric/models.go b/sdk/resourcemanager/fabric/armfabric/models.go new file mode 100644 index 000000000000..6cc446e5c121 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/models.go @@ -0,0 +1,223 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +import "time" + +// Capacity - Fabric Capacity resource +type Capacity struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // REQUIRED; The resource-specific properties for this resource. + Properties *CapacityProperties + + // REQUIRED; The SKU details + SKU *RpSKU + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/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 + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// CapacityAdministration - The administration properties of the Fabric capacity resource +type CapacityAdministration struct { + // REQUIRED; An array of administrator user identities. + Members []*string +} + +// CapacityListResult - The response of a FabricCapacity list operation. +type CapacityListResult struct { + // REQUIRED; The FabricCapacity items on this page + Value []*Capacity + + // The link to the next page of items + NextLink *string +} + +// CapacityProperties - The Microsoft Fabric capacity properties. +type CapacityProperties struct { + // REQUIRED; The capacity administration + Administration *CapacityAdministration + + // READ-ONLY; The current deployment state of Microsoft Fabric resource. The provisioningState is to indicate states for resource + // provisioning. + ProvisioningState *ProvisioningState + + // READ-ONLY; The current state of Microsoft Fabric resource. The state is to indicate more states outside of resource provisioning. + State *ResourceState +} + +// CapacityUpdate - The type used for update operations of the FabricCapacity. +type CapacityUpdate struct { + // The resource-specific properties for this resource. + Properties *CapacityUpdateProperties + + // The SKU details + SKU *RpSKU + + // Resource tags. + Tags map[string]*string +} + +// CapacityUpdateProperties - The updatable properties of the FabricCapacity. +type CapacityUpdateProperties struct { + // The capacity administration + Administration *CapacityAdministration +} + +// CheckNameAvailabilityRequest - The check availability request body. +type CheckNameAvailabilityRequest struct { + // The name of the resource for which availability needs to be checked. + Name *string + + // The resource type. + Type *string +} + +// CheckNameAvailabilityResponse - The check availability result. +type CheckNameAvailabilityResponse struct { + // Detailed reason why the given name is available. + Message *string + + // Indicates if the resource name is available. + NameAvailable *bool + + // The reason why the given name is not available. + Reason *CheckNameAvailabilityReason +} + +// 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 +} + +// RpSKU - Represents the SKU name and Azure pricing tier for Microsoft Fabric capacity resource. +type RpSKU struct { + // REQUIRED; The name of the SKU level. + Name *string + + // REQUIRED; The name of the Azure pricing tier to which the SKU applies. + Tier *RpSKUTier +} + +// RpSKUDetailsForExistingResource - An object that represents SKU details for existing resources +type RpSKUDetailsForExistingResource struct { + // REQUIRED; The resource type + ResourceType *string + + // REQUIRED; The SKU details + SKU *RpSKU +} + +// RpSKUDetailsForNewResource - The SKU details +type RpSKUDetailsForNewResource struct { + // REQUIRED; The list of available locations for the SKU + Locations []*string + + // REQUIRED; The SKU's name + Name *string + + // REQUIRED; The resource type + ResourceType *string +} + +// RpSKUEnumerationForExistingResourceResult - An object that represents enumerating SKUs for existing resources +type RpSKUEnumerationForExistingResourceResult struct { + // REQUIRED; The SKU details + Value []*RpSKUDetailsForExistingResource + + // Url for the next page. Null if no more pages available + NextLink *string +} + +// RpSKUEnumerationForNewResourceResult - An object that represents enumerating SKUs for new resources. +type RpSKUEnumerationForNewResourceResult struct { + // REQUIRED; The collection of available SKUs for new resources + Value []*RpSKUDetailsForNewResource + + // Url for the next page. Null if no more pages available + NextLink *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} diff --git a/sdk/resourcemanager/fabric/armfabric/models_serde.go b/sdk/resourcemanager/fabric/armfabric/models_serde.go new file mode 100644 index 000000000000..2a6290399474 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/models_serde.go @@ -0,0 +1,631 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Capacity. +func (c Capacity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Capacity. +func (c *Capacity) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + 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 "sku": + err = unpopulate(val, "SKU", &c.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 CapacityAdministration. +func (c CapacityAdministration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "members", c.Members) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapacityAdministration. +func (c *CapacityAdministration) 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 "members": + err = unpopulate(val, "Members", &c.Members) + 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 CapacityListResult. +func (c CapacityListResult) 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 CapacityListResult. +func (c *CapacityListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + 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 CapacityProperties. +func (c CapacityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administration", c.Administration) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "state", c.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapacityProperties. +func (c *CapacityProperties) 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 "administration": + err = unpopulate(val, "Administration", &c.Administration) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &c.State) + 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 CapacityUpdate. +func (c CapacityUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapacityUpdate. +func (c *CapacityUpdate) 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 "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &c.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + 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 CapacityUpdateProperties. +func (c CapacityUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administration", c.Administration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CapacityUpdateProperties. +func (c *CapacityUpdateProperties) 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 "administration": + err = unpopulate(val, "Administration", &c.Administration) + 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 CheckNameAvailabilityRequest. +func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. +func (c *CheckNameAvailabilityRequest) 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 "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 CheckNameAvailabilityResponse. +func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. +func (c *CheckNameAvailabilityResponse) 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 "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + 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 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 RpSKU. +func (r RpSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "tier", r.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RpSKU. +func (r *RpSKU) 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 "tier": + err = unpopulate(val, "Tier", &r.Tier) + 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 RpSKUDetailsForExistingResource. +func (r RpSKUDetailsForExistingResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceType", r.ResourceType) + populate(objectMap, "sku", r.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RpSKUDetailsForExistingResource. +func (r *RpSKUDetailsForExistingResource) 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 "resourceType": + err = unpopulate(val, "ResourceType", &r.ResourceType) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + 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 RpSKUDetailsForNewResource. +func (r RpSKUDetailsForNewResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "locations", r.Locations) + populate(objectMap, "name", r.Name) + populate(objectMap, "resourceType", r.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RpSKUDetailsForNewResource. +func (r *RpSKUDetailsForNewResource) 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 "locations": + err = unpopulate(val, "Locations", &r.Locations) + delete(rawMsg, 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", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RpSKUEnumerationForExistingResourceResult. +func (r RpSKUEnumerationForExistingResourceResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RpSKUEnumerationForExistingResourceResult. +func (r *RpSKUEnumerationForExistingResourceResult) 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 RpSKUEnumerationForNewResourceResult. +func (r RpSKUEnumerationForNewResourceResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RpSKUEnumerationForNewResourceResult. +func (r *RpSKUEnumerationForNewResourceResult) 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 SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 +} + +func populate(m map[string]any, k string, v any) { + 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 any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/fabric/armfabric/operations_client.go b/sdk/resourcemanager/fabric/armfabric/operations_client.go new file mode 100644 index 000000000000..66171abe74ac --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + 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. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2023-11-01 +// - 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 { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Fabric/operations" + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/fabric/armfabric/options.go b/sdk/resourcemanager/fabric/armfabric/options.go new file mode 100644 index 000000000000..5102720d1959 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/options.go @@ -0,0 +1,79 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +// CapacitiesClientBeginCreateOrUpdateOptions contains the optional parameters for the CapacitiesClient.BeginCreateOrUpdate +// method. +type CapacitiesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CapacitiesClientBeginDeleteOptions contains the optional parameters for the CapacitiesClient.BeginDelete method. +type CapacitiesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CapacitiesClientBeginResumeOptions contains the optional parameters for the CapacitiesClient.BeginResume method. +type CapacitiesClientBeginResumeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CapacitiesClientBeginSuspendOptions contains the optional parameters for the CapacitiesClient.BeginSuspend method. +type CapacitiesClientBeginSuspendOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CapacitiesClientBeginUpdateOptions contains the optional parameters for the CapacitiesClient.BeginUpdate method. +type CapacitiesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CapacitiesClientCheckNameAvailabilityOptions contains the optional parameters for the CapacitiesClient.CheckNameAvailability +// method. +type CapacitiesClientCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// CapacitiesClientGetOptions contains the optional parameters for the CapacitiesClient.Get method. +type CapacitiesClientGetOptions struct { + // placeholder for future optional parameters +} + +// CapacitiesClientListByResourceGroupOptions contains the optional parameters for the CapacitiesClient.NewListByResourceGroupPager +// method. +type CapacitiesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CapacitiesClientListBySubscriptionOptions contains the optional parameters for the CapacitiesClient.NewListBySubscriptionPager +// method. +type CapacitiesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// CapacitiesClientListSKUsForCapacityOptions contains the optional parameters for the CapacitiesClient.NewListSKUsForCapacityPager +// method. +type CapacitiesClientListSKUsForCapacityOptions struct { + // placeholder for future optional parameters +} + +// CapacitiesClientListSKUsOptions contains the optional parameters for the CapacitiesClient.NewListSKUsPager method. +type CapacitiesClientListSKUsOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/fabric/armfabric/responses.go b/sdk/resourcemanager/fabric/armfabric/responses.go new file mode 100644 index 000000000000..5443ae08c589 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/responses.go @@ -0,0 +1,78 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +// CapacitiesClientCheckNameAvailabilityResponse contains the response from method CapacitiesClient.CheckNameAvailability. +type CapacitiesClientCheckNameAvailabilityResponse struct { + // The check availability result. + CheckNameAvailabilityResponse +} + +// CapacitiesClientCreateOrUpdateResponse contains the response from method CapacitiesClient.BeginCreateOrUpdate. +type CapacitiesClientCreateOrUpdateResponse struct { + // Fabric Capacity resource + Capacity +} + +// CapacitiesClientDeleteResponse contains the response from method CapacitiesClient.BeginDelete. +type CapacitiesClientDeleteResponse struct { + // placeholder for future response values +} + +// CapacitiesClientGetResponse contains the response from method CapacitiesClient.Get. +type CapacitiesClientGetResponse struct { + // Fabric Capacity resource + Capacity +} + +// CapacitiesClientListByResourceGroupResponse contains the response from method CapacitiesClient.NewListByResourceGroupPager. +type CapacitiesClientListByResourceGroupResponse struct { + // The response of a FabricCapacity list operation. + CapacityListResult +} + +// CapacitiesClientListBySubscriptionResponse contains the response from method CapacitiesClient.NewListBySubscriptionPager. +type CapacitiesClientListBySubscriptionResponse struct { + // The response of a FabricCapacity list operation. + CapacityListResult +} + +// CapacitiesClientListSKUsForCapacityResponse contains the response from method CapacitiesClient.NewListSKUsForCapacityPager. +type CapacitiesClientListSKUsForCapacityResponse struct { + // An object that represents enumerating SKUs for existing resources + RpSKUEnumerationForExistingResourceResult +} + +// CapacitiesClientListSKUsResponse contains the response from method CapacitiesClient.NewListSKUsPager. +type CapacitiesClientListSKUsResponse struct { + // An object that represents enumerating SKUs for new resources. + RpSKUEnumerationForNewResourceResult +} + +// CapacitiesClientResumeResponse contains the response from method CapacitiesClient.BeginResume. +type CapacitiesClientResumeResponse struct { + // placeholder for future response values +} + +// CapacitiesClientSuspendResponse contains the response from method CapacitiesClient.BeginSuspend. +type CapacitiesClientSuspendResponse struct { + // placeholder for future response values +} + +// CapacitiesClientUpdateResponse contains the response from method CapacitiesClient.BeginUpdate. +type CapacitiesClientUpdateResponse struct { + // Fabric Capacity resource + Capacity +} + +// 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 +} diff --git a/sdk/resourcemanager/fabric/armfabric/time_rfc3339.go b/sdk/resourcemanager/fabric/armfabric/time_rfc3339.go new file mode 100644 index 000000000000..eedc342e8934 --- /dev/null +++ b/sdk/resourcemanager/fabric/armfabric/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project 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 armfabric + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// 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+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, 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] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}